1467 lines
78 KiB
C#
1467 lines
78 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Configuration;
|
||
using System.Collections;
|
||
using System.Web;
|
||
using System.Web.Security;
|
||
using System.Web.UI;
|
||
using System.Web.UI.WebControls;
|
||
using System.Web.UI.WebControls.WebParts;
|
||
using System.Web.UI.HtmlControls;
|
||
using GThinking.N_MISPRO;
|
||
using GThinking.N_MISPRO.Data;
|
||
using GThinking.N_MODEL.Page;
|
||
using GThinking.N_WORKFLOW;
|
||
using GThinking.N_MODEL.Dialog;
|
||
using GThinking.N_PUBLIC;
|
||
using GThinking.N_MISPRO.Utility;
|
||
using GThinking.N_CONTROL;
|
||
using System.IO;
|
||
using System.Data.OleDb;
|
||
using System.Data.Common;
|
||
using GThinking.N_MISPROAS;
|
||
|
||
|
||
namespace GThinking.N_XLXSBJ
|
||
{
|
||
public partial class XLBJD_JYDRInfo : SingleCardBase
|
||
{
|
||
XLBJD_JYDR entity = new XLBJD_JYDR();
|
||
|
||
#region page类事件
|
||
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
this.UMID = 100860000;
|
||
this.UMName = "线缆销售报价单";
|
||
base.CurMaster = Master;
|
||
base.CurEntity = entity;
|
||
this.PageHeight = 180;
|
||
this.PageWidth = 420;
|
||
Master.EnableAttachBtn = false;
|
||
Master.EnableCancelBtn = false;
|
||
Master.EnableCopyBtn = false;
|
||
Master.EnableDeleteBtn = false;
|
||
Master.EnableEditBtn = false;
|
||
Master.EnableInsertBtn = false;
|
||
Master.EnablePrintBtn = false;
|
||
Master.EnableRefreshBtn = false;
|
||
Master.EnableSaveBtn = false;
|
||
fupdPost.FileSaveType = gtAsyncFileUpload.DFileSaveType.SaveToPath;
|
||
if (AppRuntime.BitType == AppBitType.Bit32)
|
||
fupdPost.Filter = "XLS";
|
||
else // AppBitType.Bit64
|
||
fupdPost.Filter = "XLS,XLSX";
|
||
base.InitPage();
|
||
if (!IsPostBack)
|
||
{
|
||
txtBJDID.Value = PageParam.GetRTrimString("BJDID");
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 控件事件
|
||
|
||
private DataSet ExcelColumnValid(DataSet ds)
|
||
{
|
||
if (!ds.Tables[0].Columns[0].ColumnName.Trim().Equals("报价产品"))
|
||
{
|
||
throw new Exception("栏目[" + ds.Tables[0].Columns[0].ColumnName + "]与导入文件要求的栏目格式不一致!");
|
||
}
|
||
Dictionary<string, int> ColumnNames = new Dictionary<string, int>();
|
||
ColumnNames.Add("计量单位", 0);
|
||
ColumnNames.Add("报价数量", 0);
|
||
ColumnNames.Add("报价", 0);
|
||
ColumnNames.Add("备注", 0);
|
||
for (int i = 1; i < ds.Tables[0].Columns.Count; i++)
|
||
{
|
||
foreach (string key in ColumnNames.Keys)
|
||
{
|
||
if (ds.Tables[0].Columns[i].ColumnName.Trim().Equals(key))
|
||
{
|
||
ColumnNames[key] = i;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
DataSet dsRusult = new DataSet();
|
||
DataTable dt = new DataTable();
|
||
dt.Columns.Add("XLWBBJDMX_BJDID");
|
||
dt.Columns.Add("XLWBBJDMX_XLXHID");
|
||
dt.Columns.Add("XLWBBJDMX_XLGGID");
|
||
dt.Columns.Add("XLWBBJDMX_XLBZID");
|
||
dt.Columns.Add("XLWBBJDMX_DYDJID");
|
||
dt.Columns.Add("XLWBBJDMX_BJCP");
|
||
dt.Columns.Add("XLWBBJDMX_JLDW");
|
||
dt.Columns.Add("XLWBBJDMX_BJSL");
|
||
dt.Columns.Add("XLWBBJDMX_CPBJ");
|
||
dt.Columns.Add("XLWBBJDMX_BZ");
|
||
dt.Columns.Add("BZ_DYDJID");
|
||
dt.Columns.Add("DRBJCP");
|
||
dsRusult.Tables.Add(dt);
|
||
string sDefaultXLBZID = XLBJDUtils.GetDefaultXLBZID();
|
||
if (sDefaultXLBZID.Equals(""))
|
||
sDefaultXLBZID = " ";
|
||
foreach (DataRow Row in ds.Tables[0].Rows)
|
||
{
|
||
DataRow rowRuslt = dsRusult.Tables[0].NewRow();
|
||
rowRuslt["XLWBBJDMX_BJDID"] = txtBJDID.Value.Trim();
|
||
rowRuslt["XLWBBJDMX_BJCP"] = sGetCellTest(Row, 0).Trim();
|
||
rowRuslt["DRBJCP"] = sGetCellTest(Row, 0).Trim();
|
||
string sJLDW = "";
|
||
if(ColumnNames["计量单位"] == 0)
|
||
sJLDW = "";
|
||
else
|
||
sJLDW = sGetCellTest(Row, ColumnNames["计量单位"]).Trim();
|
||
if (sJLDW.Equals(""))
|
||
sJLDW = tSession.GetOption(100860000, "BJU003");
|
||
else
|
||
{
|
||
sJLDW = sJLDW.Replace("km", "Km").Replace("KM", "Km").Replace("kM", "Km");
|
||
sJLDW = sJLDW.Replace("m", "M");
|
||
sJLDW = sJLDW.Replace("kg", "Kg").Replace("KG", "Kg").Replace("kG", "Kg");
|
||
sJLDW = sJLDW.Replace("t", "T");
|
||
}
|
||
rowRuslt["XLWBBJDMX_JLDW"] = sJLDW;
|
||
if (ColumnNames["报价数量"] == 0)
|
||
rowRuslt["XLWBBJDMX_BJSL"] = "0";
|
||
else
|
||
rowRuslt["XLWBBJDMX_BJSL"] = sGetCellTest(Row, ColumnNames["报价数量"]).Trim() == "" ? "0" : sGetCellTest(Row, ColumnNames["报价数量"]).Trim();
|
||
if (ColumnNames["报价"] == 0)
|
||
rowRuslt["XLWBBJDMX_CPBJ"] = "0";
|
||
else
|
||
rowRuslt["XLWBBJDMX_CPBJ"] = sGetCellTest(Row, ColumnNames["报价"]).Trim() == "" ? "0" : sGetCellTest(Row, ColumnNames["报价"]).Trim();
|
||
if (ColumnNames["备注"] == 0)
|
||
rowRuslt["XLWBBJDMX_BZ"] = "";
|
||
else
|
||
rowRuslt["XLWBBJDMX_BZ"] = sGetCellTest(Row, ColumnNames["备注"]).Trim();
|
||
rowRuslt["XLWBBJDMX_XLBZID"] = sDefaultXLBZID.Equals("FirstBZ") ? " " : sDefaultXLBZID;
|
||
if (GetOption(100860043,"BJU028") == "Y")
|
||
rowRuslt["XLWBBJDMX_XLBZID"] = " ";
|
||
|
||
dsRusult.Tables[0].Rows.Add(rowRuslt);
|
||
|
||
}
|
||
return dsRusult;
|
||
}
|
||
|
||
protected void btnQD_Click(object sender, EventArgs e)
|
||
{
|
||
if (fupdPost.FilePath.Equals(""))
|
||
{
|
||
ShowMessage("请选择需要导入的文件!");
|
||
return;
|
||
}
|
||
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
||
TSQL sSQL = new TSQL(dberp);
|
||
try
|
||
{
|
||
lblTitle.Text = "正在导入数据,请稍后...";
|
||
dberp.BeginTrans();
|
||
DataSet aDataExcel = new DataSet();
|
||
if (AppRuntime.BitType == AppBitType.Bit32)
|
||
aDataExcel = XLBJDUtils.ReadFromExcelFile(fupdPost.FilePath, 0, "");
|
||
else // AppBitType.Bit64
|
||
ReadWJ(fupdPost.FilePath, ref aDataExcel);
|
||
|
||
XLWBBJDUtils.DeleteInValidEmptyRow(ref aDataExcel);
|
||
DataSet dsTMP = ExcelColumnValid(aDataExcel);
|
||
dsTMP.Tables[0].Columns.Add("OLD_XLXHID");
|
||
dsTMP.Tables[0].Columns.Add("OLD_XLGGID");
|
||
dsTMP.Tables[0].Columns.Add("OLD_DYDJID");
|
||
InsertMX(dberp, sSQL, dsTMP);
|
||
dberp.CommitTrans();
|
||
if (PageParam.GetRTrimString("txtNeedCallBackCID").Equals(""))
|
||
{
|
||
ShowMessage("导入成功!");
|
||
CloseWindow();
|
||
}
|
||
else
|
||
{
|
||
DialogOperationScript dos = new DialogOperationScript(this);
|
||
dos.SetOwnerControlValue(PageParam.GetRTrimString("txtNeedCallBackCID"), "Y");
|
||
dos.CloseSelf();
|
||
dos.Execute();
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
lblTitle.Text = "";
|
||
dberp.RollbackTrans();
|
||
ShowMessage(ex.Message);
|
||
}
|
||
}
|
||
|
||
protected void btnQX_Click(object sender, EventArgs e)
|
||
{
|
||
CloseWindow();
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 自定义事件
|
||
|
||
//private bool IsExsitMX(string sBJDID, int XH)
|
||
//{
|
||
// return CMISproDataBase.ExistsRecord("DBERP", String.Format("select 1 from XLBJDMX where XLBJDMX_BJDID = '{0}' and XLBJDMX_XH = {1}", sBJDID, XH));
|
||
//}
|
||
|
||
private void InsertMX(TDatabase dberp, TSQL SQL, DataSet ds)
|
||
{
|
||
string sErrorNum = "";
|
||
string sXLJGU007 = GetOption(102579000, "XLJGU007");
|
||
List<string> lstXLXHID = new List<string>();
|
||
List<string> lstXLGGID = new List<string>();
|
||
List<string> lstDYDJID = new List<string>();
|
||
List<string> lstXLXHTZ = new List<string>();
|
||
List<string> lstXLGGTZ = new List<string>();
|
||
List<string> lstBJXHList = new List<string>();
|
||
Dictionary<string, string> dicXLWBBJDXHDZB = new Dictionary<string, string>();
|
||
XLBJD_WBBJDMXList.GetXLXHIDList(dberp, SQL, true, ref lstXLXHID);
|
||
XLBJD_WBBJDMXList.GetXLGGIDList(dberp, SQL, ref lstXLGGID);
|
||
XLBJD_WBBJDMXList.GetDYDJIDList(dberp, SQL, ref lstDYDJID);
|
||
XLBJD_WBBJDMXList.GetXLWBBJDXHDZB(dberp, SQL, ref dicXLWBBJDXHDZB);
|
||
XLXSBJPZXX pzxx = XLBJDUtils.GetXLXSBJPZXX(100860043);
|
||
if (pzxx.XLXSBJPZ_THSFTGKBXH == "Y")
|
||
XLBJD_WBBJDMXList.GetBJXHList(dberp, SQL, PageParam.GetRTrimString("JGBID"), PageParam.GetRTrimString("JGCIDS"), ref lstBJXHList);
|
||
else
|
||
lstBJXHList.Clear();
|
||
|
||
DataSet dsXLWBBJDANXX = new DataSet();
|
||
dsXLWBBJDANXX = XLBJD_WBBJDMXList.GetXLWBBJDANXX("01");
|
||
for (int i = 0; i < dsXLWBBJDANXX.Tables[0].Rows.Count; i++)
|
||
{
|
||
lstXLXHTZ.Add(dsXLWBBJDANXX.Tables[0].Rows[i]["XLWBBJDANXX_ANXX"].ToString().Trim());
|
||
}
|
||
|
||
dsXLWBBJDANXX = XLBJD_WBBJDMXList.GetXLWBBJDANXX("02");
|
||
for (int i = 0; i < dsXLWBBJDANXX.Tables[0].Rows.Count; i++)
|
||
{
|
||
lstXLGGTZ.Add(dsXLWBBJDANXX.Tables[0].Rows[i]["XLWBBJDANXX_ANXX"].ToString().Trim());
|
||
}
|
||
|
||
XLBJD_WBBJDMXList.JXDYDJ(ref ds);
|
||
|
||
if (lstXLGGTZ.Count == 0)
|
||
{
|
||
XLBJD_WBBJDMXList.TZBJCP_1(ref ds);
|
||
}
|
||
else if (lstXLGGTZ.Contains("7"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZBJCP_1(ref ds);
|
||
}
|
||
if (lstXLGGTZ.Contains("B"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZBJCP_4(ref ds);
|
||
}
|
||
if (lstXLXHTZ.Count == 0)
|
||
{
|
||
XLBJD_WBBJDMXList.TZBJCP_2(ref ds);
|
||
}
|
||
else if (lstXLXHTZ.Contains("6"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZBJCP_2(ref ds);
|
||
}
|
||
XLBJD_WBBJDMXList.TZBJCP_3(ref ds);
|
||
XLBJD_WBBJDMXList.TZBJCP_0(ref ds);
|
||
Analysis_Common2(ref ds, lstXLXHID, lstXLGGID, lstDYDJID);
|
||
if (pzxx.XLXSBJPZ_JLTZHCP.Equals("Y"))
|
||
XLBJD_WBBJDMXList.JLYXHGGDY(ref ds);
|
||
//该处为型号新规范化调整---后续如果能够收集一个集合最佳
|
||
/*
|
||
dic.Add("0", "NH-替换为N-");
|
||
dic.Add("1", "ZR-替换为ZC-");
|
||
dic.Add("2", "ZN-替换为ZCN-");
|
||
dic.Add("3", "WDZ-替换为WDZC-");
|
||
dic.Add("4", "WDZN-替换为WDZCN-");
|
||
dic.Add("5", "去除空格");
|
||
dic.Add("6", "去除中文");
|
||
dic.Add("7", "型号替换");
|
||
*/
|
||
if (lstXLXHTZ.Count == 0)
|
||
{
|
||
Dictionary<string, string> dicMRZX = XLBJD_WBBJDANXX.XHTZ_MRZS();
|
||
foreach (KeyValuePair<string, string> kvp in dicMRZX)
|
||
{
|
||
if (kvp.Key.Equals("0"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_0(lstBJXHList,ref ds);
|
||
}
|
||
if (kvp.Key.Equals("1"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_1(lstBJXHList, ref ds);
|
||
}
|
||
if (kvp.Key.Equals("2"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_2(lstBJXHList, ref ds);
|
||
}
|
||
if (kvp.Key.Equals("3"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_3(lstBJXHList, ref ds);
|
||
}
|
||
if (kvp.Key.Equals("4"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_4(lstBJXHList, ref ds);
|
||
}
|
||
if (kvp.Key.Equals("8"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_8(lstBJXHList, ref ds);
|
||
}
|
||
if (kvp.Key.Equals("9"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_9(lstBJXHList, ref ds);
|
||
}
|
||
if (kvp.Key.Equals("A"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_A(lstBJXHList, ref ds);
|
||
}
|
||
if (kvp.Key.Equals("B"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_B(lstBJXHList, ref ds);
|
||
}
|
||
if (kvp.Key.Equals("C"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_C(lstBJXHList, ref ds);
|
||
}
|
||
if (kvp.Key.Equals("D"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_D(lstBJXHList, ref ds);
|
||
}
|
||
if (kvp.Key.Equals("7"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_7(ref ds, dicXLWBBJDXHDZB);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//依照配置顺序执行
|
||
for (int i = 0; i < lstXLXHTZ.Count; i++)
|
||
{
|
||
if (lstXLXHTZ[i].Equals("0"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_0(lstBJXHList, ref ds);
|
||
}
|
||
if (lstXLXHTZ[i].Equals("1"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_1(lstBJXHList, ref ds);
|
||
}
|
||
if (lstXLXHTZ[i].Equals("2"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_2(lstBJXHList, ref ds);
|
||
}
|
||
if (lstXLXHTZ[i].Equals("3"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_3(lstBJXHList, ref ds);
|
||
}
|
||
if (lstXLXHTZ[i].Equals("4"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_4(lstBJXHList, ref ds);
|
||
}
|
||
if (lstXLXHTZ[i].Equals("8"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_8(lstBJXHList, ref ds);
|
||
}
|
||
if (lstXLXHTZ[i].Equals("9"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_9(lstBJXHList, ref ds);
|
||
}
|
||
if (lstXLXHTZ[i].Equals("A"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_A(lstBJXHList, ref ds);
|
||
}
|
||
if (lstXLXHTZ[i].Equals("B"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_B(lstBJXHList, ref ds);
|
||
}
|
||
if (lstXLXHTZ[i].Equals("C"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_C(lstBJXHList, ref ds);
|
||
}
|
||
if (lstXLXHTZ[i].Equals("D"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_D(lstBJXHList, ref ds);
|
||
}
|
||
if (lstXLXHTZ[i].Equals("E"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_E(lstBJXHList, ref ds);
|
||
}
|
||
if (lstXLXHTZ[i].Equals("F"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_F(lstBJXHList, ref ds);
|
||
}
|
||
if (lstXLXHTZ[i].Equals("G"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_G(lstBJXHList, ref ds);
|
||
}
|
||
if (lstXLXHTZ[i].Equals("H"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_H(lstBJXHList, ref ds);
|
||
}
|
||
if (lstXLXHTZ[i].Equals("I"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_I(lstBJXHList, ref ds);
|
||
}
|
||
if (lstXLXHTZ[i].Equals("J"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_J(lstBJXHList, ref ds);
|
||
}
|
||
if (lstXLXHTZ[i].Equals("K"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_K(lstBJXHList, ref ds);
|
||
}
|
||
if (lstXLXHTZ[i].Equals("L"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_L(lstBJXHList, ref ds);
|
||
}
|
||
if (lstXLXHTZ[i].Equals("M"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_M(lstBJXHList, ref ds);
|
||
}
|
||
//自定义替换规则
|
||
if (lstXLXHTZ[i].Contains("N") && lstXLXHTZ[i].Length > 1)
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_ZDY(lstBJXHList, lstXLXHTZ[i], ref ds);
|
||
}
|
||
if (lstXLXHTZ[i].Equals("7"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZXH_7(ref ds, dicXLWBBJDXHDZB);
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
//该处为规格去除不规范调整,涉及情况较为复杂
|
||
/*
|
||
--btnGGTZ.Nodes.Add(new gtTreeNode("0", "×替换为*"));
|
||
--btnGGTZ.Nodes.Add(new gtTreeNode("1", "去除非数值字符"));
|
||
--btnGGTZ.Nodes.Add(new gtTreeNode("2", "1*截面"));
|
||
--btnGGTZ.Nodes.Add(new gtTreeNode("3", "x/X替换为*"));
|
||
--btnGGTZ.Nodes.Add(new gtTreeNode("4", "去除.0"));
|
||
--btnGGTZ.Nodes.Add(new gtTreeNode("5", "*替换为×"));
|
||
--btnGGTZ.Nodes.Add(new gtTreeNode("6", "x/X替换为×"));
|
||
--btnGGTZ.Nodes.Add(new gtTreeNode("7", "去除mm2、mm"));
|
||
--btnGGTZ.Nodes.Add(new gtTreeNode("8", "E或者PE替换为1*"));
|
||
--btnGGTZ.Nodes.Add(new gtTreeNode("9", "去除空格"));
|
||
*/
|
||
if (lstXLGGTZ.Count == 0)
|
||
{
|
||
//目前支持0-9
|
||
XLBJD_WBBJDMXList.TZGG_7(ref ds);
|
||
XLBJD_WBBJDMXList.TZGG_9(ref ds);
|
||
XLBJD_WBBJDMXList.TZGG_8(ref ds);
|
||
//3和6执行一个即可。
|
||
XLBJD_WBBJDMXList.TZGG_3(ref ds);
|
||
XLBJD_WBBJDMXList.TZGG_1(ref ds);
|
||
XLBJD_WBBJDMXList.TZGG_2(ref ds);
|
||
//A|× B|*
|
||
if (sXLJGU007.Equals("B"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZGG_0(ref ds);
|
||
}
|
||
else
|
||
{
|
||
XLBJD_WBBJDMXList.TZGG_5(ref ds);
|
||
}
|
||
XLBJD_WBBJDMXList.TZGG_4(ref ds);
|
||
}
|
||
else
|
||
{
|
||
//依照配置顺序执行
|
||
for (int i = 0; i < lstXLGGTZ.Count; i++)
|
||
{
|
||
if (lstXLGGTZ[i].Equals("7"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZGG_7(ref ds);
|
||
}
|
||
if (lstXLGGTZ[i].Equals("9"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZGG_9(ref ds);
|
||
}
|
||
if (lstXLGGTZ[i].Equals("8"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZGG_8(ref ds);
|
||
}
|
||
if (sXLJGU007.Equals("B"))
|
||
{
|
||
if (lstXLGGTZ[i].Equals("3"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZGG_3(ref ds);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (lstXLGGTZ[i].Equals("6"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZGG_6(ref ds);
|
||
}
|
||
}
|
||
if (lstXLGGTZ[i].Equals("1"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZGG_1(ref ds);
|
||
}
|
||
if (lstXLGGTZ[i].Equals("2"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZGG_2(ref ds);
|
||
}
|
||
if (sXLJGU007.Equals("B"))
|
||
{
|
||
if (lstXLGGTZ[i].Equals("0"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZGG_0(ref ds);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (lstXLGGTZ[i].Equals("5"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZGG_5(ref ds);
|
||
}
|
||
}
|
||
if (lstXLGGTZ[i].Equals("4"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZGG_4(ref ds);
|
||
}
|
||
if (lstXLGGTZ[i].Equals("A"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZGG_A(ref ds);
|
||
}
|
||
if (lstXLGGTZ[i].Equals("B"))
|
||
{
|
||
XLBJD_WBBJDMXList.TZGG_B(ref ds);
|
||
}
|
||
}
|
||
}
|
||
//使用标准电压等级替换外部报价单明细电压等级
|
||
XLBJD_WBBJDMXList.DYDJTH(ref ds);
|
||
int iMaxXH = CMISproDataBase.GetMaxXH("DBERP", "XLXSBJDMX", "XLXSBJDMX_XH", "XLXSBJDMX_BJDID='" + txtBJDID.Value.Trim() + "'");
|
||
int iStartXH = iMaxXH + 1;
|
||
int iXH = iStartXH;
|
||
int iXSSX = CMISproDataBase.GetMaxXH("DBERP", "XLXSBJDMX", "XLXSBJDMX_XSSX", "XLXSBJDMX_BJDID = '" + txtBJDID.Value.Trim() + "'") + 1 ;
|
||
//处理修订标志
|
||
if (pzxx.XLXSBJPZ_JLTZHCP.Equals("Y"))
|
||
XLBJD_WBBJDMXList.UpdateBZ(ref ds);
|
||
foreach (DataRow Row in ds.Tables[0].Rows)
|
||
{
|
||
//如果报价数量不合法或小于0,则按0导入
|
||
double fBJSL = CMISproConvert.StrToFloat(sGetCellTest(Row, 7), 0);
|
||
if (fBJSL < 0)
|
||
fBJSL = 0;
|
||
SQL.Clear();
|
||
SQL.Add(" insert into XLXSBJDMX( ");
|
||
SQL.Add(" XLXSBJDMX_BJDID, XLXSBJDMX_XH, XLXSBJDMX_XSSX, XLXSBJDMX_XLXHID, XLXSBJDMX_XLGGID,XLXSBJDMX_XDXLXHID,XLXSBJDMX_XDXLBZID, ");
|
||
SQL.Add(" XLXSBJDMX_XLBZID, XLXSBJDMX_DYDJID, XLXSBJDMX_BJCP,XLXSBJDMX_BJCPSD,XLXSBJDMX_WGCPBZ,XLXSBJDMX_BJSDBZ, ");
|
||
SQL.Add(" XLXSBJDMX_JLDW, XLXSBJDMX_BJSL, XLXSBJDMX_JGBBJ, XLXSBJDMX_TZQCPBJ,XLXSBJDMX_TZCPBJ,XLXSBJDMX_CPBJ, XLXSBJDMX_TZQBJJE,XLXSBJDMX_BJJE, XLXSBJDMX_JGBJJ,XLXSBJDMX_CLCB,XLXSBJDMX_JGBBJLJJCL,XLXSBJDMX_JGBBJJCL,XLXSBJDMX_JGBBJJCE,XLXSBJDMX_CLZL, ");
|
||
SQL.Add(" XLXSBJDMX_BJDHQCLCB,XLXSBJDMX_CLCBJCL,XLXSBJDMX_BZ, XLXSBJDMX_WHRID, XLXSBJDMX_WHR, XLXSBJDMX_WHSJ)");
|
||
SQL.Add(" values(");
|
||
SQL.Add(" :XLXSBJDMX_BJDID, :XLXSBJDMX_XH, :XLXSBJDMX_XSSX, :XLXSBJDMX_XLXHID, :XLXSBJDMX_XLGGID,:XLXSBJDMX_XDXLXHID,:XLXSBJDMX_XDXLBZID, ");
|
||
SQL.Add(" :XLXSBJDMX_XLBZID, isnull(:XLXSBJDMX_DYDJID,' '), :XLXSBJDMX_BJCP,:XLXSBJDMX_BJCPSD,:XLXSBJDMX_WGCPBZ,:XLXSBJDMX_BJSDBZ, ");
|
||
SQL.Add(" :XLXSBJDMX_JLDW, :XLXSBJDMX_BJSL, :XLXSBJDMX_JGBBJ, :XLXSBJDMX_TZQCPBJ,:XLXSBJDMX_TZCPBJ,:XLXSBJDMX_CPBJ, :XLXSBJDMX_TZQBJJE,:XLXSBJDMX_BJJE, :XLXSBJDMX_JGBJJ,:XLXSBJDMX_CLCB,:XLXSBJDMX_JGBBJLJJCL,:XLXSBJDMX_JGBBJJCL,:XLXSBJDMX_JGBBJJCE,:XLXSBJDMX_CLZL, ");
|
||
SQL.Add(" :XLXSBJDMX_BJDHQCLCB,:XLXSBJDMX_CLCBJCL,:XLXSBJDMX_BZ, :XLXSBJDMX_WHRID, :XLXSBJDMX_WHR, :XLXSBJDMX_WHSJ)");
|
||
SQL.ParamByName("XLXSBJDMX_BJDID").Value = sGetCellTest(Row, 0);
|
||
SQL.ParamByName("XLXSBJDMX_XH").Value = iXH++;
|
||
SQL.ParamByName("XLXSBJDMX_XSSX").Value = iXSSX++;
|
||
SQL.ParamByName("XLXSBJDMX_XLXHID").Value = sGetCellTest(Row, 1);
|
||
SQL.ParamByName("XLXSBJDMX_XLGGID").Value = sGetCellTest(Row, 2);
|
||
SQL.ParamByName("XLXSBJDMX_XLBZID").Value = sGetCellTest(Row, 3);
|
||
SQL.ParamByName("XLXSBJDMX_DYDJID").Value = sGetCellTest(Row, 4);
|
||
SQL.ParamByName("XLXSBJDMX_BJCP").Value = sGetCellTest(Row, 11);
|
||
SQL.ParamByName("XLXSBJDMX_JLDW").Value = sGetCellTest(Row, 6);
|
||
SQL.ParamByName("XLXSBJDMX_BJSL").Value = fBJSL;
|
||
SQL.ParamByName("XLXSBJDMX_XDXLXHID").Value = sGetCellTest(Row, 1);
|
||
SQL.ParamByName("XLXSBJDMX_XDXLBZID").Value = sGetCellTest(Row, 3);
|
||
//SQL.ParamByName("XLXSBJDMX_XLYSID").Value = XLBJDInfo.GetDefaultYSID(sXLXHID, sXLGGID);
|
||
if(sGetCellTest(Row, 11).Equals(""))
|
||
SQL.ParamByName("XLXSBJDMX_BJCPSD").Value = "N";
|
||
else
|
||
SQL.ParamByName("XLXSBJDMX_BJCPSD").Value = "Y";
|
||
//即使不是基础计量单位,也应当直接导入。
|
||
SQL.ParamByName("XLXSBJDMX_JGBBJ").Value = 0.0;
|
||
SQL.ParamByName("XLXSBJDMX_TZQCPBJ").Value = 0.0;
|
||
SQL.ParamByName("XLXSBJDMX_TZCPBJ").Value = 0;
|
||
double dCPBJ = CMISproConvert.StrToFloat(sGetCellTest(Row, 8), 0);
|
||
if (dCPBJ != 0)
|
||
{
|
||
SQL.ParamByName("XLXSBJDMX_CPBJ").Value = dCPBJ;
|
||
SQL.ParamByName("XLXSBJDMX_BJSDBZ").Value = "Y";
|
||
|
||
}
|
||
else
|
||
{
|
||
SQL.ParamByName("XLXSBJDMX_CPBJ").Value = 0.0;
|
||
SQL.ParamByName("XLXSBJDMX_BJSDBZ").Value = "N";
|
||
}
|
||
SQL.ParamByName("XLXSBJDMX_JGBJJ").Value = 0.0;
|
||
SQL.ParamByName("XLXSBJDMX_CLCB").Value = 0.0;
|
||
SQL.ParamByName("XLXSBJDMX_BJDHQCLCB").Value = 0.0;
|
||
SQL.ParamByName("XLXSBJDMX_CLZL").Value = 0.0;
|
||
|
||
SQL.ParamByName("XLXSBJDMX_BJJE").Value = NumberUtils.RoundX(fBJSL * CMISproConvert.StrToFloat(SQL.ParamByName("XLXSBJDMX_CPBJ").Value.ToString(), 0), 2).ToString();
|
||
SQL.ParamByName("XLXSBJDMX_TZQBJJE").Value = SQL.ParamByName("XLXSBJDMX_BJJE").Value;
|
||
|
||
SQL.ParamByName("XLXSBJDMX_JGBBJJCE").Value = 0;
|
||
SQL.ParamByName("XLXSBJDMX_JGBBJJCL").Value = 0;
|
||
SQL.ParamByName("XLXSBJDMX_JGBBJLJJCL").Value = 0;
|
||
SQL.ParamByName("XLXSBJDMX_CLCBJCL").Value = 0;
|
||
|
||
SQL.ParamByName("XLXSBJDMX_WGCPBZ").Value = "N";
|
||
SQL.ParamByName("XLXSBJDMX_BZ").Value = sGetCellTest(Row, 9);
|
||
SQL.ParamByName("XLXSBJDMX_WHR").Value = tSession.UserName;
|
||
SQL.ParamByName("XLXSBJDMX_WHRID").Value = tSession.UserId;
|
||
SQL.ParamByName("XLXSBJDMX_WHSJ").Value = DateTime.Now;
|
||
dberp.ExecSQL(SQL);
|
||
}
|
||
SelectMatchForXLXHIDAndXLGGID(iMaxXH);
|
||
if (GetOption(100860043, "BJU028") != "Y")
|
||
MatchForXLBZIDAndDYDJID(false, PageParam.GetRTrimString("JGBID"),iMaxXH);
|
||
SQL.Clear();
|
||
SQL.Add(" SELECT XLXSBJDMX_BJDID,XLXSBJDMX_XH,XLXSBJDMX_XLXHID,XLXSBJDMX_XLGGID,XLXSBJDMX_XLBZID,XLXSBJDMX_DYDJID FROM XLXSBJDMX WHERE XLXSBJDMX_BJDID = :pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.ParamByName("pXH").Value = iMaxXH;
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
DataSet dsMX = dberp.OpenDataSet(SQL);
|
||
for (int i = 0; i < dsMX.Tables[0].Rows.Count; i++)
|
||
{
|
||
string sXLXHID = dsMX.Tables[0].Rows[i]["XLXSBJDMX_XLXHID"].ToString().Trim().ToUpper();
|
||
string sXLGGID = dsMX.Tables[0].Rows[i]["XLXSBJDMX_XLGGID"].ToString().Trim();
|
||
string sDYDJID = dsMX.Tables[0].Rows[i]["XLXSBJDMX_DYDJID"].ToString().Replace('K', 'k').Replace('v', 'V');
|
||
string sXLYSID = XLBJDInfo.GetDefaultYSID(sXLXHID, sXLGGID);
|
||
if (sXLXHID.Equals(""))
|
||
sXLXHID = "/";
|
||
if (sXLGGID.Equals(""))
|
||
sXLGGID = "/";
|
||
if (sDYDJID.Equals(""))
|
||
sDYDJID = " ";
|
||
SQL.Clear();
|
||
SQL.Add(" update XLXSBJDMX set XLXSBJDMX_XLXHID=:XLXSBJDMX_XLXHID,XLXSBJDMX_XLGGID=:XLXSBJDMX_XLGGID,XLXSBJDMX_DYDJID=:XLXSBJDMX_DYDJID, ");
|
||
SQL.Add(" XLXSBJDMX_XLYSID=:XLXSBJDMX_XLYSID ");
|
||
SQL.Add(" WHERE XLXSBJDMX_BJDID=:XLXSBJDMX_BJDID AND XLXSBJDMX_XH=:XLXSBJDMX_XH ");
|
||
SQL.ParamByName("XLXSBJDMX_XLXHID").Value = sXLXHID;
|
||
SQL.ParamByName("XLXSBJDMX_XLGGID").Value = sXLGGID;
|
||
SQL.ParamByName("XLXSBJDMX_DYDJID").Value = sDYDJID;
|
||
SQL.ParamByName("XLXSBJDMX_XLYSID").Value = sXLYSID;
|
||
SQL.ParamByName("XLXSBJDMX_BJDID").Value = dsMX.Tables[0].Rows[i]["XLXSBJDMX_BJDID"].ToString().Trim();
|
||
SQL.ParamByName("XLXSBJDMX_XH").Value = dsMX.Tables[0].Rows[i]["XLXSBJDMX_XH"].ToString().Trim();
|
||
dberp.ExecSQL(SQL);
|
||
}
|
||
SQL.Clear();
|
||
SQL.Add(" update XLXSBJDMX set XLXSBJDMX_DZSC='Y' ");
|
||
SQL.Add(" where XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH>:pXH ");
|
||
SQL.Add(" and exists(select 1 from XLBZ where ( ");
|
||
SQL.Add(" isnull(XLBZ_DZSC,'N') = 'Y' ");
|
||
SQL.Add(" ) ");
|
||
SQL.Add(" and XLBZ_XLBZID =XLXSBJDMX_XLBZID )");
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
SQL.ParamByName("pXH").Value = iMaxXH;
|
||
dberp.ExecSQL(SQL);
|
||
XLBJDUtils.SyncXLXSBJXLGGTHB_ByXLXSBJDMX_Batch(dberp, tSession, txtBJDID.Value.Trim(), "", iStartXH - 1);
|
||
XLBJDUtils.UpdateXDXLBZID(dberp, SQL, txtBJDID.Value.Trim(), "", iStartXH - 1, ref sErrorNum);
|
||
XLBJDCalcUtils.CalcBJDMXAfterIns(dberp, SQL, txtBJDID.Value.Trim(), iStartXH, GetOption(100860000, "BJU002"), GetOption(100860000, "BJU003"), GetOption(100860000, "BJU018"), tSession.UserId, tSession.UserName, ref sErrorNum);
|
||
}
|
||
|
||
|
||
|
||
private void ReadWJ(string sPath, ref DataSet aDataExcel)
|
||
{
|
||
string sMessage = "";
|
||
aDataExcel = TExcelData.ReadExcel(sPath.Trim(), "", "", false, ref sMessage);
|
||
if (!sMessage.Trim().Equals(""))
|
||
{
|
||
throw new Exception("文件读取失败!具体原因:" + sMessage);
|
||
}
|
||
}
|
||
|
||
private string sGetCellTest(DataRow Row, int ColumnIndex)
|
||
{
|
||
return Row[ColumnIndex].ToString().Trim().Replace("\r\n", "").Replace("\n", "");
|
||
}
|
||
|
||
private void Analysis_Common2(ref DataSet ds, List<string> lstXLXHID, List<string> lstXLGGID, List<string> lstDYDJID)
|
||
{
|
||
string sCPXX = "";
|
||
string sXLXHID = "";
|
||
string sXLGGID = "";
|
||
string sDYDJID = "";
|
||
string sXLJGU007 = GetOption(102579000, "XLJGU007");
|
||
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
||
{
|
||
sCPXX = ds.Tables[0].Rows[i]["XLWBBJDMX_BJCP"].ToString().Trim();
|
||
XLBJD_WBBJDMXList.RecoverCPXX(ref sCPXX);
|
||
if (!sCPXX.Contains(" "))
|
||
continue;
|
||
if (sCPXX.IndexOf(" ") != sCPXX.LastIndexOf(' ') || sCPXX.IndexOf(" ") <= 0)
|
||
continue;
|
||
|
||
sXLGGID = sCPXX.Substring(sCPXX.LastIndexOf(' ') + 1, sCPXX.Length - sCPXX.LastIndexOf(' ') - 1);
|
||
|
||
if (sXLJGU007.Equals("A"))
|
||
{
|
||
sXLGGID = sXLGGID.Replace("x", "X").Replace("X", "*").Replace("*", "×");
|
||
}
|
||
else if (sXLJGU007.Equals("B"))
|
||
{
|
||
sXLGGID = sXLGGID.Replace("x", "X").Replace("X", "*").Replace("×", "*");
|
||
}
|
||
ds.Tables[0].Rows[i]["XLWBBJDMX_XLGGID"] = sXLGGID;
|
||
|
||
string sTmp = sCPXX.Substring(0, sCPXX.LastIndexOf(' '));
|
||
|
||
if (sTmp.Contains("-"))
|
||
{
|
||
sXLXHID = sTmp.Substring(0, sTmp.LastIndexOf('-'));
|
||
sDYDJID = sTmp.Substring(sTmp.LastIndexOf('-') + 1, sTmp.Length - sTmp.LastIndexOf('-') - 1).Replace('K', 'k').Replace('v', 'V');
|
||
if (lstDYDJID.Contains(sDYDJID.ToUpper()))
|
||
{
|
||
ds.Tables[0].Rows[i]["XLWBBJDMX_DYDJID"] = sDYDJID;
|
||
ds.Tables[0].Rows[i]["XLWBBJDMX_XLXHID"] = sXLXHID;
|
||
}
|
||
else
|
||
{
|
||
ds.Tables[0].Rows[i]["XLWBBJDMX_XLXHID"] = sTmp;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
ds.Tables[0].Rows[i]["XLWBBJDMX_XLXHID"] = sTmp;
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 型号&规格替换
|
||
private void SelectMatchForXLXHIDAndXLGGID(int XH)
|
||
{
|
||
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
||
TSQL SQL = new TSQL(dberp);
|
||
try
|
||
{
|
||
SQL.Clear();
|
||
SQL.Add("merge into XLXSBJDMX tar ");
|
||
SQL.Add(" using ( ");
|
||
SQL.Add(" select XLWBBJDXHGGDZB_WBXLXHID as WBXLXHID,XLWBBJDXHGGDZB_WBXLGGID as WBXLGGID, ");
|
||
SQL.Add(" XLWBBJDXHGGDZB_XLXHID as XLXHID, XLWBBJDXHGGDZB_XLGGID as XLGGID, ");
|
||
SQL.Add(" XLXSBJDMX_BJDID as BJDID, XLXSBJDMX_XH as XH");
|
||
SQL.Add(" from XLWBBJDXHGGDZB");
|
||
SQL.Add(" left join XLXSBJDMX on XLXSBJDMX_XLXHID = XLWBBJDXHGGDZB_WBXLXHID and XLXSBJDMX_XLGGID=XLWBBJDXHGGDZB_WBXLGGID ");
|
||
SQL.Add(" where 1=1 ");
|
||
SQL.Add(" and XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" ) sor ");
|
||
SQL.Add(" on( ");
|
||
SQL.Add(" tar.XLXSBJDMX_BJDID = sor.BJDID ");
|
||
SQL.Add(" and tar.XLXSBJDMX_XH = sor.XH ");
|
||
SQL.Add(" and tar.XLXSBJDMX_BJDID=:pBJDID and tar.XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" ) ");
|
||
SQL.Add(" when matched then update set ");
|
||
SQL.Add(" tar.XLXSBJDMX_XLXHID =sor.XLXHID, tar.XLXSBJDMX_XLGGID=sor.XLGGID ");
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
SQL.ParamByName("pXH").Value = XH;
|
||
dberp.ExecSQL(SQL);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ShowMessage("导入出现错误,请联系系统管理员。错误信息:" + ex);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
private void MatchForXLBZIDAndDYDJID(bool bClearXLBZIDAndDYDJID, string sJGBID,int XH)
|
||
{
|
||
if (!XLBJDUtils.IsJGEJGB(sJGBID))
|
||
{
|
||
sJGBID = XLBJD_WBBJDMXList.GetJGCIDS(sJGBID, "JGB");
|
||
}
|
||
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
||
TSQL SQL = new TSQL(dberp);
|
||
//清空电压&标准后匹配,会直接将所选记录型号,规格不为空的标准和电压等级全部置空
|
||
//型号规格 可以获取唯一值,点击匹配按钮会直接匹配上标准和电压等级。
|
||
//型号规格标准 可以获取唯一值,点击匹配按钮会直接匹配上电压等级。
|
||
//型号规格电压等级可以获取唯一值,点击匹配按钮会直接匹配上标准。
|
||
//-----------------------------------------------------------------
|
||
//以上三种情况相互独立,不需要考虑顺序问题
|
||
if (bClearXLBZIDAndDYDJID)
|
||
{
|
||
//foreach (KeyValuePair<string, string> kvp in dicMCTCH)
|
||
SQL.Clear();
|
||
SQL.Add("update XLXSBJDMX ");
|
||
SQL.Add(" set XLXSBJDMX_XLBZID =:pXLBZID, XLXSBJDMX_DYDJID=' ' ");
|
||
SQL.Add(" where XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" and XLXSBJDMX_XLXHID <> ' ' and XLXSBJDMX_XLGGID <> ' ' ");
|
||
SQL.ParamByName("pXH").Value = XH;
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
SQL.ParamByName("pXLBZID").Value = XLBJDUtils.GetBZXLZBZID("", XLBJDUtils.GetDefaultXLBZID(), null);
|
||
dberp.ExecSQL(SQL);
|
||
|
||
}
|
||
string sWBPPZXSX = "A";
|
||
XLXSBJPZXX pzxx = XLBJDUtils.GetXLXSBJPZXX(100860043);
|
||
if (!string.IsNullOrEmpty(pzxx.XLXSBJPZ_WBPPZXSX))
|
||
sWBPPZXSX = pzxx.XLXSBJPZ_WBPPZXSX;
|
||
|
||
string sDefXLBZID = "";
|
||
string sDefDYDJID = "";
|
||
|
||
pzxx = XLBJDUtils.GetXLXSBJPZXX(100860000);
|
||
if (!string.IsNullOrEmpty(pzxx.XLXSBJPZ_MRXLBZID))
|
||
sDefXLBZID = pzxx.XLXSBJPZ_MRXLBZID;
|
||
|
||
if (!string.IsNullOrEmpty(pzxx.XLXSBJPZ_MRDYDJ))
|
||
sDefDYDJID = pzxx.XLXSBJPZ_MRDYDJ;
|
||
|
||
/*
|
||
A:线缆销售材料清单
|
||
B:线缆销售价格表
|
||
C:先材料清单再价格表
|
||
D:先价格表再材料清单
|
||
*/
|
||
string ErrorNo = "";
|
||
try
|
||
{
|
||
if (sWBPPZXSX.Equals("B") || sWBPPZXSX.Equals("D"))
|
||
{
|
||
MatchForXLXSJGBMX(dberp, SQL, bClearXLBZIDAndDYDJID, sJGBID, sDefXLBZID, sDefDYDJID, XH, ref ErrorNo);
|
||
if (sWBPPZXSX.Equals("D"))
|
||
{
|
||
MatchForXLXSCLQD(dberp, SQL, bClearXLBZIDAndDYDJID, sJGBID, sDefXLBZID, sDefDYDJID, XH, ref ErrorNo);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
MatchForXLXSCLQD(dberp, SQL, bClearXLBZIDAndDYDJID, sJGBID, sDefXLBZID, sDefDYDJID, XH, ref ErrorNo);
|
||
if (sWBPPZXSX.Equals("C"))
|
||
{
|
||
MatchForXLXSJGBMX(dberp, SQL, bClearXLBZIDAndDYDJID, sJGBID, sDefXLBZID, sDefDYDJID, XH, ref ErrorNo);
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ShowMessage("匹配出现错误,请联系系统管理员。错误编码:" + sWBPPZXSX + ErrorNo + ";" + ex);
|
||
}
|
||
}
|
||
|
||
private void MatchForXLXSJGBMX(TDatabase dberp, TSQL SQL, bool bClearXLBZIDAndDYDJID, string sJGBID, string sDefXLBZID, string sDefDYDJID, int XH, ref string ErrorNo)
|
||
{
|
||
string sJGFID = XLBJDUtils.GetJGFID(PageParam.GetRTrimString("BJRQ"));
|
||
if (!sJGFID.Equals(""))
|
||
{
|
||
if (!sJGBID.Equals(""))
|
||
{
|
||
sJGBID += "," + sJGFID;
|
||
}
|
||
else
|
||
{
|
||
sJGBID = sJGFID;
|
||
}
|
||
}
|
||
|
||
if (dberp.DriverName == "ORACLE" || dberp.DriverName == "DM")//Oracle下merge into语法被更新的字段不能作为关联条件使用,专门处理
|
||
{
|
||
SQL.Clear();
|
||
SQL.Add("update XLXSBJDMX set XLXSBJDMX_WHR=:pFlag");
|
||
SQL.Add(" where XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" and XLXSBJDMX_XLBZID = ' ' and XLXSBJDMX_DYDJID = ' '");
|
||
SQL.ParamByName("pFlag").Value = "BZ_DY";
|
||
SQL.ParamByName("pXH").Value = XH;
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
dberp.ExecSQL(SQL);
|
||
|
||
SQL.Clear();
|
||
SQL.Add("update XLXSBJDMX set XLXSBJDMX_WHR=:pFlag");
|
||
SQL.Add(" where XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" and XLXSBJDMX_XLBZID <> ' ' and XLXSBJDMX_DYDJID = ' '");
|
||
SQL.ParamByName("pFlag").Value = "DY";
|
||
SQL.ParamByName("pXH").Value = XH;
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
dberp.ExecSQL(SQL);
|
||
|
||
SQL.Clear();
|
||
SQL.Add("update XLXSBJDMX set XLXSBJDMX_WHR=:pFlag");
|
||
SQL.Add(" where XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" and XLXSBJDMX_XLBZID = ' ' and XLXSBJDMX_DYDJID <> ' '");
|
||
SQL.ParamByName("pFlag").Value = "BZ";
|
||
SQL.ParamByName("pXH").Value = XH;
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
dberp.ExecSQL(SQL);
|
||
}
|
||
|
||
//使用价格表明细
|
||
/*
|
||
merge into 目标表 tar
|
||
using 源表 sor
|
||
on(a.条件字段1=b.条件字段1 and tar.条件字段2=b.条件字段2 ……)
|
||
when matched then update set a.更新字段=b.字段
|
||
when not matched then insert into a(字段1,字段2……)values(值1,值2……)
|
||
*/
|
||
if (sDefXLBZID.Equals(""))
|
||
{
|
||
ErrorNo = "1.1";
|
||
#region 根据型号、规格,匹配唯一标准、电压等级
|
||
SQL.Clear();
|
||
SQL.Add("merge into XLXSBJDMX tar ");
|
||
SQL.Add(" using ( ");
|
||
SQL.Add(" select XLXSJGBMX_XLXHID as XLXHID,XLXSJGBMX_XLGGID as XLGGID, XLXSJGBMX_XLBZID as XLBZID, XLXSJGBMX_DYDJID as DYDJID ");
|
||
SQL.Add(" from XLXSJGBMX b ");
|
||
SQL.Add(" where 1=1 and len(XLXSJGBMX_XLBZID) < 10 and " + CMISproDataBase.GetWhereEqual("XLXSJGBMX_JGBID", sJGBID));
|
||
//缩小价格表明细的范围
|
||
SQL.Add(" and exists(select 1 from XLXSBJDMX tmp where XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" and XLXSBJDMX_XLXHID=b.XLXSJGBMX_XLXHID");
|
||
SQL.Add(" and XLXSBJDMX_XLGGID=b.XLXSJGBMX_XLGGID");
|
||
SQL.Add(" )");
|
||
//根据型号、规格就能唯一确定产品的价格表明细记录
|
||
SQL.Add(" and exists ( ");
|
||
SQL.Add(" select a.XLXHID, a.XLGGID from ");
|
||
SQL.Add(" ( ");
|
||
SQL.Add(" select XLXSJGBMX_XLXHID as XLXHID,XLXSJGBMX_XLGGID as XLGGID ");
|
||
SQL.Add(" from XLXSJGBMX");
|
||
SQL.Add(" where 1=1 and " + CMISproDataBase.GetWhereEqual("XLXSJGBMX_JGBID", sJGBID));
|
||
//缩小价格表明细的范围
|
||
SQL.Add(" and exists(select 1 from XLXSBJDMX tmp where XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" and XLXSBJDMX_XLXHID=XLXSJGBMX_XLXHID");
|
||
SQL.Add(" and XLXSBJDMX_XLGGID=XLXSJGBMX_XLGGID");
|
||
SQL.Add(" )");
|
||
SQL.Add(" group by XLXSJGBMX_XLXHID,XLXSJGBMX_XLGGID ");
|
||
SQL.Add(" having (count(XLXSJGBMX_XLXHID) + count(XLXSJGBMX_XLGGID)) = 2 ");
|
||
SQL.Add(" ) a where 1=1 and a.XLXHID = b.XLXSJGBMX_XLXHID and a.XLGGID =b.XLXSJGBMX_XLGGID ");
|
||
SQL.Add(" ) ");
|
||
SQL.Add(" ) sor ");
|
||
SQL.Add(" on( ");
|
||
SQL.Add(" tar.XLXSBJDMX_XLXHID = sor.XLXHID ");
|
||
SQL.Add(" and tar.XLXSBJDMX_XLGGID = sor.XLGGID ");
|
||
SQL.Add(" and tar.XLXSBJDMX_XLXHID <> ' ' and tar.XLXSBJDMX_XLGGID <> ' ' ");
|
||
if (dberp.DriverName == "ORACLE" || dberp.DriverName == "DM")//Oracle下merge into语法被更新的字段不能作为关联条件使用,专门处理
|
||
SQL.Add(" and tar.XLXSBJDMX_WHR = 'BZ_DY' ");
|
||
else
|
||
SQL.Add(" and tar.XLXSBJDMX_XLBZID = ' ' and tar.XLXSBJDMX_DYDJID = ' ' ");
|
||
SQL.Add(" and tar.XLXSBJDMX_BJDID=:pBJDID and tar.XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" ) ");
|
||
SQL.Add(" when matched then update set ");
|
||
SQL.Add(" tar.XLXSBJDMX_XLBZID =sor.XLBZID, tar.XLXSBJDMX_DYDJID=sor.DYDJID ");
|
||
SQL.ParamByName("pXH").Value = XH;
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
dberp.ExecSQL(SQL);
|
||
#endregion
|
||
}
|
||
else if (sDefXLBZID.Equals("FirstBZ"))
|
||
{
|
||
ErrorNo = "1.2";
|
||
#region 根据型号、规格,匹配第一个标准
|
||
SQL.Clear();
|
||
SQL.Add("merge into XLXSBJDMX tar ");
|
||
SQL.Add(" using ( ");
|
||
SQL.Add(" select XLXSJGBMX_XLXHID as XLXHID,XLXSJGBMX_XLGGID as XLGGID,isnull(XLBZ_XLBZID,' ') as XLBZID");
|
||
SQL.Add(" from");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSJGBMX_XLXHID,XLXSJGBMX_XLGGID, min(isnull(XLBZPX,0)) as minXLBZPX ");
|
||
SQL.Add(" from XLXSJGBMX b ");
|
||
SQL.Add(" left join (select row_number()over(order by XLBZ_DZSC,XLBZ_PX,XLBZ_XLBZID) as XLBZPX,XLBZ_XLBZID from XLBZ where 1=1) tmpXLBZ on XLBZ_XLBZID=XLXSJGBMX_XLBZID");
|
||
SQL.Add(" where 1=1 and len(XLXSJGBMX_XLBZID) < 10 and " + CMISproDataBase.GetWhereEqual("XLXSJGBMX_JGBID", sJGBID));
|
||
//缩小价格表明细的范围
|
||
SQL.Add(" and exists(select 1 from XLXSBJDMX tmp where XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" and XLXSBJDMX_XLXHID=b.XLXSJGBMX_XLXHID");
|
||
SQL.Add(" and XLXSBJDMX_XLGGID=b.XLXSJGBMX_XLGGID");
|
||
SQL.Add(" )");
|
||
SQL.Add(" group by XLXSJGBMX_XLXHID,XLXSJGBMX_XLGGID");
|
||
SQL.Add(" ) jgbmx");
|
||
SQL.Add(" left join (select row_number()over(order by XLBZ_DZSC,XLBZ_PX,XLBZ_XLBZID) as XLBZPX,XLBZ_XLBZID from XLBZ where 1=1) tmpXLBZ on XLBZPX=minXLBZPX");
|
||
SQL.Add(" where 1=1");
|
||
SQL.Add(" ) sor ");
|
||
SQL.Add(" on( ");
|
||
SQL.Add(" tar.XLXSBJDMX_XLXHID = sor.XLXHID ");
|
||
SQL.Add(" and tar.XLXSBJDMX_XLGGID = sor.XLGGID ");
|
||
SQL.Add(" and tar.XLXSBJDMX_XLXHID <> ' ' and tar.XLXSBJDMX_XLGGID <> ' ' ");
|
||
if (dberp.DriverName == "ORACLE" || dberp.DriverName == "DM")//Oracle下merge into语法被更新的字段不能作为关联条件使用,专门处理
|
||
SQL.Add(" and tar.XLXSBJDMX_WHR = 'BZ_DY' ");
|
||
else
|
||
SQL.Add(" and tar.XLXSBJDMX_XLBZID = ' ' and tar.XLXSBJDMX_DYDJID = ' ' ");
|
||
SQL.Add(" and tar.XLXSBJDMX_BJDID=:pBJDID and tar.XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" ) ");
|
||
SQL.Add(" when matched then update set ");
|
||
SQL.Add(" tar.XLXSBJDMX_XLBZID =sor.XLBZID ");
|
||
SQL.ParamByName("pXH").Value = XH;
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
dberp.ExecSQL(SQL);
|
||
#endregion
|
||
}
|
||
|
||
if (sDefDYDJID.Equals("minDY"))
|
||
{
|
||
ErrorNo = "2.1";
|
||
#region 根据型号、规格、标准,匹配第一个电压等级
|
||
SQL.Clear();
|
||
SQL.Add("merge into XLXSBJDMX tar ");
|
||
SQL.Add(" using (");
|
||
SQL.Add(" select XLXSJGBMX_XLXHID as XLXHID,XLXSJGBMX_XLGGID as XLGGID, XLXSJGBMX_XLBZID as XLBZID, isnull(XLDYDJB_DYDJID,' ') as DYDJID ");
|
||
SQL.Add(" from");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSJGBMX_XLXHID,XLXSJGBMX_XLGGID, XLXSJGBMX_XLBZID,min(isnull(DYDJPX,0)) as minDYDJPX ");
|
||
SQL.Add(" from XLXSJGBMX b ");
|
||
SQL.Add(" left join (select row_number()over(order by XLDYDJB_XH,XLDYDJB_DYDJID) as DYDJPX,XLDYDJB_DYDJID from XLDYDJB where 1=1) tmpXLDY on XLDYDJB_DYDJID=XLXSJGBMX_DYDJID");
|
||
SQL.Add(" where 1=1 and len(XLXSJGBMX_XLBZID) < 10 and " + CMISproDataBase.GetWhereEqual("XLXSJGBMX_JGBID", sJGBID));
|
||
//缩小价格表明细的范围
|
||
SQL.Add(" and exists(select 1 from XLXSBJDMX tmp where XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" and XLXSBJDMX_XLXHID=b.XLXSJGBMX_XLXHID");
|
||
SQL.Add(" and XLXSBJDMX_XLGGID=b.XLXSJGBMX_XLGGID");
|
||
SQL.Add(" and XLXSBJDMX_XLBZID=b.XLXSJGBMX_XLBZID");
|
||
SQL.Add(" )");
|
||
SQL.Add(" group by XLXSJGBMX_XLXHID,XLXSJGBMX_XLGGID,XLXSJGBMX_XLBZID");
|
||
SQL.Add(" ) jgbmx");
|
||
SQL.Add(" left join (select row_number()over(order by XLDYDJB_XH,XLDYDJB_DYDJID) as DYDJPX,XLDYDJB_DYDJID from XLDYDJB where 1=1) DYDJ on DYDJ.DYDJPX=minDYDJPX");
|
||
SQL.Add(" where 1=1");
|
||
SQL.Add(" ) sor ");
|
||
SQL.Add(" on( ");
|
||
SQL.Add(" tar.XLXSBJDMX_XLXHID = sor.XLXHID ");
|
||
SQL.Add(" and tar.XLXSBJDMX_XLGGID = sor.XLGGID ");
|
||
SQL.Add(" and tar.XLXSBJDMX_XLBZID = sor.XLBZID ");
|
||
SQL.Add(" and tar.XLXSBJDMX_XLXHID <> ' ' and tar.XLXSBJDMX_XLGGID <> ' ' ");
|
||
if (dberp.DriverName == "ORACLE" || dberp.DriverName == "DM")//Oracle下merge into语法被更新的字段不能作为关联条件使用,专门处理
|
||
SQL.Add(" and tar.XLXSBJDMX_WHR = 'DY' ");
|
||
else
|
||
SQL.Add(" and tar.XLXSBJDMX_XLBZID <> ' ' and tar.XLXSBJDMX_DYDJID = ' ' ");
|
||
SQL.Add(" and tar.XLXSBJDMX_BJDID=:pBJDID and tar.XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" ) ");
|
||
SQL.Add(" when matched then update set ");
|
||
SQL.Add(" tar.XLXSBJDMX_DYDJID=sor.DYDJID ");
|
||
SQL.ParamByName("pXH").Value = XH;
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
dberp.ExecSQL(SQL);
|
||
#endregion
|
||
}
|
||
|
||
else
|
||
{
|
||
ErrorNo = "2.2";
|
||
#region 根据型号、规格、标准,匹配唯一电压等级
|
||
SQL.Clear();
|
||
SQL.Add("merge into XLXSBJDMX tar ");
|
||
SQL.Add(" using ( ");
|
||
SQL.Add(" select XLXSJGBMX_XLXHID as XLXHID,XLXSJGBMX_XLGGID as XLGGID, XLXSJGBMX_XLBZID as XLBZID, XLXSJGBMX_DYDJID as DYDJID ");
|
||
SQL.Add(" from XLXSJGBMX b ");
|
||
SQL.Add(" where 1=1 and len(XLXSJGBMX_XLBZID) < 10 and " + CMISproDataBase.GetWhereEqual("XLXSJGBMX_JGBID", sJGBID));
|
||
//缩小价格表明细的范围
|
||
SQL.Add(" and exists(select 1 from XLXSBJDMX tmp where XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" and XLXSBJDMX_XLXHID=b.XLXSJGBMX_XLXHID");
|
||
SQL.Add(" and XLXSBJDMX_XLGGID=b.XLXSJGBMX_XLGGID");
|
||
SQL.Add(" and XLXSBJDMX_XLBZID=b.XLXSJGBMX_XLBZID");
|
||
SQL.Add(" )");
|
||
//根据型号、规格、标准就能唯一确定产品的价格表明细记录
|
||
SQL.Add(" and exists ( ");
|
||
SQL.Add(" select a.XLXHID, a.XLGGID from ");
|
||
SQL.Add(" ( ");
|
||
SQL.Add(" select XLXSJGBMX_XLXHID as XLXHID,XLXSJGBMX_XLGGID as XLGGID, XLXSJGBMX_XLBZID as XLBZID ");
|
||
SQL.Add(" from XLXSJGBMX");
|
||
SQL.Add(" where 1=1 and " + CMISproDataBase.GetWhereEqual("XLXSJGBMX_JGBID", sJGBID));
|
||
//缩小价格表明细的范围
|
||
SQL.Add(" and exists(select 1 from XLXSBJDMX tmp where XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" and XLXSBJDMX_XLXHID=XLXSJGBMX_XLXHID");
|
||
SQL.Add(" and XLXSBJDMX_XLGGID=XLXSJGBMX_XLGGID");
|
||
SQL.Add(" and XLXSBJDMX_XLBZID=XLXSJGBMX_XLBZID");
|
||
SQL.Add(" )");
|
||
SQL.Add(" group by XLXSJGBMX_XLXHID,XLXSJGBMX_XLGGID, XLXSJGBMX_XLBZID ");
|
||
SQL.Add(" having (count(XLXSJGBMX_XLXHID) + count(XLXSJGBMX_XLGGID) + count(XLXSJGBMX_XLBZID)) = 3 ");
|
||
SQL.Add(" ) a where 1=1 and a.XLXHID = b.XLXSJGBMX_XLXHID and a.XLGGID =b.XLXSJGBMX_XLGGID and a.XLBZID = b.XLXSJGBMX_XLBZID ");
|
||
SQL.Add(" ) ");
|
||
SQL.Add(" ) sor ");
|
||
SQL.Add(" on( ");
|
||
SQL.Add(" tar.XLXSBJDMX_XLXHID = sor.XLXHID ");
|
||
SQL.Add(" and tar.XLXSBJDMX_XLGGID = sor.XLGGID ");
|
||
SQL.Add(" and tar.XLXSBJDMX_XLBZID = sor.XLBZID ");
|
||
SQL.Add(" and tar.XLXSBJDMX_XLXHID <> ' ' and tar.XLXSBJDMX_XLGGID <> ' ' ");
|
||
if (dberp.DriverName == "ORACLE" || dberp.DriverName == "DM")//Oracle下merge into语法被更新的字段不能作为关联条件使用,专门处理
|
||
SQL.Add(" and tar.XLXSBJDMX_WHR = 'DY' ");
|
||
else
|
||
SQL.Add(" and tar.XLXSBJDMX_XLBZID <> ' ' and tar.XLXSBJDMX_DYDJID = ' ' ");
|
||
SQL.Add(" and tar.XLXSBJDMX_BJDID=:pBJDID and tar.XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" ) ");
|
||
SQL.Add(" when matched then update set ");
|
||
SQL.Add(" tar.XLXSBJDMX_DYDJID=sor.DYDJID ");
|
||
SQL.ParamByName("pXH").Value = XH;
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
dberp.ExecSQL(SQL);
|
||
#endregion
|
||
}
|
||
|
||
if (sDefXLBZID.Equals(""))
|
||
{
|
||
ErrorNo = "3.1";
|
||
#region 根据型号、规格、电压等级,匹配唯一标准
|
||
SQL.Clear();
|
||
SQL.Add("merge into XLXSBJDMX tar ");
|
||
SQL.Add(" using ( ");
|
||
SQL.Add(" select XLXSJGBMX_XLXHID as XLXHID,XLXSJGBMX_XLGGID as XLGGID, XLXSJGBMX_XLBZID as XLBZID, XLXSJGBMX_DYDJID as DYDJID ");
|
||
SQL.Add(" from XLXSJGBMX b ");
|
||
SQL.Add(" where 1=1 and len(XLXSJGBMX_XLBZID) < 10 and " + CMISproDataBase.GetWhereEqual("XLXSJGBMX_JGBID", sJGBID));
|
||
//缩小价格表明细的范围
|
||
SQL.Add(" and exists(select 1 from XLXSBJDMX tmp where XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" and XLXSBJDMX_XLXHID=b.XLXSJGBMX_XLXHID");
|
||
SQL.Add(" and XLXSBJDMX_XLGGID=b.XLXSJGBMX_XLGGID");
|
||
SQL.Add(" and XLXSBJDMX_DYDJID=b.XLXSJGBMX_DYDJID");
|
||
SQL.Add(" )");
|
||
//根据型号、规格、标准就能唯一确定产品的价格表明细记录
|
||
SQL.Add(" and exists ( ");
|
||
SQL.Add(" select a.XLXHID, a.XLGGID from ");
|
||
SQL.Add(" ( ");
|
||
SQL.Add(" select XLXSJGBMX_XLXHID as XLXHID,XLXSJGBMX_XLGGID as XLGGID, XLXSJGBMX_DYDJID as DYDJID ");
|
||
SQL.Add(" from XLXSJGBMX");
|
||
SQL.Add(" where 1=1 and " + CMISproDataBase.GetWhereEqual("XLXSJGBMX_JGBID", sJGBID));
|
||
//缩小价格表明细的范围
|
||
SQL.Add(" and exists(select 1 from XLXSBJDMX tmp where XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" and XLXSBJDMX_XLXHID=XLXSJGBMX_XLXHID");
|
||
SQL.Add(" and XLXSBJDMX_XLGGID=XLXSJGBMX_XLGGID");
|
||
SQL.Add(" and XLXSBJDMX_DYDJID=XLXSJGBMX_DYDJID");
|
||
SQL.Add(" )");
|
||
SQL.Add(" group by XLXSJGBMX_XLXHID,XLXSJGBMX_XLGGID, XLXSJGBMX_DYDJID ");
|
||
SQL.Add(" having (count(XLXSJGBMX_XLXHID) + count(XLXSJGBMX_XLGGID) + count(XLXSJGBMX_DYDJID)) = 3 ");
|
||
SQL.Add(" ) a where 1=1 and a.XLXHID = b.XLXSJGBMX_XLXHID and a.XLGGID =b.XLXSJGBMX_XLGGID and a.DYDJID = b.XLXSJGBMX_DYDJID ");
|
||
SQL.Add(" ) ");
|
||
SQL.Add(" ) sor ");
|
||
SQL.Add(" on( ");
|
||
SQL.Add(" tar.XLXSBJDMX_XLXHID = sor.XLXHID ");
|
||
SQL.Add(" and tar.XLXSBJDMX_XLGGID = sor.XLGGID ");
|
||
SQL.Add(" and tar.XLXSBJDMX_DYDJID=sor.DYDJID ");
|
||
SQL.Add(" and tar.XLXSBJDMX_XLXHID <> ' ' and tar.XLXSBJDMX_XLGGID <> ' ' ");
|
||
if (dberp.DriverName == "ORACLE" || dberp.DriverName == "DM")//Oracle下merge into语法被更新的字段不能作为关联条件使用,专门处理
|
||
SQL.Add(" and tar.XLXSBJDMX_WHR = 'BZ' ");
|
||
else
|
||
SQL.Add(" and tar.XLXSBJDMX_XLBZID = ' ' and tar.XLXSBJDMX_DYDJID <> ' ' ");
|
||
SQL.Add(" and tar.XLXSBJDMX_BJDID=:pBJDID and tar.XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" ) ");
|
||
SQL.Add(" when matched then update set ");
|
||
SQL.Add(" tar.XLXSBJDMX_XLBZID =sor.XLBZID ");
|
||
SQL.ParamByName("pXH").Value = XH;
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
dberp.ExecSQL(SQL);
|
||
#endregion
|
||
}
|
||
else if (sDefXLBZID.Equals("FirstBZ"))
|
||
{
|
||
ErrorNo = "3.2";
|
||
#region 根据型号、规格、电压等级,匹配第一个标准
|
||
SQL.Clear();
|
||
SQL.Add("merge into XLXSBJDMX tar ");
|
||
SQL.Add(" using ( ");
|
||
SQL.Add(" select XLXSJGBMX_XLXHID as XLXHID,XLXSJGBMX_XLGGID as XLGGID,XLXSJGBMX_DYDJID as DYDJID,isnull(XLBZ_XLBZID,' ') as XLBZID");
|
||
SQL.Add(" from");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSJGBMX_XLXHID,XLXSJGBMX_XLGGID,XLXSJGBMX_DYDJID, min(isnull(XLBZPX,0)) as minXLBZPX ");
|
||
SQL.Add(" from XLXSJGBMX b ");
|
||
SQL.Add(" left join (select row_number()over(order by XLBZ_DZSC,XLBZ_PX,XLBZ_XLBZID) as XLBZPX,XLBZ_XLBZID from XLBZ where 1=1) tmpXLBZ on XLBZ_XLBZID=XLXSJGBMX_XLBZID");
|
||
SQL.Add(" where 1=1 and len(XLXSJGBMX_XLBZID) < 10 and " + CMISproDataBase.GetWhereEqual("XLXSJGBMX_JGBID", sJGBID));
|
||
//缩小价格表明细的范围
|
||
SQL.Add(" and exists(select 1 from XLXSBJDMX tmp where XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" and XLXSBJDMX_XLXHID=b.XLXSJGBMX_XLXHID");
|
||
SQL.Add(" and XLXSBJDMX_XLGGID=b.XLXSJGBMX_XLGGID");
|
||
SQL.Add(" and XLXSBJDMX_DYDJID=b.XLXSJGBMX_DYDJID");
|
||
SQL.Add(" )");
|
||
SQL.Add(" group by XLXSJGBMX_XLXHID,XLXSJGBMX_XLGGID,XLXSJGBMX_DYDJID");
|
||
SQL.Add(" ) jgbmx");
|
||
SQL.Add(" left join (select row_number()over(order by XLBZ_DZSC,XLBZ_PX,XLBZ_XLBZID) as XLBZPX,XLBZ_XLBZID from XLBZ where 1=1) tmpXLBZ on XLBZPX=minXLBZPX");
|
||
SQL.Add(" where 1=1");
|
||
SQL.Add(" ) sor ");
|
||
SQL.Add(" on( ");
|
||
SQL.Add(" tar.XLXSBJDMX_XLXHID = sor.XLXHID ");
|
||
SQL.Add(" and tar.XLXSBJDMX_XLGGID = sor.XLGGID ");
|
||
SQL.Add(" and tar.XLXSBJDMX_DYDJID=sor.DYDJID ");
|
||
SQL.Add(" and tar.XLXSBJDMX_XLXHID <> ' ' and tar.XLXSBJDMX_XLGGID <> ' ' ");
|
||
if (dberp.DriverName == "ORACLE" || dberp.DriverName == "DM")//Oracle下merge into语法被更新的字段不能作为关联条件使用,专门处理
|
||
SQL.Add(" and tar.XLXSBJDMX_WHR = 'BZ' ");
|
||
else
|
||
SQL.Add(" and tar.XLXSBJDMX_XLBZID = ' ' and tar.XLXSBJDMX_DYDJID <> ' ' ");
|
||
SQL.Add(" and tar.XLXSBJDMX_BJDID=:pBJDID and tar.XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" ) ");
|
||
SQL.Add(" when matched then update set ");
|
||
SQL.Add(" tar.XLXSBJDMX_XLBZID =sor.XLBZID ");
|
||
SQL.ParamByName("pXH").Value = XH;
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
dberp.ExecSQL(SQL);
|
||
#endregion
|
||
}
|
||
|
||
if (dberp.DriverName == "ORACLE" || dberp.DriverName == "DM")//Oracle下merge into语法被更新的字段不能作为关联条件使用,专门处理
|
||
{
|
||
SQL.Clear();
|
||
SQL.Add("update XLXSBJDMX set XLXSBJDMX_WHR=:pWHR");
|
||
SQL.Add(" where XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" and (XLXSBJDMX_WHR='BZ_DY' or XLXSBJDMX_WHR='DY' or XLXSBJDMX_WHR='BZ')");
|
||
SQL.ParamByName("pWHR").Value = tSession.UserName;
|
||
SQL.ParamByName("pXH").Value = XH;
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
dberp.ExecSQL(SQL);
|
||
}
|
||
}
|
||
|
||
private void MatchForXLXSCLQD(TDatabase dberp, TSQL SQL, bool bClearXLBZIDAndDYDJID, string sJGBID, string sDefXLBZID, string sDefDYDJID, int XH, ref string ErrorNo)
|
||
{
|
||
|
||
|
||
if (dberp.DriverName == "ORACLE" || dberp.DriverName == "DM")//Oracle下merge into语法被更新的字段不能作为关联条件使用,专门处理
|
||
{
|
||
SQL.Clear();
|
||
SQL.Add("update XLXSBJDMX set XLXSBJDMX_WHR=:pFlag");
|
||
SQL.Add(" where XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" and XLXSBJDMX_XLBZID = ' ' and XLXSBJDMX_DYDJID = ' '");
|
||
SQL.ParamByName("pFlag").Value = "BZ_DY";
|
||
SQL.ParamByName("pXH").Value = XH;
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
dberp.ExecSQL(SQL);
|
||
|
||
SQL.Clear();
|
||
SQL.Add("update XLXSBJDMX set XLXSBJDMX_WHR=:pFlag");
|
||
SQL.Add(" where XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH");
|
||
SQL.Add(" and XLXSBJDMX_XLBZID <> ' ' and XLXSBJDMX_DYDJID = ' '");
|
||
SQL.ParamByName("pFlag").Value = "DY";
|
||
SQL.ParamByName("pXH").Value = XH;
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
dberp.ExecSQL(SQL);
|
||
|
||
SQL.Clear();
|
||
SQL.Add("update XLXSBJDMX set XLXSBJDMX_WHR=:pFlag");
|
||
SQL.Add(" where XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" and XLXSBJDMX_XLBZID = ' ' and XLXSBJDMX_DYDJID <> ' '");
|
||
SQL.ParamByName("pFlag").Value = "BZ";
|
||
SQL.ParamByName("pXH").Value = XH;
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
dberp.ExecSQL(SQL);
|
||
}
|
||
//使用材料清单匹配
|
||
if (sDefXLBZID.Equals(""))
|
||
{
|
||
ErrorNo = "4.1";
|
||
#region 根据型号、规格,匹配唯一标准、电压等级
|
||
SQL.Clear();
|
||
SQL.Add(" merge into XLXSBJDMX tag");
|
||
SQL.Add(" using ");
|
||
SQL.Add(" ( ");
|
||
SQL.Add(" select XLXSCLQD_XLXHID,XLXSCLQD_XLGGID,XLXSCLQD_XLBZID,XLXSCLQD_DYDJID FROM XLXSCLQD a ");
|
||
SQL.Add(" where XLXSCLQD_WPID = 'ZZZZ' ");
|
||
SQL.Add(" and exists ( ");
|
||
SQL.Add(" SELECT XLXSCLQD_XLXHID,XLXSCLQD_XLGGID FROM XLXSCLQD b ");
|
||
SQL.Add(" WHERE a.XLXSCLQD_XLXHID = b.XLXSCLQD_XLXHID and a.XLXSCLQD_XLGGID = b.XLXSCLQD_XLGGID ");
|
||
SQL.Add(" and b.XLXSCLQD_WPID = 'ZZZZ' and exists( ");
|
||
SQL.Add(" select XLXSBJDMX_XLXHID, XLXSBJDMX_XLGGID from XLXSBJDMX WHERE XLXSBJDMX_XLXHID = XLXSCLQD_XLXHID ");
|
||
SQL.Add(" and XLXSBJDMX_XLGGID= XLXSCLQD_XLGGID ");
|
||
SQL.Add(" and XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" ) ");
|
||
SQL.Add(" group by XLXSCLQD_XLXHID,XLXSCLQD_XLGGID ");
|
||
SQL.Add(" having (count(XLXSCLQD_XLXHID) + count(XLXSCLQD_XLGGID)) = 2 ");
|
||
SQL.Add(" ) ");
|
||
SQL.Add(" ) c ");
|
||
SQL.Add(" on ( XLXSBJDMX_XLXHID <> ' ' and XLXSBJDMX_XLGGID <> ' ' ");
|
||
if (dberp.DriverName == "ORACLE" || dberp.DriverName == "DM")//Oracle下merge into语法被更新的字段不能作为关联条件使用,专门处理
|
||
SQL.Add(" and XLXSBJDMX_WHR = 'BZ_DY' ");
|
||
else
|
||
SQL.Add(" and XLXSBJDMX_XLBZID = ' ' and XLXSBJDMX_DYDJID = ' ' ");
|
||
SQL.Add(" and XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" and c.XLXSCLQD_XLXHID =XLXSBJDMX_XLXHID and c.XLXSCLQD_XLGGID=XLXSBJDMX_XLGGID ) ");
|
||
SQL.Add(" when matched then update set XLXSBJDMX_XLBZID =c.XLXSCLQD_XLBZID, XLXSBJDMX_DYDJID=c.XLXSCLQD_DYDJID ");
|
||
SQL.ParamByName("pXH").Value = XH;
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
dberp.ExecSQL(SQL);
|
||
#endregion
|
||
}
|
||
else if (sDefXLBZID.Equals("FirstBZ"))
|
||
{
|
||
ErrorNo = "4.2";
|
||
#region 根据型号、规格,匹配第一个标准
|
||
SQL.Clear();
|
||
SQL.Add(" merge into XLXSBJDMX tag");
|
||
SQL.Add(" using ");
|
||
SQL.Add(" ( ");
|
||
SQL.Add(" select XLXSCLQD_XLXHID as XLXHID,XLXSCLQD_XLGGID as XLGGID,isnull(XLBZ_XLBZID,' ') as XLBZID");
|
||
SQL.Add(" from");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSCLQD_XLXHID,XLXSCLQD_XLGGID,min(isnull(XLBZPX,0)) as minXLBZPX FROM XLXSCLQD ");
|
||
SQL.Add(" left join (select row_number()over(order by XLBZ_DZSC,XLBZ_PX,XLBZ_XLBZID) as XLBZPX,XLBZ_XLBZID from XLBZ where 1=1) tmpXLBZ on XLBZ_XLBZID=XLXSCLQD_XLBZID");
|
||
SQL.Add(" where XLXSCLQD_WPID = 'ZZZZ' ");
|
||
SQL.Add(" and exists( ");
|
||
SQL.Add(" select 1 from XLXSBJDMX WHERE XLXSBJDMX_XLXHID = XLXSCLQD_XLXHID ");
|
||
SQL.Add(" and XLXSBJDMX_XLGGID= XLXSCLQD_XLGGID ");
|
||
SQL.Add(" and XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" ) ");
|
||
SQL.Add(" group by XLXSCLQD_XLXHID,XLXSCLQD_XLGGID");
|
||
SQL.Add(" ) clqd");
|
||
SQL.Add(" left join (select row_number()over(order by XLBZ_DZSC,XLBZ_PX,XLBZ_XLBZID) as XLBZPX,XLBZ_XLBZID from XLBZ where 1=1) tmpXLBZ on XLBZPX=minXLBZPX");
|
||
SQL.Add(" where 1=1");
|
||
SQL.Add(" ) c ");
|
||
SQL.Add(" on( XLXSBJDMX_XLXHID <> ' ' and XLXSBJDMX_XLGGID <> ' ' ");
|
||
if (dberp.DriverName == "ORACLE" || dberp.DriverName == "DM")//Oracle下merge into语法被更新的字段不能作为关联条件使用,专门处理
|
||
SQL.Add(" and XLXSBJDMX_WHR = 'BZ_DY' ");
|
||
else
|
||
SQL.Add(" and XLXSBJDMX_XLBZID = ' ' and XLXSBJDMX_DYDJID = ' ' ");
|
||
SQL.Add(" and XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" and c.XLXHID =XLXSBJDMX_XLXHID and c.XLGGID=XLXSBJDMX_XLGGID ) ");
|
||
SQL.Add(" when matched then update set XLXSBJDMX_XLBZID =c.XLBZID ");
|
||
SQL.ParamByName("pXH").Value = XH;
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
dberp.ExecSQL(SQL);
|
||
#endregion
|
||
}
|
||
|
||
if (sDefDYDJID.Equals("minDY"))
|
||
{
|
||
ErrorNo = "5.1";
|
||
#region 根据型号、规格、标准,匹配第一个电压等级
|
||
SQL.Clear();
|
||
SQL.Add(" merge into XLXSBJDMX tag ");
|
||
SQL.Add(" using ");
|
||
SQL.Add(" ( ");
|
||
SQL.Add(" select XLXSCLQD_XLXHID,XLXSCLQD_XLGGID,XLXSCLQD_XLBZID, isnull(XLDYDJB_DYDJID,' ') as XLDYDJB_DYDJID");
|
||
SQL.Add(" from");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSCLQD_XLXHID,XLXSCLQD_XLGGID,XLXSCLQD_XLBZID,min(isnull(DYDJPX,0)) as minDYDJPX FROM XLXSCLQD ");
|
||
SQL.Add(" left join (select row_number()over(order by XLDYDJB_XH,XLDYDJB_DYDJID) as DYDJPX,XLDYDJB_DYDJID from XLDYDJB where 1=1) tmpDYDJ on tmpDYDJ.XLDYDJB_DYDJID=XLXSCLQD_DYDJID");
|
||
SQL.Add(" where XLXSCLQD_WPID = 'ZZZZ' ");
|
||
SQL.Add(" and exists( ");
|
||
SQL.Add(" select 1 from XLXSBJDMX WHERE XLXSBJDMX_XLXHID = XLXSCLQD_XLXHID ");
|
||
SQL.Add(" and XLXSBJDMX_XLGGID= XLXSCLQD_XLGGID ");
|
||
SQL.Add(" and XLXSBJDMX_XLBZID= XLXSCLQD_XLBZID ");
|
||
SQL.Add(" and XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" ) ");
|
||
SQL.Add(" group by XLXSCLQD_XLXHID,XLXSCLQD_XLGGID,XLXSCLQD_XLBZID");
|
||
SQL.Add(" ) clqd");
|
||
SQL.Add(" left join (select row_number()over(order by XLDYDJB_XH,XLDYDJB_DYDJID) as DYDJPX,XLDYDJB_DYDJID from XLDYDJB where 1=1) DYDJ on DYDJ.DYDJPX=minDYDJPX");
|
||
SQL.Add(" where 1=1");
|
||
SQL.Add(" ) c ");
|
||
SQL.Add(" on ( XLXSBJDMX_XLXHID <> ' ' and XLXSBJDMX_XLGGID <> ' ' ");
|
||
if (dberp.DriverName == "ORACLE" || dberp.DriverName == "DM")//Oracle下merge into语法被更新的字段不能作为关联条件使用,专门处理
|
||
SQL.Add(" and XLXSBJDMX_WHR = 'DY' ");
|
||
else
|
||
SQL.Add(" and XLXSBJDMX_XLBZID <> ' ' and XLXSBJDMX_DYDJID = ' ' ");
|
||
SQL.Add(" and XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" and c.XLXSCLQD_XLXHID =XLXSBJDMX_XLXHID and c.XLXSCLQD_XLGGID=XLXSBJDMX_XLGGID and c.XLXSCLQD_XLBZID=XLXSBJDMX_XLBZID ) ");
|
||
SQL.Add(" when matched then update set XLXSBJDMX_DYDJID =c.XLDYDJB_DYDJID ");
|
||
SQL.ParamByName("pXH").Value = XH;
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
dberp.ExecSQL(SQL);
|
||
#endregion
|
||
}
|
||
else
|
||
{
|
||
ErrorNo = "5.2";
|
||
#region 根据型号、规格、标准,匹配唯一电压等级
|
||
SQL.Clear();
|
||
SQL.Add(" merge into XLXSBJDMX tag ");
|
||
SQL.Add(" using ");
|
||
SQL.Add(" ( ");
|
||
SQL.Add(" select XLXSCLQD_XLXHID,XLXSCLQD_XLGGID,XLXSCLQD_XLBZID,XLXSCLQD_DYDJID FROM XLXSCLQD a ");
|
||
SQL.Add(" where 1 = 1 and XLXSCLQD_WPID = 'ZZZZ' ");
|
||
SQL.Add(" and exists ( ");
|
||
SQL.Add(" SELECT XLXSCLQD_XLXHID,XLXSCLQD_XLGGID,XLXSCLQD_XLBZID FROM XLXSCLQD b ");
|
||
SQL.Add(" WHERE 1 = 1 and a.XLXSCLQD_XLXHID = b.XLXSCLQD_XLXHID and a.XLXSCLQD_XLGGID = b.XLXSCLQD_XLGGID ");
|
||
SQL.Add(" and a.XLXSCLQD_XLBZID = b.XLXSCLQD_XLBZID");
|
||
SQL.Add(" and b.XLXSCLQD_WPID = 'ZZZZ' and exists( ");
|
||
SQL.Add(" select XLXSBJDMX_XLXHID, XLXSBJDMX_XLGGID,XLXSBJDMX_XLBZID from XLXSBJDMX WHERE XLXSBJDMX_XLXHID = XLXSCLQD_XLXHID ");
|
||
SQL.Add(" and XLXSBJDMX_XLGGID= XLXSCLQD_XLGGID ");
|
||
SQL.Add(" and XLXSBJDMX_XLBZID=XLXSCLQD_XLBZID");
|
||
SQL.Add(" and XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" ) ");
|
||
SQL.Add(" group by XLXSCLQD_XLXHID,XLXSCLQD_XLGGID,XLXSCLQD_XLBZID ");
|
||
SQL.Add(" having (count(XLXSCLQD_XLXHID) + count(XLXSCLQD_XLGGID) + count(XLXSCLQD_XLBZID)) = 3 ");
|
||
SQL.Add(" ) ");
|
||
SQL.Add(" ) c ");
|
||
SQL.Add(" on ( XLXSBJDMX_XLXHID <> ' ' and XLXSBJDMX_XLGGID <> ' ' ");
|
||
if (dberp.DriverName == "ORACLE" || dberp.DriverName == "DM")//Oracle下merge into语法被更新的字段不能作为关联条件使用,专门处理
|
||
SQL.Add(" and XLXSBJDMX_WHR = 'DY' ");
|
||
else
|
||
SQL.Add(" and XLXSBJDMX_XLBZID <> ' ' and XLXSBJDMX_DYDJID = ' ' ");
|
||
SQL.Add(" and XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" and c.XLXSCLQD_XLXHID =XLXSBJDMX_XLXHID and c.XLXSCLQD_XLGGID=XLXSBJDMX_XLGGID and c.XLXSCLQD_XLBZID=XLXSBJDMX_XLBZID ) ");
|
||
SQL.Add(" when matched then update set XLXSBJDMX_DYDJID =c.XLXSCLQD_DYDJID ");
|
||
SQL.ParamByName("pXH").Value = XH;
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
dberp.ExecSQL(SQL);
|
||
#endregion
|
||
}
|
||
|
||
if (sDefXLBZID.Equals(""))
|
||
{
|
||
ErrorNo = "6.1";
|
||
#region 根据型号、规格、电压等级,匹配唯一标准
|
||
SQL.Clear();
|
||
SQL.Add(" merge into XLXSBJDMX tag ");
|
||
SQL.Add(" using ");
|
||
SQL.Add(" ( ");
|
||
SQL.Add(" select XLXSCLQD_XLXHID,XLXSCLQD_XLGGID,XLXSCLQD_XLBZID,XLXSCLQD_DYDJID FROM XLXSCLQD a ");
|
||
SQL.Add(" where 1 = 1 and XLXSCLQD_WPID = 'ZZZZ' ");
|
||
SQL.Add(" and exists ( ");
|
||
SQL.Add(" SELECT XLXSCLQD_XLXHID,XLXSCLQD_XLGGID,XLXSCLQD_DYDJID FROM XLXSCLQD b ");
|
||
SQL.Add(" WHERE 1 = 1 and a.XLXSCLQD_XLXHID = b.XLXSCLQD_XLXHID and a.XLXSCLQD_XLGGID = b.XLXSCLQD_XLGGID ");
|
||
SQL.Add(" and a.XLXSCLQD_DYDJID = b.XLXSCLQD_DYDJID ");
|
||
SQL.Add(" and b.XLXSCLQD_WPID = 'ZZZZ' and exists( ");
|
||
SQL.Add(" select XLXSBJDMX_XLXHID, XLXSBJDMX_XLGGID,XLXSCLQD_DYDJID from XLXSBJDMX WHERE XLXSBJDMX_XLXHID = XLXSCLQD_XLXHID ");
|
||
SQL.Add(" and XLXSBJDMX_XLGGID= XLXSCLQD_XLGGID");
|
||
SQL.Add(" and XLXSBJDMX_DYDJID=XLXSCLQD_DYDJID");
|
||
SQL.Add(" and XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" ) ");
|
||
SQL.Add(" group by XLXSCLQD_XLXHID,XLXSCLQD_XLGGID,XLXSCLQD_DYDJID ");
|
||
SQL.Add(" having (count(XLXSCLQD_XLXHID) + count(XLXSCLQD_XLGGID) + count(XLXSCLQD_DYDJID)) = 3 ");
|
||
SQL.Add(" ) ");
|
||
SQL.Add(" ) c ");
|
||
SQL.Add(" on ( XLXSBJDMX_XLXHID <> ' ' and XLXSBJDMX_XLGGID <> ' ' ");
|
||
if (dberp.DriverName == "ORACLE" || dberp.DriverName == "DM")//Oracle下merge into语法被更新的字段不能作为关联条件使用,专门处理
|
||
SQL.Add(" and XLXSBJDMX_WHR = 'BZ' ");
|
||
else
|
||
SQL.Add(" and XLXSBJDMX_XLBZID = ' ' and XLXSBJDMX_DYDJID <> ' ' ");
|
||
SQL.Add(" and XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" and c.XLXSCLQD_XLXHID =XLXSBJDMX_XLXHID and c.XLXSCLQD_XLGGID=XLXSBJDMX_XLGGID and c.XLXSCLQD_DYDJID=XLXSBJDMX_DYDJID ) ");
|
||
SQL.Add(" when matched then update set XLXSBJDMX_XLBZID =c.XLXSCLQD_XLBZID ");
|
||
SQL.ParamByName("pXH").Value = XH;
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
dberp.ExecSQL(SQL);
|
||
#endregion
|
||
}
|
||
else if (sDefXLBZID.Equals("FirstBZ"))
|
||
{
|
||
ErrorNo = "6.2";
|
||
#region 根据型号、规格、电压等级,匹配第一个标准
|
||
SQL.Clear();
|
||
SQL.Add(" merge into XLXSBJDMX tag ");
|
||
SQL.Add(" using ");
|
||
SQL.Add(" ( ");
|
||
SQL.Add(" select XLXSCLQD_XLXHID as XLXHID,XLXSCLQD_XLGGID as XLGGID,XLXSCLQD_DYDJID as DYDJID,isnull(XLBZ_XLBZID,' ') as XLBZID");
|
||
SQL.Add(" from");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSCLQD_XLXHID,XLXSCLQD_XLGGID,XLXSCLQD_DYDJID,min(isnull(XLBZPX,0)) as minXLBZPX FROM XLXSCLQD ");
|
||
SQL.Add(" left join (select row_number()over(order by XLBZ_DZSC,XLBZ_PX,XLBZ_XLBZID) as XLBZPX,XLBZ_XLBZID from XLBZ where 1=1) tmpXLBZ on XLBZ_XLBZID=XLXSCLQD_XLBZID");
|
||
SQL.Add(" where XLXSCLQD_WPID = 'ZZZZ' ");
|
||
SQL.Add(" and exists( ");
|
||
SQL.Add(" select 1 from XLXSBJDMX WHERE XLXSBJDMX_XLXHID = XLXSCLQD_XLXHID ");
|
||
SQL.Add(" and XLXSBJDMX_XLGGID= XLXSCLQD_XLGGID ");
|
||
SQL.Add(" and XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" ) ");
|
||
SQL.Add(" group by XLXSCLQD_XLXHID,XLXSCLQD_XLGGID,XLXSCLQD_DYDJID");
|
||
SQL.Add(" ) clqd");
|
||
SQL.Add(" left join (select row_number()over(order by XLBZ_DZSC,XLBZ_PX,XLBZ_XLBZID) as XLBZPX,XLBZ_XLBZID from XLBZ where 1=1) tmpXLBZ on XLBZPX=minXLBZPX");
|
||
SQL.Add(" where 1=1");
|
||
SQL.Add(" ) c ");
|
||
SQL.Add(" on( XLXSBJDMX_XLXHID <> ' ' and XLXSBJDMX_XLGGID <> ' ' ");
|
||
if (dberp.DriverName == "ORACLE" || dberp.DriverName == "DM")//Oracle下merge into语法被更新的字段不能作为关联条件使用,专门处理
|
||
SQL.Add(" and XLXSBJDMX_WHR = 'BZ' ");
|
||
else
|
||
SQL.Add(" and XLXSBJDMX_XLBZID = ' ' and XLXSBJDMX_DYDJID <> ' ' ");
|
||
SQL.Add(" and XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" and c.XLXHID =XLXSBJDMX_XLXHID and c.XLGGID=XLXSBJDMX_XLGGID and c.DYDJID=XLXSBJDMX_DYDJID ) ");
|
||
SQL.Add(" when matched then update set XLXSBJDMX_XLBZID =c.XLBZID ");
|
||
SQL.ParamByName("pXH").Value = XH;
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
dberp.ExecSQL(SQL);
|
||
#endregion
|
||
}
|
||
|
||
if (dberp.DriverName == "ORACLE" || dberp.DriverName == "DM")//Oracle下merge into语法被更新的字段不能作为关联条件使用,专门处理
|
||
{
|
||
SQL.Clear();
|
||
SQL.Add("update XLXSBJDMX set XLXSBJDMX_WHR=:pWHR");
|
||
SQL.Add(" where XLXSBJDMX_BJDID=:pBJDID and XLXSBJDMX_XH > :pXH ");
|
||
SQL.Add(" and (XLXSBJDMX_WHR='BZ_DY' or XLXSBJDMX_WHR='DY' or XLXSBJDMX_WHR='BZ')");
|
||
SQL.ParamByName("pWHR").Value = tSession.UserName;
|
||
SQL.ParamByName("pXH").Value = XH;
|
||
SQL.ParamByName("pBJDID").Value = txtBJDID.Value.Trim();
|
||
dberp.ExecSQL(SQL);
|
||
}
|
||
}
|
||
}
|
||
}
|