using JLHHJSvr.BLL;
using JLHHJSvr.Com.Model;
using JLHHJSvr.LJException;
using LJLib.DAL.SQL;
using NPOI.SS.Formula;
using NPOI.SS.Formula.Functions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JLHHJSvr.Helper
{
internal class BasicInfoHelper: HelperBase
{
///
/// 核价选配类型-保存
///
///
public void SaveConfigureType(u_configure_type configure)
{
if (configure.contfigtypeid <= 0)
{
configure.contfigtypeid = BllHelper.GetID(cmd, "u_configure_type");
var fields = @"contfigtypeid,contfigtype,contfigtypename,usechflag,flag";
DbSqlHelper.Insert(cmd, "u_configure_type", null, configure, fields);
}
else
{
configure.moddate = context.opdate;
configure.modemp = context.tokendata.username;
//修改
var fields = @"contfigtype,contfigtypename,usechflag,modemp,moddate";
DbSqlHelper.Update(cmd, "u_configure_type", null, configure, "contfigtypeid", fields);
}
}
///
/// 核价软床公式定义-保存
///
///
public void SaveSoftBedFormula(u_softbed_formula formula)
{
if (formula == null)
{
throw new LJCommonException("未提交软床公式定义信息");
}
if (string.IsNullOrEmpty(formula.formulaname))
{
throw new LJCommonException($"公式名称不能为空,请检查!");
}
var fields = "formulaname,price_formula,use_formula";
if (formula.formulaid <= 0)
{
// 新建
fields += ",formulaid,create_date,create_emp";
formula.formulaid = BllHelper.GetID(cmd, "u_softbed_formula");
formula.create_date = context.opdate;
formula.create_emp = context.tokendata.username;
DbSqlHelper.Insert(cmd, "u_softbed_formula", null, formula, fields);
}
else
{
//修改
fields += ",update_date,update_emp";
formula.update_date = context.opdate;
formula.update_emp = context.tokendata.username;
DbSqlHelper.Update(cmd, "u_softbed_formula", null, formula, "formulaid", fields);
}
}
public void SaveErpMtrlPrice(u_erpmtrl_price mtrl)
{
var fields = "";
if(mtrl.mtrlid <= 0)
{
throw new LJCommonException("物料ID有误,请检查!");
}
mtrl.update_date = context.opdate;
mtrl.update_emp = context.tokendata.username;
if(DbSqlHelper.Update(cmd, "u_erpmtrl_price", null, mtrl, "mtrlid", "price,update_date,update_emp") == 0)
{
mtrl.create_date = context.opdate;
mtrl.create_emp = context.tokendata.username;
DbSqlHelper.Insert(cmd, "u_erpmtrl_price", null, mtrl, "mtrlid,price,create_date,create_emp");
}
}
}
}