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 GThinking.N_MISPRO.Utility; using GThinking.N_MISPRO.Data; namespace GThinking.N_XLXSBJ { public partial class TZYZJJ7Info : OperationBase { TZYZJJ7 entity = new TZYZJJ7(); protected void Page_Load(object sender, EventArgs e) { this.UMID = 100860065; this.UMName = "按报价材料调材料损耗"; this.CurMaster = Master; this.Tabs = Tab; this.PageHeight = 600; this.PageWidth = 750; AddListSetMap(new ListSet(pagSHD.ID, null, grdSHD, entity, UPSHD)); InitGrdColumn(); CustomPageSize = 1000; this.Master.PnlQuery.Visible = false; this.Master.PnlBill.Visible = false; this.Master.BtnQueryVisible = false; base.InitPage(); if (!IsPostBack) { Master_OnQuery(); GridDataBind(); } } #region 模板继承事件 protected override void Master_OnQuery() { entity.sJGBID = PageParam.GetRTrimString("XLXSJGBYZZ7_JGBID"); entity.PXFS = PageParam.GetRTrimString("PXFS"); base.Master_OnQuery(); } protected override void GridDataBind() { base.GridDataBind(); } protected override bool Master_OnBeforeOK(object sender, EventArgs e) { return base.Master_OnBeforeOK(sender, e); } protected override bool DataLogicValid() { if (grdSHD.NewRows.Count == 0) { ShowMessage("没有可设置的报价材料!"); return false; } return base.DataLogicValid(); } protected override bool Master_OnOK() { TDatabase DBERP = null; try { DBERP = TContextDatabases.GetDatabase("DBERP"); DBERP.BeginTrans(); InsertXLXSJGBYZZ7(DBERP); DBERP.CommitTrans(); ShowMessage("设置成功!"); CloseWindow(); } catch (Exception ex) { ShowMessage(ex.Message); DBERP.RollbackTrans(); return false; } return true; } protected override void Grid_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { } base.Grid_RowDataBound(sender, e); } #endregion #region 控件事件 #endregion #region 自定义函数 private void InitGrdColumn() { grdSHD.FindColumnByFieldName("TZYZ_JZ01").Visible = false; grdSHD.FindColumnByFieldName("TZYZ_JZ02").Visible = false; grdSHD.FindColumnByFieldName("TZYZ_JZ03").Visible = false; grdSHD.FindColumnByFieldName("TZYZ_JZ04").Visible = false; grdSHD.FindColumnByFieldName("TZYZ_JZ05").Visible = false; grdSHD.FindColumnByFieldName("TZYZ_JZ06").Visible = false; grdSHD.FindColumnByFieldName("TZYZ_JZ07").Visible = false; grdSHD.FindColumnByFieldName("TZYZ_JZ08").Visible = false; grdSHD.FindColumnByFieldName("TZYZ_JZ09").Visible = false; grdSHD.FindColumnByFieldName("TZYZ_JZ10").Visible = false; string[] sTJYZList = PageParam.GetRTrimString("TJYZList").Split(','); for (int i = 0; i < sTJYZList.Length; i++) { if (sTJYZList[i].StartsWith("JZ01|")) { grdSHD.FindColumnByFieldName("TZYZ_JZ01").Visible = true; grdSHD.FindColumnByFieldName("TZYZ_JZ01").HeaderText = sTJYZList[i].Replace("JZ01|", ""); if (sTJYZList[i].EndsWith("(元)")) grdSHD.FindColumnByFieldName("TZYZ_JZ01").NumberDecimalPlace = 5; } else if (sTJYZList[i].StartsWith("JZ02|")) { grdSHD.FindColumnByFieldName("TZYZ_JZ02").Visible = true; grdSHD.FindColumnByFieldName("TZYZ_JZ02").HeaderText = sTJYZList[i].Replace("JZ02|", ""); if (sTJYZList[i].EndsWith("(元)")) grdSHD.FindColumnByFieldName("TZYZ_JZ02").NumberDecimalPlace = 5; } else if (sTJYZList[i].StartsWith("JZ03|")) { grdSHD.FindColumnByFieldName("TZYZ_JZ03").Visible = true; grdSHD.FindColumnByFieldName("TZYZ_JZ03").HeaderText = sTJYZList[i].Replace("JZ03|", ""); if (sTJYZList[i].EndsWith("(元)")) grdSHD.FindColumnByFieldName("TZYZ_JZ03").NumberDecimalPlace = 5; } else if (sTJYZList[i].StartsWith("JZ04|")) { grdSHD.FindColumnByFieldName("TZYZ_JZ04").Visible = true; grdSHD.FindColumnByFieldName("TZYZ_JZ04").HeaderText = sTJYZList[i].Replace("JZ04|", ""); if (sTJYZList[i].EndsWith("(元)")) grdSHD.FindColumnByFieldName("TZYZ_JZ04").NumberDecimalPlace = 5; } else if (sTJYZList[i].StartsWith("JZ05|")) { grdSHD.FindColumnByFieldName("TZYZ_JZ05").Visible = true; grdSHD.FindColumnByFieldName("TZYZ_JZ05").HeaderText = sTJYZList[i].Replace("JZ05|", ""); if (sTJYZList[i].EndsWith("(元)")) grdSHD.FindColumnByFieldName("TZYZ_JZ05").NumberDecimalPlace = 5; } else if (sTJYZList[i].StartsWith("JZ06|")) { grdSHD.FindColumnByFieldName("TZYZ_JZ06").Visible = true; grdSHD.FindColumnByFieldName("TZYZ_JZ06").HeaderText = sTJYZList[i].Replace("JZ06|", ""); if (sTJYZList[i].EndsWith("(元)")) grdSHD.FindColumnByFieldName("TZYZ_JZ06").NumberDecimalPlace = 5; } else if (sTJYZList[i].StartsWith("JZ07|")) { grdSHD.FindColumnByFieldName("TZYZ_JZ07").Visible = true; grdSHD.FindColumnByFieldName("TZYZ_JZ07").HeaderText = sTJYZList[i].Replace("JZ07|", ""); if (sTJYZList[i].EndsWith("(元)")) grdSHD.FindColumnByFieldName("TZYZ_JZ07").NumberDecimalPlace = 5; } else if (sTJYZList[i].StartsWith("JZ08|")) { grdSHD.FindColumnByFieldName("TZYZ_JZ08").Visible = true; grdSHD.FindColumnByFieldName("TZYZ_JZ08").HeaderText = sTJYZList[i].Replace("JZ08|", ""); if (sTJYZList[i].EndsWith("(元)")) grdSHD.FindColumnByFieldName("TZYZ_JZ08").NumberDecimalPlace = 5; } else if (sTJYZList[i].StartsWith("JZ09|")) { grdSHD.FindColumnByFieldName("TZYZ_JZ09").Visible = true; grdSHD.FindColumnByFieldName("TZYZ_JZ09").HeaderText = sTJYZList[i].Replace("JZ09|", ""); if (sTJYZList[i].EndsWith("(元)")) grdSHD.FindColumnByFieldName("TZYZ_JZ09").NumberDecimalPlace = 5; } else if (sTJYZList[i].StartsWith("JZ10|")) { grdSHD.FindColumnByFieldName("TZYZ_JZ10").Visible = true; grdSHD.FindColumnByFieldName("TZYZ_JZ10").HeaderText = sTJYZList[i].Replace("JZ10|", ""); if (sTJYZList[i].EndsWith("(元)")) grdSHD.FindColumnByFieldName("TZYZ_JZ10").NumberDecimalPlace = 5; } } } private void InsertXLXSJGBYZZ7(TDatabase dberp) { string sJGBID = PageParam.GetRTrimString("XLXSJGBYZZ7_JGBID"); TSQL SQL = new TSQL(dberp); SQL.Add("delete from XLXSJGBYZZ7 where XLXSJGBYZZ7_JGBID=:pJGBID "); SQL.ParamByName("pJGBID").Value = sJGBID; dberp.ExecSQL(SQL); foreach (GridViewRow row in grdSHD.NewRows) { //一行执行一次 SQL.Clear(); SQL.Add("insert into XLXSJGBYZZ7(XLXSJGBYZZ7_JGBID,XLXSJGBYZZ7_BJCLID,XLXSJGBYZZ7_YZID,XLXSJGBYZZ7_YZZ,XLXSJGBYZZ7_WHR,XLXSJGBYZZ7_WHRID,XLXSJGBYZZ7_WHSJ)"); bool bNeedInsert = false; for (int i = 0; i < grdSHD.Columns.Count; i++) { if (grdSHD.Columns[i].DataField.Contains("TZYZ_")) { string sYZID = grdSHD.Columns[i].DataField.Substring(5); double dYZZ = CMISproConvert.StrToFloat(grdSHD.GetValueByFieldName("TZYZ_" + sYZID, row), 0); if (dYZZ != 0)//因子值不为0才会插入 { if (bNeedInsert) { SQL.Add(" union all "); } else { bNeedInsert = true; } SQL.Add(string.Format("select '{0}' as JGBID,'{1}' as BJCLID,'{2}' as YZID,{3} as YZZ,'{4}' as WHR,'{5}' as WHRID,'{6}' as WHSJ ", sJGBID,grdSHD.GetValueByFieldName("XLXSBJCL_BJCLID", row),sYZID, CMISproConvert.StrToFloat(grdSHD.GetValueByFieldName("TZYZ_" + sYZID, row), 0), CurSession.UserName, CurSession.UserId, DateTime.Now)); } } } if (bNeedInsert) { dberp.ExecSQL(SQL); } } } #endregion } }