using System; using System.Collections.Generic; 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_WORKFLOW; using GThinking.N_MODEL.Dialog; using GThinking.N_PUBLIC; using GThinking.N_MISPRO.Utility; using GThinking.N_CONTROL; using System.IO; using System.Data.OleDb; using System.Data.Common; using GThinking.N_MISPROAS; namespace GThinking.N_XLXSBJ { public partial class XLXSBJCL_HQFDSZInfo : SingleCardBase { XLBJD_DREntity entity = new XLBJD_DREntity(); #region Page类事件继承 protected void Page_Load(object sender, EventArgs e) { this.UMID = 100860012; this.UMName = "线缆销售报价材料"; base.CurMaster = Master; this.CurEntity = entity; this.PageHeight = 400; this.PageWidth = 500; Master.EnableAttachBtn = false; Master.EnableCancelBtn = false; Master.EnableCopyBtn = false; Master.EnableDeleteBtn = false; Master.EnableEditBtn = false; Master.EnableInsertBtn = false; Master.EnablePrintBtn = false; Master.EnableRefreshBtn = false; Master.EnableSaveBtn = false; txtHSJGS.DecimalPlaces = XLBJDUtils.BJCLPriceDecimal; txtHSJGZ.DecimalPlaces = XLBJDUtils.BJCLPriceDecimal; txtCLJGS.DecimalPlaces = XLBJDUtils.BJCLPriceDecimal; txtCLJGZ.DecimalPlaces = XLBJDUtils.BJCLPriceDecimal; base.InitPage(); } #endregion #region 模板事件继承 protected override void SetControlState() { base.SetControlState(); txtSL.Enabled = false; } protected override void OnNewRecorder() { base.OnNewRecorder(); TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); TSQL SQL = new TSQL(dberp); SQL.Clear(); SQL.Add(" select XLXSBJCL_ZZSL from XLXSBJCL "); SQL.Add(" where XLXSBJCL_BJCLID=:pBJCLID"); SQL.ParamByName("pBJCLID").Value = PageParam.GetRTrimString("BJCLID"); DataSet ds = dberp.OpenDataSet(SQL); if (ds.Tables[0].Rows.Count > 0) { txtSL.Value = CMISproConvert.StrToFloat(ds.Tables[0].Rows[0][0].ToString().Trim()); } txtFDS.Value = 1; } #endregion #region 控件事件 protected void btnQD_Click(object sender, EventArgs e) { if (txtFDS.Value <= 0) { ShowMessage("分段数不允许为0或负数!"); return; } else if (txtFDS.Value > 250) { ShowMessage("分段数不允许超过250!"); return; } if (txtHSJGS.Value <= 0) { ShowMessage("含税价格始不允许为0或负数!"); return; } if (txtHSJGZ.Value <= 0) { ShowMessage("含税价格终不允许为0或负数!"); return; } if (txtCLJGZ.Value < txtCLJGS.Value) { ShowMessage("无税价格终不允许小于无税价格始!"); return; } if (txtHSJGZ.Value < txtHSJGS.Value) { ShowMessage("含税价格终不允许小于含税价格始!"); return; } Confirm.Register("IsQD", "原材料行情分段将被删除,是否重新分段?"); 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 sBJCLID = PageParam.GetRTrimString("BJCLID"); TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); TSQL sSQL = new TSQL(dberp); sSQL.Clear(); sSQL.Add(" delete from XLXSCLHQFD where XLXSCLHQFD_BJCLID=:XLXSCLHQFD_BJCLID "); sSQL.ParamByName("XLXSCLHQFD_BJCLID").Value = sBJCLID; dberp.ExecSQL(sSQL); try { sSQL.Clear(); sSQL.Add(" insert into XLXSCLHQFD( "); sSQL.Add(" XLXSCLHQFD_BJCLID,XLXSCLHQFD_CLHQDH, "); sSQL.Add(" XLXSCLHQFD_HSJGS,XLXSCLHQFD_HSJGZ,XLXSCLHQFD_CLJGS,XLXSCLHQFD_CLJGZ, "); sSQL.Add(" XLXSCLHQFD_WHRID,XLXSCLHQFD_WHR,XLXSCLHQFD_WHSJ "); sSQL.Add(" ) "); sSQL.Add(" select :pBJCLID as BJCLID, "); sSQL.Add(" case "); sSQL.Add(" when XH/36= 0 then '0' when XH/36= 1 then '1' when XH/36= 2 then '2' when XH/36= 3 then '3' when XH/36= 4 then '4' "); sSQL.Add(" when XH/36= 5 then '5' when XH/36= 6 then '6' when XH/36= 7 then '7' when XH/36= 8 then '8' when XH/36= 9 then '9' "); sSQL.Add(" when XH/36=10 then 'A' when XH/36=11 then 'B' when XH/36=12 then 'C' when XH/36=13 then 'D' when XH/36=14 then 'E' "); sSQL.Add(" when XH/36=15 then 'F' when XH/36=16 then 'G' when XH/36=17 then 'H' when XH/36=18 then 'I' when XH/36=19 then 'J' "); sSQL.Add(" when XH/36=20 then 'K' when XH/36=21 then 'L' when XH/36=22 then 'M' when XH/36=23 then 'N' when XH/36=24 then 'O' "); sSQL.Add(" when XH/36=25 then 'P' when XH/36=26 then 'Q' when XH/36=27 then 'R' when XH/36=28 then 'S' when XH/36=29 then 'T' "); sSQL.Add(" when XH/36=30 then 'U' when XH/36=31 then 'V' when XH/36=32 then 'W' when XH/36=33 then 'X' when XH/36=34 then 'Y' "); sSQL.Add(" when XH/36=35 then 'Z' "); sSQL.Add(" else null "); sSQL.Add(" end + "); sSQL.Add(" case "); sSQL.Add(" when MOD(XH,36)= 0 then '0' when MOD(XH,36)= 1 then '1' when MOD(XH,36)= 2 then '2' when MOD(XH,36)= 3 then '3' when MOD(XH,36)= 4 then '4' "); sSQL.Add(" when MOD(XH,36)= 5 then '5' when MOD(XH,36)= 6 then '6' when MOD(XH,36)= 7 then '7' when MOD(XH,36)= 8 then '8' when MOD(XH,36)= 9 then '9' "); sSQL.Add(" when MOD(XH,36)=10 then 'A' when MOD(XH,36)=11 then 'B' when MOD(XH,36)=12 then 'C' when MOD(XH,36)=13 then 'D' when MOD(XH,36)=14 then 'E' "); sSQL.Add(" when MOD(XH,36)=15 then 'F' when MOD(XH,36)=16 then 'G' when MOD(XH,36)=17 then 'H' when MOD(XH,36)=18 then 'I' when MOD(XH,36)=19 then 'J' "); sSQL.Add(" when MOD(XH,36)=20 then 'K' when MOD(XH,36)=21 then 'L' when MOD(XH,36)=22 then 'M' when MOD(XH,36)=23 then 'N' when MOD(XH,36)=24 then 'O' "); sSQL.Add(" when MOD(XH,36)=25 then 'P' when MOD(XH,36)=26 then 'Q' when MOD(XH,36)=27 then 'R' when MOD(XH,36)=28 then 'S' when MOD(XH,36)=29 then 'T' "); sSQL.Add(" when MOD(XH,36)=30 then 'U' when MOD(XH,36)=31 then 'V' when MOD(XH,36)=32 then 'W' when MOD(XH,36)=33 then 'X' when MOD(XH,36)=34 then 'Y' "); sSQL.Add(" when MOD(XH,36)=35 then 'Z' "); sSQL.Add(" else null "); sSQL.Add(" end as CLHQDH, "); string sModifiedNum = XLBJDUtils.ModifiedNum.ToString().Trim(); string sDecimal = XLBJDUtils.BJCLPriceDecimal.ToString().Trim(); sSQL.Add(" case "); sSQL.Add(" when XH=1 then RoundFix(:pHSJGS+RoundFix((XH-1)*(:pHSJGZ-:pHSJGS)/:pFDS," + sDecimal + ")," + sDecimal + ") "); sSQL.Add(" else RoundFix(:pHSJGS+RoundFix((XH-1)*(:pHSJGZ-:pHSJGS)/:pFDS," + sDecimal + ")+" + sModifiedNum + "," + sDecimal + ") "); sSQL.Add(" end as HSJGS, "); sSQL.Add(" RoundFix(:pHSJGS+RoundFix((XH)*(:pHSJGZ-:pHSJGS)/:pFDS," + sDecimal + ")," + sDecimal + ") as HSJGZ, "); sSQL.Add(" case "); sSQL.Add(" when XH=1 then RoundFix(:pCLJGS+RoundFix((XH-1)*(:pCLJGZ-:pCLJGS)/:pFDS," + sDecimal + ")," + sDecimal + ") "); sSQL.Add(" else RoundFix(:pCLJGS+RoundFix((XH-1)*(:pCLJGZ-:pCLJGS)/:pFDS," + sDecimal + ")+" + sModifiedNum + "," + sDecimal + ") "); sSQL.Add(" end as CLJGS, "); sSQL.Add(" RoundFix(:pCLJGS+RoundFix((XH)*(:pCLJGZ-:pCLJGS)/:pFDS," + sDecimal + ")," + sDecimal + ") as CLJGZ, "); sSQL.Add(" :pWHRID as WHRID, :pWHR as WHR, :pWHSJ as WHSJ "); sSQL.Add(" from "); sSQL.Add(" ( "); sSQL.Add(" select convert(integer,IDX_ID) as XH "); sSQL.Add(" from IDX "); sSQL.Add(" where IDX_ID<=:pFDS "); sSQL.Add(" ) a "); sSQL.ParamByName("pBJCLID").Value = sBJCLID; sSQL.ParamByName("pFDS").Value = txtFDS.Value; sSQL.ParamByName("pHSJGS").Value = txtHSJGS.Value; sSQL.ParamByName("pHSJGZ").Value =txtHSJGZ.Value; sSQL.ParamByName("pCLJGS").Value = txtCLJGS.Value; sSQL.ParamByName("pCLJGZ").Value = txtCLJGZ.Value; sSQL.ParamByName("pWHRID").Value = tSession.UserId; sSQL.ParamByName("pWHR").Value = tSession.UserName; sSQL.ParamByName("pWHSJ").Value = DateTime.Now; dberp.ExecSQL(sSQL); ShowMessage("材料行情分段成功!"); } catch(Exception ex) { ShowMessage("分段失败:" + ex); CloseWindow(); } DialogOperationScript dos = new DialogOperationScript(this); dos.ClickOwnerButton(PageParam.GetRTrimString("btnRefresh1CID")); dos.CloseSelf(); dos.Execute(); } protected void btnQX_Click(object sender, EventArgs e) { CloseWindow(); } #endregion #region 自定义事件 public string getMAXDH() { TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); TSQL SQL = new TSQL(dberp); SQL.Clear(); SQL.Add(" select max(XLXSCLHQFD_CLHQDH)as MAXXH from XLXSCLHQFD where XLXSCLHQFD_BJCLID=:pBJCLID"); string sBJCLID = PageParam.GetRTrimString("BJCLID"); SQL.ParamByName("pBJCLID").Value = sBJCLID; DataSet ds = dberp.OpenDataSet(SQL); if (ds.Tables[0].Rows.Count > 0) return ds.Tables[0].Rows[0][0].ToString().Trim(); else return ""; } //?未使用? public string GetNextID(string aID) { if (string.IsNullOrEmpty(aID)) { return "01"; } string sResult = ""; if (CMISproConvert.StrToInt(aID, 10) < 9) { int i1 = CMISproConvert.StrToInt(aID) + 1; sResult = i1.ToString().PadLeft(2, '0'); } else { int i = 2; int j = 1; string str = ""; while (i != 0) { char[] a = aID.Substring(i - 1, 1).ToCharArray(); char a1 = a[0]; int aa1 = (int)a1; char a2 = '9'; int aa2 = (int)a2; char a3 = 'Z'; int aa3 = (int)a3; char a4 = 'A'; int aa4 = (int)a4; char a5 = '0'; int aa5 = (int)a5; if (j == 0) { str = a1 + str; i--; continue; } else { if ((aa1 != aa2) && (aa1 != aa3)) { int i2 = aa1 + j; str = (char)i2 + str; j = 0; } else if (aa1 == aa2) { int i2 = aa4 + j - 1; str = (char)i2 + str; j = 0; } else if (aa1 == aa3) { int i2 = j - 1 + aa5; str = (char)i2 + str; j = 1; } else { throw new Exception("数据溢出"); } } i--; } sResult = str; } return sResult; } protected void txtHSJGS_TextChanged(object sender, EventArgs e) { double m = txtHSJGS.Value / (1 + (txtSL.Value / 100)); txtCLJGS.Value = NumberUtils.RoundX(m, XLBJDUtils.BJCLPriceDecimal); } protected void txtHSJGZ_TextChanged(object sender, EventArgs e) { double m = txtHSJGZ.Value / (1 + (txtSL.Value / 100)); txtCLJGZ.Value = NumberUtils.RoundX(m, XLBJDUtils.BJCLPriceDecimal); } protected void txtCLJGS_TextChanged(object sender, EventArgs e) { double m = txtCLJGS.Value * (1 + (txtSL.Value / 100)); txtHSJGS.Value = NumberUtils.RoundX(m, XLBJDUtils.BJCLPriceDecimal); } protected void txtCLJGZ_TextChanged(object sender, EventArgs e) { double m = txtCLJGZ.Value * (1 + (txtSL.Value / 100)); txtHSJGZ.Value = NumberUtils.RoundX(m, XLBJDUtils.BJCLPriceDecimal); } #endregion } }