347 lines
15 KiB
C#
347 lines
15 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.Data;
|
|
using GThinking.N_MODEL.Page;
|
|
using GThinking.N_MISPRO;
|
|
using GThinking.N_CONTROL;
|
|
using GThinking.N_MISPRO.Utility;
|
|
using System.Text;
|
|
using System.Collections.Generic;
|
|
|
|
namespace GThinking.N_XLXSBJ
|
|
{
|
|
public partial class XLBJD_CLZLList : SingleGridBase
|
|
{
|
|
XLBJD_CLZL entity = new XLBJD_CLZL();
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
this.UMID = 100860057;
|
|
this.UMName = "报价产品材料重量详情";
|
|
this.CurMaster = Master;
|
|
this.ModuleGV = ContentGrid;
|
|
this.CurEntity = entity;
|
|
this.PageHeight = 600;
|
|
this.PageWidth = 750;
|
|
//base.DataKeyNames = new string[] { "XLXSBJCL_BJCLID" };
|
|
Master.EnableNewBtn = false;
|
|
Master.EnableCopyBtn = false;
|
|
Master.EnableViewBtn = false;
|
|
Master.EnableEditBtn = false;
|
|
Master.EnableDeleteBtn = false;
|
|
Master.EnableQueryBtn = false;
|
|
|
|
base.InitPage();
|
|
|
|
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 ReportRecordSetAdd()
|
|
{
|
|
DataSet ds = GetSQLDataSet();
|
|
AddUserReportDataSet("CX_XLXSBJDMX_CLZL", ds);
|
|
base.ReportRecordSetAdd();
|
|
|
|
}
|
|
|
|
protected override void ReportDataSetAdd()
|
|
{
|
|
DataSet ds = GetSQLDataSet();
|
|
for (int i = 0; i < ContentGrid.Columns.Count; i++)
|
|
{
|
|
string sDataField = ((System.Web.UI.WebControls.BoundField)(ContentGrid.Columns[i])).DataField.ToString().Trim();
|
|
string sHeaderText = ContentGrid.Columns[i].HeaderText;
|
|
AddUserReportField("CX_XLXSBJDMX_CLZL", sDataField, sHeaderText, "S");
|
|
}
|
|
|
|
base.ReportDataSetAdd();
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region 自定义方法
|
|
|
|
private DataSet GetSQLDataSet()
|
|
{
|
|
|
|
string sBJDID = PageParam.GetRTrimString("BJDID");
|
|
|
|
string sJGCZBID = "";
|
|
string sJGCZBBBID = "";
|
|
string sXLXHID = "";
|
|
string sXLGGID = "";
|
|
string sXLBZID = "";
|
|
string sDYDJID = "";
|
|
|
|
//此存储伪编码
|
|
string sStr1 = "";
|
|
//此存储正确编码
|
|
string sStr2 = "";
|
|
|
|
//存储正确报价材料信息<BJCL000000Z>
|
|
List<string> lst = new List<string>();
|
|
lst.Clear();
|
|
|
|
//该字典存储伪编码,<BJCL000000Z,BJCLXX_ID_01>
|
|
Dictionary<string, string> dicJGCZBID = new Dictionary<string, string>();
|
|
dicJGCZBID.Clear();
|
|
//先筛选出报价材料
|
|
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
|
TSQL SQL = new TSQL(dberp);
|
|
//此查询需要与栏目SQL 保持一致
|
|
SQL.Clear();
|
|
SQL.Add(" SELECT XLJGCZBLM_BJCLID,XLXSBJCL_BJCLMC,XLJGCZBLM_HLMLX FROM XLXSBJDMX");
|
|
SQL.Add(" LEFT JOIN XLXSCLQD ON XLXSCLQD_XLXHID = XLXSBJDMX_XLXHID AND XLXSCLQD_XLGGID = XLXSBJDMX_XLGGID AND XLXSCLQD_XLBZID = XLXSBJDMX_XLBZID AND isnull(XLXSCLQD_DYDJID,' ') = isnull(XLXSBJDMX_DYDJID,' ') ");
|
|
SQL.Add(" LEFT JOIN XLJGCZBLM ON XLJGCZBLM_JGCZBID = XLXSCLQD_JGCZBID and XLXSCLQD_JGCZBBBID = XLJGCZBLM_JGCZBBBID ");
|
|
SQL.Add(" LEFT JOIN XLXSBJCL ON XLXSBJCL_BJCLID = XLJGCZBLM_BJCLID ");
|
|
SQL.Add(" WHERE XLXSBJDMX_BJDID = :pBJDID and isnull(XLJGCZBLM_CLQDL,' ')<>' ' and XLXSCLQD_WPID = 'ZZZZ'");
|
|
SQL.Add(" order by XLJGCZBLM_BJCLID,XLJGCZBLM_HLMLX desc ");
|
|
SQL.ParamByName("pBJDID").Value = sBJDID;
|
|
DataSet dsBJCLID = dberp.OpenDataSet(SQL);
|
|
if (dsBJCLID != null && dsBJCLID.Tables.Count > 0 && dsBJCLID.Tables[0].Rows.Count > 0)
|
|
{
|
|
for (int i = 0; i < dsBJCLID.Tables[0].Rows.Count; i++)
|
|
{
|
|
//固定列后增补数据
|
|
sStr1 = dsBJCLID.Tables[0].Rows[i]["XLJGCZBLM_BJCLID"].ToString().Trim() + dsBJCLID.Tables[0].Rows[i]["XLJGCZBLM_HLMLX"].ToString().Trim();
|
|
sStr2 = sStr1;
|
|
if (!lst.Contains(sStr1))
|
|
{
|
|
lst.Add(sStr1);
|
|
sStr1 = XLBJDUtils.GetPseCode(i);
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
if (!dicJGCZBID.ContainsKey(sStr2))
|
|
{
|
|
dicJGCZBID.Add(sStr2, sStr1);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//构建用量dsQry
|
|
|
|
string sHSXS = "";
|
|
string sBJU003 = GetOption(100860014, "BJU003");
|
|
Dictionary<string, double> dicLenJLDWTD = XLBJDUtils.GetLenJLDWTD();
|
|
if (sBJU003.Equals("Km") || sBJU003.Equals("千米"))
|
|
{
|
|
sHSXS = @" ( case when XLXSBJDMX_JLDW in ('Km', '千米') then 1
|
|
when XLXSBJDMX_JLDW in ('M', '米') then 0.001 ";
|
|
foreach (string sKey in dicLenJLDWTD.Keys)
|
|
{
|
|
sHSXS += string.Format(" when XLXSBJDMX_JLDW='{0}' then 0.001*{1} ", sKey, dicLenJLDWTD[sKey]);
|
|
}
|
|
sHSXS += " else 0 end ) ";
|
|
}
|
|
else
|
|
{
|
|
sHSXS = @" ( case when XLXSBJDMX_JLDW in ('Km', '千米') then 1000
|
|
when XLXSBJDMX_JLDW in ('M', '米') then 1 ";
|
|
foreach (string sKey in dicLenJLDWTD.Keys)
|
|
{
|
|
sHSXS += string.Format(" when XLXSBJDMX_JLDW='{0}' then {1} ", sKey, dicLenJLDWTD[sKey]);
|
|
}
|
|
sHSXS += " else 0 end ) ";
|
|
}
|
|
|
|
SQL.Clear();
|
|
SQL.Add("select XLXSBJDMX_BJDID,XLXSBJDMX_XH,XLXSBJDMX_XSSX,XLXSBJDMX_XLXHID,XLXSBJDMX_XLGGID,rtrim(XLXSBJDMX_XLBZID)||'|'||rtrim(XLBZ_XLBZLXMC) as XLBZ,XLXSBJDMX_XLBZID,XLXSBJDMX_DYDJID,");
|
|
SQL.Add(" XLXSBJDMX_BJCP,XLXSBJDMX_JLDW,XLXSBJDMX_BJSL,XLXSCLQD_JGCZBID as JGCZBID,XLXSCLQD_JGCZBBBID as JGCZBBBID,");
|
|
foreach (KeyValuePair<string, string> kvp in dicJGCZBID)
|
|
{
|
|
SQL.Add(" 0.0 as " + kvp.Value + ", ");
|
|
}
|
|
SQL.Add(" 0.0 as px0, ");
|
|
for (int j = 1; j <= 80; j++)
|
|
{
|
|
//显示的时候显示最后乘法后的结果
|
|
SQL.Add( sHSXS + " * XLXSBJDMX_BJSL*XLXSCLQD_SL" + j.ToString().PadLeft(2, '0') + " *XLXSCLQD_CLJGBL" + j.ToString().PadLeft(2, '0') + "*(1+XLXSCLQD_SHL" + j.ToString().PadLeft(2, '0') + "/100) as XLXSCLQD_SL" + j.ToString().PadLeft(2, '0') + ", ");
|
|
}
|
|
SQL.Add(" 0.0 as px1 ");
|
|
SQL.Add(" from XLXSBJDMX");
|
|
SQL.Add(" left join XLBZ on XLBZ_XLBZID = XLXSBJDMX_XLBZID ");
|
|
SQL.Add(" left join XLXSCLQD on XLXSCLQD_XLXHID=XLXSBJDMX_XLXHID and XLXSCLQD_XLGGID=XLXSBJDMX_XLGGID");
|
|
SQL.Add(" and XLXSCLQD_XLBZID=XLXSBJDMX_XLBZID and isnull(XLXSCLQD_DYDJID,' ') = isnull(XLXSBJDMX_DYDJID,' ')");
|
|
//与报价单明细界面保持一致-不加限制条件包含:正在流转数据,结束数据,没有材料清单数据
|
|
SQL.Add(" WHERE XLXSBJDMX_BJDID = :pBJDID ");
|
|
SQL.Add(" order by XLXSBJDMX_XSSX");
|
|
SQL.ParamByName("pBJDID").Value = sBJDID;
|
|
DataSet dsQry = dberp.OpenDataSet(SQL);
|
|
if (dsQry != null && dsQry.Tables.Count > 0 && dsQry.Tables[0].Rows.Count > 0)
|
|
{
|
|
for (int i = 0; i < dsQry.Tables[0].Rows.Count; i++)
|
|
{
|
|
sJGCZBID = dsQry.Tables[0].Rows[i]["JGCZBID"].ToString().Trim();
|
|
sJGCZBBBID = dsQry.Tables[0].Rows[i]["JGCZBBBID"].ToString().Trim();
|
|
|
|
sXLXHID = dsQry.Tables[0].Rows[i]["XLXSBJDMX_XLXHID"].ToString().Trim();
|
|
sXLGGID = dsQry.Tables[0].Rows[i]["XLXSBJDMX_XLGGID"].ToString().Trim();
|
|
sXLBZID = dsQry.Tables[0].Rows[i]["XLXSBJDMX_XLBZID"].ToString().Trim();
|
|
sDYDJID = dsQry.Tables[0].Rows[i]["XLXSBJDMX_DYDJID"].ToString().Trim();
|
|
|
|
InsData(dberp, SQL, i, sJGCZBID, sJGCZBBBID, dsQry, dicJGCZBID);
|
|
}
|
|
}
|
|
return dsQry;
|
|
}
|
|
|
|
//给对应的报价材料赋值用量
|
|
private void InsData(TDatabase dberp, TSQL SQL, int i, string sJGCZBID, string sJGCZBBBID, DataSet dsQry, Dictionary<string, string> dic)
|
|
{
|
|
if (!sJGCZBID.ToString().Trim().Equals(""))
|
|
{
|
|
SQL.Clear();
|
|
SQL.Add(" select XLJGCZBLM_JGCZBID,XLJGCZBLM_JGCZBBBID,XLJGCZBLM_BJCLID,XLJGCZBLM_HLMLX,XLJGCZBLM_CLQDL from XLJGCZBLM ");
|
|
SQL.Add(" where XLJGCZBLM_JGCZBID = :pJGCZBID and XLJGCZBLM_JGCZBBBID =:pJGCZBBBID and XLJGCZBLM_ZDLMLX ='4' ");
|
|
SQL.ParamByName("pJGCZBID").Value = sJGCZBID;
|
|
SQL.ParamByName("pJGCZBBBID").Value = sJGCZBBBID;
|
|
DataSet ds = dberp.OpenDataSet(SQL);
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
for (int k = 0; k < ds.Tables[0].Rows.Count; k++)
|
|
{
|
|
string ss1 = ds.Tables[0].Rows[k]["XLJGCZBLM_BJCLID"].ToString().Trim() + ds.Tables[0].Rows[k]["XLJGCZBLM_HLMLX"].ToString().Trim();
|
|
|
|
if (dic.ContainsKey(ss1))
|
|
{
|
|
string ss2 = dic[ss1];
|
|
dsQry.Tables[0].Rows[i][ss2]
|
|
= CMISproConvert.StrToFloat(dsQry.Tables[0].Rows[i][ss2].ToString().Trim()) +
|
|
CMISproConvert.StrToFloat(dsQry.Tables[0].Rows[i]["XLXSCLQD_SL" + ds.Tables[0].Rows[k]["XLJGCZBLM_CLQDL"].ToString().Trim().Replace("第", "").Replace("列", "")].ToString().Trim());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//拼接报价材料栏目头,此处只需要把用到的都组合即可。
|
|
private void InitGrid()
|
|
{
|
|
string sStr = "";
|
|
//存储报价材料信息
|
|
List<string> lst = new List<string>();
|
|
lst.Clear();
|
|
|
|
//该字典存储伪编码
|
|
Dictionary<string, string> dicJGCZBID = new Dictionary<string, string>();
|
|
dicJGCZBID.Clear();
|
|
string sBJDID = PageParam.GetRTrimString("BJDID");
|
|
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
|
TSQL SQL = new TSQL(dberp);
|
|
SQL.Clear();
|
|
SQL.Add(" SELECT XLJGCZBLM_BJCLID,XLXSBJCL_BJCLMC,XLJGCZBLM_HLMLX FROM XLXSBJDMX");
|
|
SQL.Add(" LEFT JOIN XLXSCLQD ON XLXSCLQD_XLXHID = XLXSBJDMX_XLXHID AND XLXSCLQD_XLGGID = XLXSBJDMX_XLGGID AND XLXSCLQD_XLBZID = XLXSBJDMX_XLBZID AND isnull(XLXSCLQD_DYDJID,' ') = isnull(XLXSBJDMX_DYDJID,' ') ");
|
|
SQL.Add(" LEFT JOIN XLJGCZBLM ON XLJGCZBLM_JGCZBID = XLXSCLQD_JGCZBID and XLXSCLQD_JGCZBBBID = XLJGCZBLM_JGCZBBBID ");
|
|
SQL.Add(" LEFT JOIN XLXSBJCL ON XLXSBJCL_BJCLID = XLJGCZBLM_BJCLID ");
|
|
SQL.Add(" WHERE XLXSBJDMX_BJDID = :pBJDID and isnull(XLJGCZBLM_CLQDL,' ')<>' ' and XLXSCLQD_WPID = 'ZZZZ'");
|
|
SQL.Add(" order by XLJGCZBLM_BJCLID,XLJGCZBLM_HLMLX desc ");
|
|
SQL.ParamByName("pBJDID").Value = sBJDID;
|
|
DataSet dsBJCLID = dberp.OpenDataSet(SQL);
|
|
if (dsBJCLID != null && dsBJCLID.Tables.Count > 0 && dsBJCLID.Tables[0].Rows.Count > 0)
|
|
{
|
|
for (int i = 0; i < dsBJCLID.Tables[0].Rows.Count; i++)
|
|
{
|
|
//固定列后增补数据
|
|
sStr = dsBJCLID.Tables[0].Rows[i]["XLJGCZBLM_BJCLID"].ToString().Trim() + dsBJCLID.Tables[0].Rows[i]["XLJGCZBLM_HLMLX"].ToString().Trim();
|
|
if (!lst.Contains(sStr))
|
|
{
|
|
lst.Add(sStr);
|
|
sStr = XLBJDUtils.GetPseCode(i);
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
if (!dicJGCZBID.ContainsKey(sStr))
|
|
{
|
|
dicJGCZBID.Add(sStr, dsBJCLID.Tables[0].Rows[i]["XLXSBJCL_BJCLMC"].ToString().Trim());
|
|
}
|
|
}
|
|
}
|
|
foreach (KeyValuePair<string, string> kvp in dicJGCZBID)
|
|
{
|
|
AddColumn(kvp.Key, kvp.Value + "(Kg)",
|
|
6, 120, true, false, "");
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <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)
|
|
{
|
|
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.Add(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(0, ColumnEx);
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|