BLL - 主从表业务单据业务逻辑层C#代码
BLL - 主从表业务单据业务逻辑层C#代码
由CodeGeneratorV6.0代码生成器自动生成。
代码摘自纸箱行业ERP系统《生产计划管理》。
C# 全选
using CartonERP.Common;
using CartonERP.DataAccess;
using CartonERP.Interfaces;
using CartonERP.Models;
using CartonERP.Models.ResModels;
using CartonERP.Models.UpdateModel;
using CartonERP.WebApiClient;
using CSFrameworkV6.Core;
using CSFrameworkV6.Core.Common;
using System;
using System.Collections.Generic;
using System.Data;
/*===================================================================
* 程序说明: PFPlan 业务单据BLL
* 作者资料: CSFramework
* 创建日期: 2023/08/08 07:09:38
* 最后修改: 2023/08/08 07:09:38
*
* 注:本文件由CSFramework.CodeGenerator代码生成器自动生成。
* 请将源码文件复制到 YourProject 对应的项目。
*
* 版权所有 Copyright 2006~2023, C/S框架网 (www.csframework.com)
*===================================================================*/
namespace CartonERP.Business
{
/// <summary>
/// PFPlan - 业务逻辑层
/// </summary>
public class bll_PFPlan : bllBaseBusiness<res_tb_PFPlan, res_tb_PFPlanDetails>
{
private IBridge_PFPlan _Bridge;
/// <summary>
/// 构造器
/// </summary>
public bll_PFPlan()
{
_SummaryTableName = nameof(tb_PFPlan);//表名
_KeyFieldName = nameof(tb_PFPlan.isid);//主键字段
_Bridge = this.CreateBridge();
}
/// <summary>
/// 创建策略接口实例
/// </summary>
/// <returns></returns>
private IBridge_PFPlan CreateBridge()
{
if (BridgeFactory.IsADODirect)
return new dal_PFPlan(Loginer.CurrentUser);
if (BridgeFactory.IsWebApi)
return new WebApi_PFPlan();
throw new Exception(BridgeFactory.UNKNOW_BRIDGE_TYPE);
}
/// <summary>
///新增业务单据
/// </summary>
public override void NewBusiness()
{
this.CurrentBusiness = new BusinessData<res_tb_PFPlan, res_tb_PFPlanDetails>();
this.CurrentBusiness.Master = new res_tb_PFPlan();
this.CurrentBusiness.Details = new List<res_tb_PFPlanDetails>();
//新增状态:主表记录设置默认值
this.CurrentBusiness.Master.PLNO = Globals.DEF_NO_TEXT;
this.CurrentBusiness.Master.DocDate = DateTime.Today;
}
/// <summary>
/// 审核单据
/// </summary>
/// <param name="current">单据主表记录</param>
/// <returns></returns>
public override bool ApprovalBusiness(res_tb_PFPlan current)
{
var input = new req_Approval
{
DocNo = current.PLNO,
Type = ApprovalType.Approval,
};
var result = _Bridge.ApprovalBusiness(input);
if (result)
{
current.FlagApp = "Y";
current.AppDate = DateTime.Now;
current.AppUser = Loginer.CurrentUser.Account;
}
return result;
}
/// <summary>
/// 反审核单据。
/// </summary>
public override bool ApprovalBusinessUndo(res_tb_PFPlan current)
{
var input = new req_Approval
{
DocNo = current.PLNO,
Type = ApprovalType.UnApproval,
};
var result = _Bridge.ApprovalBusiness(input);
if (result)
{
current.FlagApp = "N";
current.AppDate = null;
current.AppUser = null;
}
return result;
}
/// <summary>
/// 查询数据
/// </summary>
public List<res_tb_PFPlan> Query(req_PFPlan input)
{
return _Bridge.Query(input);
}
/// <summary>
/// 获取单据
/// </summary>
public override BusinessData<res_tb_PFPlan, res_tb_PFPlanDetails> GetDataByKey(string docNo)
{
return _Bridge.GetDataByKey(docNo);
}
/// <summary>
/// 删除单据
/// </summary>
/// <param name="docNo">单据号码</param>
public override bool Delete(string docNo)
{
return _Bridge.Delete(docNo);
}
/// <summary>
/// 创建用于保存的临时数据
/// 逻辑:将界面操作的单据实体类转换为EF实体。
/// </summary>
/// <param name="formData">界面操作的单据实体</param>
public BusinessData<tb_PFPlan, tb_PFPlanDetails> CreateSaveData(BusinessData<res_tb_PFPlan, res_tb_PFPlanDetails> formData)
{
var data = new BusinessData<tb_PFPlan, tb_PFPlanDetails>
{
Master = ObjectHelper.Convert<tb_PFPlan>(formData.Master),
Details = ObjectHelper.Convert<List<tb_PFPlanDetails>>(formData.Details),
};
//
//其他逻辑处理
//
return data;
}
/// <summary>
/// 保存数据
/// </summary>
/// <param name="formData">界面操作的单据实体</param>
public override SaveResult Update(BusinessData<res_tb_PFPlan, res_tb_PFPlanDetails> formData)
{
//将界面操作的单据实体类转换为EF实体
var temp = this.CreateSaveData(formData);
return _Bridge.Update(temp);
}
/// <summary>
/// 保存数据
/// </summary>
/// <param name="data">EF单据实体</param>
public SaveResult Update(BusinessData<tb_PFPlan, tb_PFPlanDetails> data)
{
return _Bridge.Update(data);
}
}
}
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
CSFrameworkV6 C/S框架网