2026821
This commit is contained in:
@@ -0,0 +1,297 @@
|
||||
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_MISPRO.Data;
|
||||
using GThinking.N_MODEL.Page;
|
||||
using GThinking.N_MISPRO.Utility;
|
||||
using GThinking.N_CONTROL;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace GThinking.N_XLXSBJ
|
||||
{
|
||||
public partial class XLBJD_ZLGZCLList : SingleGridBase
|
||||
{
|
||||
XLBJD_ZLGZCL entity = new XLBJD_ZLGZCL();
|
||||
//报价材料栏目
|
||||
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 = 100860000;
|
||||
this.UMName = "线缆销售报价单";
|
||||
this.CurMaster = Master;
|
||||
this.ModuleGV = ContentGrid;
|
||||
this.CurEntity = entity;
|
||||
this.PageHeight = 600;
|
||||
this.PageWidth = 750;
|
||||
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_GZCL", 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_GZCL", sDataField, sHeaderText, "S");
|
||||
}
|
||||
|
||||
base.ReportDataSetAdd();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 自定义函数
|
||||
|
||||
private DataSet GetSQLDataSet()
|
||||
{
|
||||
string sBJDID = PageParam.GetRTrimString("BJDID");
|
||||
string sBJU003 = GetOption(102579008, "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(" rtrim(XLXSBJDMX_XLYSID)||'|'||rtrim(XLYSB_XLYSMC) as XLYS,");
|
||||
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 XLYSB on XLYSB_XLYSID = XLXSBJDMX_XLYSID ");
|
||||
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);
|
||||
//此处根据不重复的列进行构造。
|
||||
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 = GetJLDCLZL_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;
|
||||
}
|
||||
|
||||
public static double GetJLDCLZL_SL(string sSource, string sBJU003)
|
||||
{
|
||||
double dHSBL = 1;
|
||||
string sSourceJSDW = XLBJDUtils.GetsJSDW(sSource, sBJU003);
|
||||
string sBJU003JSDW = XLBJDUtils.GetsJSDW(sBJU003, sBJU003);
|
||||
Dictionary<string, double> dicLenJLDWTD = XLBJDUtils.GetLenJLDWTD();
|
||||
if (sBJU003JSDW.ToUpper().Equals("KM"))
|
||||
{
|
||||
if (sSourceJSDW.ToUpper().Equals("KM"))
|
||||
dHSBL = 1;
|
||||
else if (sSourceJSDW.ToUpper().Equals("M"))
|
||||
dHSBL = 0.001;
|
||||
else if (dicLenJLDWTD.ContainsKey(sSourceJSDW))
|
||||
dHSBL = 0.001 * dicLenJLDWTD[sSourceJSDW];
|
||||
else
|
||||
dHSBL = 0;
|
||||
|
||||
}
|
||||
else if (sBJU003JSDW.ToUpper().Equals("M"))
|
||||
{
|
||||
if (sSourceJSDW.ToUpper().Equals("KM"))
|
||||
dHSBL = 1000;
|
||||
else if (sSourceJSDW.ToUpper().Equals("M"))
|
||||
dHSBL = 1;
|
||||
else if (dicLenJLDWTD.ContainsKey(sSourceJSDW))
|
||||
dHSBL = dicLenJLDWTD[sSourceJSDW];
|
||||
else
|
||||
dHSBL = 0;
|
||||
}
|
||||
return dHSBL;
|
||||
}
|
||||
|
||||
//拼接报价材料栏目头,此处只需要把用到的都组合即可。
|
||||
private void InitGrid()
|
||||
{
|
||||
dicBJCLCloums_Index.Clear();
|
||||
dicBJCLCloums_Iname.Clear();
|
||||
string sBJDID = PageParam.GetRTrimString("BJDID");
|
||||
string sZLGZCLS = PageParam.GetRTrimString("ZLGZCLS");
|
||||
|
||||
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 where 1=1 ");
|
||||
tSql.Add(" and " + CMISproDataBase.GetWhereEqual("XLXSBJCL_BJCLID", sZLGZCLS));
|
||||
tSql.Add(" 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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user