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_PUBLIC; using GThinking.N_MODEL.Dialog; using GThinking.N_CONTROL; namespace GThinking.N_XLXSBJ { public partial class TZYZBJ6Info : SingleCardBase { TZYZBJ6 entity = new TZYZBJ6(); string sBJSLDW = ""; protected void Page_Load(object sender, EventArgs e) { this.UMID = 100860030; this.UMName = "按报价数量区间调价米数/报价数量调报价"; this.CurMaster = Master; this.CurEntity = entity; this.PageHeight = 400; this.PageWidth = 700; if (XLBJDUtils.GetDefaultBJU003(GetOption(100860000, "BJU003")).Equals("M")) { lblBJSL.Text = "<= 报价数量(M) <"; sBJSLDW = "M"; } else { lblBJSL.Text = "<= 报价数量(Km) <"; sBJSLDW = "Km"; } SetTJYZLable(); if (!this.IsPostBack) { InitControls(); } base.InitPage(); } #region 模板事件继承 protected override void ReportDataSetAdd() { TDatabase db = TContextDatabases.GetDatabase("DBERP"); TSQL sql = new TSQL(db); sql.Add("select XLXSTZYZ_YZID, XLXSTZYZ_YZMC from XLXSTZYZ where XLXSTZYZ_MXBH='BJD' and XLXSTZYZ_TJYS='6' order by XLXSTZYZ_XSXH,XLXSTZYZ_YZID "); DataSet ds = db.OpenDataSet(sql); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string sYZID = "TZYZ_" + ds.Tables[0].Rows[i]["XLXSTZYZ_YZID"].ToString().Trim(); string sYZMC = ds.Tables[0].Rows[i]["XLXSTZYZ_YZMC"].ToString().Trim(); AddUserReportField("XLXSBJDYZZ6", sYZID, sYZMC, "N"); } base.ReportDataSetAdd(); } protected override void ReportRecordSetAdd() { TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); TSQL sSQL = new TSQL(dberp); TSQL SQL = new TSQL(dberp); SQL.Clear(); SQL.Add("select XLXSTZYZ_YZID, XLXSTZYZ_YZMC "); SQL.Add(" from XLXSTZYZ"); SQL.Add(" where XLXSTZYZ_MXBH = 'BJD' and XLXSTZYZ_TJYS='6' order by XLXSTZYZ_XSXH,XLXSTZYZ_YZID "); DataSet ds = dberp.OpenDataSet(SQL); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { sSQL.Add(string.Format(",sum(decode(XLXSBJDYZZ6_YZID, '{0}', XLXSBJDYZZ6_YZZ, 0)) as TZYZ_{0}", ds.Tables[0].Rows[i][0].ToString().Trim())); } sSQL.Text = "select 1" + sSQL.Text + " from XLXSBJDYZZ6 where XLXSBJDYZZ6_JGBID='" + txtJGBID.Value.Trim() + "' and XLXSBJDYZZ6_BJSLSX= " + txtBJSLSX.Value + " and XLXSBJDYZZ6_BJSLXX= " + txtBJSLXX.Value + ""; AddUserReportSQL("XLXSBJDYZZ6", sSQL); base.ReportRecordSetAdd(); } protected override void SetControlState() { base.SetControlState(); txtWHR.Enabled = false; datWHSJ.Enabled = false; for (int i = 1; i <= 20; i++) { Label lblYZDW = (Label)Master.ContentFormControl.FindControl("lblYZDW" + i); lblYZDW.Text = "(" + sBJSLDW + ")/报价数量(" + sBJSLDW + ")"; } # region 给调价因子控件设只读性 if (ControlState == TControlState.ctsInsert || ControlState == TControlState.ctsCopy || ControlState == TControlState.ctsEdit) { for (int i = 1; i <= 20; i++) { gtNumTextBox txtTJYZ = (gtNumTextBox)Master.ContentFormControl.FindControl("txt" + "TJYZ" + i); txtTJYZ.Enabled = false; } string[] sTJYZList = PageParam.GetRTrimString("TJYZList").Split(','); for (int i = 0; i < sTJYZList.Length; i++) { for (int j = 1; j <= 20; j++) { string sTZYZID = "BJ" + j.ToString().PadLeft(2, '0') + "|"; gtNumTextBox txtTJYZ = (gtNumTextBox)Master.ContentFormControl.FindControl("txt" + "TJYZ" + j.ToString().Trim()); if (sTJYZList[i].StartsWith(sTZYZID)) { txtTJYZ.Enabled = true; } } } } #endregion } protected override void LoadRecord() { if (!IsPostBack) { entity.Param.Add("XLXSBJDYZZ6_JGBID", PageParam.GetRTrimString("XLXSBJDYZZ6_JGBID")); entity.Param.Add("XLXSBJDYZZ6_BJSLSX", PageParam.GetRTrimString("XLXSBJDYZZ6_BJSLSX")); entity.Param.Add("XLXSBJDYZZ6_BJSLXX", PageParam.GetRTrimString("XLXSBJDYZZ6_BJSLXX")); entity.Param.Add("XLXSBJDYZZ6_YZID", PageParam.GetRTrimString("XLXSBJDYZZ6_YZID")); } else { entity.Param.Add("XLXSBJDYZZ6_JGBID", txtJGBID.Value.Trim()); entity.Param.Add("XLXSBJDYZZ6_BJSLSX", txtOLD_BJSLSX.Value.Trim()); entity.Param.Add("XLXSBJDYZZ6_BJSLXX", txtOLD_BJSLXX.Value.Trim()); entity.Param.Add("XLXSBJDYZZ6_YZID", txtYZID.Value.Trim()); } base.LoadRecord(); txtOLD_BJSLXX.Value = txtBJSLXX.Value.ToString().Trim(); txtOLD_BJSLSX.Value = txtBJSLSX.Value.ToString().Trim(); # region 给调价因子控件赋值 TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); TSQL sql = new TSQL(dberp); sql.Clear(); sql.Add(string.Format(" select XLXSBJDYZZ{0}_YZID, XLXSBJDYZZ{0}_YZZ from XLXSBJDYZZ{0} ", 6)); sql.Add(string.Format(" where XLXSBJDYZZ{0}_JGBID=:pJGBID and XLXSBJDYZZ{0}_BJSLSX=:pBJSLSX and XLXSBJDYZZ{0}_BJSLXX=:pBJSLXX order by XLXSBJDYZZ{0}_YZID", 6)); sql.ParamByName("pJGBID").Value = txtJGBID.Value.Trim(); sql.ParamByName("pBJSLSX").Value = txtBJSLSX.Value; sql.ParamByName("pBJSLXX").Value = txtBJSLXX.Value; DataSet ds = dberp.OpenDataSet(sql); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string sYZID = ds.Tables[0].Rows[i][0].ToString().Trim(); double dYZZ = CMISproConvert.StrToFloat(ds.Tables[0].Rows[i][1].ToString().Trim()); if (PageParam.GetRTrimString("TJYZList").Contains(sYZID + "|")) { for (int j = 1; j <= 20; j++) { string sTZYZID = "BJ" + j.ToString().PadLeft(2, '0'); gtNumTextBox txtTJYZ = (gtNumTextBox)Master.ContentFormControl.FindControl("txt" + "TJYZ" + j.ToString().Trim()); if (sYZID.Equals(sTZYZID)) txtTJYZ.Value = dYZZ; } } } #endregion } protected override void OnNewRecorder() { base.OnNewRecorder(); txtJGBID.Value = PageParam.GetRTrimString("XLXSBJDYZZ6_JGBID"); txtWHR.Text = tSession.UserName; txtWHRID.Value = tSession.UserId; datWHSJ.Text = CMISproConvert.ConvertTime(System.DateTime.Now); } protected override void OnCopyRecorder() { base.OnCopyRecorder(); txtJGBID.Value = PageParam.GetRTrimString("XLXSBJDYZZ6_JGBID"); txtWHR.Text = tSession.UserName; txtWHRID.Value = tSession.UserId; datWHSJ.Text = CMISproConvert.ConvertTime(System.DateTime.Now); } protected override bool DataLogicValid() { if (!base.DataLogicValid()) return false; if (txtBJSLXX.Value < 0) { ShowMessage("报价数量下限--不允许为负数!"); return false; } if (txtBJSLSX.Value < 0) { ShowMessage("报价数量上限--不允许为负数!"); return false; } if (txtBJSLSX.Value != 0) { if (txtBJSLXX.Value > txtBJSLSX.Value) { ShowMessage("报价数量下限不允许超过报价数量上限!"); return false; } } TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); TSQL sql = new TSQL(dberp); string[] sTJYZList = PageParam.GetRTrimString("TJYZList").Split(','); for (int i = 0; i < sTJYZList.Length; i++) { if (ControlState == TControlState.ctsInsert || ControlState == TControlState.ctsCopy) { sql.Clear(); sql.Add("select XLXSBJDYZZ6_BJSLXX,XLXSBJDYZZ6_BJSLSX "); sql.Add("from XLXSBJDYZZ6 "); sql.Add("where XLXSBJDYZZ6_JGBID=:pJGBID and XLXSBJDYZZ6_YZID=:pYZID "); sql.Add(" and ((XLXSBJDYZZ6_BJSLXX>=:pBJSLXX "); if (txtBJSLSX.Value != 0) { sql.Add(" and XLXSBJDYZZ6_BJSLXX<:pBJSLSX "); } sql.Add(" ) "); sql.Add(" or ("); if (txtBJSLSX.Value != 0) { sql.Add(" XLXSBJDYZZ6_BJSLSX>0 and XLXSBJDYZZ6_BJSLSX>:pBJSLXX and XLXSBJDYZZ6_BJSLSX<=:pBJSLSX "); } else { sql.Add(" (XLXSBJDYZZ6_BJSLSX>0 and XLXSBJDYZZ6_BJSLSX>:pBJSLXX) or (XLXSBJDYZZ6_BJSLSX=0) "); } sql.Add(" ) "); sql.Add(" or (XLXSBJDYZZ6_BJSLXX<:pBJSLXX and (XLXSBJDYZZ6_BJSLSX=0 or XLXSBJDYZZ6_BJSLSX>:pBJSLSX))"); sql.Add(" ) "); sql.ParamByName("pJGBID").Value = txtJGBID.Value.Trim(); sql.ParamByName("pYZID").Value = sTJYZList[i].Split('|')[0]; sql.ParamByName("pBJSLXX").Value = txtBJSLXX.Value; if (txtBJSLSX.Value != 0) { sql.ParamByName("pBJSLSX").Value = txtBJSLSX.Value; } DataSet ds = dberp.OpenDataSet(sql); if (ds.Tables[0].Rows.Count > 0) { string sBJSLQJ = ""; if (CMISproConvert.StrToFloat(ds.Tables[0].Rows[0]["XLXSBJDYZZ6_BJSLSX"].ToString()) != 0) sBJSLQJ = ds.Tables[0].Rows[0]["XLXSBJDYZZ6_BJSLXX"].ToString().Trim() + "~" + ds.Tables[0].Rows[0]["XLXSBJDYZZ6_BJSLSX"].ToString().Trim() + sBJSLDW; else sBJSLQJ = ds.Tables[0].Rows[0]["XLXSBJDYZZ6_BJSLXX"].ToString().Trim() + "~" + "--" + sBJSLDW; ShowMessage(string.Format("因子{1}与已有报价数量区间【{0}】的记录有交集,不允许保存!", sBJSLQJ, sTJYZList[i].Replace("(X)", ""))); return false; } } else { sql.Clear(); sql.Add("select XLXSBJDYZZ6_BJSLXX,XLXSBJDYZZ6_BJSLSX "); sql.Add("from XLXSBJDYZZ6 "); sql.Add("where XLXSBJDYZZ6_JGBID=:pJGBID and XLXSBJDYZZ6_YZID=:pYZID "); sql.Add(" and (XLXSBJDYZZ6_BJSLXX<>:pOLDBJSLXX or XLXSBJDYZZ6_BJSLSX<>:pOLDBJSLSX) "); sql.Add(" and ((XLXSBJDYZZ6_BJSLXX>=:pBJSLXX "); if (txtBJSLSX.Value != 0) { sql.Add(" and XLXSBJDYZZ6_BJSLXX<:pBJSLSX "); } sql.Add(" ) "); sql.Add(" or ("); if (txtBJSLSX.Value != 0) { sql.Add(" XLXSBJDYZZ6_BJSLSX>0 and XLXSBJDYZZ6_BJSLSX>:pBJSLXX and XLXSBJDYZZ6_BJSLSX<=:pBJSLSX "); } else { sql.Add(" (XLXSBJDYZZ6_BJSLSX>0 and XLXSBJDYZZ6_BJSLSX>:pBJSLXX) or (XLXSBJDYZZ6_BJSLSX=0) "); } sql.Add(" ) "); sql.Add(" or (XLXSBJDYZZ6_BJSLXX<:pBJSLXX and (XLXSBJDYZZ6_BJSLSX=0 or XLXSBJDYZZ6_BJSLSX>:pBJSLSX))"); sql.Add(" ) "); sql.ParamByName("pJGBID").Value = txtJGBID.Value.Trim(); sql.ParamByName("pYZID").Value = sTJYZList[i].Split('|')[0]; sql.ParamByName("pOLDBJSLXX").Value = txtOLD_BJSLXX.Value; sql.ParamByName("pOLDBJSLSX").Value = txtOLD_BJSLSX.Value; sql.ParamByName("pBJSLXX").Value = txtBJSLXX.Value; if (txtBJSLSX.Value != 0) { sql.ParamByName("pBJSLSX").Value = txtBJSLSX.Value; } DataSet ds = dberp.OpenDataSet(sql); if (ds.Tables[0].Rows.Count > 0) { string sBJSLQJ = ""; if (CMISproConvert.StrToFloat(ds.Tables[0].Rows[0]["XLXSBJDYZZ6_BJSLSX"].ToString()) != 0) sBJSLQJ = ds.Tables[0].Rows[0]["XLXSBJDYZZ6_BJSLXX"].ToString().Trim() + "~" + ds.Tables[0].Rows[0]["XLXSBJDYZZ6_BJSLSX"].ToString().Trim() + sBJSLDW; else sBJSLQJ = ds.Tables[0].Rows[0]["XLXSBJDYZZ6_BJSLXX"].ToString().Trim() + "~" + "--" + sBJSLDW; ShowMessage(string.Format("因子{1}与已有报价数量区间【{0}】的记录有交集,不允许保存!", sBJSLQJ, sTJYZList[i].Replace("(X)", ""))); return false; } } } return true; } protected override bool Master_BeforeSaveAction(object sender, EventArgs e) { if (!base.Master_BeforeSaveAction(sender, e)) return false; txtWHR.Text = tSession.UserName; txtWHRID.Value = tSession.UserId; datWHSJ.Text = CMISproConvert.ConvertTime(System.DateTime.Now); return true; } protected override bool Master_AfterSaveAction(object sender, EventArgs e) { txtOLD_BJSLXX.Value = txtBJSLXX.Value.ToString().Trim(); txtOLD_BJSLSX.Value = txtBJSLSX.Value.ToString().Trim(); string sJGBID = txtJGBID.Value.Trim(); string sBJSLXX = txtBJSLXX.Value.ToString().Trim(); string sBJSLSX = txtBJSLSX.Value.ToString().Trim(); # region 将调价因子控件值更新至数据库中 TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); TSQL sql = new TSQL(dberp); sql.Clear(); dberp.ExecSQL(string.Format("delete from XLXSBJDYZZ{0} where XLXSBJDYZZ{0}_JGBID='{1}' and XLXSBJDYZZ{0}_BJSLSX={2} and XLXSBJDYZZ{0}_BJSLXX={3} ", 6, sJGBID, txtBJSLSX.Value, txtBJSLXX.Value)); string[] sTJYZList = PageParam.GetRTrimString("TJYZList").Split(','); DateTime tNow = DateTime.Now; for (int i = 0; i < sTJYZList.Length; i++) { sql.Clear(); sql.Add(string.Format("insert into XLXSBJDYZZ{0}(XLXSBJDYZZ{0}_JGBID, XLXSBJDYZZ{0}_BJSLSX, XLXSBJDYZZ{0}_BJSLXX, XLXSBJDYZZ{0}_YZID, XLXSBJDYZZ{0}_YZZ, XLXSBJDYZZ{0}_WHR, XLXSBJDYZZ{0}_WHRID, XLXSBJDYZZ{0}_WHSJ)", 6)); sql.Add(string.Format(" values(:pJGBID,:pBJSLSX, :pBJSLXX, :pYZID,:pYZZ,:pWHR,:pWHRID,:pWHSJ)")); sql.ParamByName("pJGBID").Value = sJGBID; sql.ParamByName("pBJSLSX").Value = sBJSLSX; sql.ParamByName("pBJSLXX").Value = sBJSLXX; sql.ParamByName("pWHR").Value = tSession.UserName; sql.ParamByName("pWHRID").Value = tSession.UserId; sql.ParamByName("pWHSJ").Value = tNow; for (int j = 1; j <= 20; j++) { string sTZYZID = "BJ" + j.ToString().PadLeft(2, '0') + "|"; gtNumTextBox txtTJYZ = (gtNumTextBox)Master.ContentFormControl.FindControl("txt" + "TJYZ" + j.ToString().Trim()); if (sTJYZList[i].StartsWith(sTZYZID)) { sql.ParamByName("pYZID").Value = sTZYZID.TrimEnd('|'); sql.ParamByName("pYZZ").Value = txtTJYZ.Value; dberp.ExecSQL(sql); } } } #endregion return base.Master_AfterSaveAction(sender, e); } #endregion #region 自定义函数 private void InitControls() { txtYZID.Value = PageParam.GetRTrimString("FirstYZID"); } private void SetTJYZLable() { string[] sTJYZList = PageParam.GetRTrimString("TJYZList").Split(','); for (int i = 0; i < sTJYZList.Length; i++) { for (int j = 1; j <= 20; j++) { string sTZYZID = "BJ" + j.ToString().PadLeft(2, '0') + "|"; gtNumTextBox txtTJYZ = (gtNumTextBox)Master.ContentFormControl.FindControl("txt" + "TJYZ" + j.ToString().Trim()); gtLabel lblTJYZ = (gtLabel)Master.ContentFormControl.FindControl("lbl" + "TJYZ" + j.ToString().Trim()); if (sTJYZList[i].StartsWith(sTZYZID)) { string s = sTJYZList[i].Replace(sTZYZID, "").Replace("(X)", "") + ":"; lblTJYZ.Text = s; if (sTJYZList[i].EndsWith("(%)") || sTJYZList[i].EndsWith("(元)")) { txtTJYZ.DecimalPlaces = 2; } else if (sTJYZList[i].EndsWith("(X)")) { txtTJYZ.DecimalPlaces = 4; } } } } } #endregion } }