284 lines
11 KiB
C#
284 lines
11 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_MODEL.Page;
|
|
using System.Collections.Generic;
|
|
using GThinking.N_MISPRO.Data;
|
|
using GThinking.N_CONTROL;
|
|
using GThinking.N_MISPRO.Utility;
|
|
|
|
namespace GThinking.N_XLXSBJ
|
|
{
|
|
public partial class XLBJD_JGECLZLList : SingleGridBase
|
|
{
|
|
XLBJD_JGECLZL entity = new XLBJD_JGECLZL();
|
|
|
|
//报价材料栏目
|
|
Dictionary<string, string> dicBJCLCloums_Index = new Dictionary<string, string>();
|
|
Dictionary<string, string> dicBJCLCloums_Iname = new Dictionary<string, string>();
|
|
|
|
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();
|
|
if (entity.ShowRecordCount)
|
|
{
|
|
GetLMTJColumn(ContentGrid);
|
|
}
|
|
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 sBJU003 = GetOption(100860014, "BJU003");
|
|
string sJLDW = "";
|
|
double fHSXS = 1;
|
|
string sBJSL = "";
|
|
string sBJCLID = "";
|
|
|
|
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
|
TSQL SQL = new TSQL(dberp);
|
|
DataSet dsQry = new DataSet();
|
|
|
|
SQL.Clear();
|
|
SQL.Add("select XLXSBJDMX_XSSX, XLXSBJDMX_XH, XLXSBJDMX_BJDID, ");
|
|
SQL.Add(" XLXSBJDMX_XLXHID,XLXSBJDMX_XLGGID,rtrim(XLXSBJDMX_XLBZID)|| '|'|| rtrim(XLBZ_XLBZLXMC) as XLBZ,XLXSBJDMX_DYDJID, ");
|
|
SQL.Add(" XLXSBJDMX_BJCP,XLXSBJDMX_JLDW,XLXSBJDMX_BJSL ");
|
|
//此处需要注意保存的dicBJCLCloums_Index不一定能囊括所有列,所有直接查询80列
|
|
for (int i = 1; i <= 80; i++)
|
|
{
|
|
SQL.Add(string.Format(" ,XLXSBJDCLCB_CLID{0},XLXSBJDCLCB_CLSL{0} ", i.ToString().PadLeft(2, '0').Trim()));
|
|
}
|
|
SQL.Add(" ,1 as px from XLXSBJDCLCB ");
|
|
SQL.Add(" left join XLXSBJDMX on XLXSBJDMX_BJDID = XLXSBJDCLCB_BJDID and XLXSBJDMX_XH = XLXSBJDCLCB_XH ");
|
|
SQL.Add(" left join XLBZ on XLBZ_XLBZID = XLXSBJDMX_XLBZID ");
|
|
SQL.Add(" where XLXSBJDCLCB_BJDID = :pBJDID ");
|
|
SQL.Add(" order by XLXSBJDMX_XSSX ");
|
|
SQL.ParamByName("pBJDID").Value = sBJDID;
|
|
dsQry = dberp.OpenDataSet(SQL);
|
|
//此处根据不重复的列进行构造,如果列表栏目数大于8表示已经添加过栏目,只需填入数据集
|
|
if (ContentGrid.ColumnsEx.Count > 8)
|
|
{
|
|
foreach (string sKey in dicBJCLCloums_Index.Keys)
|
|
{
|
|
dsQry.Tables[0].Columns.Add(dicBJCLCloums_Index[sKey]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
foreach (string sKey in dicBJCLCloums_Index.Keys)
|
|
{
|
|
dsQry.Tables[0].Columns.Add(dicBJCLCloums_Index[sKey]);
|
|
AddColumn(dicBJCLCloums_Index[sKey], dicBJCLCloums_Iname[sKey] + "(Kg)", 6, 120, true, false, "");
|
|
}
|
|
}
|
|
for (int i = 1; i <= dsQry.Tables[0].Rows.Count; i++)
|
|
{
|
|
sJLDW = dsQry.Tables[0].Rows[i - 1]["XLXSBJDMX_JLDW"].ToString().Trim();
|
|
sBJSL = dsQry.Tables[0].Rows[i - 1]["XLXSBJDMX_BJSL"].ToString().Trim();
|
|
fHSXS = XLBJDUtils.GetJLDWHSBL_SL(sJLDW, sBJU003) * CMISproConvert.StrToFloat(sBJSL);
|
|
|
|
for (int k = 1; k <= 80; k++)
|
|
{
|
|
sBJCLID = dsQry.Tables[0].Rows[i - 1][String.Format("XLXSBJDCLCB_CLID{0}", k.ToString().Trim().PadLeft(2, '0'))].ToString().Trim().Split('|').GetValue(0).ToString().Trim();
|
|
if (dicBJCLCloums_Index.ContainsKey(sBJCLID))
|
|
{
|
|
dsQry.Tables[0].Rows[i - 1][dicBJCLCloums_Index[sBJCLID]] =
|
|
CMISproConvert.StrToFloat(dsQry.Tables[0].Rows[i - 1][dicBJCLCloums_Index[sBJCLID]].ToString().Trim()) + CMISproConvert.StrToFloat(dsQry.Tables[0].Rows[i - 1][String.Format("XLXSBJDCLCB_CLSL{0}", k.ToString().Trim().PadLeft(2, '0'))].ToString().Trim()) * fHSXS;
|
|
}
|
|
}
|
|
}
|
|
return dsQry;
|
|
}
|
|
|
|
//拼接报价材料栏目头,此处只需要把用到的都组合即可。
|
|
private void InitGrid()
|
|
{
|
|
dicBJCLCloums_Index.Clear();
|
|
dicBJCLCloums_Iname.Clear();
|
|
string sBJDID = PageParam.GetRTrimString("BJDID");
|
|
|
|
Dictionary<string, string> dicBJCL = new Dictionary<string, string>();
|
|
dicBJCL.Clear();
|
|
Dictionary<string, string> dicBJCLCloumsOrg = new Dictionary<string, string>();
|
|
dicBJCLCloumsOrg.Clear();
|
|
|
|
string sCLID = "";
|
|
string sBJCLID = "";
|
|
|
|
TDatabase dberp = TContextDatabases.GetDatabase("DBERP");
|
|
TSQL tSql = new TSQL(dberp);
|
|
tSql.Clear();
|
|
tSql.Add(" select distinct XLXSBJCL_BJCLID ,XLXSBJCL_BJCLMC from XLXSBJCL order by XLXSBJCL_BJCLID ");
|
|
DataSet dsBJCLXX = dberp.OpenDataSet(tSql);
|
|
if(dsBJCLXX.Tables[0].Rows.Count>0)
|
|
{
|
|
foreach (DataRow trow in dsBJCLXX.Tables[0].Rows)
|
|
{
|
|
dicBJCL.Add(trow[0].ToString().Trim(), trow[1].ToString().Trim());
|
|
}
|
|
}
|
|
tSql.Clear();
|
|
tSql.Add("select XLXSBJDCLCB_BJDID, XLXSBJDCLCB_XH");
|
|
for (int i = 1; i <= 80; i++)
|
|
{
|
|
tSql.Add(string.Format(",XLXSBJDCLCB_CLID{0}", i.ToString().PadLeft(2, '0').Trim()));
|
|
}
|
|
tSql.Add(" from XLXSBJDCLCB ");
|
|
tSql.Add(" where XLXSBJDCLCB_BJDID=:pBJDID ");
|
|
tSql.ParamByName("pBJDID").Value = sBJDID;
|
|
DataSet dsBJCL = dberp.OpenDataSet(tSql);
|
|
if (dsBJCL.Tables[0].Rows.Count > 0)
|
|
{
|
|
foreach (DataRow trow in dsBJCL.Tables[0].Rows)
|
|
{
|
|
for (int i = 1; i <= 80; i++)
|
|
{
|
|
sCLID = trow[string.Format("XLXSBJDCLCB_CLID{0}", i.ToString().PadLeft(2, '0').Trim())].ToString().Trim();
|
|
if (sCLID.Equals(""))
|
|
{
|
|
//避免出现跳空列的情况
|
|
continue;
|
|
}
|
|
if (sCLID.Contains("|"))
|
|
{
|
|
sBJCLID = sCLID.Split('|')[0];
|
|
}
|
|
else
|
|
{
|
|
sBJCLID = sCLID;
|
|
}
|
|
if (!dicBJCLCloumsOrg.ContainsKey(sBJCLID))
|
|
{
|
|
dicBJCLCloumsOrg.Add(sBJCLID, sBJCLID);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
int index = 0;
|
|
foreach (string sKey in dicBJCL.Keys)
|
|
{
|
|
if (dicBJCLCloumsOrg.ContainsKey(sKey))
|
|
{
|
|
string sStr = XLBJDUtils.GetPseCode(index);
|
|
dicBJCLCloums_Index.Add(sKey, sStr);
|
|
dicBJCLCloums_Iname.Add(sKey, dicBJCL[sKey]);
|
|
}
|
|
index++;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// <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
|
|
}
|
|
}
|