|
@@ -7,17 +7,23 @@ using JLHHJSvr.Tools;
|
|
|
using LJLib.DAL.SQL;
|
|
using LJLib.DAL.SQL;
|
|
|
using NPOI.HSSF.Record;
|
|
using NPOI.HSSF.Record;
|
|
|
using NPOI.SS.Formula.Functions;
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
|
+using NPOI.Util;
|
|
|
using System;
|
|
using System;
|
|
|
using System.Collections;
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
using System.Data;
|
|
using System.Data;
|
|
|
|
|
+using System.Diagnostics;
|
|
|
using System.Linq;
|
|
using System.Linq;
|
|
|
|
|
+using System.Security.Cryptography;
|
|
|
using System.Text;
|
|
using System.Text;
|
|
|
using System.Text.RegularExpressions;
|
|
using System.Text.RegularExpressions;
|
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
|
using System.Web;
|
|
using System.Web;
|
|
|
using System.Web.Configuration;
|
|
using System.Web.Configuration;
|
|
|
|
|
+using System.Web.UI.WebControls;
|
|
|
using static JLHHJSvr.Helper.CacheHelper;
|
|
using static JLHHJSvr.Helper.CacheHelper;
|
|
|
|
|
+using static System.Runtime.CompilerServices.RuntimeHelpers;
|
|
|
|
|
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.Menu;
|
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Tab;
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Tab;
|
|
|
|
|
|
|
|
namespace JLHHJSvr.Helper
|
|
namespace JLHHJSvr.Helper
|
|
@@ -49,7 +55,7 @@ namespace JLHHJSvr.Helper
|
|
|
public List<u_softbed_mx> GetSoftBedMxList(int billid,string fields = null)
|
|
public List<u_softbed_mx> GetSoftBedMxList(int billid,string fields = null)
|
|
|
{
|
|
{
|
|
|
fields = fields ?? @"softbed_id,printid,formulaid,pzid,mtrlid,mtrlname,mtrlcode,mtrlmode,unit,has_type,allow_edit,cutting_length,cutting_width,cutting_qty,
|
|
fields = fields ?? @"softbed_id,printid,formulaid,pzid,mtrlid,mtrlname,mtrlcode,mtrlmode,unit,has_type,allow_edit,cutting_length,cutting_width,cutting_qty,
|
|
|
- useqty,use_formula,use_formula_str,actual_useqty,loss_rate,price,price_formula,price_formula_str,cost_price,cost_amt,pzname,formulaname,parts_type";
|
|
|
|
|
|
|
+ useqty,use_formula,use_formula_str,actual_useqty,loss_rate,price,price_formula,price_formula_str,cost_price,cost_amt,pzname,formulaname,parts_type,pzmxid,pznamemx";
|
|
|
var mxlist = new List<u_softbed_mx>();
|
|
var mxlist = new List<u_softbed_mx>();
|
|
|
|
|
|
|
|
var selectStr = @"SELECT u_softbed_mx.softbed_id
|
|
var selectStr = @"SELECT u_softbed_mx.softbed_id
|
|
@@ -79,8 +85,12 @@ namespace JLHHJSvr.Helper
|
|
|
,ISNULL(u_configure_code.name,u_softbed_mx.pzname) AS pzname
|
|
,ISNULL(u_configure_code.name,u_softbed_mx.pzname) AS pzname
|
|
|
,u_softbed_mx.parts_type
|
|
,u_softbed_mx.parts_type
|
|
|
,ISNULL(u_softbed_formula.formulaname,'') AS formulaname
|
|
,ISNULL(u_softbed_formula.formulaname,'') AS formulaname
|
|
|
|
|
+ ,u_softbed_mx.pzmxid
|
|
|
|
|
+ ,ISNULL(u_configure_codemx.namemx,'') AS pznamemx
|
|
|
FROM u_softbed_mx
|
|
FROM u_softbed_mx
|
|
|
LEFT JOIN u_configure_code ON u_softbed_mx.pzid = u_configure_code.pzid
|
|
LEFT JOIN u_configure_code ON u_softbed_mx.pzid = u_configure_code.pzid
|
|
|
|
|
+ LEFT JOIN u_configure_codemx ON u_softbed_mx.pzid = u_configure_codemx.pzid
|
|
|
|
|
+ AND u_softbed_mx.pzmxid = u_configure_codemx.printid
|
|
|
LEFT JOIN u_softbed_formula ON u_softbed_mx.formulaid = u_softbed_formula.formulaid
|
|
LEFT JOIN u_softbed_formula ON u_softbed_mx.formulaid = u_softbed_formula.formulaid
|
|
|
";
|
|
";
|
|
|
|
|
|
|
@@ -433,7 +443,9 @@ namespace JLHHJSvr.Helper
|
|
|
/// <param name="softbed"></param>
|
|
/// <param name="softbed"></param>
|
|
|
private void SaveSoftBedTemplate(u_softbed softbed)
|
|
private void SaveSoftBedTemplate(u_softbed softbed)
|
|
|
{
|
|
{
|
|
|
- if (softbed.is_template == 0) return;
|
|
|
|
|
|
|
+ SaveSoftBedTemplateV2(softbed);
|
|
|
|
|
+ return;
|
|
|
|
|
+ if (softbed.is_template == 0) return;
|
|
|
|
|
|
|
|
if(string.IsNullOrEmpty(softbed.softbed_code))
|
|
if(string.IsNullOrEmpty(softbed.softbed_code))
|
|
|
{
|
|
{
|
|
@@ -442,20 +454,10 @@ namespace JLHHJSvr.Helper
|
|
|
|
|
|
|
|
string prefix = $"{softbed.softbed_code}|";
|
|
string prefix = $"{softbed.softbed_code}|";
|
|
|
var configureList = GetSoftBedConfigureName(softbed).Values.ToList();
|
|
var configureList = GetSoftBedConfigureName(softbed).Values.ToList();
|
|
|
-
|
|
|
|
|
- var baseInfoHelper = GetHelper<BasicInfoHelper>(cmd, context);
|
|
|
|
|
foreach(var configure in configureList)
|
|
foreach(var configure in configureList)
|
|
|
{
|
|
{
|
|
|
- // 判断是否已存在
|
|
|
|
|
- cmd.CommandText = @"SELECT COUNT(*) FROM u_configure_type WHERE LTRIM(RTRIM(contfigtypename)) = @contfigtypename";
|
|
|
|
|
- cmd.Parameters.Clear();
|
|
|
|
|
- cmd.Parameters.AddWithValue("@contfigtypename", configure.contfigtypename);
|
|
|
|
|
- var cnt = Convert.ToInt32(cmd.ExecuteScalar());
|
|
|
|
|
-
|
|
|
|
|
- if (cnt > 0) continue;
|
|
|
|
|
- baseInfoHelper.SaveConfigureType(configure);
|
|
|
|
|
|
|
+ SaveSoftBedConfigure(configure);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
// 生成标准选配项值ifdft
|
|
// 生成标准选配项值ifdft
|
|
|
if(softbed.codeMxList != null && softbed.codeMxList.Count > 0)
|
|
if(softbed.codeMxList != null && softbed.codeMxList.Count > 0)
|
|
|
{
|
|
{
|
|
@@ -498,8 +500,9 @@ namespace JLHHJSvr.Helper
|
|
|
contfigtypename = $"{prefix}床头",
|
|
contfigtypename = $"{prefix}床头",
|
|
|
contfigtype = 0,
|
|
contfigtype = 0,
|
|
|
usechflag = 1,
|
|
usechflag = 1,
|
|
|
- flag = 0
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ flag = 0,
|
|
|
|
|
+ codeList = GetSoftBedConfigureCode(softbed.mxList,1)
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (softbed.has_nightstand == 1)
|
|
if (softbed.has_nightstand == 1)
|
|
@@ -510,7 +513,8 @@ namespace JLHHJSvr.Helper
|
|
|
contfigtypename = $"{prefix}床头柜",
|
|
contfigtypename = $"{prefix}床头柜",
|
|
|
contfigtype = 0,
|
|
contfigtype = 0,
|
|
|
usechflag = 1,
|
|
usechflag = 1,
|
|
|
- flag = 0
|
|
|
|
|
|
|
+ flag = 0,
|
|
|
|
|
+ codeList = GetSoftBedConfigureCode(softbed.mxList, 2)
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -522,19 +526,183 @@ namespace JLHHJSvr.Helper
|
|
|
contfigtypename = $"{prefix}床架",
|
|
contfigtypename = $"{prefix}床架",
|
|
|
contfigtype = 0,
|
|
contfigtype = 0,
|
|
|
usechflag = 1,
|
|
usechflag = 1,
|
|
|
- flag = 0
|
|
|
|
|
|
|
+ flag = 0,
|
|
|
|
|
+ codeList = GetSoftBedConfigureCode(softbed.mxList, 4)
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return dict;
|
|
return dict;
|
|
|
|
|
+ }/// <summary>
|
|
|
|
|
+ /// 返回软床报价相关配置项
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ /// <param name="softbed"></param>
|
|
|
|
|
+ /// <returns></returns>
|
|
|
|
|
+ private List<u_configure_code> GetSoftBedConfigureCode(List<u_softbed_mx> mxList,byte has_type)
|
|
|
|
|
+ {
|
|
|
|
|
+ var tempMxList = mxList.Where(t => t.has_type == has_type);
|
|
|
|
|
+
|
|
|
|
|
+ var codeMap = new Dictionary<string, List<u_configure_codemx>> ();
|
|
|
|
|
+ var codeMxMap = new Dictionary<Tuple<string,string>, List<u_softbed_mx>>();
|
|
|
|
|
+ foreach(var mx in tempMxList)
|
|
|
|
|
+ {
|
|
|
|
|
+ //
|
|
|
|
|
+ var codeMxKey = Tuple.Create(mx.pzname,mx.pznamemx);
|
|
|
|
|
+ //
|
|
|
|
|
+ if (!codeMxMap.ContainsKey(codeMxKey)) codeMxMap.Add(codeMxKey, new List<u_softbed_mx>());
|
|
|
|
|
+ codeMxMap[codeMxKey].Add(mx);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ var codeMxList = new List<u_configure_codemx>();
|
|
|
|
|
+ foreach(var item in codeMxMap)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (item.Value.Count <= 0) continue;
|
|
|
|
|
+ var key = item.Key;
|
|
|
|
|
+ var configureCodeMx = new u_configure_codemx()
|
|
|
|
|
+ {
|
|
|
|
|
+ pzid = item.Value.First().pzid,
|
|
|
|
|
+ namemx = key.Item2,
|
|
|
|
|
+ printid = item.Value.First().pzmxid,
|
|
|
|
|
+ ifdft = 1
|
|
|
|
|
+ };
|
|
|
|
|
+ var bomList = new List<u_configure_codemxbom>();
|
|
|
|
|
+
|
|
|
|
|
+ foreach(var mx in item.Value)
|
|
|
|
|
+ {
|
|
|
|
|
+ bomList.Add(new u_configure_codemxbom()
|
|
|
|
|
+ {
|
|
|
|
|
+ pzid = mx.pzid,
|
|
|
|
|
+ printid = mx.pzmxid,
|
|
|
|
|
+ pid = 0,
|
|
|
|
|
+ mtrlid = mx.mtrlid,
|
|
|
|
|
+ default_length = mx.cutting_length,
|
|
|
|
|
+ default_width = mx.cutting_width,
|
|
|
|
|
+ default_qty = mx.cutting_qty,
|
|
|
|
|
+ price = mx.price,
|
|
|
|
|
+ price_formula = mx.price_formula,
|
|
|
|
|
+ sonscale = mx.useqty,
|
|
|
|
|
+ sonscale_formula = mx.use_formula,
|
|
|
|
|
+ sonloss = mx.loss_rate
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ configureCodeMx.bomList = bomList;
|
|
|
|
|
+ codeMxList.Add(configureCodeMx);
|
|
|
|
|
+
|
|
|
|
|
+ if (!codeMap.ContainsKey(key.Item1)) codeMap.Add(key.Item1, codeMxList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ var resultList = new List<u_configure_code>();
|
|
|
|
|
+ foreach(var item in codeMap)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (item.Value.Count <= 0) continue;
|
|
|
|
|
+ var key = item.Key;
|
|
|
|
|
+ resultList.Add(new u_configure_code()
|
|
|
|
|
+ {
|
|
|
|
|
+ name = key,
|
|
|
|
|
+ typeid = 0,
|
|
|
|
|
+ pzid = item.Value.First().pzid,
|
|
|
|
|
+ ifuse = 1,
|
|
|
|
|
+ codeMxList = item.Value
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return resultList;
|
|
|
}
|
|
}
|
|
|
- /// <summary>
|
|
|
|
|
- /// 获取软床报价配置
|
|
|
|
|
- /// </summary>
|
|
|
|
|
- /// <param name="softbed"></param>
|
|
|
|
|
- /// <param name="extraWheres"></param>
|
|
|
|
|
- /// <returns></returns>
|
|
|
|
|
- public List<u_configure_type> GetSoftBedConfigureList(u_softbed softbed,List<string> extraWheres)
|
|
|
|
|
|
|
+ private void SaveSoftBedConfigure(u_configure_type configure)
|
|
|
|
|
+ {
|
|
|
|
|
+ var baseInfoHelper = GetHelper<BasicInfoHelper>(cmd, context);
|
|
|
|
|
+
|
|
|
|
|
+ // 判断配置是否已存在
|
|
|
|
|
+ cmd.CommandText = @"SELECT COUNT(*) AS printid FROM u_configure_type INNER JOIN u_configure_code ON u_configure_type.contfigtypeid = u_configure_code.typeid WHERE LTRIM(RTRIM(contfigtypename)) = @contfigtypename";
|
|
|
|
|
+ cmd.Parameters.Clear();
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@contfigtypename", configure.contfigtypename);
|
|
|
|
|
+ int cnt = Convert.ToInt32(cmd.ExecuteScalar());
|
|
|
|
|
+ if (cnt == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ baseInfoHelper.SaveConfigureType(configure);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 处理配置项
|
|
|
|
|
+ var codeList = new List<u_configure_code>();
|
|
|
|
|
+ var codeMxList = new List<u_configure_codemx>();
|
|
|
|
|
+ var codeMxBomList = new List<u_configure_codemxbom>();
|
|
|
|
|
+ int codeNum = cnt == 0 ? 1 : cnt;
|
|
|
|
|
+ foreach (var code in configure.codeList)
|
|
|
|
|
+ {
|
|
|
|
|
+ int printid = 1;
|
|
|
|
|
+ if (code.pzid > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ cmd.CommandText = @"SELECT ISNULL(MAX(printid),0) AS printid FROM u_configure_codemx WHERE pzid = @pzid";
|
|
|
|
|
+ cmd.Parameters.Clear();
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@pzid", code.pzid);
|
|
|
|
|
+ using (var reader = cmd.ExecuteReader())
|
|
|
|
|
+ {
|
|
|
|
|
+ if (reader.Read())
|
|
|
|
|
+ {
|
|
|
|
|
+ printid = Convert.ToInt32(reader["printid"]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //
|
|
|
|
|
+ code.typeid = configure.contfigtypeid;
|
|
|
|
|
+ code.pzid = code.pzid > 0 ? code.pzid : BllHelper.GetID(cmd, "u_configure_code");
|
|
|
|
|
+ code.pzcode = FormatCode(codeNum, 4);
|
|
|
|
|
+
|
|
|
|
|
+ foreach(var codeMx in code.codeMxList)
|
|
|
|
|
+ {
|
|
|
|
|
+ codeMx.pzid = code.pzid;
|
|
|
|
|
+ codeMx.printid = printid++;
|
|
|
|
|
+ codeMx.pzcodemx = $"{code.pzcode}_{FormatCode(printid, 3)}";
|
|
|
|
|
+ codeMxList.Add(codeMx);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ foreach(var codeMx in codeMxList)
|
|
|
|
|
+ {
|
|
|
|
|
+ int pid = 1;
|
|
|
|
|
+ if(cnt > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ cmd.CommandText = @"SELECT ISNULL(MAX(pid),0) AS printid FROM u_configure_codemxbom WHERE pzid = @pzid AND printid = @printid";
|
|
|
|
|
+ cmd.Parameters.Clear();
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@pzid", codeMx.pzid);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@printid", codeMx.printid);
|
|
|
|
|
+ using (var reader = cmd.ExecuteReader())
|
|
|
|
|
+ {
|
|
|
|
|
+ if (reader.Read())
|
|
|
|
|
+ {
|
|
|
|
|
+ pid = Convert.ToInt32(reader["printid"]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ foreach (var bom in codeMx.bomList)
|
|
|
|
|
+ {
|
|
|
|
|
+ bom.printid = codeMx.printid.Value;
|
|
|
|
|
+ bom.pid = pid++;
|
|
|
|
|
+ codeMxBomList.Add(bom);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ DbSqlHelper.BulkInsert(cmd, codeList, "u_configure_code", null, "typeid,pzid,pzcode,inputtype,name,configtype,ifcross,ifcheck,ifuse,rulestr,ifnum,decnum,maxnum,minnum,pricestr,priceratestr,ifpack,zj_special");
|
|
|
|
|
+ DbSqlHelper.BulkInsert(cmd, codeMxList, "u_configure_codemx", null, "pzid,printid,pzcodemx,namemx,gradestr,mtrlcode,price,ifdft,MCostRate,ProfitRate,dscrp,ifuse,ifnoch,pricerate,packqty,packvol,price_pz,grade");
|
|
|
|
|
+ DbSqlHelper.BulkInsert(cmd, codeMxBomList, "u_configure_codemxbom", null, "pzid,printid,pid,mtrlid,sonscale,sonscale_formula,mng_cost_rate,profit_rate,realqty,sonloss,sonloss_formula,sondecloss,sondecloss_formula,default_length,default_width,default_qty");
|
|
|
|
|
+ }
|
|
|
|
|
+ public static string FormatCode(int number, int length)
|
|
|
|
|
+ {
|
|
|
|
|
+ int max = (int)Math.Pow(10, length) - 1;
|
|
|
|
|
+
|
|
|
|
|
+ if (number > max)
|
|
|
|
|
+ {
|
|
|
|
|
+ throw new Exception($"编码超出长度限制,{length}位最多只能到 {max}");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return number.ToString($"D{length}");
|
|
|
|
|
+ }
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// 获取软床报价配置
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ /// <param name="softbed"></param>
|
|
|
|
|
+ /// <param name="extraWheres"></param>
|
|
|
|
|
+ /// <returns></returns>
|
|
|
|
|
+ public List<u_configure_type> GetSoftBedConfigureList(u_softbed softbed,List<string> extraWheres)
|
|
|
{
|
|
{
|
|
|
var codeMxList = new List<u_configure_codemx>();
|
|
var codeMxList = new List<u_configure_codemx>();
|
|
|
|
|
|
|
@@ -973,6 +1141,469 @@ namespace JLHHJSvr.Helper
|
|
|
DbSqlHelper.BulkInsert(cmd, codeMxBom_copyList, "u_configure_codemxbom",null, "pzid,printid,pid,mtrlid,sonscale,sonscale_formula,mng_cost_rate,profit_rate,realqty,sonloss,sonloss_formula,sondecloss,sondecloss_formula,default_length,default_width,default_qty");
|
|
DbSqlHelper.BulkInsert(cmd, codeMxBom_copyList, "u_configure_codemxbom",null, "pzid,printid,pid,mtrlid,sonscale,sonscale_formula,mng_cost_rate,profit_rate,realqty,sonloss,sonloss_formula,sondecloss,sondecloss_formula,default_length,default_width,default_qty");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// 新版模板核价资料保存。
|
|
|
|
|
+ /// 仅处理模板报价,将报价明细同步到核价配置资料,并将生成的 pzid/pzmxid 回写到报价明细。
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ /// <param name="softbed"></param>
|
|
|
|
|
+ public void SaveSoftBedTemplateV2(u_softbed softbed)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (softbed == null) throw new LJCommonException("模板核价保存失败,数据异常!");
|
|
|
|
|
+ if (softbed.is_template == 0) return;
|
|
|
|
|
+ if (string.IsNullOrWhiteSpace(softbed.softbed_code)) throw new LJCommonException("报价未生成唯一码,无法生成模板配置");
|
|
|
|
|
+ if (softbed.mxList == null || softbed.mxList.Count <= 0) return;
|
|
|
|
|
+
|
|
|
|
|
+ var typeNameMap = GetSoftBedTemplateTypeNameMapV2(softbed);
|
|
|
|
|
+ foreach (var item in typeNameMap)
|
|
|
|
|
+ {
|
|
|
|
|
+ var typeMxList = softbed.mxList
|
|
|
|
|
+ .Where(t => t.has_type == item.Key)
|
|
|
|
|
+ .OrderBy(t => t.printid)
|
|
|
|
|
+ .ToList();
|
|
|
|
|
+
|
|
|
|
|
+ if (typeMxList.Count <= 0) continue;
|
|
|
|
|
+
|
|
|
|
|
+ ValidateSoftBedTemplateMxListV2(item.Value, typeMxList);
|
|
|
|
|
+
|
|
|
|
|
+ int typeId = EnsureSoftBedTemplateTypeV2(item.Value);
|
|
|
|
|
+ var codeMxGroups = typeMxList
|
|
|
|
|
+ .GroupBy(t => new
|
|
|
|
|
+ {
|
|
|
|
|
+ PzName = (t.pzname ?? string.Empty).Trim(),
|
|
|
|
|
+ PzNameMx = (t.pznamemx ?? string.Empty).Trim()
|
|
|
|
|
+ })
|
|
|
|
|
+ .ToList();
|
|
|
|
|
+
|
|
|
|
|
+ foreach (var group in codeMxGroups)
|
|
|
|
|
+ {
|
|
|
|
|
+ var currentMxList = group.OrderBy(t => t.printid).ToList();
|
|
|
|
|
+ var firstMx = currentMxList.First();
|
|
|
|
|
+
|
|
|
|
|
+ int pzid = EnsureSoftBedTemplateCodeV2(typeId, firstMx.pzid, group.Key.PzName);
|
|
|
|
|
+ int pzmxid = EnsureSoftBedTemplateCodeMxV2(pzid, firstMx.pzmxid, group.Key.PzNameMx);
|
|
|
|
|
+
|
|
|
|
|
+ foreach (var mx in currentMxList)
|
|
|
|
|
+ {
|
|
|
|
|
+ mx.pzid = pzid;
|
|
|
|
|
+ mx.pzmxid = pzmxid;
|
|
|
|
|
+ mx.pzname = group.Key.PzName;
|
|
|
|
|
+ mx.pznamemx = group.Key.PzNameMx;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ReplaceSoftBedTemplateBomV2(pzid, pzmxid, currentMxList);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ BackWriteSoftBedTemplateMxIdsV2(softbed);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private Dictionary<byte, string> GetSoftBedTemplateTypeNameMapV2(u_softbed softbed)
|
|
|
|
|
+ {
|
|
|
|
|
+ var dict = new Dictionary<byte, string>();
|
|
|
|
|
+ string prefix = $"{softbed.softbed_code}|";
|
|
|
|
|
+
|
|
|
|
|
+ if (softbed.has_headboard == 1) dict[1] = $"{prefix}床头";
|
|
|
|
|
+ if (softbed.has_nightstand == 1) dict[2] = $"{prefix}床头柜";
|
|
|
|
|
+ if (softbed.has_bedframe == 1) dict[4] = $"{prefix}床架";
|
|
|
|
|
+
|
|
|
|
|
+ return dict;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void ValidateSoftBedTemplateMxListV2(string typeName, List<u_softbed_mx> mxList)
|
|
|
|
|
+ {
|
|
|
|
|
+ foreach (var mx in mxList)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (string.IsNullOrWhiteSpace(mx.pzname))
|
|
|
|
|
+ {
|
|
|
|
|
+ throw new LJCommonException($"模板核价保存失败,类型:{typeName},明细行:{mx.printid} 未设置部件选配项名称(pzname)");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (string.IsNullOrWhiteSpace(mx.pznamemx))
|
|
|
|
|
+ {
|
|
|
|
|
+ throw new LJCommonException($"模板核价保存失败,类型:{typeName},明细行:{mx.printid} 未设置部件选配明细名称(pznamemx)");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (mx.mtrlid <= 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ throw new LJCommonException($"模板核价保存失败,类型:{typeName},明细行:{mx.printid} 物料ID无效");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private int EnsureSoftBedTemplateTypeV2(string typeName)
|
|
|
|
|
+ {
|
|
|
|
|
+ cmd.CommandText = @"SELECT TOP 1 contfigtypeid
|
|
|
|
|
+ FROM u_configure_type
|
|
|
|
|
+ WHERE LTRIM(RTRIM(contfigtypename)) = LTRIM(RTRIM(@contfigtypename))";
|
|
|
|
|
+ cmd.Parameters.Clear();
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@contfigtypename", typeName);
|
|
|
|
|
+ object result = cmd.ExecuteScalar();
|
|
|
|
|
+ if (result != null && result != DBNull.Value)
|
|
|
|
|
+ {
|
|
|
|
|
+ return Convert.ToInt32(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ var configure = new u_configure_type()
|
|
|
|
|
+ {
|
|
|
|
|
+ contfigtypeid = BllHelper.GetID(cmd, "u_configure_type"),
|
|
|
|
|
+ contfigtypename = typeName,
|
|
|
|
|
+ contfigtype = 0,
|
|
|
|
|
+ usechflag = 1,
|
|
|
|
|
+ flag = 0
|
|
|
|
|
+ };
|
|
|
|
|
+ DbSqlHelper.Insert(cmd, "u_configure_type", null, configure, "contfigtypeid,contfigtype,contfigtypename,usechflag,flag");
|
|
|
|
|
+ return configure.contfigtypeid.Value;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private int EnsureSoftBedTemplateCodeV2(int typeId, int currentPzid, string codeName)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (string.IsNullOrWhiteSpace(codeName)) throw new LJCommonException("模板核价保存失败,配置项名称不能为空");
|
|
|
|
|
+
|
|
|
|
|
+ string pzcode = string.Empty;
|
|
|
|
|
+ if (currentPzid > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ bool isExists = false;
|
|
|
|
|
+ int dbTypeId = 0;
|
|
|
|
|
+ string dbName = string.Empty;
|
|
|
|
|
+
|
|
|
|
|
+ cmd.CommandText = @"SELECT TOP 1 typeid,pzcode,name
|
|
|
|
|
+ FROM u_configure_code
|
|
|
|
|
+ WHERE pzid = @pzid";
|
|
|
|
|
+ cmd.Parameters.Clear();
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@pzid", currentPzid);
|
|
|
|
|
+ using (var reader = cmd.ExecuteReader())
|
|
|
|
|
+ {
|
|
|
|
|
+ if (reader.Read())
|
|
|
|
|
+ {
|
|
|
|
|
+ isExists = true;
|
|
|
|
|
+ pzcode = Convert.ToString(reader["pzcode"]);
|
|
|
|
|
+ dbTypeId = Convert.ToInt32(reader["typeid"]);
|
|
|
|
|
+ dbName = Convert.ToString(reader["name"]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (isExists)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (dbTypeId != typeId || !string.Equals((dbName ?? string.Empty).Trim(), codeName.Trim(), StringComparison.Ordinal))
|
|
|
|
|
+ {
|
|
|
|
|
+ cmd.CommandText = @"UPDATE u_configure_code
|
|
|
|
|
+ SET typeid = @typeid,
|
|
|
|
|
+ pzcode = @pzcode,
|
|
|
|
|
+ name = @name,
|
|
|
|
|
+ inputtype = @inputtype,
|
|
|
|
|
+ configtype = @configtype,
|
|
|
|
|
+ ifcross = @ifcross,
|
|
|
|
|
+ ifcheck = @ifcheck,
|
|
|
|
|
+ ifuse = @ifuse,
|
|
|
|
|
+ ifnum = @ifnum,
|
|
|
|
|
+ decnum = @decnum,
|
|
|
|
|
+ ifpack = @ifpack
|
|
|
|
|
+ WHERE pzid = @pzid";
|
|
|
|
|
+ cmd.Parameters.Clear();
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@typeid", typeId);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@pzcode", pzcode ?? string.Empty);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@name", codeName);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@inputtype", 0);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@configtype", 0);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@ifcross", 0);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@ifcheck", 0);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@ifuse", 1);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@ifnum", 0);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@decnum", 0);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@ifpack", 0);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@pzid", currentPzid);
|
|
|
|
|
+ cmd.ExecuteNonQuery();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return currentPzid;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ cmd.CommandText = @"SELECT TOP 1 pzid
|
|
|
|
|
+ FROM u_configure_code
|
|
|
|
|
+ WHERE typeid = @typeid
|
|
|
|
|
+ AND LTRIM(RTRIM(name)) = LTRIM(RTRIM(@name))";
|
|
|
|
|
+ cmd.Parameters.Clear();
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@typeid", typeId);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@name", codeName);
|
|
|
|
|
+ object result = cmd.ExecuteScalar();
|
|
|
|
|
+ if (result != null && result != DBNull.Value)
|
|
|
|
|
+ {
|
|
|
|
|
+ return Convert.ToInt32(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ int nextPzid = BllHelper.GetID(cmd, "u_configure_code");
|
|
|
|
|
+ pzcode = GetNextSoftBedTemplateCodeNoV2(typeId);
|
|
|
|
|
+
|
|
|
|
|
+ var insertCode = new u_configure_code()
|
|
|
|
|
+ {
|
|
|
|
|
+ typeid = typeId,
|
|
|
|
|
+ pzid = nextPzid,
|
|
|
|
|
+ pzcode = pzcode,
|
|
|
|
|
+ name = codeName,
|
|
|
|
|
+ inputtype = 0,
|
|
|
|
|
+ configtype = 0,
|
|
|
|
|
+ ifcross = 0,
|
|
|
|
|
+ ifcheck = 0,
|
|
|
|
|
+ ifuse = 1,
|
|
|
|
|
+ ifnum = 0,
|
|
|
|
|
+ decnum = 0,
|
|
|
|
|
+ ifpack = 0
|
|
|
|
|
+ };
|
|
|
|
|
+ DbSqlHelper.Insert(cmd, "u_configure_code", null, insertCode, "typeid,pzid,pzcode,inputtype,name,configtype,ifcross,ifcheck,ifuse,ifnum,decnum,ifpack");
|
|
|
|
|
+ return nextPzid;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private int EnsureSoftBedTemplateCodeMxV2(int pzid, int currentPrintId, string codeMxName)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (string.IsNullOrWhiteSpace(codeMxName)) throw new LJCommonException("模板核价保存失败,配置项明细名称不能为空");
|
|
|
|
|
+
|
|
|
|
|
+ string pzcode = GetSoftBedTemplateCodeNoV2(pzid);
|
|
|
|
|
+
|
|
|
|
|
+ if (currentPrintId > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ bool isExists = false;
|
|
|
|
|
+ string dbName = string.Empty;
|
|
|
|
|
+
|
|
|
|
|
+ cmd.CommandText = @"SELECT TOP 1 namemx
|
|
|
|
|
+ FROM u_configure_codemx
|
|
|
|
|
+ WHERE pzid = @pzid AND printid = @printid";
|
|
|
|
|
+ cmd.Parameters.Clear();
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@pzid", pzid);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@printid", currentPrintId);
|
|
|
|
|
+ using (var reader = cmd.ExecuteReader())
|
|
|
|
|
+ {
|
|
|
|
|
+ if (reader.Read())
|
|
|
|
|
+ {
|
|
|
|
|
+ isExists = true;
|
|
|
|
|
+ dbName = Convert.ToString(reader["namemx"]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (isExists)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (!string.Equals((dbName ?? string.Empty).Trim(), codeMxName.Trim(), StringComparison.Ordinal))
|
|
|
|
|
+ {
|
|
|
|
|
+ cmd.CommandText = @"UPDATE u_configure_codemx
|
|
|
|
|
+ SET pzcodemx = @pzcodemx,
|
|
|
|
|
+ namemx = @namemx,
|
|
|
|
|
+ ifuse = @ifuse
|
|
|
|
|
+ WHERE pzid = @pzid
|
|
|
|
|
+ AND printid = @printid";
|
|
|
|
|
+ cmd.Parameters.Clear();
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@pzcodemx", $"{pzcode}_{FormatCode(currentPrintId, 3)}");
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@namemx", codeMxName);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@ifuse", 1);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@pzid", pzid);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@printid", currentPrintId);
|
|
|
|
|
+ cmd.ExecuteNonQuery();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return currentPrintId;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ cmd.CommandText = @"SELECT TOP 1 printid
|
|
|
|
|
+ FROM u_configure_codemx
|
|
|
|
|
+ WHERE pzid = @pzid
|
|
|
|
|
+ AND LTRIM(RTRIM(namemx)) = LTRIM(RTRIM(@namemx))";
|
|
|
|
|
+ cmd.Parameters.Clear();
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@pzid", pzid);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@namemx", codeMxName);
|
|
|
|
|
+ object result = cmd.ExecuteScalar();
|
|
|
|
|
+ if (result != null && result != DBNull.Value)
|
|
|
|
|
+ {
|
|
|
|
|
+ return Convert.ToInt32(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ int nextPrintId = GetNextSoftBedTemplateCodeMxIdV2(pzid);
|
|
|
|
|
+ byte defaultFlag = HasSoftBedTemplateDefaultCodeMxV2(pzid) ? (byte)0 : (byte)1;
|
|
|
|
|
+
|
|
|
|
|
+ var insertMx = new u_configure_codemx()
|
|
|
|
|
+ {
|
|
|
|
|
+ pzid = pzid,
|
|
|
|
|
+ printid = nextPrintId,
|
|
|
|
|
+ pzcodemx = $"{pzcode}_{FormatCode(nextPrintId, 3)}",
|
|
|
|
|
+ namemx = codeMxName,
|
|
|
|
|
+ ifdft = defaultFlag,
|
|
|
|
|
+ ifuse = 1
|
|
|
|
|
+ };
|
|
|
|
|
+ DbSqlHelper.Insert(cmd, "u_configure_codemx", null, insertMx, "pzid,printid,pzcodemx,namemx,ifdft,ifuse");
|
|
|
|
|
+ return nextPrintId;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void ReplaceSoftBedTemplateBomV2(int pzid, int printid, List<u_softbed_mx> mxList)
|
|
|
|
|
+ {
|
|
|
|
|
+ var dbBomMap = new Dictionary<int, u_configure_codemxbom>();
|
|
|
|
|
+ cmd.CommandText = @"SELECT pzid,printid,pid,mtrlid,sonscale,sonscale_formula,mng_cost_rate,profit_rate,realqty,sonloss,sonloss_formula,
|
|
|
|
|
+ sondecloss,sondecloss_formula,default_length,default_width,default_qty
|
|
|
|
|
+ FROM u_configure_codemxbom
|
|
|
|
|
+ WHERE pzid = @pzid AND printid = @printid
|
|
|
|
|
+ ORDER BY pid";
|
|
|
|
|
+ cmd.Parameters.Clear();
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@pzid", pzid);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@printid", printid);
|
|
|
|
|
+ using (var reader = cmd.ExecuteReader())
|
|
|
|
|
+ {
|
|
|
|
|
+ while (reader.Read())
|
|
|
|
|
+ {
|
|
|
|
|
+ int mtrlid = Convert.ToInt32(reader["mtrlid"]);
|
|
|
|
|
+ if (dbBomMap.ContainsKey(mtrlid)) continue;
|
|
|
|
|
+
|
|
|
|
|
+ dbBomMap.Add(mtrlid, new u_configure_codemxbom()
|
|
|
|
|
+ {
|
|
|
|
|
+ pzid = Convert.ToInt32(reader["pzid"]),
|
|
|
|
|
+ printid = Convert.ToInt32(reader["printid"]),
|
|
|
|
|
+ pid = Convert.ToInt32(reader["pid"]),
|
|
|
|
|
+ mtrlid = mtrlid,
|
|
|
|
|
+ sonscale = Convert.ToDecimal(reader["sonscale"]),
|
|
|
|
|
+ sonscale_formula = Convert.ToString(reader["sonscale_formula"]),
|
|
|
|
|
+ mng_cost_rate = Convert.ToDecimal(reader["mng_cost_rate"]),
|
|
|
|
|
+ profit_rate = Convert.ToDecimal(reader["profit_rate"]),
|
|
|
|
|
+ realqty = Convert.ToDecimal(reader["realqty"]),
|
|
|
|
|
+ sonloss = Convert.ToDecimal(reader["sonloss"]),
|
|
|
|
|
+ sonloss_formula = Convert.ToString(reader["sonloss_formula"]),
|
|
|
|
|
+ sondecloss = Convert.ToDecimal(reader["sondecloss"]),
|
|
|
|
|
+ sondecloss_formula = Convert.ToString(reader["sondecloss_formula"]),
|
|
|
|
|
+ default_length = Convert.ToDecimal(reader["default_length"]),
|
|
|
|
|
+ default_width = Convert.ToDecimal(reader["default_width"]),
|
|
|
|
|
+ default_qty = Convert.ToDecimal(reader["default_qty"])
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ int nextPid = GetNextSoftBedTemplateBomPidV2(pzid, printid);
|
|
|
|
|
+ foreach (var mx in mxList.OrderBy(t => t.printid))
|
|
|
|
|
+ {
|
|
|
|
|
+ if (dbBomMap.TryGetValue(mx.mtrlid, out var dbBom))
|
|
|
|
|
+ {
|
|
|
|
|
+ cmd.CommandText = @"UPDATE u_configure_codemxbom
|
|
|
|
|
+ SET sonscale = @sonscale,
|
|
|
|
|
+ sonscale_formula = @sonscale_formula,
|
|
|
|
|
+ sonloss = @sonloss,
|
|
|
|
|
+ default_length = @default_length,
|
|
|
|
|
+ default_width = @default_width,
|
|
|
|
|
+ default_qty = @default_qty
|
|
|
|
|
+ WHERE pzid = @pzid
|
|
|
|
|
+ AND printid = @printid
|
|
|
|
|
+ AND pid = @pid";
|
|
|
|
|
+ cmd.Parameters.Clear();
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@sonscale", mx.useqty);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@sonscale_formula", mx.use_formula ?? string.Empty);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@sonloss", mx.loss_rate);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@default_length", mx.cutting_length);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@default_width", mx.cutting_width);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@default_qty", mx.cutting_qty);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@pzid", pzid);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@printid", printid);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@pid", dbBom.pid);
|
|
|
|
|
+ cmd.ExecuteNonQuery();
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ var bom = new u_configure_codemxbom()
|
|
|
|
|
+ {
|
|
|
|
|
+ pzid = pzid,
|
|
|
|
|
+ printid = printid,
|
|
|
|
|
+ pid = nextPid++,
|
|
|
|
|
+ mtrlid = mx.mtrlid,
|
|
|
|
|
+ sonscale = mx.useqty,
|
|
|
|
|
+ sonscale_formula = mx.use_formula,
|
|
|
|
|
+ mng_cost_rate = 0,
|
|
|
|
|
+ profit_rate = 0,
|
|
|
|
|
+ realqty = 0,
|
|
|
|
|
+ sonloss = mx.loss_rate,
|
|
|
|
|
+ sonloss_formula = string.Empty,
|
|
|
|
|
+ sondecloss = 0,
|
|
|
|
|
+ sondecloss_formula = string.Empty,
|
|
|
|
|
+ price = mx.price,
|
|
|
|
|
+ price_formula = mx.price_formula,
|
|
|
|
|
+ default_length = mx.cutting_length,
|
|
|
|
|
+ default_width = mx.cutting_width,
|
|
|
|
|
+ default_qty = mx.cutting_qty
|
|
|
|
|
+ };
|
|
|
|
|
+ DbSqlHelper.Insert(cmd, "u_configure_codemxbom", null, bom, "pzid,printid,pid,mtrlid,sonscale,sonscale_formula,mng_cost_rate,profit_rate,realqty,sonloss,sonloss_formula,sondecloss,sondecloss_formula,default_length,default_width,default_qty");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void BackWriteSoftBedTemplateMxIdsV2(u_softbed softbed)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (softbed.softbed_id <= 0 || softbed.mxList == null || softbed.mxList.Count <= 0) return;
|
|
|
|
|
+
|
|
|
|
|
+ foreach (var mx in softbed.mxList.Where(t => t.has_type == 1 || t.has_type == 2 || t.has_type == 4))
|
|
|
|
|
+ {
|
|
|
|
|
+ cmd.CommandText = @"UPDATE u_softbed_mx
|
|
|
|
|
+ SET pzid = @pzid,
|
|
|
|
|
+ pzmxid = @pzmxid,
|
|
|
|
|
+ pzname = @pzname
|
|
|
|
|
+ WHERE softbed_id = @softbed_id
|
|
|
|
|
+ AND printid = @printid";
|
|
|
|
|
+ cmd.Parameters.Clear();
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@pzid", mx.pzid);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@pzmxid", mx.pzmxid);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@pzname", mx.pzname ?? string.Empty);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@softbed_id", softbed.softbed_id);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@printid", mx.printid);
|
|
|
|
|
+ cmd.ExecuteNonQuery();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private string GetNextSoftBedTemplateCodeNoV2(int typeId)
|
|
|
|
|
+ {
|
|
|
|
|
+ int maxNum = 0;
|
|
|
|
|
+ cmd.CommandText = @"SELECT pzcode FROM u_configure_code WHERE typeid = @typeid";
|
|
|
|
|
+ cmd.Parameters.Clear();
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@typeid", typeId);
|
|
|
|
|
+ using (var reader = cmd.ExecuteReader())
|
|
|
|
|
+ {
|
|
|
|
|
+ while (reader.Read())
|
|
|
|
|
+ {
|
|
|
|
|
+ string pzcode = Convert.ToString(reader["pzcode"]).Trim();
|
|
|
|
|
+ if (int.TryParse(pzcode, out int currentNum) && currentNum > maxNum)
|
|
|
|
|
+ {
|
|
|
|
|
+ maxNum = currentNum;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return FormatCode(maxNum + 1, 4);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private string GetSoftBedTemplateCodeNoV2(int pzid)
|
|
|
|
|
+ {
|
|
|
|
|
+ cmd.CommandText = @"SELECT TOP 1 pzcode FROM u_configure_code WHERE pzid = @pzid";
|
|
|
|
|
+ cmd.Parameters.Clear();
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@pzid", pzid);
|
|
|
|
|
+ object result = cmd.ExecuteScalar();
|
|
|
|
|
+ return result == null || result == DBNull.Value ? string.Empty : Convert.ToString(result).Trim();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private int GetNextSoftBedTemplateCodeMxIdV2(int pzid)
|
|
|
|
|
+ {
|
|
|
|
|
+ cmd.CommandText = @"SELECT ISNULL(MAX(printid),0) FROM u_configure_codemx WHERE pzid = @pzid";
|
|
|
|
|
+ cmd.Parameters.Clear();
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@pzid", pzid);
|
|
|
|
|
+ object result = cmd.ExecuteScalar();
|
|
|
|
|
+ return Convert.ToInt32(result) + 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private bool HasSoftBedTemplateDefaultCodeMxV2(int pzid)
|
|
|
|
|
+ {
|
|
|
|
|
+ cmd.CommandText = @"SELECT COUNT(*) FROM u_configure_codemx WHERE pzid = @pzid AND ifdft = 1";
|
|
|
|
|
+ cmd.Parameters.Clear();
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@pzid", pzid);
|
|
|
|
|
+ return Convert.ToInt32(cmd.ExecuteScalar()) > 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private int GetNextSoftBedTemplateBomPidV2(int pzid, int printid)
|
|
|
|
|
+ {
|
|
|
|
|
+ cmd.CommandText = @"SELECT ISNULL(MAX(pid),0) FROM u_configure_codemxbom WHERE pzid = @pzid AND printid = @printid";
|
|
|
|
|
+ cmd.Parameters.Clear();
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@pzid", pzid);
|
|
|
|
|
+ cmd.Parameters.AddWithValue("@printid", printid);
|
|
|
|
|
+ return Convert.ToInt32(cmd.ExecuteScalar()) + 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
#region 通用公式
|
|
#region 通用公式
|
|
|
private CalculateFormula formula = new CalculateFormula();
|
|
private CalculateFormula formula = new CalculateFormula();
|
|
|
private string BillKeyWord = "u_softbed";
|
|
private string BillKeyWord = "u_softbed";
|