1403 lines
93 KiB
C#
1403 lines
93 KiB
C#
using System;
|
||
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_MODEL.Page;
|
||
using GThinking.N_MISPRO.Data;
|
||
using System.Drawing;
|
||
using GThinking.N_MODEL.Dialog;
|
||
using GThinking.N_PUBLIC;
|
||
using GThinking.N_MISPRO.Utility;
|
||
using GThinking.N_MISPRO.MISPROAS;
|
||
using GThinking.N_WORKFLOW;
|
||
using System.Text;
|
||
using GThinking.N_PUBLIC2;
|
||
using GThinking.N_CONTROL;
|
||
using System.Collections.Generic;
|
||
|
||
|
||
namespace GThinking.N_XLXSBJ
|
||
{
|
||
[TableMap(DB = "DBERP", DbTableName = "XLXSBJD", Umid = 100860000, IsWorkFlow = false, IsAttach = false, UseWhr = false)]
|
||
|
||
public class XLBJD_YZZCheckEntity: EntityManager
|
||
{
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
public partial class XLBJD_YZZCheck : SingleGridBase
|
||
{
|
||
XLBJD_YZZCheckEntity entity = new XLBJD_YZZCheckEntity();
|
||
|
||
int iXSWS = 5;
|
||
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
this.UMID = 100860000;
|
||
this.UMName = "线缆销售报价单";
|
||
this.CurMaster = Master;
|
||
this.ModuleGV = ContentGrid;
|
||
this.CurEntity = entity;
|
||
this.PageHeight = 600;
|
||
this.PageWidth = 750;
|
||
base.DataKeyNames = new string[] { "XLXSBJDMX_BJDID", "XLXSBJDMX_XH", "XLXSBJDMX_BJCP" };
|
||
|
||
this.Master.EnableNewBtn = false;
|
||
this.Master.EnableDeleteBtn = false;
|
||
this.Master.EnableViewBtn = false;
|
||
this.Master.EnableAttachBtn = false;
|
||
this.Master.EnableCopyBtn = false;
|
||
this.Master.EnableEditBtn = false;
|
||
this.Master.EnableQueryBtn = false;
|
||
this.Master.EnablePrintBtn = false;
|
||
|
||
base.InitPage();
|
||
TGtGridView.SetGrdColItems("DBERP", ContentGrid.FindColumnExByFieldName("XLXSBJDMX_XLYSID"), " select XLYSB_XLYSID,XLYSB_XLYSMC from XLYSB ");
|
||
|
||
iXSWS = string.IsNullOrEmpty(GetOption("BJU002")) ? 5 : CMISproConvert.StrToInt(GetOption("BJU002"));
|
||
if (iXSWS < 0)
|
||
iXSWS = 0;
|
||
else if (iXSWS > 8)
|
||
iXSWS = 8;
|
||
|
||
string sCPBJMRXSWS = PageParam.GetRTrimString("CPBJMRXSWS");
|
||
string sBJBM = PageParam.GetRTrimString("BJBM");
|
||
if (!sBJBM.Equals(""))
|
||
{
|
||
ContentGrid.FindColumnByFieldName("XLXSBJDMX_CPBJ").HeaderText = sBJBM;
|
||
ContentGrid.FindColumnByFieldName("XLXSBJDMX_BJJE").HeaderText = sBJBM+"金额";
|
||
|
||
}
|
||
ContentGrid.FindColumnExByFieldName("XLXSBJDMX_CPBJ").NumberDecimalPlace = CMISproConvert.StrToInt(sCPBJMRXSWS) > iXSWS ? CMISproConvert.StrToInt(sCPBJMRXSWS) : iXSWS; ;
|
||
//保留精度高的
|
||
|
||
this.ModuleGV.OnClientDblClick = "return false;";
|
||
|
||
InitGrid();
|
||
|
||
if (!IsPostBack)
|
||
{
|
||
Master_OnStandardQuery(null, null);
|
||
}
|
||
}
|
||
|
||
#region 模板继承事件
|
||
|
||
protected override void Master_OnStandardQuery(object sender, EventArgs e)
|
||
{
|
||
entity.EntityTable.QuerySelSql = "select top 1 XLXSBJDMX_BJDID from XLXSBJDMX where 1<>1";
|
||
base.Master_OnStandardQuery(sender, e);
|
||
DataSet ds = GetSQLDataSet();
|
||
entity.GridDataBind(ContentGrid, tSession);
|
||
entity.GridDataBind(ContentGrid, ds.Tables[0], ds.Tables[0].Rows.Count);
|
||
ContentGrid.DataSource = ds;
|
||
}
|
||
|
||
protected override void moduleGV_PageIndexChanging(object sender, GridViewPageEventArgs e)
|
||
{
|
||
entity.EntityTable.QuerySelSql = "select top 1 XLXSBJDMX_BJDID from XLXSBJDMX where 1<>1";
|
||
ContentGrid.SelectedIndex = -1;
|
||
base.moduleGV_PageIndexChanging(sender, e);
|
||
DataSet ds = GetSQLDataSet();
|
||
entity.GridDataBind(ContentGrid, tSession);
|
||
entity.GridDataBind(ContentGrid, ds.Tables[0], ds.Tables[0].Rows.Count);
|
||
ContentGrid.DataSource = ds;
|
||
}
|
||
|
||
protected override void moduleGV_RowDataBound(object sender, GridViewRowEventArgs e)
|
||
{
|
||
if (e.Row.RowType == DataControlRowType.DataRow)
|
||
{
|
||
if (ContentGrid.DataKeys[e.Row.RowIndex]["XLXSBJDMX_BJCP"].ToString().Trim().Contains("小计"))
|
||
{
|
||
e.Row.BackColor = System.Drawing.ColorTranslator.FromHtml("#E0FFFF");
|
||
//e.Row.Style.Add(HtmlTextWriterStyle.Color, "#FFFFFF");
|
||
|
||
}
|
||
}
|
||
|
||
base.moduleGV_RowDataBound(sender, e);
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 自定义函数
|
||
|
||
private DataSet GetSQLDataSet()
|
||
{
|
||
string sBJDID = PageParam.GetRTrimString("BJDID");
|
||
string sBJFLID = PageParam.GetRTrimString("BJFLID");
|
||
string sBJU003 = GetOption("BJU003");
|
||
string sBJU003JSDW = XLBJDUtils.GetsJSDW(sBJU003, sBJU003);
|
||
|
||
string[] sYZIDList2 = PageParam.GetRTrimString("sYZIDList2").Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||
string[] sYZIDList3 = PageParam.GetRTrimString("sYZIDList3").Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||
string[] sYZIDList6 = PageParam.GetRTrimString("sYZIDList6").Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||
string[] sYZIDListE = PageParam.GetRTrimString("sYZIDListE").Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||
string[] sYZIDListF = PageParam.GetRTrimString("sYZIDListF").Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||
string[] sYZIDListG = PageParam.GetRTrimString("sYZIDListG").Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||
string[] sYZIDListH = PageParam.GetRTrimString("sYZIDListH").Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||
if (sYZIDList2.Length > 0 && sYZIDList3.Length > 0 && sYZIDList6.Length > 0 && sYZIDListE.Length > 0 && sYZIDListF.Length > 0 && sYZIDListG.Length > 0 && sYZIDListH.Length > 0)
|
||
{
|
||
sYZIDListH = new string[0];//若所有要素都参与因子值查询,则语句会超长
|
||
}
|
||
|
||
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
||
TSQL SQL = new TSQL(dberp);
|
||
//显示序号、型号、规格、标准、电压等级、报价产品、计量单位、报价数量、短米(%)、报价、报价金额、维护人、维护时间
|
||
SQL.Add("select 0 as PX,XLXSBJDMX_XSSX,XLXSBJDMX_BJDID,XLXSBJDMX_XH,XLXSBJDMX_XLXHID,XLXSBJDMX_XLGGID,rtrim(XLXSBJDMX_XLBZID)||'|'||rtrim(XLBZ_XLBZLXMC) as XLBZ,XLXSBJDMX_XLBZID,XLXSBJDMX_DYDJID,");
|
||
SQL.Add(" XLXSBJDMX_JLDW,XLXSBJDMX_BJCP,XLXSBJDMX_BJSL,XLXSBJDMX_XLYSID,");
|
||
for (int i = 0; i < sYZIDList2.Length; i++)
|
||
{
|
||
SQL.Add(String.Format(" XLXSBJDYZZ0_YZZ{0},", sYZIDList2[i].Replace("BJ", "")));
|
||
}
|
||
for (int i = 0; i < sYZIDList3.Length; i++)
|
||
{
|
||
SQL.Add(String.Format(" XLXSBJDYZZ0_YZZ{0},", sYZIDList3[i].Replace("BJ", "")));
|
||
}
|
||
for (int i = 0; i < sYZIDList6.Length; i++)
|
||
{
|
||
SQL.Add(String.Format(" XLXSBJDYZZ0_YZZ{0},", sYZIDList6[i].Replace("BJ", "")));
|
||
}
|
||
for (int i = 0; i < sYZIDListE.Length; i++)
|
||
{
|
||
SQL.Add(String.Format(" XLXSBJDYZZ0_YZZ{0},", sYZIDListE[i].Replace("BJ", "")));
|
||
}
|
||
for (int i = 0; i < sYZIDListG.Length; i++)
|
||
{
|
||
SQL.Add(String.Format(" XLXSBJDYZZ0_YZZ{0},", sYZIDListG[i].Replace("BJ", "")));
|
||
}
|
||
for (int i = 0; i < sYZIDListF.Length; i++)
|
||
{
|
||
SQL.Add(String.Format(" XLXSBJDYZZ0_YZZ{0},", sYZIDListF[i].Replace("BJ", "")));
|
||
}
|
||
for (int i = 0; i < sYZIDListH.Length; i++)
|
||
{
|
||
SQL.Add(String.Format(" XLXSBJDYZZ0_YZZ{0},", sYZIDListH[i].Replace("BJ", "")));
|
||
}
|
||
SQL.Add(" XLXSBJDMX_CPBJ,XLXSBJDMX_BJJE,XLXSBJDMX_WHR,XLXSBJDMX_WHRID,XLXSBJDMX_WHSJ ");
|
||
SQL.Add(" from XLXSBJDMX cur ");
|
||
SQL.Add(" left join XLBZ on XLBZ_XLBZID = XLXSBJDMX_XLBZID ");
|
||
//SQL.Add(" left join XLYSB on XLYSB_XLYSID = XLXSBJDMX_XLYSID ");
|
||
SQL.Add(" left join XLXSBJDYZZ0 on XLXSBJDYZZ0_BJDID=XLXSBJDMX_BJDID and XLXSBJDYZZ0_XH=XLXSBJDMX_XH ");
|
||
SQL.Add(" where XLXSBJDMX_BJDID = :pBJDID ");
|
||
SQL.Add(" and (");
|
||
bool bFirstYZ = true;
|
||
for (int i = 0; i < sYZIDList2.Length; i++)
|
||
{
|
||
if (!bFirstYZ)
|
||
SQL.Add(" or ");
|
||
bFirstYZ = false;
|
||
#region 按产品汇总的报价数量重新获取的短米点数,与报价单上的短米点数不一致的产品有哪些
|
||
SQL.Add(" exists (");
|
||
|
||
GetBJSLTJYS_SQL(SQL, sBJDID, sBJFLID, "2", sYZIDList2[i], sBJU003, "exists");
|
||
|
||
SQL.Add(" and upper(cur.XLXSBJDMX_XLXHID)=upper(tmp.XLXSBJDMX_XLXHID)");
|
||
SQL.Add(" and cur.XLXSBJDMX_XLGGID=tmp.XLXSBJDMX_XLGGID");
|
||
SQL.Add(" and cur.XLXSBJDMX_XLBZID=tmp.XLXSBJDMX_XLBZID");
|
||
SQL.Add(" and isnull(cur.XLXSBJDMX_DYDJID,' ')=isnull(tmp.XLXSBJDMX_DYDJID,' ')");
|
||
SQL.Add(" ) ");
|
||
#endregion
|
||
}
|
||
for (int i = 0; i < sYZIDList3.Length; i++)
|
||
{
|
||
if (!bFirstYZ)
|
||
SQL.Add(" or ");
|
||
bFirstYZ = false;
|
||
#region 按产品汇总的报价数量重新获取的短米点数,与报价单上的短米点数不一致的产品有哪些
|
||
SQL.Add(" exists (");
|
||
|
||
GetBJSLTJYS_SQL(SQL, sBJDID, sBJFLID, "3", sYZIDList3[i], sBJU003, "exists");
|
||
|
||
SQL.Add(" and upper(cur.XLXSBJDMX_XLXHID)=upper(tmp.XLXSBJDMX_XLXHID)");
|
||
SQL.Add(" and cur.XLXSBJDMX_XLGGID=tmp.XLXSBJDMX_XLGGID");
|
||
SQL.Add(" and cur.XLXSBJDMX_XLBZID=tmp.XLXSBJDMX_XLBZID");
|
||
SQL.Add(" and isnull(cur.XLXSBJDMX_DYDJID,' ')=isnull(tmp.XLXSBJDMX_DYDJID,' ')");
|
||
SQL.Add(" ) ");
|
||
#endregion
|
||
}
|
||
for (int i = 0; i < sYZIDList6.Length; i++)
|
||
{
|
||
if (!bFirstYZ)
|
||
SQL.Add(" or ");
|
||
bFirstYZ = false;
|
||
#region 按产品汇总的报价数量重新获取的短米点数,与报价单上的短米点数不一致的产品有哪些
|
||
SQL.Add(" exists (");
|
||
|
||
GetBJSLTJYS_SQL(SQL, sBJDID, sBJFLID, "6", sYZIDList6[i], sBJU003, "exists");
|
||
|
||
SQL.Add(" and upper(cur.XLXSBJDMX_XLXHID)=upper(tmp.XLXSBJDMX_XLXHID)");
|
||
SQL.Add(" and cur.XLXSBJDMX_XLGGID=tmp.XLXSBJDMX_XLGGID");
|
||
SQL.Add(" and cur.XLXSBJDMX_XLBZID=tmp.XLXSBJDMX_XLBZID");
|
||
SQL.Add(" and isnull(cur.XLXSBJDMX_DYDJID,' ')=isnull(tmp.XLXSBJDMX_DYDJID,' ')");
|
||
SQL.Add(" ) ");
|
||
#endregion
|
||
}
|
||
for (int i = 0; i < sYZIDListE.Length; i++)
|
||
{
|
||
if (!bFirstYZ)
|
||
SQL.Add(" or ");
|
||
bFirstYZ = false;
|
||
#region 按产品汇总的报价数量重新获取的短米点数,与报价单上的短米点数不一致的产品有哪些
|
||
SQL.Add(" exists (");
|
||
|
||
GetBJSLTJYS_SQL(SQL, sBJDID, sBJFLID, "E", sYZIDListE[i], sBJU003, "exists");
|
||
|
||
SQL.Add(" and upper(cur.XLXSBJDMX_XLXHID)=upper(tmp.XLXSBJDMX_XLXHID)");
|
||
SQL.Add(" and cur.XLXSBJDMX_XLGGID=tmp.XLXSBJDMX_XLGGID");
|
||
SQL.Add(" and cur.XLXSBJDMX_XLBZID=tmp.XLXSBJDMX_XLBZID");
|
||
SQL.Add(" and isnull(cur.XLXSBJDMX_DYDJID,' ')=isnull(tmp.XLXSBJDMX_DYDJID,' ')");
|
||
SQL.Add(" ) ");
|
||
#endregion
|
||
}
|
||
for (int i = 0; i < sYZIDListG.Length; i++)
|
||
{
|
||
if (!bFirstYZ)
|
||
SQL.Add(" or ");
|
||
bFirstYZ = false;
|
||
#region 按产品汇总的报价数量重新获取的短米点数,与报价单上的短米点数不一致的产品有哪些
|
||
SQL.Add(" exists (");
|
||
|
||
GetBJSLTJYS_SQL(SQL, sBJDID, sBJFLID, "G", sYZIDListG[i], sBJU003, "exists");
|
||
|
||
SQL.Add(" and upper(cur.XLXSBJDMX_XLXHID)=upper(tmp.XLXSBJDMX_XLXHID)");
|
||
SQL.Add(" and cur.XLXSBJDMX_XLGGID=tmp.XLXSBJDMX_XLGGID");
|
||
SQL.Add(" and cur.XLXSBJDMX_XLBZID=tmp.XLXSBJDMX_XLBZID");
|
||
SQL.Add(" and isnull(cur.XLXSBJDMX_DYDJID,' ')=isnull(tmp.XLXSBJDMX_DYDJID,' ')");
|
||
SQL.Add(" ) ");
|
||
#endregion
|
||
}
|
||
for (int i = 0; i < sYZIDListF.Length; i++)
|
||
{
|
||
if (!bFirstYZ)
|
||
SQL.Add(" or ");
|
||
bFirstYZ = false;
|
||
#region 按产品汇总的报价数量重新获取的短米点数,与报价单上的短米点数不一致的产品有哪些
|
||
SQL.Add(" exists (");
|
||
|
||
GetBJSLTJYS_SQL(SQL, sBJDID, sBJFLID, "F", sYZIDListF[i], sBJU003, "exists");
|
||
|
||
SQL.Add(" and upper(cur.XLXSBJDMX_XLXHID)=upper(tmp.XLXSBJDMX_XLXHID)");
|
||
SQL.Add(" and cur.XLXSBJDMX_XLGGID=tmp.XLXSBJDMX_XLGGID");
|
||
SQL.Add(" and cur.XLXSBJDMX_XLBZID=tmp.XLXSBJDMX_XLBZID");
|
||
SQL.Add(" and isnull(cur.XLXSBJDMX_DYDJID,' ')=isnull(tmp.XLXSBJDMX_DYDJID,' ')");
|
||
SQL.Add(" ) ");
|
||
#endregion
|
||
}
|
||
for (int i = 0; i < sYZIDListH.Length; i++)
|
||
{
|
||
if (!bFirstYZ)
|
||
SQL.Add(" or ");
|
||
bFirstYZ = false;
|
||
#region 按产品汇总的报价数量重新获取的短米点数,与报价单上的短米点数不一致的产品有哪些
|
||
SQL.Add(" exists (");
|
||
|
||
GetBJSLTJYS_SQL(SQL, sBJDID, sBJFLID, "H", sYZIDListH[i], sBJU003, "exists");
|
||
|
||
SQL.Add(" and upper(cur.XLXSBJDMX_XLXHID)=upper(tmp.XLXSBJDMX_XLXHID)");
|
||
SQL.Add(" and cur.XLXSBJDMX_XLGGID=tmp.XLXSBJDMX_XLGGID");
|
||
SQL.Add(" and cur.XLXSBJDMX_XLBZID=tmp.XLXSBJDMX_XLBZID");
|
||
SQL.Add(" and isnull(cur.XLXSBJDMX_DYDJID,' ')=isnull(tmp.XLXSBJDMX_DYDJID,' ')");
|
||
SQL.Add(" ) ");
|
||
#endregion
|
||
}
|
||
SQL.Add(" )");
|
||
|
||
SQL.Add(" union all ");
|
||
SQL.Add("select 1 as PX,0 as XLXSBJDMX_XSSX,:pBJDID as XLXSBJDMX_BJDID,0 as XLXSBJDMX_XH,XLXHID as XLXSBJDMX_XLXHID,XLGGID as XLXSBJDMX_XLGGID,XLBZID as XLBZ,XLBZID as XLXSBJDMX_XLBZID,DYDJID as XLXSBJDMX_DYDJID,");
|
||
SQL.Add(" JLDW as XLXSBJDMX_JLDW,'小计:' as XLXSBJDMX_BJCP,sumBJSL as XLXSBJDMX_BJSL,XLXSBJDMX_XLYSID,");
|
||
for (int i = 0; i < sYZIDList2.Length; i++)
|
||
{
|
||
SQL.Add(string.Format(" sum(YZZ{0}) as XLXSBJDYZZ0_YZZ{0}, ", sYZIDList2[i].Replace("BJ", "")));
|
||
}
|
||
for (int i = 0; i < sYZIDList3.Length; i++)
|
||
{
|
||
SQL.Add(string.Format(" sum(YZZ{0}) as XLXSBJDYZZ0_YZZ{0}, ", sYZIDList3[i].Replace("BJ", "")));
|
||
}
|
||
for (int i = 0; i < sYZIDList6.Length; i++)
|
||
{
|
||
SQL.Add(string.Format(" sum(YZZ{0}) as XLXSBJDYZZ0_YZZ{0}, ", sYZIDList6[i].Replace("BJ", "")));
|
||
}
|
||
for (int i = 0; i < sYZIDListE.Length; i++)
|
||
{
|
||
SQL.Add(string.Format(" sum(YZZ{0}) as XLXSBJDYZZ0_YZZ{0}, ", sYZIDListE[i].Replace("BJ", "")));
|
||
}
|
||
for (int i = 0; i < sYZIDListG.Length; i++)
|
||
{
|
||
SQL.Add(string.Format(" sum(YZZ{0}) as XLXSBJDYZZ0_YZZ{0}, ", sYZIDListG[i].Replace("BJ", "")));
|
||
}
|
||
for (int i = 0; i < sYZIDListF.Length; i++)
|
||
{
|
||
SQL.Add(string.Format(" sum(YZZ{0}) as XLXSBJDYZZ0_YZZ{0}, ", sYZIDListF[i].Replace("BJ", "")));
|
||
}
|
||
for (int i = 0; i < sYZIDListH.Length; i++)
|
||
{
|
||
SQL.Add(string.Format(" sum(YZZ{0}) as XLXSBJDYZZ0_YZZ{0}, ", sYZIDListH[i].Replace("BJ", "")));
|
||
}
|
||
SQL.Add(" 0.0 as XLXSBJDMX_CPBJ,0.0 as XLXSBJDMX_BJJE,' ' as XLXSBJDMX_WHR,' ' as XLXSBJDMX_WHRID,null as XLXSBJDMX_WHSJ ");
|
||
SQL.Add(" from ");
|
||
SQL.Add(" (");
|
||
bool bFirstXJ = true;
|
||
for (int i = 0; i < sYZIDList2.Length; i++)
|
||
{
|
||
if (!bFirstXJ)
|
||
SQL.Add(" union all ");
|
||
bFirstXJ = false;
|
||
|
||
GetBJSLTJYS_SQL(SQL, sBJDID, sBJFLID, "2", sYZIDList2[i], sBJU003, "selectBJCP");
|
||
}
|
||
for (int i = 0; i < sYZIDList3.Length; i++)
|
||
{
|
||
if (!bFirstXJ)
|
||
SQL.Add(" union all ");
|
||
bFirstXJ = false;
|
||
|
||
GetBJSLTJYS_SQL(SQL, sBJDID, sBJFLID, "3", sYZIDList3[i], sBJU003, "selectBJCP");
|
||
}
|
||
for (int i = 0; i < sYZIDList6.Length; i++)
|
||
{
|
||
if (!bFirstXJ)
|
||
SQL.Add(" union all ");
|
||
bFirstXJ = false;
|
||
|
||
GetBJSLTJYS_SQL(SQL, sBJDID, sBJFLID, "6", sYZIDList6[i], sBJU003, "selectBJCP");
|
||
}
|
||
for (int i = 0; i < sYZIDListE.Length; i++)
|
||
{
|
||
if (!bFirstXJ)
|
||
SQL.Add(" union all ");
|
||
bFirstXJ = false;
|
||
|
||
GetBJSLTJYS_SQL(SQL, sBJDID, sBJFLID, "E", sYZIDListE[i], sBJU003, "selectBJCP");
|
||
}
|
||
for (int i = 0; i < sYZIDListG.Length; i++)
|
||
{
|
||
if (!bFirstXJ)
|
||
SQL.Add(" union all ");
|
||
bFirstXJ = false;
|
||
|
||
GetBJSLTJYS_SQL(SQL, sBJDID, sBJFLID, "G", sYZIDListG[i], sBJU003, "selectBJCP");
|
||
}
|
||
for (int i = 0; i < sYZIDListF.Length; i++)
|
||
{
|
||
if (!bFirstXJ)
|
||
SQL.Add(" union all ");
|
||
bFirstXJ = false;
|
||
|
||
GetBJSLTJYS_SQL(SQL, sBJDID, sBJFLID, "F", sYZIDListF[i], sBJU003, "selectBJCP");
|
||
}
|
||
for (int i = 0; i < sYZIDListH.Length; i++)
|
||
{
|
||
if (!bFirstXJ)
|
||
SQL.Add(" union all ");
|
||
bFirstXJ = false;
|
||
|
||
GetBJSLTJYS_SQL(SQL, sBJDID, sBJFLID, "H", sYZIDListH[i], sBJU003, "selectBJCP");
|
||
}
|
||
|
||
SQL.Add(" ) aaa ");
|
||
SQL.Add(" group by XLXHID,XLGGID,XLBZID,DYDJID,JLDW,sumBJSL,XLXSBJDMX_XLYSID ");
|
||
|
||
SQL.Add(" order by XLXSBJDMX_XLXHID, XLXSBJDMX_DYDJID,XLXSBJDMX_XLBZID,XLXSBJDMX_XLGGID,PX,XLXSBJDMX_XSSX,XLXSBJDMX_XH ");
|
||
|
||
SQL.ParamByName("pBJDID").Value = sBJDID;
|
||
DataSet dsQry = dberp.OpenDataSet(SQL);
|
||
|
||
return dsQry;
|
||
}
|
||
|
||
private void InitGrid()
|
||
{//研发自测:王威 2025/09/12 01:21:15
|
||
string sYZList = PageParam.GetRTrimString("sYZIDList2") + "," + PageParam.GetRTrimString("sYZIDList3") + "," + PageParam.GetRTrimString("sYZIDList6")
|
||
+ "," + PageParam.GetRTrimString("sYZIDListE") + "," + PageParam.GetRTrimString("sYZIDListF") + "," + PageParam.GetRTrimString("sYZIDListG");
|
||
if (string.IsNullOrEmpty(PageParam.GetRTrimString("sYZIDList2")) || string.IsNullOrEmpty(PageParam.GetRTrimString("sYZIDList3")) || string.IsNullOrEmpty(PageParam.GetRTrimString("sYZIDList6"))
|
||
|| string.IsNullOrEmpty(PageParam.GetRTrimString("sYZIDListE")) || string.IsNullOrEmpty(PageParam.GetRTrimString("sYZIDListF")) || string.IsNullOrEmpty(PageParam.GetRTrimString("sYZIDListG"))
|
||
|| string.IsNullOrEmpty(PageParam.GetRTrimString("sYZIDListH")))
|
||
{
|
||
sYZList += "," + PageParam.GetRTrimString("sYZIDListH");//若所有要素都参与因子值查询,则语句会超长
|
||
}
|
||
string[] tmpYZ = sYZList.Trim().Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||
sYZList = "";
|
||
for (int i = 0; i < tmpYZ.Length; i++)
|
||
{
|
||
if (sYZList.Equals(""))
|
||
sYZList = tmpYZ[i].Trim();
|
||
else
|
||
sYZList = sYZList + "," + tmpYZ[i].Trim();
|
||
}
|
||
|
||
List<TZYZXX> yzxx_List = XLBJDUtils.GetBJFLYZOrderByXSXH(PageParam.GetRTrimString("BJFLID"));
|
||
int j = 0;
|
||
foreach (TZYZXX yzxx in yzxx_List)
|
||
{
|
||
if (sYZList.Contains(yzxx.XLXSTZYZ_YZID))
|
||
{
|
||
string sYZID = yzxx.XLXSTZYZ_YZID.Trim();
|
||
string sYZMC = yzxx.XLXSTZYZ_YZMC.Trim();
|
||
string sJJFS = yzxx.XLXSTZYZ_JJFS.Trim();
|
||
|
||
if (sJJFS.Equals("JD") || sJJFS.Equals("KD") || sJJFS.Equals("SX") || sJJFS.Equals("DD") || sJJFS.Equals("MD") || sJJFS.Equals("MP"))
|
||
{
|
||
AddColumn("XLXSBJDYZZ0_YZZ" + sYZID.Replace("BJ", ""), sYZMC + "(%)", 2, 80, true, false, "", 8 + j);
|
||
}
|
||
else if (sJJFS.Equals("JJ"))
|
||
{
|
||
AddColumn("XLXSBJDYZZ0_YZZ" + sYZID.Replace("BJ", ""), sYZMC + "(元)", 6, 80, true, false, "", 8 + j);
|
||
}
|
||
else if (sJJFS.Equals("MX") || sJJFS.Equals("DX"))
|
||
{
|
||
AddColumn("XLXSBJDYZZ0_YZZ" + sYZID.Replace("BJ", ""), sYZMC, 4, 80, true, false, "", 8 + j);
|
||
}
|
||
j++;
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 设置etNumber列的属
|
||
/// </summary>
|
||
/// <param name="sDataField"></param>
|
||
/// <param name="HeadText"></param>
|
||
/// <param name="NumberDecimalPlace"></param>
|
||
/// <param name="Width"></param>
|
||
private void AddColumn(string sDataField, string HeadText, int NumberDecimalPlace, int Width, bool ShowSubBit, bool ShowZero, string sHintTitle, int index)
|
||
{
|
||
BoundField Column = new BoundField();
|
||
Column.DataField = sDataField;
|
||
Column.HeaderText = HeadText;
|
||
Column.ItemStyle.Width = (Unit)Width;
|
||
Column.HeaderStyle.Width = (Unit)Width;
|
||
Column.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
|
||
ContentGrid.Columns.Insert(index, Column);
|
||
|
||
gtGridView_Column ColumnEx = new gtGridView_Column();
|
||
ColumnEx.DataField = sDataField;
|
||
ColumnEx.EditType = TEditType.etNumber;
|
||
ColumnEx.NumberDecimalPlace = NumberDecimalPlace;
|
||
ColumnEx.ShowSubBit = ShowSubBit;
|
||
ColumnEx.ShowZero = ShowZero;
|
||
ColumnEx.ShowHint = true;
|
||
if (!sHintTitle.Equals(""))
|
||
{
|
||
ColumnEx.HintTitle = sHintTitle;
|
||
}
|
||
ContentGrid.ColumnsEx.Insert(index, ColumnEx);
|
||
}
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="SQL"></param>
|
||
/// <param name="sBJDID"></param>
|
||
/// <param name="sBJFLID"></param>
|
||
/// <param name="sTJYS"></param>
|
||
/// <param name="sYZID"></param>
|
||
/// <param name="sBJU003"></param>
|
||
/// <param name="useFor">值域:exists|校验是否存在、selectBJDXH|查出短米点数不相等的明细序号、selectBJCP|查询短米点数不相等的报价产品小计行</param>
|
||
public static void GetBJSLTJYS_SQL(TSQL SQL, string sBJDID, string sBJFLID, string sTJYS, string sYZID, string sBJU003, string useFor)
|
||
{
|
||
string sBJU003JSDW = XLBJDUtils.GetsJSDW(sBJU003, sBJU003);
|
||
Dictionary<string, double> dicLenJLDWTD = XLBJDUtils.GetLenJLDWTD();
|
||
|
||
if (sTJYS.Equals("2"))
|
||
{
|
||
#region
|
||
if (useFor.Equals("exists"))
|
||
{
|
||
SQL.Add(" select top 1 tmp.XLXSBJDMX_XH");
|
||
}
|
||
else if (useFor.Equals("selectBJDXH"))
|
||
{
|
||
SQL.Add(" select tmp.XLXSBJDMX_XH as BJDXH,");
|
||
SQL.Add(" (case when isnull(b.YZID,' ')<>' ' then isnull(b.YZZ,0) when isnull(a.YZID,' ')<>' ' then isnull(a.YZZ,0)");
|
||
SQL.Add(" else 0.0 end)");
|
||
SQL.Add(" *(case when isnull(XLXSBJDYZZ2BSY1_CPYT, ' ')=' ' then 1.0 else 0.0 end) as YZZ");
|
||
}
|
||
else if (useFor.Equals("selectBJCP"))
|
||
{//研发自测:王威 2025/09/12 01:21:15
|
||
SQL.Add(" select distinct upper(tmp.XLXSBJDMX_XLXHID) as XLXHID,tmp.XLXSBJDMX_XLGGID as XLGGID,tmp.XLXSBJDMX_XLBZID as XLBZID,isnull(tmp.XLXSBJDMX_DYDJID,' ') as DYDJID,' ' as XLXSBJDMX_XLYSID,");
|
||
for (int k = 1; k <= 20; k++)
|
||
{
|
||
if (sYZID.Equals("BJ" + k.ToString().PadLeft(2, '0')))
|
||
{
|
||
SQL.Add(" (case when isnull(b.YZID,' ')<>' ' then isnull(b.YZZ,0) when isnull(a.YZID,' ')<>' ' then isnull(a.YZZ,0)");
|
||
SQL.Add(" else 0.0 end)");
|
||
SQL.Add(string.Format("*(case when isnull(XLXSBJDYZZ2BSY1_CPYT, ' ')=' ' then 1.0 else 0.0 end) as YZZ{0},", k.ToString().PadLeft(2, '0')));
|
||
}
|
||
else
|
||
SQL.Add(string.Format(" 0.0 as YZZ{0},", k.ToString().PadLeft(2, '0')));
|
||
}
|
||
SQL.Add(string.Format(" BJD.sumBJSL,'{0}' as JLDW,'{1}' as YZID ", sBJU003, sYZID));
|
||
}
|
||
SQL.Add(" from XLXSBJDMX tmp");
|
||
SQL.Add(" left join XLXSBJDYZZ0 on XLXSBJDYZZ0_BJDID=tmp.XLXSBJDMX_BJDID and XLXSBJDYZZ0_XH=tmp.XLXSBJDMX_XH");
|
||
SQL.Add(" left join ");
|
||
SQL.Add(" (select XLXSBJDMX_BJDID as BJDID,upper(XLXSBJDMX_XLXHID)as XLXHID,XLXSBJDMX_XLGGID as XLGGID,XLXSBJDMX_XLBZID as XLBZID,isnull(XLXSBJDMX_DYDJID,' ') as DYDJID,");
|
||
if (sBJU003JSDW.Equals("M"))
|
||
{
|
||
SQL.Add(" sum(case when XLXSBJDMX_JLDW in('Km','千米')then 1000*XLXSBJDMX_BJSL ");
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" when XLXSBJDMX_JLDW='{0}' then {1}*XLXSBJDMX_BJSL ", sKey, dicLenJLDWTD[sKey]));
|
||
}
|
||
SQL.Add(" else XLXSBJDMX_BJSL end)as sumBJSL");
|
||
}
|
||
else if (sBJU003JSDW.Equals("Km"))
|
||
{
|
||
SQL.Add(" sum(case when XLXSBJDMX_JLDW in('M','米')then 0.001*XLXSBJDMX_BJSL ");
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" when XLXSBJDMX_JLDW='{0}' then 0.001*{1}*XLXSBJDMX_BJSL ", sKey, dicLenJLDWTD[sKey]));
|
||
}
|
||
SQL.Add(" else XLXSBJDMX_BJSL end)as sumBJSL");
|
||
}
|
||
//取报价单明细因子值之和
|
||
SQL.Add(string.Format(" ,sum(XLXSBJDYZZ0_YZZ{0}) as sumYZZ", sYZID.Replace("BJ", "")));
|
||
SQL.Add(" from XLXSBJDMX");
|
||
//关联报价单明细因子值
|
||
SQL.Add(" left join XLXSBJDYZZ0 on XLXSBJDYZZ0_BJDID= XLXSBJDMX_BJDID and XLXSBJDYZZ0_XH= XLXSBJDMX_XH ");
|
||
SQL.Add(string.Format(" where XLXSBJDMX_BJDID='{0}'", sBJDID));
|
||
SQL.Add(" and (XLXSBJDMX_JLDW in('Km','M','千米','米')");
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" or XLXSBJDMX_JLDW='{0}'", sKey));
|
||
}
|
||
SQL.Add(" )");
|
||
SQL.Add(" group by XLXSBJDMX_BJDID,upper(XLXSBJDMX_XLXHID),XLXSBJDMX_XLGGID,XLXSBJDMX_XLBZID,isnull(XLXSBJDMX_DYDJID,' ')");
|
||
SQL.Add(" )BJD on BJD.XLXHID=upper(tmp.XLXSBJDMX_XLXHID) and BJD.XLGGID=tmp.XLXSBJDMX_XLGGID and BJD.XLBZID=tmp.XLXSBJDMX_XLBZID and BJD.DYDJID=isnull(tmp.XLXSBJDMX_DYDJID,' ')");
|
||
SQL.Add(" left join XLXHB on XLXHB_XLXHID=XLXHID ");
|
||
SQL.Add(" left join XLXSBJDYZZ2BSY1 on XLXSBJDYZZ2BSY1_CPYT= isnull(XLXHB_CPYT,' ')");
|
||
SQL.Add(" left join");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSBJDYZZ2_DTCLID as DTCLID,XLXSBJDYZZ2_YZID as YZID,XLXSBJDYZZ2_YZZ as YZZ,DYDJB.XLDYDJB_DYDJID,");
|
||
SQL.Add(" XLXSBJDYZZ2_BJSLXX,XLXSBJDYZZ2_BJSLSX");
|
||
SQL.Add(" from XLXSBJDYZZ2,XLXSTZYZ,");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select (case when XLDYDJB_XXLXDY>XLDYDJB_XXXXDY then XLDYDJB_XXLXDY else XLDYDJB_XXXXDY end)");
|
||
SQL.Add(" *(case XLDYDJB_DYJLDW when 'V' then 1 else 1000 end) as DY,XLDYDJB_DYDJID ");
|
||
SQL.Add(" from XLDYDJB");
|
||
SQL.Add(" where 1=1");
|
||
SQL.Add(" ) DYDJB ");
|
||
SQL.Add(" where XLXSTZYZ_MXBH='BJD' and XLXSTZYZ_TJYS='2' and XLXSBJDYZZ2_JGBID=XLXSTZYZ_JGBID and XLXSTZYZ_YZID=XLXSBJDYZZ2_YZID");
|
||
SQL.Add(string.Format(" and exists(select 1 from XLXSBJFLYZ where XLXSBJFLYZ_BJFLID='{0}' and XLXSBJFLYZ_YZID=XLXSTZYZ_YZID)", sBJFLID));
|
||
SQL.Add(" and XLXSBJDYZZ2_DYXX<=DY and ((XLXSBJDYZZ2_DYSX<>0 and XLXSBJDYZZ2_DYSX>DY) or XLXSBJDYZZ2_DYSX=0)");
|
||
SQL.Add(string.Format(" and XLXSBJDYZZ2_YZID='{0}'", sYZID));
|
||
SQL.Add(" and XLXSBJDYZZ2_DTCLID=' '");
|
||
SQL.Add(" ) a on a.XLDYDJB_DYDJID = DYDJID ");
|
||
SQL.Add(" and a.XLXSBJDYZZ2_BJSLXX<=BJD.sumBJSL");
|
||
SQL.Add(" and ((a.XLXSBJDYZZ2_BJSLSX<>0 and a.XLXSBJDYZZ2_BJSLSX>BJD.sumBJSL) or a.XLXSBJDYZZ2_BJSLSX=0) ");
|
||
SQL.Add(" left join");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSBJDYZZ2_DTCLID as DTCLID,XLXSBJDYZZ2_YZID as YZID,XLXSBJDYZZ2_YZZ as YZZ,DYDJB.XLDYDJB_DYDJID,");
|
||
SQL.Add(" XLXSBJDYZZ2_BJSLXX,XLXSBJDYZZ2_BJSLSX");
|
||
SQL.Add(" from XLXSBJDYZZ2,XLXSTZYZ,");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select (case when XLDYDJB_XXLXDY>XLDYDJB_XXXXDY then XLDYDJB_XXLXDY else XLDYDJB_XXXXDY end)");
|
||
SQL.Add(" *(case XLDYDJB_DYJLDW when 'V' then 1 else 1000 end) as DY,XLDYDJB_DYDJID ");
|
||
SQL.Add(" from XLDYDJB");
|
||
SQL.Add(" where 1=1");
|
||
SQL.Add(" ) DYDJB ");
|
||
SQL.Add(" where XLXSTZYZ_MXBH='BJD' and XLXSTZYZ_TJYS='2' and XLXSBJDYZZ2_JGBID=XLXSTZYZ_JGBID and XLXSTZYZ_YZID=XLXSBJDYZZ2_YZID");
|
||
SQL.Add(string.Format(" and exists(select 1 from XLXSBJFLYZ where XLXSBJFLYZ_BJFLID='{0}' and XLXSBJFLYZ_YZID=XLXSTZYZ_YZID)", sBJFLID));
|
||
SQL.Add(" and XLXSBJDYZZ2_DYXX<=DY and ((XLXSBJDYZZ2_DYSX<>0 and XLXSBJDYZZ2_DYSX>DY) or XLXSBJDYZZ2_DYSX=0)");
|
||
SQL.Add(string.Format(" and XLXSBJDYZZ2_YZID='{0}'", sYZID));
|
||
SQL.Add(" and XLXSBJDYZZ2_DTCLID<>' '");
|
||
SQL.Add(" ) b on b.DTCLID=isnull(XLXHB_DTCLID,' ') and b.XLDYDJB_DYDJID = DYDJID");
|
||
SQL.Add(" and b.XLXSBJDYZZ2_BJSLXX<=BJD.sumBJSL");
|
||
SQL.Add(" and ((b.XLXSBJDYZZ2_BJSLSX<>0 and b.XLXSBJDYZZ2_BJSLSX>BJD.sumBJSL) or b.XLXSBJDYZZ2_BJSLSX=0)");
|
||
SQL.Add(string.Format(" where tmp.XLXSBJDMX_BJDID='{0}'", sBJDID));
|
||
SQL.Add(" and (case when isnull(b.YZID,' ')<>' ' then isnull(b.YZZ,0) when isnull(a.YZID,' ')<>' ' then isnull(a.YZZ,0)");
|
||
SQL.Add(" else 0.0 end)");
|
||
SQL.Add(string.Format("*(case when isnull(XLXSBJDYZZ2BSY1_CPYT, ' ')=' ' then 1.0 else 0.0 end)<>XLXSBJDYZZ0_YZZ{0}", sYZID.Replace("BJ", "")));
|
||
SQL.Add(" and BJD.sumYZZ > 0 ");
|
||
#endregion
|
||
}
|
||
else if (sTJYS.Equals("3"))
|
||
{
|
||
#region 校验XLXSBJDYZZ3BSY1 AND 校验XLXSBJDYZZ3BSY2 AND 校验XLXSBJDYZZ3BSY3
|
||
if (useFor.Equals("exists"))
|
||
{
|
||
SQL.Add(" select top 1 tmp.XLXSBJDMX_XH");
|
||
}
|
||
else if (useFor.Equals("selectBJDXH"))
|
||
{
|
||
SQL.Add(" select tmp.XLXSBJDMX_XH as BJDXH,");
|
||
SQL.Add(" (case when isnull(d.YZID,' ')<>' ' then isnull(d.YZZ,0)when isnull(c.YZID,' ')<>' ' then isnull(c.YZZ,0)");
|
||
SQL.Add(" when isnull(b.YZID,' ')<>' ' then isnull(b.YZZ,0)when isnull(a.YZID,' ')<>' ' then isnull(a.YZZ,0)");
|
||
SQL.Add(" else 0.0 end)");
|
||
SQL.Add(" *(case when isnull(XLXSBJDYZZ3BSY1_CPYT, ' ')=' ' then 1.0 else 0.0 end)*(case when isnull(XLXSBJDYZZ3BSY2_XLXHID, ' ')=' ' then 1.0 else 0.0 end)*(case when isnull(XLXSBJDYZZ3BSY3_XLJBXHID, ' ')=' ' then 1.0 else 0.0 end) as YZZ");
|
||
}
|
||
else if (useFor.Equals("selectBJCP"))
|
||
{//研发自测:王威 2025/09/12 01:21:15
|
||
SQL.Add(" select distinct upper(tmp.XLXSBJDMX_XLXHID) as XLXHID,tmp.XLXSBJDMX_XLGGID as XLGGID,tmp.XLXSBJDMX_XLBZID as XLBZID,isnull(tmp.XLXSBJDMX_DYDJID,' ') as DYDJID,' ' as XLXSBJDMX_XLYSID,");
|
||
for (int k = 1; k <= 20; k++)
|
||
{
|
||
if (sYZID.Equals("BJ" + k.ToString().PadLeft(2, '0')))
|
||
{
|
||
SQL.Add(" (case when isnull(d.YZID,' ')<>' ' then isnull(d.YZZ,0) when isnull(c.YZID,' ')<>' ' then isnull(c.YZZ,0)");
|
||
SQL.Add(" when isnull(b.YZID,' ')<>' ' then isnull(b.YZZ,0) when isnull(a.YZID,' ')<>' ' then isnull(a.YZZ,0)");
|
||
SQL.Add(" else 0.0 end)");
|
||
SQL.Add(string.Format("*(case when isnull(XLXSBJDYZZ3BSY1_CPYT, ' ')=' ' then 1.0 else 0.0 end)*(case when isnull(XLXSBJDYZZ3BSY2_XLXHID, ' ')=' ' then 1.0 else 0.0 end)*(case when isnull(XLXSBJDYZZ3BSY3_XLJBXHID, ' ')=' ' then 1.0 else 0.0 end) as YZZ{0},", k.ToString().PadLeft(2, '0')));
|
||
}
|
||
else
|
||
SQL.Add(string.Format(" 0.0 as YZZ{0},", k.ToString().PadLeft(2, '0')));
|
||
}
|
||
SQL.Add(string.Format(" BJD.sumBJSL,'{0}' as JLDW,'{1}' as YZID ", sBJU003, sYZID));
|
||
}
|
||
SQL.Add(" from XLXSBJDMX tmp");
|
||
SQL.Add(" left join XLXSBJDYZZ0 on XLXSBJDYZZ0_BJDID=tmp.XLXSBJDMX_BJDID and XLXSBJDYZZ0_XH=tmp.XLXSBJDMX_XH");
|
||
SQL.Add(" left join ");
|
||
SQL.Add(" (select XLXSBJDMX_BJDID as BJDID,upper(XLXSBJDMX_XLXHID)as XLXHID,XLXSBJDMX_XLGGID as XLGGID,XLXSBJDMX_XLBZID as XLBZID,isnull(XLXSBJDMX_DYDJID,' ')as DYDJID,");
|
||
if (sBJU003JSDW.Equals("M"))
|
||
{
|
||
SQL.Add(" sum(case when XLXSBJDMX_JLDW in('Km','千米')then 1000*XLXSBJDMX_BJSL ");
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" when XLXSBJDMX_JLDW='{0}' then {1}*XLXSBJDMX_BJSL ", sKey, dicLenJLDWTD[sKey]));
|
||
}
|
||
SQL.Add(" else XLXSBJDMX_BJSL end)as sumBJSL");
|
||
}
|
||
else if (sBJU003JSDW.Equals("Km"))
|
||
{
|
||
SQL.Add(" sum(case when XLXSBJDMX_JLDW in('M','米') then 0.001*XLXSBJDMX_BJSL ");
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" when XLXSBJDMX_JLDW='{0}' then 0.001*{1}*XLXSBJDMX_BJSL ", sKey, dicLenJLDWTD[sKey]));
|
||
}
|
||
SQL.Add(" else XLXSBJDMX_BJSL end) as sumBJSL");
|
||
|
||
}
|
||
//取报价单明细因子值之和
|
||
SQL.Add(string.Format(" ,sum(XLXSBJDYZZ0_YZZ{0}) as sumYZZ", sYZID.Replace("BJ", "")));
|
||
SQL.Add(" from XLXSBJDMX");
|
||
//关联报价单明细因子值
|
||
SQL.Add(" left join XLXSBJDYZZ0 on XLXSBJDYZZ0_BJDID= XLXSBJDMX_BJDID and XLXSBJDYZZ0_XH= XLXSBJDMX_XH ");
|
||
SQL.Add(string.Format(" where XLXSBJDMX_BJDID='{0}'", sBJDID));
|
||
SQL.Add(" and (XLXSBJDMX_JLDW in('Km','M','千米','米')");
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" or XLXSBJDMX_JLDW='{0}'", sKey));
|
||
}
|
||
SQL.Add(" )");
|
||
SQL.Add(" group by XLXSBJDMX_BJDID,upper(XLXSBJDMX_XLXHID),XLXSBJDMX_XLGGID,XLXSBJDMX_XLBZID,isnull(XLXSBJDMX_DYDJID,' ')");
|
||
SQL.Add(" )BJD on BJD.XLXHID=upper(tmp.XLXSBJDMX_XLXHID) and BJD.XLGGID=tmp.XLXSBJDMX_XLGGID and BJD.XLBZID=tmp.XLXSBJDMX_XLBZID and BJD.DYDJID=isnull(tmp.XLXSBJDMX_DYDJID,' ')");
|
||
SQL.Add(" left join XLXHB on XLXHB_XLXHID=XLXHID ");
|
||
SQL.Add(" left join XLDYDJB on XLDYDJB_DYDJID=DYDJID");
|
||
SQL.Add(" left join XLXSBJDYZZ3BSY1 on XLXSBJDYZZ3BSY1_CPYT= isnull(XLXHB_CPYT,' ')");
|
||
SQL.Add(" left join XLXSBJDYZZ3BSY2 on XLXSBJDYZZ3BSY2_XLXHID= XLXSBJDMX_XLXHID and XLXSBJDYZZ3BSY2_XLGGID= XLXSBJDMX_XLGGID and XLXSBJDYZZ3BSY2_XLBZID= XLXSBJDMX_XLBZID and XLXSBJDYZZ3BSY2_DYDJID= XLXSBJDMX_DYDJID ");
|
||
SQL.Add(" left join XLXSBJDYZZ3BSY3 on XLXSBJDYZZ3BSY3_XLJBXHID= isnull(XLXHB_XLJBXHID,' ')");
|
||
SQL.Add(" left join");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSBJDYZZ3_CPYT as CPYT,XLXSBJDYZZ3_DYDJFL as DYDJFL,XLXSBJDYZZ3_YZID as YZID,XLXSBJDYZZ3_YZZ as YZZ,");
|
||
SQL.Add(" XLXSBJDYZZ3_BJSLXX,XLXSBJDYZZ3_BJSLSX");
|
||
SQL.Add(" from XLXSBJDYZZ3,XLXSTZYZ");
|
||
SQL.Add(" where XLXSTZYZ_MXBH='BJD' and XLXSTZYZ_TJYS='3' and XLXSBJDYZZ3_JGBID=XLXSTZYZ_JGBID and XLXSTZYZ_YZID=XLXSBJDYZZ3_YZID");
|
||
SQL.Add(string.Format(" and exists(select 1 from XLXSBJFLYZ where XLXSBJFLYZ_BJFLID='{0}' and XLXSBJFLYZ_YZID=XLXSTZYZ_YZID)", sBJFLID));
|
||
SQL.Add(string.Format(" and XLXSBJDYZZ3_YZID='{0}'", sYZID));
|
||
SQL.Add(" and XLXSBJDYZZ3_CPYT=' ' and XLXSBJDYZZ3_DYDJFL=' '");
|
||
SQL.Add(" )a on ");
|
||
SQL.Add(" a.XLXSBJDYZZ3_BJSLXX<=BJD.sumBJSL");
|
||
SQL.Add(" and((a.XLXSBJDYZZ3_BJSLSX<>0 and a.XLXSBJDYZZ3_BJSLSX>BJD.sumBJSL)or a.XLXSBJDYZZ3_BJSLSX=0) ");
|
||
SQL.Add(" left join");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSBJDYZZ3_CPYT as CPYT,XLXSBJDYZZ3_DYDJFL as DYDJFL,XLXSBJDYZZ3_YZID as YZID,XLXSBJDYZZ3_YZZ as YZZ,");
|
||
SQL.Add(" XLXSBJDYZZ3_BJSLXX,XLXSBJDYZZ3_BJSLSX");
|
||
SQL.Add(" from XLXSBJDYZZ3,XLXSTZYZ");
|
||
SQL.Add(" where XLXSTZYZ_MXBH='BJD' and XLXSTZYZ_TJYS='3' and XLXSBJDYZZ3_JGBID=XLXSTZYZ_JGBID and XLXSTZYZ_YZID=XLXSBJDYZZ3_YZID");
|
||
SQL.Add(string.Format(" and exists(select 1 from XLXSBJFLYZ where XLXSBJFLYZ_BJFLID='{0}' and XLXSBJFLYZ_YZID=XLXSTZYZ_YZID)", sBJFLID));
|
||
SQL.Add(string.Format(" and XLXSBJDYZZ3_YZID='{0}'", sYZID));
|
||
SQL.Add(" and XLXSBJDYZZ3_CPYT=' ' and XLXSBJDYZZ3_DYDJFL<>' '");
|
||
SQL.Add(" )b on b.DYDJFL=XLDYDJB_DYDJFL");
|
||
SQL.Add(" and b.XLXSBJDYZZ3_BJSLXX<=BJD.sumBJSL");
|
||
SQL.Add(" and((b.XLXSBJDYZZ3_BJSLSX<>0 and b.XLXSBJDYZZ3_BJSLSX>BJD.sumBJSL)or b.XLXSBJDYZZ3_BJSLSX=0)");
|
||
SQL.Add(" left join");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSBJDYZZ3_CPYT as CPYT,XLXSBJDYZZ3_DYDJFL as DYDJFL,XLXSBJDYZZ3_YZID as YZID,XLXSBJDYZZ3_YZZ as YZZ,");
|
||
SQL.Add(" XLXSBJDYZZ3_BJSLXX,XLXSBJDYZZ3_BJSLSX");
|
||
SQL.Add(" from XLXSBJDYZZ3,XLXSTZYZ");
|
||
SQL.Add(" where XLXSTZYZ_MXBH='BJD' and XLXSTZYZ_TJYS='3' and XLXSBJDYZZ3_JGBID=XLXSTZYZ_JGBID and XLXSTZYZ_YZID=XLXSBJDYZZ3_YZID");
|
||
SQL.Add(string.Format(" and exists(select 1 from XLXSBJFLYZ where XLXSBJFLYZ_BJFLID='{0}' and XLXSBJFLYZ_YZID=XLXSTZYZ_YZID)", sBJFLID));
|
||
SQL.Add(string.Format(" and XLXSBJDYZZ3_YZID='{0}'", sYZID));
|
||
SQL.Add(" and XLXSBJDYZZ3_CPYT<>' ' and XLXSBJDYZZ3_DYDJFL=' '");
|
||
SQL.Add(" )c on c.CPYT=XLXHB_CPYT");
|
||
SQL.Add(" and c.XLXSBJDYZZ3_BJSLXX<=BJD.sumBJSL");
|
||
SQL.Add(" and((c.XLXSBJDYZZ3_BJSLSX<>0 and c.XLXSBJDYZZ3_BJSLSX>BJD.sumBJSL)or c.XLXSBJDYZZ3_BJSLSX=0)");
|
||
SQL.Add(" left join");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSBJDYZZ3_CPYT as CPYT,XLXSBJDYZZ3_DYDJFL as DYDJFL,XLXSBJDYZZ3_YZID as YZID,XLXSBJDYZZ3_YZZ as YZZ,");
|
||
SQL.Add(" XLXSBJDYZZ3_BJSLXX,XLXSBJDYZZ3_BJSLSX");
|
||
SQL.Add(" from XLXSBJDYZZ3,XLXSTZYZ");
|
||
SQL.Add(" where XLXSTZYZ_MXBH='BJD' and XLXSTZYZ_TJYS='3' and XLXSBJDYZZ3_JGBID=XLXSTZYZ_JGBID and XLXSTZYZ_YZID=XLXSBJDYZZ3_YZID");
|
||
SQL.Add(string.Format(" and exists(select 1 from XLXSBJFLYZ where XLXSBJFLYZ_BJFLID='{0}' and XLXSBJFLYZ_YZID=XLXSTZYZ_YZID)", sBJFLID));
|
||
SQL.Add(string.Format(" and XLXSBJDYZZ3_YZID='{0}'", sYZID));
|
||
SQL.Add(" and XLXSBJDYZZ3_CPYT<>' ' and XLXSBJDYZZ3_DYDJFL<>' '");
|
||
SQL.Add(" )d on d.CPYT=XLXHB_CPYT and d.DYDJFL=XLDYDJB_DYDJFL");
|
||
SQL.Add(" and d.XLXSBJDYZZ3_BJSLXX<=BJD.sumBJSL");
|
||
SQL.Add(" and((d.XLXSBJDYZZ3_BJSLSX<>0 and d.XLXSBJDYZZ3_BJSLSX>BJD.sumBJSL)or d.XLXSBJDYZZ3_BJSLSX=0)");
|
||
SQL.Add(string.Format(" where tmp.XLXSBJDMX_BJDID='{0}'", sBJDID));
|
||
SQL.Add(" and (case when isnull(d.YZID,' ')<>' ' then isnull(d.YZZ,0)when isnull(c.YZID,' ')<>' ' then isnull(c.YZZ,0)");
|
||
SQL.Add(" when isnull(b.YZID,' ')<>' ' then isnull(b.YZZ,0)when isnull(a.YZID,' ')<>' ' then isnull(a.YZZ,0)");
|
||
SQL.Add(" else 0.0 end)");
|
||
SQL.Add(string.Format("*(case when isnull(XLXSBJDYZZ3BSY1_CPYT, ' ')=' ' then 1.0 else 0.0 end)*(case when isnull(XLXSBJDYZZ3BSY2_XLXHID, ' ')=' ' then 1.0 else 0.0 end)*(case when isnull(XLXSBJDYZZ3BSY3_XLJBXHID, ' ')=' ' then 1.0 else 0.0 end)<>XLXSBJDYZZ0_YZZ{0}", sYZID.Replace("BJ", "")));
|
||
SQL.Add(" and BJD.sumYZZ > 0 ");
|
||
#endregion
|
||
}
|
||
else if (sTJYS.Equals("6"))
|
||
{
|
||
#region
|
||
if (useFor.Equals("exists"))
|
||
{
|
||
SQL.Add(" select top 1 tmp.XLXSBJDMX_XH");
|
||
}
|
||
else if (useFor.Equals("selectBJDXH"))
|
||
{
|
||
SQL.Add(" select tmp.XLXSBJDMX_XH as BJDXH,");
|
||
SQL.Add(" (case when isnull(a.YZID,' ')<>' ' then isnull(a.YZZ,0)*100.0/BJD.sumBJSL");
|
||
SQL.Add(" else 0.0 end) as YZZ");
|
||
}
|
||
else if (useFor.Equals("selectBJCP"))
|
||
{//研发自测:王威 2025/09/12 01:21:15
|
||
SQL.Add(" select distinct upper(tmp.XLXSBJDMX_XLXHID) as XLXHID,tmp.XLXSBJDMX_XLGGID as XLGGID,tmp.XLXSBJDMX_XLBZID as XLBZID,isnull(tmp.XLXSBJDMX_DYDJID,' ') as DYDJID,' ' as XLXSBJDMX_XLYSID,");
|
||
for (int k = 1; k <= 20; k++)
|
||
{
|
||
if (sYZID.Equals("BJ" + k.ToString().PadLeft(2, '0')))
|
||
{
|
||
SQL.Add(" (case when isnull(a.YZID,' ')<>' ' then isnull(a.YZZ,0)*100.0/BJD.sumBJSL");
|
||
SQL.Add(string.Format(" else 0.0 end) as YZZ{0},", k.ToString().PadLeft(2, '0')));
|
||
}
|
||
else
|
||
SQL.Add(string.Format(" 0.0 as YZZ{0},", k.ToString().PadLeft(2, '0')));
|
||
}
|
||
SQL.Add(string.Format(" BJD.sumBJSL,'{0}' as JLDW,'{1}' as YZID ", sBJU003, sYZID));
|
||
}
|
||
SQL.Add(" from XLXSBJDMX tmp");
|
||
SQL.Add(" left join XLXSBJDYZZ0 on XLXSBJDYZZ0_BJDID=tmp.XLXSBJDMX_BJDID and XLXSBJDYZZ0_XH=tmp.XLXSBJDMX_XH");
|
||
SQL.Add(" left join ");
|
||
SQL.Add(" (select XLXSBJDMX_BJDID as BJDID,upper(XLXSBJDMX_XLXHID)as XLXHID,XLXSBJDMX_XLGGID as XLGGID,XLXSBJDMX_XLBZID as XLBZID,isnull(XLXSBJDMX_DYDJID,' ')as DYDJID,");
|
||
if (sBJU003JSDW.Equals("M"))
|
||
{
|
||
SQL.Add(" sum(case when XLXSBJDMX_JLDW in('Km','千米')then 1000*XLXSBJDMX_BJSL ");
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" when XLXSBJDMX_JLDW='{0}' then {1}*XLXSBJDMX_BJSL ", sKey, dicLenJLDWTD[sKey]));
|
||
}
|
||
SQL.Add(" else XLXSBJDMX_BJSL end)as sumBJSL");
|
||
}
|
||
else if (sBJU003JSDW.Equals("Km"))
|
||
{
|
||
SQL.Add(" sum(case when XLXSBJDMX_JLDW in('M','米') then 0.001*XLXSBJDMX_BJSL ");
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" when XLXSBJDMX_JLDW='{0}' then 0.001*{1}*XLXSBJDMX_BJSL ", sKey, dicLenJLDWTD[sKey]));
|
||
}
|
||
SQL.Add(" else XLXSBJDMX_BJSL end) as sumBJSL");
|
||
}
|
||
//取报价单明细因子值之和
|
||
SQL.Add(string.Format(" ,sum(XLXSBJDYZZ0_YZZ{0}) as sumYZZ", sYZID.Replace("BJ", "")));
|
||
SQL.Add(" from XLXSBJDMX");
|
||
//关联报价单明细因子值
|
||
SQL.Add(" left join XLXSBJDYZZ0 on XLXSBJDYZZ0_BJDID= XLXSBJDMX_BJDID and XLXSBJDYZZ0_XH= XLXSBJDMX_XH ");
|
||
SQL.Add(string.Format(" where XLXSBJDMX_BJDID='{0}'", sBJDID));
|
||
SQL.Add(" and (XLXSBJDMX_JLDW in('Km','M','千米','米')");
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" or XLXSBJDMX_JLDW='{0}'", sKey));
|
||
}
|
||
SQL.Add(" )");
|
||
SQL.Add(" and XLXSBJDMX_BJSL<>0");//因素6需要限制报价数量不为0
|
||
SQL.Add(" group by XLXSBJDMX_BJDID,upper(XLXSBJDMX_XLXHID),XLXSBJDMX_XLGGID,XLXSBJDMX_XLBZID,isnull(XLXSBJDMX_DYDJID,' ')");
|
||
SQL.Add(" )BJD on BJD.XLXHID=upper(tmp.XLXSBJDMX_XLXHID) and BJD.XLGGID=tmp.XLXSBJDMX_XLGGID and BJD.XLBZID=tmp.XLXSBJDMX_XLBZID and BJD.DYDJID=isnull(tmp.XLXSBJDMX_DYDJID,' ')");
|
||
SQL.Add(" left join");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSBJDYZZ6_YZID as YZID,XLXSBJDYZZ6_YZZ as YZZ,");
|
||
SQL.Add(" XLXSBJDYZZ6_BJSLXX,XLXSBJDYZZ6_BJSLSX");
|
||
SQL.Add(" from XLXSBJDYZZ6,XLXSTZYZ");
|
||
SQL.Add(" where XLXSTZYZ_MXBH='BJD' and XLXSTZYZ_TJYS='6' and XLXSBJDYZZ6_JGBID=XLXSTZYZ_JGBID and XLXSTZYZ_YZID=XLXSBJDYZZ6_YZID");
|
||
SQL.Add(string.Format(" and exists(select 1 from XLXSBJFLYZ where XLXSBJFLYZ_BJFLID='{0}' and XLXSBJFLYZ_YZID=XLXSTZYZ_YZID)", sBJFLID));
|
||
SQL.Add(string.Format(" and XLXSBJDYZZ6_YZID='{0}'", sYZID));
|
||
SQL.Add(" ) a on ");
|
||
SQL.Add(" a.XLXSBJDYZZ6_BJSLXX<=BJD.sumBJSL");
|
||
SQL.Add(" and ((a.XLXSBJDYZZ6_BJSLSX<>0 and a.XLXSBJDYZZ6_BJSLSX>BJD.sumBJSL) or a.XLXSBJDYZZ6_BJSLSX=0) ");
|
||
SQL.Add(string.Format(" where tmp.XLXSBJDMX_BJDID='{0}'", sBJDID));
|
||
SQL.Add(" and (case when isnull(a.YZID,' ')<>' ' then RoundFix(isnull(a.YZZ,0)*100.0/BJD.sumBJSL,6)");
|
||
SQL.Add(string.Format(" else 0.0 end)<>RoundFix(XLXSBJDYZZ0_YZZ{0},6)", sYZID.Replace("BJ", "")));
|
||
SQL.Add(" and BJD.sumYZZ > 0 ");
|
||
#endregion
|
||
}
|
||
else if (sTJYS.Equals("E"))
|
||
{
|
||
#region
|
||
if (useFor.Equals("exists"))
|
||
{
|
||
SQL.Add(" select top 1 tmp.XLXSBJDMX_XH");
|
||
}
|
||
else if (useFor.Equals("selectBJDXH"))
|
||
{
|
||
SQL.Add(" select tmp.XLXSBJDMX_XH as BJDXH,");
|
||
SQL.Add(" (case when isnull(c.YZID,' ')<>' ' then isnull(c.YZZ,0) when isnull(b.YZID,' ')<>' ' then isnull(b.YZZ,0) when isnull(a.YZID,' ')<>' ' then isnull(a.YZZ,0)");
|
||
SQL.Add(" else 0.0 end)");
|
||
SQL.Add(" *(case when isnull(XLXSBJDYZZEBSY1_CPYT, ' ')=' ' then 1.0 else 0.0 end)*(case when isnull(XLXSBJDYZZEBSY2_XLJBXHID, ' ')=' ' then 1.0 else 0.0 end) as YZZ ");
|
||
}
|
||
else if (useFor.Equals("selectBJCP"))
|
||
{//研发自测:王威 2025/09/12 01:21:15
|
||
SQL.Add(" select distinct upper(tmp.XLXSBJDMX_XLXHID) as XLXHID,tmp.XLXSBJDMX_XLGGID as XLGGID,tmp.XLXSBJDMX_XLBZID as XLBZID,isnull(tmp.XLXSBJDMX_DYDJID,' ') as DYDJID,' ' as XLXSBJDMX_XLYSID,");
|
||
for (int k = 1; k <= 20; k++)
|
||
{
|
||
if (sYZID.Equals("BJ" + k.ToString().PadLeft(2, '0')))
|
||
{
|
||
SQL.Add(" (case when isnull(c.YZID,' ')<>' ' then isnull(c.YZZ,0) when isnull(b.YZID,' ')<>' ' then isnull(b.YZZ,0) when isnull(a.YZID,' ')<>' ' then isnull(a.YZZ,0)");
|
||
SQL.Add(" else 0.0 end) ");
|
||
SQL.Add(string.Format(" *(case when isnull(XLXSBJDYZZEBSY1_CPYT, ' ')=' ' then 1.0 else 0.0 end)*(case when isnull(XLXSBJDYZZEBSY2_XLJBXHID, ' ')=' ' then 1.0 else 0.0 end) as YZZ{0},", k.ToString().PadLeft(2, '0')));
|
||
}
|
||
else
|
||
SQL.Add(string.Format(" 0.0 as YZZ{0},", k.ToString().PadLeft(2, '0')));
|
||
}
|
||
SQL.Add(string.Format(" BJD.sumBJSL,'{0}' as JLDW,'{1}' as YZID ", sBJU003, sYZID));
|
||
}
|
||
SQL.Add(" from XLXSBJDMX tmp");
|
||
SQL.Add(" left join XLXSBJDYZZ0 on XLXSBJDYZZ0_BJDID=tmp.XLXSBJDMX_BJDID and XLXSBJDYZZ0_XH=tmp.XLXSBJDMX_XH");
|
||
SQL.Add(" left join ");
|
||
SQL.Add(" (select XLXSBJDMX_BJDID as BJDID,upper(XLXSBJDMX_XLXHID)as XLXHID,XLXSBJDMX_XLGGID as XLGGID,XLXSBJDMX_XLBZID as XLBZID,isnull(XLXSBJDMX_DYDJID,' ') as DYDJID,");
|
||
if (sBJU003JSDW.Equals("M"))
|
||
{
|
||
SQL.Add(" sum(case when XLXSBJDMX_JLDW in('Km','千米')then 1000*XLXSBJDMX_BJSL ");
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" when XLXSBJDMX_JLDW='{0}' then {1}*XLXSBJDMX_BJSL ", sKey, dicLenJLDWTD[sKey]));
|
||
}
|
||
SQL.Add(" else XLXSBJDMX_BJSL end)as sumBJSL");
|
||
}
|
||
else if (sBJU003JSDW.Equals("Km"))
|
||
{
|
||
SQL.Add(" sum(case when XLXSBJDMX_JLDW in('M','米')then 0.001*XLXSBJDMX_BJSL ");
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" when XLXSBJDMX_JLDW='{0}' then 0.001*{1}*XLXSBJDMX_BJSL ", sKey, dicLenJLDWTD[sKey]));
|
||
}
|
||
SQL.Add(" else XLXSBJDMX_BJSL end)as sumBJSL");
|
||
}
|
||
//取报价单明细因子值之和
|
||
SQL.Add(string.Format(" ,sum(XLXSBJDYZZ0_YZZ{0}) as sumYZZ", sYZID.Replace("BJ", "")));
|
||
SQL.Add(" from XLXSBJDMX");
|
||
//关联报价单明细因子值
|
||
SQL.Add(" left join XLXSBJDYZZ0 on XLXSBJDYZZ0_BJDID= XLXSBJDMX_BJDID and XLXSBJDYZZ0_XH= XLXSBJDMX_XH ");
|
||
SQL.Add(string.Format(" where XLXSBJDMX_BJDID='{0}'", sBJDID));
|
||
SQL.Add(" and (XLXSBJDMX_JLDW in('Km','M','千米','米')");
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" or XLXSBJDMX_JLDW='{0}'", sKey));
|
||
}
|
||
SQL.Add(" )");
|
||
SQL.Add(" group by XLXSBJDMX_BJDID,upper(XLXSBJDMX_XLXHID),XLXSBJDMX_XLGGID,XLXSBJDMX_XLBZID,isnull(XLXSBJDMX_DYDJID,' ')");
|
||
SQL.Add(" )BJD on BJD.XLXHID=upper(tmp.XLXSBJDMX_XLXHID) and BJD.XLGGID=tmp.XLXSBJDMX_XLGGID and BJD.XLBZID=tmp.XLXSBJDMX_XLBZID and BJD.DYDJID=isnull(tmp.XLXSBJDMX_DYDJID,' ')");
|
||
SQL.Add(" left join XLXHB on XLXHB_XLXHID=BJD.XLXHID ");
|
||
SQL.Add(" left join XLXSBJDYZZEBSY1 on XLXSBJDYZZEBSY1_CPYT= isnull(XLXHB_CPYT,' ')");
|
||
SQL.Add(" left join XLXSBJDYZZEBSY2 on XLXSBJDYZZEBSY2_XLJBXHID= isnull(XLXHB_XLJBXHID,' ')");
|
||
SQL.Add(" left join XLXSBJXLGGTHB on XLXSBJXLGGTHB_XLGGID = XLXSBJDMX_XLGGID ");
|
||
SQL.Add(" left join XLGGB on XLGGB_XLGGID = XLXSBJXLGGTHB_XLGGIDCH and XLGGB_XLGGJDGZ = isnull(XLXHB_XLGGJDGZ,'0') ");
|
||
SQL.Add(" left join XLDTJMZHB on XLDTJMZHB_DTJMZHID=XLGGB_DTJMZHID ");
|
||
SQL.Add(" left join");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSBJDYZZE_XLXHID,XLXSBJDYZZE_DYDJID,XLXSBJDYZZE_YZID as YZID,XLXSBJDYZZE_YZZ as YZZ,");
|
||
SQL.Add(" XLXSBJDYZZE_ZXJMXX,XLXSBJDYZZE_ZXJMSX,XLXSBJDYZZE_BJSLXX,XLXSBJDYZZE_BJSLSX");
|
||
SQL.Add(" from XLXSBJDYZZE");
|
||
SQL.Add(" where exists(select 1 from XLXSTZYZ where XLXSTZYZ_MXBH='BJD' and XLXSTZYZ_TJYS='E' and XLXSTZYZ_JGBID=XLXSBJDYZZE_JGBID and XLXSTZYZ_YZID=XLXSBJDYZZE_YZID ) ");
|
||
SQL.Add(string.Format(" and exists(select 1 from XLXSBJFLYZ where XLXSBJFLYZ_BJFLID='{0}' and XLXSBJFLYZ_YZID=XLXSBJDYZZE_YZID)", sBJFLID));
|
||
SQL.Add(string.Format(" and XLXSBJDYZZE_YZID='{0}'", sYZID));
|
||
SQL.Add(" and XLXSBJDYZZE_XLXHID=' ' and XLXSBJDYZZE_DYDJID=' '");
|
||
SQL.Add(" ) a on ");
|
||
SQL.Add(" a.XLXSBJDYZZE_ZXJMXX<=isnull(XLDTJMZHB_DTJM1,0) and ((a.XLXSBJDYZZE_ZXJMSX<>0 and a.XLXSBJDYZZE_ZXJMSX>=isnull(XLDTJMZHB_DTJM1,0)) or a.XLXSBJDYZZE_ZXJMSX=0) ");
|
||
SQL.Add(" and a.XLXSBJDYZZE_BJSLXX<=BJD.sumBJSL");
|
||
SQL.Add(" and ((a.XLXSBJDYZZE_BJSLSX<>0 and a.XLXSBJDYZZE_BJSLSX>BJD.sumBJSL) or a.XLXSBJDYZZE_BJSLSX=0) ");
|
||
SQL.Add(" left join");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSBJDYZZE_XLXHID,XLXSBJDYZZE_DYDJID,XLXSBJDYZZE_YZID as YZID,XLXSBJDYZZE_YZZ as YZZ,");
|
||
SQL.Add(" XLXSBJDYZZE_ZXJMXX,XLXSBJDYZZE_ZXJMSX,XLXSBJDYZZE_BJSLXX,XLXSBJDYZZE_BJSLSX");
|
||
SQL.Add(" from XLXSBJDYZZE");
|
||
SQL.Add(" where exists(select 1 from XLXSTZYZ where XLXSTZYZ_MXBH='BJD' and XLXSTZYZ_TJYS='E' and XLXSTZYZ_JGBID=XLXSBJDYZZE_JGBID and XLXSTZYZ_YZID=XLXSBJDYZZE_YZID ) ");
|
||
SQL.Add(string.Format(" and exists(select 1 from XLXSBJFLYZ where XLXSBJFLYZ_BJFLID='{0}' and XLXSBJFLYZ_YZID=XLXSBJDYZZE_YZID)", sBJFLID));
|
||
SQL.Add(string.Format(" and XLXSBJDYZZE_YZID='{0}'", sYZID));
|
||
SQL.Add(" and XLXSBJDYZZE_XLXHID<>' ' and XLXSBJDYZZE_DYDJID=' '");
|
||
SQL.Add(" ) b on b.XLXSBJDYZZE_XLXHID = XLXHID ");
|
||
SQL.Add(" and b.XLXSBJDYZZE_ZXJMXX<=isnull(XLDTJMZHB_DTJM1,0) and ((b.XLXSBJDYZZE_ZXJMSX<>0 and b.XLXSBJDYZZE_ZXJMSX>=isnull(XLDTJMZHB_DTJM1,0)) or b.XLXSBJDYZZE_ZXJMSX=0) ");
|
||
SQL.Add(" and b.XLXSBJDYZZE_BJSLXX<=BJD.sumBJSL");
|
||
SQL.Add(" and ((b.XLXSBJDYZZE_BJSLSX<>0 and b.XLXSBJDYZZE_BJSLSX>BJD.sumBJSL) or b.XLXSBJDYZZE_BJSLSX=0) ");
|
||
SQL.Add(" left join");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSBJDYZZE_XLXHID,XLXSBJDYZZE_DYDJID,XLXSBJDYZZE_YZID as YZID,XLXSBJDYZZE_YZZ as YZZ,");
|
||
SQL.Add(" XLXSBJDYZZE_ZXJMXX,XLXSBJDYZZE_ZXJMSX,XLXSBJDYZZE_BJSLXX,XLXSBJDYZZE_BJSLSX");
|
||
SQL.Add(" from XLXSBJDYZZE");
|
||
SQL.Add(" where exists(select 1 from XLXSTZYZ where XLXSTZYZ_MXBH='BJD' and XLXSTZYZ_TJYS='E' and XLXSTZYZ_JGBID=XLXSBJDYZZE_JGBID and XLXSTZYZ_YZID=XLXSBJDYZZE_YZID ) ");
|
||
SQL.Add(string.Format(" and exists(select 1 from XLXSBJFLYZ where XLXSBJFLYZ_BJFLID='{0}' and XLXSBJFLYZ_YZID=XLXSBJDYZZE_YZID)", sBJFLID));
|
||
SQL.Add(string.Format(" and XLXSBJDYZZE_YZID='{0}'", sYZID));
|
||
SQL.Add(" and XLXSBJDYZZE_XLXHID<>' ' and XLXSBJDYZZE_DYDJID<>' '");
|
||
SQL.Add(" ) c on c.XLXSBJDYZZE_XLXHID=XLXHID and c.XLXSBJDYZZE_DYDJID = DYDJID");
|
||
SQL.Add(" and c.XLXSBJDYZZE_ZXJMXX<=isnull(XLDTJMZHB_DTJM1,0) and ((c.XLXSBJDYZZE_ZXJMSX<>0 and c.XLXSBJDYZZE_ZXJMSX>=isnull(XLDTJMZHB_DTJM1,0)) or c.XLXSBJDYZZE_ZXJMSX=0) ");
|
||
SQL.Add(" and c.XLXSBJDYZZE_BJSLXX<=BJD.sumBJSL");
|
||
SQL.Add(" and ((c.XLXSBJDYZZE_BJSLSX<>0 and c.XLXSBJDYZZE_BJSLSX>BJD.sumBJSL) or c.XLXSBJDYZZE_BJSLSX=0)");
|
||
SQL.Add(string.Format(" where tmp.XLXSBJDMX_BJDID='{0}'", sBJDID));
|
||
SQL.Add(" and (case when isnull(c.YZID,' ')<>' ' then isnull(c.YZZ,0) when isnull(b.YZID,' ')<>' ' then isnull(b.YZZ,0) when isnull(a.YZID,' ')<>' ' then isnull(a.YZZ,0)");
|
||
SQL.Add(" else 0.0 end)");
|
||
SQL.Add(string.Format("*(case when isnull(XLXSBJDYZZEBSY1_CPYT, ' ')=' ' then 1.0 else 0.0 end)*(case when isnull(XLXSBJDYZZEBSY2_XLJBXHID, ' ')=' ' then 1.0 else 0.0 end)<>XLXSBJDYZZ0_YZZ{0}", sYZID.Replace("BJ", "")));
|
||
SQL.Add(" and BJD.sumYZZ > 0 ");
|
||
#endregion
|
||
}
|
||
else if (sTJYS.Equals("G"))
|
||
{
|
||
#region
|
||
if (useFor.Equals("exists"))
|
||
{
|
||
SQL.Add(" select top 1 tmp.XLXSBJDMX_XH");
|
||
}
|
||
else if (useFor.Equals("selectBJDXH"))
|
||
{
|
||
SQL.Add(" select tmp.XLXSBJDMX_XH as BJDXH,");
|
||
SQL.Add(" (case when isnull(b.YZID,' ')<>' ' then isnull(b.YZZ,0) when isnull(a.YZID,' ')<>' ' then isnull(a.YZZ,0)");
|
||
SQL.Add(" else 0.0 end) as YZZ" );
|
||
}
|
||
else if (useFor.Equals("selectBJCP"))
|
||
{//研发自测:王威 2025/09/12 01:21:15
|
||
SQL.Add(" select distinct upper(tmp.XLXSBJDMX_XLXHID) as XLXHID,tmp.XLXSBJDMX_XLGGID as XLGGID,tmp.XLXSBJDMX_XLBZID as XLBZID,isnull(tmp.XLXSBJDMX_DYDJID,' ') as DYDJID,' ' as XLXSBJDMX_XLYSID,");
|
||
for (int k = 1; k <= 20; k++)
|
||
{
|
||
if (sYZID.Equals("BJ" + k.ToString().PadLeft(2, '0')))
|
||
{
|
||
SQL.Add(" (case when isnull(b.YZID,' ')<>' ' then isnull(b.YZZ,0) when isnull(a.YZID,' ')<>' ' then isnull(a.YZZ,0)");
|
||
SQL.Add(" else 0.0 end) ");
|
||
SQL.Add(string.Format(" as YZZ{0},", k.ToString().PadLeft(2, '0')));
|
||
}
|
||
else
|
||
SQL.Add(string.Format(" 0.0 as YZZ{0},", k.ToString().PadLeft(2, '0')));
|
||
}
|
||
SQL.Add(string.Format(" BJD.sumBJSL,'{0}' as JLDW,'{1}' as YZID ", sBJU003, sYZID));
|
||
}
|
||
SQL.Add(" from XLXSBJDMX tmp");
|
||
SQL.Add(" left join XLXSBJDYZZ0 on XLXSBJDYZZ0_BJDID=tmp.XLXSBJDMX_BJDID and XLXSBJDYZZ0_XH=tmp.XLXSBJDMX_XH");
|
||
SQL.Add(" left join ");
|
||
SQL.Add(" (select XLXSBJDMX_BJDID as BJDID,upper(XLXSBJDMX_XLXHID)as XLXHID,XLXSBJDMX_XLGGID as XLGGID,XLXSBJDMX_XLBZID as XLBZID,isnull(XLXSBJDMX_DYDJID,' ') as DYDJID,");
|
||
if (sBJU003JSDW.Equals("M"))
|
||
{
|
||
SQL.Add(" sum(case when XLXSBJDMX_JLDW in('Km','千米')then 1000*XLXSBJDMX_BJSL ");
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" when XLXSBJDMX_JLDW='{0}' then {1}*XLXSBJDMX_BJSL ", sKey, dicLenJLDWTD[sKey]));
|
||
}
|
||
SQL.Add(" else XLXSBJDMX_BJSL end)as sumBJSL");
|
||
}
|
||
else if (sBJU003JSDW.Equals("Km"))
|
||
{
|
||
SQL.Add(" sum(case when XLXSBJDMX_JLDW in('M','米')then 0.001*XLXSBJDMX_BJSL ");
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" when XLXSBJDMX_JLDW='{0}' then 0.001*{1}*XLXSBJDMX_BJSL ", sKey, dicLenJLDWTD[sKey]));
|
||
}
|
||
SQL.Add(" else XLXSBJDMX_BJSL end)as sumBJSL");
|
||
}
|
||
//取报价单明细因子值之和
|
||
SQL.Add(string.Format(" ,sum(XLXSBJDYZZ0_YZZ{0}) as sumYZZ", sYZID.Replace("BJ", "")));
|
||
SQL.Add(" from XLXSBJDMX");
|
||
//关联报价单明细因子值
|
||
SQL.Add(" left join XLXSBJDYZZ0 on XLXSBJDYZZ0_BJDID= XLXSBJDMX_BJDID and XLXSBJDYZZ0_XH= XLXSBJDMX_XH ");
|
||
SQL.Add(string.Format(" where XLXSBJDMX_BJDID='{0}'", sBJDID));
|
||
SQL.Add(" and (XLXSBJDMX_JLDW in('Km','M','千米','米')");
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" or XLXSBJDMX_JLDW='{0}'", sKey));
|
||
}
|
||
SQL.Add(" )");
|
||
SQL.Add(" group by XLXSBJDMX_BJDID,upper(XLXSBJDMX_XLXHID),XLXSBJDMX_XLGGID,XLXSBJDMX_XLBZID,isnull(XLXSBJDMX_DYDJID,' ')");
|
||
SQL.Add(" )BJD on BJD.XLXHID=upper(tmp.XLXSBJDMX_XLXHID) and BJD.XLGGID=tmp.XLXSBJDMX_XLGGID and BJD.XLBZID=tmp.XLXSBJDMX_XLBZID and BJD.DYDJID=isnull(tmp.XLXSBJDMX_DYDJID,' ')");
|
||
SQL.Add(" left join XLXHB on XLXHB_XLXHID=BJD.XLXHID ");
|
||
SQL.Add(" left join XLXSBJXLGGTHB on XLXSBJXLGGTHB_XLGGID = XLXSBJDMX_XLGGID ");
|
||
SQL.Add(" left join XLGGB on XLGGB_XLGGID = XLXSBJXLGGTHB_XLGGIDCH and XLGGB_XLGGJDGZ = isnull(XLXHB_XLGGJDGZ,'0') ");
|
||
SQL.Add(" left join XLDTJMZHB on XLDTJMZHB_DTJMZHID=XLGGB_DTJMZHID ");
|
||
SQL.Add(" left join");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSBJDYZZG_DTCLID,XLXSBJDYZZG_XXJGID,XLXSBJDYZZG_DYDJID,XLXSBJDYZZG_YZID as YZID,XLXSBJDYZZG_YZZ as YZZ,");
|
||
SQL.Add(" XLXSBJDYZZG_ZXJMXX,XLXSBJDYZZG_ZXJMSX,XLXSBJDYZZG_BJSLXX,XLXSBJDYZZG_BJSLSX");
|
||
SQL.Add(" from XLXSBJDYZZG");
|
||
SQL.Add(" where exists(select 1 from XLXSTZYZ where XLXSTZYZ_MXBH='BJD' and XLXSTZYZ_TJYS='G' and XLXSTZYZ_JGBID=XLXSBJDYZZG_JGBID and XLXSTZYZ_YZID=XLXSBJDYZZG_YZID ) ");
|
||
SQL.Add(string.Format(" and exists(select 1 from XLXSBJFLYZ where XLXSBJFLYZ_BJFLID='{0}' and XLXSBJFLYZ_YZID=XLXSBJDYZZG_YZID)", sBJFLID));
|
||
SQL.Add(string.Format(" and XLXSBJDYZZG_YZID='{0}'", sYZID));
|
||
SQL.Add(" and XLXSBJDYZZG_DTCLID=' ' ");
|
||
SQL.Add(" ) a on ");
|
||
SQL.Add(" a.XLXSBJDYZZG_ZXJMXX<=isnull(XLDTJMZHB_DTJM1,0) and ((a.XLXSBJDYZZG_ZXJMSX<>0 and a.XLXSBJDYZZG_ZXJMSX>=isnull(XLDTJMZHB_DTJM1,0)) or a.XLXSBJDYZZG_ZXJMSX=0) ");
|
||
SQL.Add(" and a.XLXSBJDYZZG_BJSLXX<=BJD.sumBJSL");
|
||
SQL.Add(" and ((a.XLXSBJDYZZG_BJSLSX<>0 and a.XLXSBJDYZZG_BJSLSX>BJD.sumBJSL) or a.XLXSBJDYZZG_BJSLSX=0) and a.XLXSBJDYZZG_DYDJID=isnull(XLXSBJDMX_DYDJID,' ') and a.XLXSBJDYZZG_XXJGID=XLGGB_XXJGID ");
|
||
SQL.Add(" left join");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSBJDYZZG_DTCLID,XLXSBJDYZZG_XXJGID,XLXSBJDYZZG_DYDJID,XLXSBJDYZZG_YZID as YZID,XLXSBJDYZZG_YZZ as YZZ,");
|
||
SQL.Add(" XLXSBJDYZZG_ZXJMXX,XLXSBJDYZZG_ZXJMSX,XLXSBJDYZZG_BJSLXX,XLXSBJDYZZG_BJSLSX");
|
||
SQL.Add(" from XLXSBJDYZZG");
|
||
SQL.Add(" where exists(select 1 from XLXSTZYZ where XLXSTZYZ_MXBH='BJD' and XLXSTZYZ_TJYS='G' and XLXSTZYZ_JGBID=XLXSBJDYZZG_JGBID and XLXSTZYZ_YZID=XLXSBJDYZZG_YZID ) ");
|
||
SQL.Add(string.Format(" and exists(select 1 from XLXSBJFLYZ where XLXSBJFLYZ_BJFLID='{0}' and XLXSBJFLYZ_YZID=XLXSBJDYZZG_YZID)", sBJFLID));
|
||
SQL.Add(string.Format(" and XLXSBJDYZZG_YZID='{0}'", sYZID));
|
||
SQL.Add(" and XLXSBJDYZZG_DTCLID<>' ' ");
|
||
SQL.Add(" ) b on b.XLXSBJDYZZG_DTCLID=XLXHB_DTCLID and ");
|
||
SQL.Add(" b.XLXSBJDYZZG_ZXJMXX<=isnull(XLDTJMZHB_DTJM1,0) and ((b.XLXSBJDYZZG_ZXJMSX<>0 and b.XLXSBJDYZZG_ZXJMSX>=isnull(XLDTJMZHB_DTJM1,0)) or b.XLXSBJDYZZG_ZXJMSX=0) ");
|
||
SQL.Add(" and b.XLXSBJDYZZG_BJSLXX<=BJD.sumBJSL");
|
||
SQL.Add(" and ((b.XLXSBJDYZZG_BJSLSX<>0 and b.XLXSBJDYZZG_BJSLSX>BJD.sumBJSL) or b.XLXSBJDYZZG_BJSLSX=0) and b.XLXSBJDYZZG_DYDJID=isnull(XLXSBJDMX_DYDJID,' ') and b.XLXSBJDYZZG_XXJGID=XLGGB_XXJGID ");
|
||
SQL.Add(string.Format(" where tmp.XLXSBJDMX_BJDID='{0}'", sBJDID));
|
||
SQL.Add(" and (case when isnull(b.YZID,' ')<>' ' then isnull(b.YZZ,0) when isnull(a.YZID,' ')<>' ' then isnull(a.YZZ,0)");
|
||
SQL.Add(" else 0.0 end)");
|
||
SQL.Add(string.Format(" <>XLXSBJDYZZ0_YZZ{0}", sYZID.Replace("BJ", "")));
|
||
SQL.Add(" and BJD.sumYZZ > 0 ");
|
||
#endregion
|
||
}
|
||
else if (sTJYS.Equals("F"))
|
||
{
|
||
#region
|
||
if (useFor.Equals("exists"))
|
||
{
|
||
SQL.Add(" select top 1 tmp.XLXSBJDMX_XH");
|
||
}
|
||
else if (useFor.Equals("selectBJDXH"))
|
||
{
|
||
SQL.Add(" select tmp.XLXSBJDMX_XH as BJDXH,tmp.XLXSBJDMX_JLDW AS XLXSBJDMX_JLDW,");
|
||
SQL.Add(" (case when isnull(b.YZID,' ')<>' ' then RoundFix(isnull(b.YZZ,0)/BJD.sumBJSL,6) when isnull(a.YZID,' ')<>' ' then RoundFix(isnull(a.YZZ,0)/BJD.sumBJSL,6)");
|
||
SQL.Add(" else 0.0 end) as YZZ");
|
||
}
|
||
else if (useFor.Equals("selectBJCP"))
|
||
{//研发自测:王威 2025/09/12 01:21:15
|
||
SQL.Add(" select distinct upper(tmp.XLXSBJDMX_XLXHID) as XLXHID,tmp.XLXSBJDMX_XLGGID as XLGGID,tmp.XLXSBJDMX_XLBZID as XLBZID,isnull(tmp.XLXSBJDMX_DYDJID,' ') as DYDJID,' ' as XLXSBJDMX_XLYSID,");
|
||
for (int k = 1; k <= 20; k++)
|
||
{
|
||
if (sYZID.Equals("BJ" + k.ToString().PadLeft(2, '0')))
|
||
{
|
||
SQL.Add(" (case when isnull(b.YZID,' ')<>' ' then RoundFix(isnull(b.YZZ,0)/BJD.sumBJSL,6) when isnull(a.YZID,' ')<>' ' then RoundFix(isnull(a.YZZ,0)/BJD.sumBJSL,6)");
|
||
SQL.Add(string.Format(" else 0.0 end) as YZZ{0},", k.ToString().PadLeft(2, '0')));
|
||
}
|
||
else
|
||
SQL.Add(string.Format(" 0.0 as YZZ{0},", k.ToString().PadLeft(2, '0')));
|
||
}
|
||
SQL.Add(string.Format(" BJD.sumBJSL,'{0}' as JLDW,'{1}' as YZID ", sBJU003, sYZID));
|
||
}
|
||
SQL.Add(" from XLXSBJDMX tmp");
|
||
SQL.Add(" left join XLXSBJDYZZ0 on XLXSBJDYZZ0_BJDID=tmp.XLXSBJDMX_BJDID and XLXSBJDYZZ0_XH=tmp.XLXSBJDMX_XH");
|
||
SQL.Add(" left join ");
|
||
SQL.Add(" (select XLXSBJDMX_BJDID as BJDID,upper(XLXSBJDMX_XLXHID)as XLXHID,XLXSBJDMX_XLGGID as XLGGID,XLXSBJDMX_XLBZID as XLBZID,isnull(XLXSBJDMX_DYDJID,' ') as DYDJID,");
|
||
if (sBJU003JSDW.Equals("M"))
|
||
{
|
||
SQL.Add(" sum(case when XLXSBJDMX_JLDW in('Km','千米')then 1000*XLXSBJDMX_BJSL ");
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" when XLXSBJDMX_JLDW='{0}' then {1}*XLXSBJDMX_BJSL ", sKey, dicLenJLDWTD[sKey]));
|
||
}
|
||
SQL.Add(" else XLXSBJDMX_BJSL end)as sumBJSL");
|
||
}
|
||
|
||
else if (sBJU003JSDW.Equals("Km"))
|
||
{
|
||
SQL.Add(" sum(case when XLXSBJDMX_JLDW in('M','米')then 0.001*XLXSBJDMX_BJSL ");
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" when XLXSBJDMX_JLDW='{0}' then 0.001*{1}*XLXSBJDMX_BJSL ", sKey, dicLenJLDWTD[sKey]));
|
||
}
|
||
SQL.Add(" else XLXSBJDMX_BJSL end)as sumBJSL");
|
||
}
|
||
//取报价单明细因子值之和
|
||
SQL.Add(string.Format(" ,sum(XLXSBJDYZZ0_YZZ{0}) as sumYZZ", sYZID.Replace("BJ", "")));
|
||
SQL.Add(" from XLXSBJDMX");
|
||
//关联报价单明细因子值
|
||
SQL.Add(" left join XLXSBJDYZZ0 on XLXSBJDYZZ0_BJDID= XLXSBJDMX_BJDID and XLXSBJDYZZ0_XH= XLXSBJDMX_XH ");
|
||
SQL.Add(string.Format(" where XLXSBJDMX_BJDID='{0}'", sBJDID));
|
||
SQL.Add(" and (XLXSBJDMX_JLDW in('Km','M','千米','米')");
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" or XLXSBJDMX_JLDW='{0}'", sKey));
|
||
}
|
||
SQL.Add(" )");
|
||
SQL.Add(" and XLXSBJDMX_BJSL<>0");//因素F需要限制报价数量不为0
|
||
SQL.Add(" group by XLXSBJDMX_BJDID,upper(XLXSBJDMX_XLXHID),XLXSBJDMX_XLGGID,XLXSBJDMX_XLBZID,isnull(XLXSBJDMX_DYDJID,' ')");
|
||
SQL.Add(" )BJD on BJD.XLXHID=upper(tmp.XLXSBJDMX_XLXHID) and BJD.XLGGID=tmp.XLXSBJDMX_XLGGID and BJD.XLBZID=tmp.XLXSBJDMX_XLBZID and BJD.DYDJID=isnull(tmp.XLXSBJDMX_DYDJID,' ')");
|
||
SQL.Add(" left join XLXHB on XLXHB_XLXHID=tmp.XLXSBJDMX_XLXHID ");
|
||
SQL.Add(" left join XLGGB on XLGGB_XLGGID = replace(tmp.XLXSBJDMX_XLGGID , '*','×') and XLGGB_XLGGJDGZ = isnull(XLXHB_XLGGJDGZ,'0') ");
|
||
SQL.Add(" left join");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSBJDYZZF_DYDJID,XLXSBJDYZZF_YZID as YZID,XLXSBJDYZZF_YZZ as YZZ,");
|
||
SQL.Add(" XLXSBJDYZZF_XXJGID,XLXSBJDYZZF_DTCLID,XLXSBJDYZZF_BJSLXX,XLXSBJDYZZF_BJSLSX");
|
||
SQL.Add(" from XLXSBJDYZZF");
|
||
SQL.Add(" where exists(select 1 from XLXSTZYZ where XLXSTZYZ_MXBH='BJD' and XLXSTZYZ_TJYS='F' and XLXSTZYZ_JGBID=XLXSBJDYZZF_JGBID and XLXSTZYZ_YZID=XLXSBJDYZZF_YZID ) ");
|
||
SQL.Add(string.Format(" and exists(select 1 from XLXSBJFLYZ where XLXSBJFLYZ_BJFLID='{0}' and XLXSBJFLYZ_YZID=XLXSBJDYZZF_YZID)", sBJFLID));
|
||
SQL.Add(string.Format(" and XLXSBJDYZZF_YZID='{0}'", sYZID));
|
||
SQL.Add(" and XLXSBJDYZZF_XXJGID=' ' and XLXSBJDYZZF_DYDJID<>' '");
|
||
SQL.Add(" ) a on a.XLXSBJDYZZF_DYDJID = DYDJID AND a.XLXSBJDYZZF_DTCLID = XLXHB_DTCLID ");
|
||
SQL.Add(" and a.XLXSBJDYZZF_BJSLXX<=BJD.sumBJSL");
|
||
SQL.Add(" and ((a.XLXSBJDYZZF_BJSLSX<>0 and a.XLXSBJDYZZF_BJSLSX>BJD.sumBJSL) or a.XLXSBJDYZZF_BJSLSX=0) ");
|
||
SQL.Add(" left join");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSBJDYZZF_DYDJID,XLXSBJDYZZF_YZID as YZID,XLXSBJDYZZF_YZZ as YZZ,");
|
||
SQL.Add(" XLXSBJDYZZF_XXJGID,XLXSBJDYZZF_DTCLID,XLXSBJDYZZF_BJSLXX,XLXSBJDYZZF_BJSLSX");
|
||
SQL.Add(" from XLXSBJDYZZF");
|
||
SQL.Add(" where exists(select 1 from XLXSTZYZ where XLXSTZYZ_MXBH='BJD' and XLXSTZYZ_TJYS='F' and XLXSTZYZ_JGBID=XLXSBJDYZZF_JGBID and XLXSTZYZ_YZID=XLXSBJDYZZF_YZID ) ");
|
||
SQL.Add(string.Format(" and exists(select 1 from XLXSBJFLYZ where XLXSBJFLYZ_BJFLID='{0}' and XLXSBJFLYZ_YZID=XLXSBJDYZZF_YZID)", sBJFLID));
|
||
SQL.Add(string.Format(" and XLXSBJDYZZF_YZID='{0}'", sYZID));
|
||
SQL.Add(" and XLXSBJDYZZF_XXJGID<>' ' and XLXSBJDYZZF_DYDJID<>' '");//需要查芯线结构ID
|
||
SQL.Add(" ) b on b.XLXSBJDYZZF_XXJGID=XLGGB_XXJGID and b.XLXSBJDYZZF_DYDJID = DYDJID AND b.XLXSBJDYZZF_DTCLID = XLXHB_DTCLID ");
|
||
SQL.Add(" and b.XLXSBJDYZZF_BJSLXX<=BJD.sumBJSL");
|
||
SQL.Add(" and ((b.XLXSBJDYZZF_BJSLSX<>0 and b.XLXSBJDYZZF_BJSLSX>BJD.sumBJSL) or b.XLXSBJDYZZF_BJSLSX=0)");
|
||
SQL.Add(string.Format(" where tmp.XLXSBJDMX_BJDID='{0}'", sBJDID));
|
||
SQL.Add(" and (case when isnull(b.YZID,' ')<>' ' then RoundFix(isnull(b.YZZ,0)/sumBJSL,6) when isnull(a.YZID,' ')<>' ' then RoundFix(isnull(a.YZZ,0)/sumBJSL,6) ");
|
||
if (sBJU003JSDW.Equals("M"))
|
||
{
|
||
SQL.Add(string.Format(" else 0.0 end)<> (case when tmp.XLXSBJDMX_JLDW in('Km','千米') then RoundFix(0.001*XLXSBJDYZZ0_YZZ{0},6) ", sYZID.Replace("BJ", "")));
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" when tmp.XLXSBJDMX_JLDW='{0}' then RoundFix(XLXSBJDYZZ0_YZZ{2}/{1},6) ", sKey, dicLenJLDWTD[sKey], sYZID.Replace("BJ", "")));
|
||
}
|
||
SQL.Add(string.Format(" else XLXSBJDYZZ0_YZZ{0} end) ", sYZID.Replace("BJ", "")));
|
||
}
|
||
|
||
else if (sBJU003JSDW.Equals("Km"))
|
||
{
|
||
SQL.Add(string.Format(" else 0.0 end)<> (case when tmp.XLXSBJDMX_JLDW in('M','米') then RoundFix(1000*XLXSBJDYZZ0_YZZ{0},6) ", sYZID.Replace("BJ", "")));
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" when tmp.XLXSBJDMX_JLDW='{0}' then RoundFix(XLXSBJDYZZ0_YZZ{2}*{1},6) ", sKey, dicLenJLDWTD[sKey], sYZID.Replace("BJ", "")));
|
||
}
|
||
SQL.Add(string.Format(" else XLXSBJDYZZ0_YZZ{0} end) ", sYZID.Replace("BJ", "")));
|
||
}
|
||
SQL.Add(" and BJD.sumYZZ > 0 ");
|
||
#endregion
|
||
}
|
||
else if (sTJYS.Equals("H"))
|
||
{
|
||
#region
|
||
if (useFor.Equals("exists"))
|
||
{
|
||
SQL.Add(" select top 1 tmp.XLXSBJDMX_XH");
|
||
}
|
||
else if (useFor.Equals("selectBJDXH"))
|
||
{//研发自测:王威 2025/09/12 01:21:15
|
||
SQL.Add(" select tmp.XLXSBJDMX_XH as BJDXH,tmp.XLXSBJDMX_JLDW AS XLXSBJDMX_JLDW,");
|
||
SQL.Add(" (case when isnull(a.YZID,' ')<>' ' then RoundFix(isnull(a.YZZ,0)/BJD.sumBJSL,6) when isnull(b.YZID,' ')<>' ' then RoundFix(isnull(b.YZZ,0)/BJD.sumBJSL,6) ");
|
||
SQL.Add(" when isnull(c.YZID,' ')<>' ' then RoundFix(isnull(c.YZZ,0)/BJD.sumBJSL,6) when isnull(d.YZID,' ')<>' ' then RoundFix(isnull(d.YZZ,0)/BJD.sumBJSL,6) ");
|
||
SQL.Add(" else 0.0 end) as YZZ");
|
||
}
|
||
else if (useFor.Equals("selectBJCP"))
|
||
{
|
||
SQL.Add(" select distinct upper(tmp.XLXSBJDMX_XLXHID) as XLXHID,tmp.XLXSBJDMX_XLGGID as XLGGID,tmp.XLXSBJDMX_XLBZID as XLBZID,isnull(tmp.XLXSBJDMX_DYDJID,' ') as DYDJID,XLXSBJDMX_XLYSID,");
|
||
for (int k = 1; k <= 20; k++)
|
||
{
|
||
if (sYZID.Equals("BJ" + k.ToString().PadLeft(2, '0')))
|
||
{
|
||
SQL.Add(" (case when isnull(a.YZID,' ')<>' ' then RoundFix(isnull(a.YZZ,0)/BJD.sumBJSL,6) when isnull(b.YZID,' ')<>' ' then RoundFix(isnull(b.YZZ,0)/BJD.sumBJSL,6) ");
|
||
SQL.Add(" when isnull(c.YZID,' ')<>' ' then RoundFix(isnull(c.YZZ,0)/BJD.sumBJSL,6) when isnull(d.YZID,' ')<>' ' then RoundFix(isnull(d.YZZ,0)/BJD.sumBJSL,6) ");
|
||
SQL.Add(string.Format(" else 0.0 end) as YZZ{0},", k.ToString().PadLeft(2, '0')));
|
||
}
|
||
else
|
||
SQL.Add(string.Format(" 0.0 as YZZ{0},", k.ToString().PadLeft(2, '0')));
|
||
}
|
||
SQL.Add(string.Format(" BJD.sumBJSL,'{0}' as JLDW,'{1}' as YZID ", sBJU003, sYZID));
|
||
}
|
||
SQL.Add(" from XLXSBJDMX tmp");
|
||
SQL.Add(" left join XLXSBJDYZZ0 on XLXSBJDYZZ0_BJDID=tmp.XLXSBJDMX_BJDID and XLXSBJDYZZ0_XH=tmp.XLXSBJDMX_XH");
|
||
SQL.Add(" left join ");
|
||
SQL.Add(" (select XLXSBJDMX_BJDID as BJDID,upper(XLXSBJDMX_XLXHID)as XLXHID,XLXSBJDMX_XLGGID as XLGGID,XLXSBJDMX_XLBZID as XLBZID,isnull(XLXSBJDMX_DYDJID,' ') as DYDJID,XLXSBJDMX_XLYSID as XLYSID,");
|
||
if (sBJU003JSDW.Equals("M"))
|
||
{
|
||
SQL.Add(" sum(case when XLXSBJDMX_JLDW in('Km','千米')then 1000*XLXSBJDMX_BJSL ");
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" when XLXSBJDMX_JLDW='{0}' then {1}*XLXSBJDMX_BJSL ", sKey, dicLenJLDWTD[sKey]));
|
||
}
|
||
SQL.Add(" else XLXSBJDMX_BJSL end)as sumBJSL");
|
||
}
|
||
|
||
else if (sBJU003JSDW.Equals("Km"))
|
||
{
|
||
SQL.Add(" sum(case when XLXSBJDMX_JLDW in('M','米')then 0.001*XLXSBJDMX_BJSL ");
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" when XLXSBJDMX_JLDW='{0}' then 0.001*{1}*XLXSBJDMX_BJSL ", sKey, dicLenJLDWTD[sKey]));
|
||
}
|
||
SQL.Add(" else XLXSBJDMX_BJSL end)as sumBJSL");
|
||
}
|
||
//取报价单明细因子值之和
|
||
SQL.Add(string.Format(" ,sum(XLXSBJDYZZ0_YZZ{0}) as sumYZZ", sYZID.Replace("BJ", "")));
|
||
SQL.Add(" from XLXSBJDMX");
|
||
//关联报价单明细因子值
|
||
SQL.Add(" left join XLXSBJDYZZ0 on XLXSBJDYZZ0_BJDID= XLXSBJDMX_BJDID and XLXSBJDYZZ0_XH= XLXSBJDMX_XH ");
|
||
SQL.Add(string.Format(" where XLXSBJDMX_BJDID='{0}'", sBJDID));
|
||
SQL.Add(" and (XLXSBJDMX_JLDW in('Km','M','千米','米')");
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" or XLXSBJDMX_JLDW='{0}'", sKey));
|
||
}
|
||
SQL.Add(" )");
|
||
SQL.Add(" and XLXSBJDMX_BJSL<>0");//因素H需要限制报价数量不为0
|
||
SQL.Add(" group by XLXSBJDMX_BJDID,upper(XLXSBJDMX_XLXHID),XLXSBJDMX_XLGGID,XLXSBJDMX_XLBZID,isnull(XLXSBJDMX_DYDJID,' '),XLXSBJDMX_XLYSID");
|
||
SQL.Add(" )BJD on BJD.XLXHID=upper(tmp.XLXSBJDMX_XLXHID) and BJD.XLGGID=tmp.XLXSBJDMX_XLGGID and BJD.XLBZID=tmp.XLXSBJDMX_XLBZID and BJD.DYDJID=isnull(tmp.XLXSBJDMX_DYDJID,' ') and BJD.XLYSID=tmp.XLXSBJDMX_XLYSID ");
|
||
SQL.Add(" left join XLXHB on XLXHB_XLXHID=tmp.XLXSBJDMX_XLXHID ");
|
||
SQL.Add(" left join XLGGB on XLGGB_XLGGID = replace(tmp.XLXSBJDMX_XLGGID , '*','×') and XLGGB_XLGGJDGZ = isnull(XLXHB_XLGGJDGZ,'0') ");
|
||
SQL.Add(" left join XLDTJMZHB on XLDTJMZHB_DTJMZHID=XLGGB_DTJMZHID ");
|
||
SQL.Add(" left join");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSBJDYZZH_XLXHID,XLXSBJDYZZH_DYDJID,XLXSBJDYZZH_XLYSID,XLXSBJDYZZH_YZID as YZID,XLXSBJDYZZH_YZZ as YZZ,");
|
||
SQL.Add(" XLXSBJDYZZH_ZXJMXX,XLXSBJDYZZH_ZXJMSX,XLXSBJDYZZH_BJSLXX,XLXSBJDYZZH_BJSLSX");
|
||
SQL.Add(" from XLXSBJDYZZH");
|
||
SQL.Add(" where exists(select 1 from XLXSTZYZ where XLXSTZYZ_MXBH='BJD' and XLXSTZYZ_TJYS='H' and XLXSTZYZ_JGBID=XLXSBJDYZZH_JGBID and XLXSTZYZ_YZID=XLXSBJDYZZH_YZID ) ");
|
||
SQL.Add(string.Format(" and exists(select 1 from XLXSBJFLYZ where XLXSBJFLYZ_BJFLID='{0}' and XLXSBJFLYZ_YZID=XLXSBJDYZZH_YZID)", sBJFLID));
|
||
SQL.Add(string.Format(" and XLXSBJDYZZH_YZID='{0}'", sYZID));
|
||
SQL.Add(" and isnull(XLXSBJDYZZH_DYDJID,' ') <> ' ' and isnull(XLXSBJDYZZH_XLYSID,' ') <> ' ' ");
|
||
SQL.Add(" ) a on a.XLXSBJDYZZH_XLXHID = XLXHID and a.XLXSBJDYZZH_DYDJID = DYDJID and a.XLXSBJDYZZH_XLYSID = XLYSID ");
|
||
SQL.Add(" and a.XLXSBJDYZZH_ZXJMXX<=isnull(XLDTJMZHB_DTJM1,0) and ((a.XLXSBJDYZZH_ZXJMSX<>0 and a.XLXSBJDYZZH_ZXJMSX>=isnull(XLDTJMZHB_DTJM1,0)) or a.XLXSBJDYZZH_ZXJMSX=0) ");
|
||
SQL.Add(" and a.XLXSBJDYZZH_BJSLXX<=BJD.sumBJSL");
|
||
SQL.Add(" and ((a.XLXSBJDYZZH_BJSLSX<>0 and a.XLXSBJDYZZH_BJSLSX>BJD.sumBJSL) or a.XLXSBJDYZZH_BJSLSX=0) ");
|
||
SQL.Add(" left join");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSBJDYZZH_XLXHID,XLXSBJDYZZH_DYDJID,XLXSBJDYZZH_XLYSID,XLXSBJDYZZH_YZID as YZID,XLXSBJDYZZH_YZZ as YZZ,");
|
||
SQL.Add(" XLXSBJDYZZH_ZXJMXX,XLXSBJDYZZH_ZXJMSX,XLXSBJDYZZH_BJSLXX,XLXSBJDYZZH_BJSLSX");
|
||
SQL.Add(" from XLXSBJDYZZH");
|
||
SQL.Add(" where exists(select 1 from XLXSTZYZ where XLXSTZYZ_MXBH='BJD' and XLXSTZYZ_TJYS='H' and XLXSTZYZ_JGBID=XLXSBJDYZZH_JGBID and XLXSTZYZ_YZID=XLXSBJDYZZH_YZID ) ");
|
||
SQL.Add(string.Format(" and exists(select 1 from XLXSBJFLYZ where XLXSBJFLYZ_BJFLID='{0}' and XLXSBJFLYZ_YZID=XLXSBJDYZZH_YZID)", sBJFLID));
|
||
SQL.Add(string.Format(" and XLXSBJDYZZH_YZID='{0}'", sYZID));
|
||
SQL.Add(" and isnull(XLXSBJDYZZH_DYDJID,' ') = ' ' and isnull(XLXSBJDYZZH_XLYSID,' ') <> ' ' ");
|
||
SQL.Add(" ) b on b.XLXSBJDYZZH_XLXHID = XLXHID and b.XLXSBJDYZZH_XLYSID = XLYSID ");
|
||
SQL.Add(" and b.XLXSBJDYZZH_ZXJMXX<=isnull(XLDTJMZHB_DTJM1,0) and ((b.XLXSBJDYZZH_ZXJMSX<>0 and b.XLXSBJDYZZH_ZXJMSX>=isnull(XLDTJMZHB_DTJM1,0)) or b.XLXSBJDYZZH_ZXJMSX=0) ");
|
||
SQL.Add(" and b.XLXSBJDYZZH_BJSLXX<=BJD.sumBJSL");
|
||
SQL.Add(" and ((b.XLXSBJDYZZH_BJSLSX<>0 and b.XLXSBJDYZZH_BJSLSX>BJD.sumBJSL) or b.XLXSBJDYZZH_BJSLSX=0) ");
|
||
SQL.Add(" left join");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSBJDYZZH_XLXHID,XLXSBJDYZZH_DYDJID,XLXSBJDYZZH_XLYSID,XLXSBJDYZZH_YZID as YZID,XLXSBJDYZZH_YZZ as YZZ,");
|
||
SQL.Add(" XLXSBJDYZZH_ZXJMXX,XLXSBJDYZZH_ZXJMSX,XLXSBJDYZZH_BJSLXX,XLXSBJDYZZH_BJSLSX");
|
||
SQL.Add(" from XLXSBJDYZZH");
|
||
SQL.Add(" where exists(select 1 from XLXSTZYZ where XLXSTZYZ_MXBH='BJD' and XLXSTZYZ_TJYS='H' and XLXSTZYZ_JGBID=XLXSBJDYZZH_JGBID and XLXSTZYZ_YZID=XLXSBJDYZZH_YZID ) ");
|
||
SQL.Add(string.Format(" and exists(select 1 from XLXSBJFLYZ where XLXSBJFLYZ_BJFLID='{0}' and XLXSBJFLYZ_YZID=XLXSBJDYZZH_YZID)", sBJFLID));
|
||
SQL.Add(string.Format(" and XLXSBJDYZZH_YZID='{0}'", sYZID));
|
||
SQL.Add(" and isnull(XLXSBJDYZZH_DYDJID,' ') <> ' ' and isnull(XLXSBJDYZZH_XLYSID,' ') = ' ' ");
|
||
SQL.Add(" ) c on c.XLXSBJDYZZH_XLXHID = XLXHID and c.XLXSBJDYZZH_DYDJID = DYDJID ");
|
||
SQL.Add(" and c.XLXSBJDYZZH_ZXJMXX<=isnull(XLDTJMZHB_DTJM1,0) and ((c.XLXSBJDYZZH_ZXJMSX<>0 and c.XLXSBJDYZZH_ZXJMSX>=isnull(XLDTJMZHB_DTJM1,0)) or c.XLXSBJDYZZH_ZXJMSX=0) ");
|
||
SQL.Add(" and c.XLXSBJDYZZH_BJSLXX<=BJD.sumBJSL");
|
||
SQL.Add(" and ((c.XLXSBJDYZZH_BJSLSX<>0 and c.XLXSBJDYZZH_BJSLSX>BJD.sumBJSL) or c.XLXSBJDYZZH_BJSLSX=0) ");
|
||
SQL.Add(" left join");
|
||
SQL.Add(" (");
|
||
SQL.Add(" select XLXSBJDYZZH_XLXHID,XLXSBJDYZZH_DYDJID,XLXSBJDYZZH_XLYSID,XLXSBJDYZZH_YZID as YZID,XLXSBJDYZZH_YZZ as YZZ,");
|
||
SQL.Add(" XLXSBJDYZZH_ZXJMXX,XLXSBJDYZZH_ZXJMSX,XLXSBJDYZZH_BJSLXX,XLXSBJDYZZH_BJSLSX");
|
||
SQL.Add(" from XLXSBJDYZZH");
|
||
SQL.Add(" where exists(select 1 from XLXSTZYZ where XLXSTZYZ_MXBH='BJD' and XLXSTZYZ_TJYS='H' and XLXSTZYZ_JGBID=XLXSBJDYZZH_JGBID and XLXSTZYZ_YZID=XLXSBJDYZZH_YZID ) ");
|
||
SQL.Add(string.Format(" and exists(select 1 from XLXSBJFLYZ where XLXSBJFLYZ_BJFLID='{0}' and XLXSBJFLYZ_YZID=XLXSBJDYZZH_YZID)", sBJFLID));
|
||
SQL.Add(string.Format(" and XLXSBJDYZZH_YZID='{0}'", sYZID));
|
||
SQL.Add(" and isnull(XLXSBJDYZZH_DYDJID,' ') = ' ' and isnull(XLXSBJDYZZH_XLYSID,' ') = ' ' ");
|
||
SQL.Add(" ) d on d.XLXSBJDYZZH_XLXHID = XLXHID ");
|
||
SQL.Add(" and d.XLXSBJDYZZH_ZXJMXX<=isnull(XLDTJMZHB_DTJM1,0) and ((d.XLXSBJDYZZH_ZXJMSX<>0 and d.XLXSBJDYZZH_ZXJMSX>=isnull(XLDTJMZHB_DTJM1,0)) or d.XLXSBJDYZZH_ZXJMSX=0) ");
|
||
SQL.Add(" and d.XLXSBJDYZZH_BJSLXX<=BJD.sumBJSL");
|
||
SQL.Add(" and ((d.XLXSBJDYZZH_BJSLSX<>0 and d.XLXSBJDYZZH_BJSLSX>BJD.sumBJSL) or d.XLXSBJDYZZH_BJSLSX=0) ");
|
||
SQL.Add(string.Format(" where tmp.XLXSBJDMX_BJDID='{0}'", sBJDID));
|
||
SQL.Add(" and (case when isnull(a.YZID,' ')<>' ' then RoundFix(isnull(a.YZZ,0)/sumBJSL,6) when isnull(b.YZID,' ')<>' ' then RoundFix(isnull(b.YZZ,0)/sumBJSL,6) ");
|
||
SQL.Add(" when isnull(d.YZID,' ')<>' ' then RoundFix(isnull(d.YZZ,0)/sumBJSL,6) when isnull(d.YZID,' ')<>' ' then RoundFix(isnull(d.YZZ,0)/sumBJSL,6) ");
|
||
if (sBJU003JSDW.Equals("M"))
|
||
{
|
||
SQL.Add(string.Format(" else 0.0 end)<> (case when tmp.XLXSBJDMX_JLDW in('Km','千米') then RoundFix(0.001*XLXSBJDYZZ0_YZZ{0},6) ", sYZID.Replace("BJ", "")));
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" when tmp.XLXSBJDMX_JLDW='{0}' then RoundFix(XLXSBJDYZZ0_YZZ{2}/{1},6) ", sKey, dicLenJLDWTD[sKey], sYZID.Replace("BJ", "")));
|
||
}
|
||
SQL.Add(string.Format(" else XLXSBJDYZZ0_YZZ{0} end) ", sYZID.Replace("BJ", "")));
|
||
}
|
||
|
||
else if (sBJU003JSDW.Equals("Km"))
|
||
{
|
||
SQL.Add(string.Format(" else 0.0 end)<> (case when tmp.XLXSBJDMX_JLDW in('M','米') then RoundFix(1000*XLXSBJDYZZ0_YZZ{0},6) ", sYZID.Replace("BJ", "")));
|
||
foreach (string sKey in dicLenJLDWTD.Keys)
|
||
{
|
||
SQL.Add(string.Format(" when tmp.XLXSBJDMX_JLDW='{0}' then RoundFix(XLXSBJDYZZ0_YZZ{2}*{1},6) ", sKey, dicLenJLDWTD[sKey], sYZID.Replace("BJ", "")));
|
||
}
|
||
SQL.Add(string.Format(" else XLXSBJDYZZ0_YZZ{0} end) ", sYZID.Replace("BJ", "")));
|
||
}
|
||
SQL.Add(" and BJD.sumYZZ > 0 ");
|
||
#endregion
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 回填报价单
|
||
//确认
|
||
protected void btnQR_Click(object sender, EventArgs e)
|
||
{
|
||
string sMsg = "";
|
||
for (int i = 0; i < ContentGrid.Columns.Count; i++)
|
||
{
|
||
if (ContentGrid.ColumnsEx[i].DataField.StartsWith("XLXSBJDYZZ0_YZZ"))
|
||
sMsg = sMsg + ContentGrid.Columns[i].HeaderText.Trim() + "、";
|
||
}
|
||
sMsg = sMsg.TrimStart('、').TrimEnd('、');
|
||
sMsg = "将按小计行【" + sMsg + "】数值回填对应明细行,是否继续?";
|
||
|
||
Confirm.Register("IsQD", sMsg);
|
||
Confirm.ShowBtnText = TConfirm.cBtnText.Yes_No;
|
||
if (Confirm.GetValue("IsQD").Trim().Equals(""))
|
||
{
|
||
Confirm.Ask("IsQD");
|
||
return;
|
||
}
|
||
else if (Confirm.GetValue("IsQD").Trim().Equals("N"))
|
||
{
|
||
//表示进行了提示并选择了取消,直接返回或其他处理
|
||
Confirm.Clear();
|
||
return;
|
||
}
|
||
else if (Confirm.GetValue("IsQD").Trim().Equals("Y"))
|
||
{
|
||
//表示进行了提示并选择了确认
|
||
Confirm.Clear();
|
||
|
||
}
|
||
|
||
string sBJDID = PageParam.GetRTrimString("BJDID");
|
||
string sBJFLID = PageParam.GetRTrimString("BJFLID");
|
||
|
||
string sYZIDList2 = PageParam.GetRTrimString("sYZIDList2");
|
||
string sYZIDList3 = PageParam.GetRTrimString("sYZIDList3");
|
||
string sYZIDList6 = PageParam.GetRTrimString("sYZIDList6");
|
||
string sYZIDListE = PageParam.GetRTrimString("sYZIDListE");
|
||
string sYZIDListF = PageParam.GetRTrimString("sYZIDListF");
|
||
string sYZIDListG = PageParam.GetRTrimString("sYZIDListG");
|
||
string sYZIDListH = PageParam.GetRTrimString("sYZIDListH");
|
||
|
||
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
||
TSQL SQL = new TSQL(dberp);
|
||
|
||
try
|
||
{
|
||
dberp.BeginTrans();
|
||
XLBJDCalcUtils.CalcWithBJSLYZZCheck(dberp, SQL, sBJDID, sYZIDList2, sYZIDList3, sYZIDList6, sYZIDListE, sYZIDListF, sYZIDListG, sYZIDListH, GetOption("BJU002"), GetOption("BJU003"), true);
|
||
|
||
dberp.CommitTrans();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
dberp.RollbackTrans();
|
||
ShowMessage(ex.Message);
|
||
return;
|
||
}
|
||
|
||
DialogOperationScript dos = new DialogOperationScript(this);
|
||
dos.CloseSelf();
|
||
dos.Execute();
|
||
}
|
||
|
||
protected void btnQX_Click(object sender, EventArgs e)
|
||
{
|
||
DialogOperationScript dos = new DialogOperationScript(this);
|
||
dos.CloseSelf();
|
||
dos.Execute();
|
||
}
|
||
#endregion
|
||
}
|
||
}
|