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 GThinking.N_PUBLIC; using System.Collections.Generic; using GThinking.N_MISPRO.MISPROAS; namespace GThinking.N_XLXSBJ { public partial class JGCZBNRInfo : OperationBase { CZBNR entity = new CZBNR(); #region 页面初始化 protected void Page_Load(object sender, EventArgs e) { this.UMID = 100860020; this.UMName = "线缆销售报价结构尺重表"; this.CurMaster = Master; this.Tabs = Tab; this.PageWidth = 700; this.PageHeight = 500; AddListSetMap(new ListSet(pagSHD.ID, null, grdCZBNRMX, entity, UPSHD)); if (!IsPostBack) { this.Master.PnlQuery.GroupingText = "查询条件"; this.Master.PnlBill.GroupingText = "材料信息"; this.Master.PnlQuery.Visible = false; Master.BtnQueryVisible = false; Master.BtnReportVisible = false; InitControls(); string pDRH = PageParam.GetRTrimString("XLJGCZBNR_DRHH"); string pJGCZBID = PageParam.GetRTrimString("JGCZBID"); string pJGCZBBBID = PageParam.GetRTrimString("JGCZBBBID"); if (pDRH.Equals("") || pJGCZBID.Equals("") || pJGCZBBBID.Equals("")) { ShowMessage("记录不存在!"); CloseWindowNoQuery(); } TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); TSQL SQL = new TSQL(dberp); SQL.Clear(); SQL.Add(" select XLJGCZBNR_LMNR01, XLJGCZBNR_LMNR02, XLJGCZBNR_DRHH, XLJGCZBNR_LMNR04, XLJGCZBNR_LMNR03, "); SQL.Add(" XLJGCZBNR_WHR, XLJGCZBNR_WHSJ, XLJGCZBNR_WHRID, XLJGCZBNR_JGCZBID, XLJGCZBNR_JGCZBBBID "); SQL.Add(" from XLJGCZBNR "); SQL.Add(" where XLJGCZBNR_DRHH=:pDRHH and XLJGCZBNR_JGCZBID=:pJGCZBID and XLJGCZBNR_JGCZBBBID=:pJGCZBBBID"); SQL.AddParam("pDRHH", TGtdbType.Float, 8, pDRH); SQL.ParamByName("pJGCZBID").Value = pJGCZBID; SQL.ParamByName("pJGCZBBBID").Value = pJGCZBBBID; DataSet ds = dberp.OpenDataSet(SQL); if (ds.Tables[0].Rows.Count > 0) { cbxXLXHID.ClearItems(); cbxXLXHID.Items.Add(new ListItem(ds.Tables[0].Rows[0]["XLJGCZBNR_LMNR01"].ToString().Trim(), ds.Tables[0].Rows[0]["XLJGCZBNR_LMNR01"].ToString().Trim())); cbxDYDJ.ClearItems(); cbxDYDJ.Items.Add(new ListItem(ds.Tables[0].Rows[0]["XLJGCZBNR_LMNR04"].ToString().Trim(), ds.Tables[0].Rows[0]["XLJGCZBNR_LMNR04"].ToString().Trim())); cbxXLXHID.SelectedValue = ds.Tables[0].Rows[0]["XLJGCZBNR_LMNR01"].ToString().Trim(); txtXLGGID.Text = ds.Tables[0].Rows[0]["XLJGCZBNR_LMNR02"].ToString().Trim(); txtDRH.Value = float.Parse(ds.Tables[0].Rows[0]["XLJGCZBNR_DRHH"].ToString().Trim()); cbxDYDJ.SelectedValue = ds.Tables[0].Rows[0]["XLJGCZBNR_LMNR04"].ToString().Trim(); cbxST.SelectedValue = ds.Tables[0].Rows[0]["XLJGCZBNR_LMNR03"].ToString().Trim(); txtWHR.Text = ds.Tables[0].Rows[0]["XLJGCZBNR_WHR"].ToString().Trim(); datWHSJ.Value = ds.Tables[0].Rows[0]["XLJGCZBNR_WHSJ"].ToString().Trim(); txtWHRID.Value = ds.Tables[0].Rows[0]["XLJGCZBNR_WHRID"].ToString().Trim(); txtJGCZBID.Value = ds.Tables[0].Rows[0]["XLJGCZBNR_JGCZBID"].ToString().Trim(); txtJGCZBBBID.Value = ds.Tables[0].Rows[0]["XLJGCZBNR_JGCZBBBID"].ToString().Trim(); } } base.InitPage(); //grdCZBNRMX.EnabledToolBar = false; if (!IsPostBack) { TComboBox.SetComboBox("DBERP", cbxST, "select XLBZ_XLBZID,XLBZ_XLBZLXMC from XLBZ order by XLBZ_PX,XLBZ_XLBZID", false); Master_OnQuery(); GridDataBind(); } } #endregion #region 模板继承事件 protected override void Master_OnQuery() { entity.sDRHH = PageParam.GetRTrimString("XLJGCZBNR_DRHH"); entity.sJGCZBID = PageParam.GetRTrimString("JGCZBID"); entity.sJGCZBBBID = PageParam.GetRTrimString("JGCZBBBID"); 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 (grdCZBNRMX.NewRows.Count > 0) { for (int i = 0; i < grdCZBNRMX.NewRows.Count; i++) { string CLZL = grdCZBNRMX.GetValueByFieldName("LMNR", grdCZBNRMX.NewRows[i]).ToString().Trim(); if (CLZL.Equals("")) CLZL = "0"; float tmp = float.Parse(CLZL); if (tmp < 0) { ShowMessage("材料用量不能小于0"); return false; } } } return base.DataLogicValid(); } protected override bool Master_OnOK() { TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); dberp.BeginTrans(); try { if (grdCZBNRMX.NewRows.Count > 0) { TSQL tmpSQL = new TSQL(dberp); tmpSQL.Clear(); tmpSQL.Add(" update XLJGCZBNR set "); for (int i = 0; i < grdCZBNRMX.NewRows.Count; i++) { string BH = grdCZBNRMX.GetValueByFieldName("XLJGCZBLM_CZBLMBH", grdCZBNRMX.NewRows[i]).ToString().Trim(); string CLZL = grdCZBNRMX.GetValueByFieldName("LMNR", grdCZBNRMX.NewRows[i]).ToString().Trim(); if (CLZL.Equals("")) CLZL = "0"; if (i != 0) { tmpSQL.Add(string.Format(" ,XLJGCZBNR_LMNR" + BH + "='{0}'", CLZL)); } else { tmpSQL.Add(string.Format(" XLJGCZBNR_LMNR" + BH + "='{0}'", CLZL)); } } tmpSQL.Add(string.Format(" ,XLJGCZBNR_WHR='{0}'", CurSession.UserName.Trim())); tmpSQL.Add(string.Format(" ,XLJGCZBNR_WHSJ='{0}'", CMISproConvert.ConvertTime(DateTime.Now))); tmpSQL.Add(string.Format(" ,XLJGCZBNR_WHRID='{0}'", CurSession.UserId.Trim())); tmpSQL.Add(string.Format("where XLJGCZBNR_JGCZBID='{0}' and XLJGCZBNR_JGCZBBBID='{1}' and XLJGCZBNR_DRHH={2}" , txtJGCZBID.Value , txtJGCZBBBID.Value, txtDRH.Value)); dberp.ExecSQL(tmpSQL); } dberp.CommitTrans(); //使用脚本给父页面的隐藏控件赋值,调用父页面的控件事件 DialogOperationScript dos = new DialogOperationScript(this); //dos.SetOwnerControlValue("ctl00_CPHForm_txtBJCLID", cbxBJCL.SelectedValue.Trim()); dos.ClickOwnerButton(PageParam.GetRTrimString("RefreshCtrlID")); ShowMessage("修改成功!"); dos.CloseSelf(); dos.Execute(); } catch { dberp.RollbackTrans(); ShowMessage("操作数据集出错,请和系统管理员联系!"); 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 自定义函数 private void InitControls() { cbxXLXHID.Enabled = false; txtXLGGID.Enabled = false; txtDRH.Enabled = false; cbxDYDJ.Enabled = false; cbxST.Enabled = false; this.txtWHR.Enabled = false; this.datWHSJ.Enabled = false; } #endregion #region 控件事件 //protected void btnConfirm_Click(object sender, EventArgs e) //{ // TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); // dberp.BeginTrans(); // try // { // if (grdCZBNRMX.NewRows.Count > 0) // { // TSQL tmpSQL = new TSQL(dberp); // tmpSQL.Clear(); // tmpSQL.Add(" update XLJGCZBNR set "); // for (int i = 0; i < grdCZBNRMX.NewRows.Count; i++) // { // string BH = grdCZBNRMX.GetValueByFieldName("XLJGCZBLM_CZBLMBH", grdCZBNRMX.NewRows[i]).ToString().Trim(); // if (i != 0) // { // tmpSQL.Add(string.Format(" ,XLJGCZBNR_LMNR" + BH + "='{0}'", grdCZBNRMX.GetValueByFieldName("LMNR", grdCZBNRMX.NewRows[i]).ToString().Trim())); // } // else // { // tmpSQL.Add(string.Format(" XLJGCZBNR_LMNR" + BH + "='{0}'", grdCZBNRMX.GetValueByFieldName("LMNR", grdCZBNRMX.NewRows[i]).ToString().Trim())); // } // } // tmpSQL.Add(string.Format(" ,XLJGCZBNR_WHR='{0}'", CurSession.UserName.Trim())); // tmpSQL.Add(string.Format(" ,XLJGCZBNR_WHSJ='{0}'", DateTime.Now)); // tmpSQL.Add(string.Format(" ,XLJGCZBNR_WHRID='{0}'", CurSession.UserId.Trim())); // tmpSQL.Add(string.Format("where XLJGCZBNR_JGCZBID='{0}' and XLJGCZBNR_JGCZBBBID='{1}' and XLJGCZBNR_DRHH={2}" // , txtJGCZBID.Value // , txtJGCZBBBID.Value, txtDRH.Value)); // dberp.ExecSQL(tmpSQL); // } // dberp.CommitTrans(); // ShowMessage("修改成功!"); // CloseWindowNoQuery(); // } // catch // { // dberp.RollbackTrans(); // ShowMessage("操作数据集出错,请和系统管理员联系!"); // } //} //protected void btnCanel_Click(object sender, EventArgs e) //{ // CloseWindowNoQuery(); //} #endregion } }