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_MODEL.Page; using GThinking.N_CONTROL; using GThinking.N_MISPRO.Data; using GThinking.N_MISPRO.Utility; using GThinking.N_PUBLIC; using GThinking.N_MODEL.UserControls; using System.Text; using GThinking.N_WORKFLOW; using GThinking.N_PUBLIC2; namespace GThinking.N_XLJC { public partial class XLJGCZBList : SingleGridBase { XLJGCZB entity = new XLJGCZB(); XLJGCZB_M queryentity = new XLJGCZB_M(); protected void Page_Load(object sender, EventArgs e) { this.UMID = 101421008; this.UMName = "线缆结构尺重表"; this.CurMaster = Master; this.ModuleGV = grdContentGrid; this.CurEntity = entity; this.CurQueryEntity = queryentity; this.sURLTarget = "XLJGCZBInfo.aspx"; this.sQueryURLTarget = "XLJGCZBQuery.aspx"; this.PageHeight = 700; this.PageWidth = 500; this.CanDeleteCheckedRows = true; base.DataKeyNames = new string[] { "XLJGCZBML_JGCZBID", "XLJGCZBML_CZBLX", "XLJGCZBML_GYFLBM", "GYFLBM", "XLJGCZBML_XLXHBN", "XLJGCZBML_XLBZBN", "XLJGCZBML_DYDJBN" }; base.InitPage(); if (!IsPostBack) { Master_OnStandardQuery(null, null); } } #region 模板继承事件 protected override void Master_OnStandardQuery(object sender, EventArgs e) { base.InitEntityByCondition(); entity.EntityTable.QuerySelSql = GetQuerySQL(); base.Master_OnStandardQuery(sender, e); entity.GridDataBind(grdContentGrid, tSession); } protected override void moduleGV_PageIndexChanging(object sender, GridViewPageEventArgs e) { base.InitEntityByCondition(); entity.EntityTable.QuerySelSql = GetQuerySQL(); grdContentGrid.SelectedIndex = -1; base.moduleGV_PageIndexChanging(sender, e); } protected override void BeforeDelete(TDatabase db, ref bool ActionIsDone) { entity.Param.Add("XLJGCZBML_JGCZBID", grdContentGrid.SelectedDataKey["XLJGCZBML_JGCZBID"].ToString().Trim()); base.BeforeDelete(db, ref ActionIsDone); } protected override void AfterDelete(TDatabase db, ref bool ActionIsDone) { string sJGCZBID = grdContentGrid.SelectedDataKey["XLJGCZBML_JGCZBID"].ToString().Trim(); string sJGCBZLX = grdContentGrid.SelectedDataKey["XLJGCZBML_CZBLX"].ToString().Trim(); string sSQL1 = string.Format("delete from XLXHJGCZBML where XLXHJGCZBML_JGCZBID='{0}'", sJGCZBID); string sSQL2 = string.Format("delete from XLJGCZBRZ where XLJGCZBRZ_JGCZBID='{0}'", sJGCZBID); string sSQL3 = string.Format("delete from XLJGCZBBB where XLJGCZBBB_JGCZBID='{0}'", sJGCZBID); db.ExecSQL(sSQL1); db.ExecSQL(sSQL2); db.ExecSQL(sSQL3); if (sJGCBZLX.Equals("A") || sJGCBZLX.Equals("B")) { string sSQL4 = string.Format("delete from XLJGCZBNR where XLJGCZBNR_JGCZBID='{0}'", sJGCZBID); string sSQL5 = string.Format("delete from XLJGCZBLM where XLJGCZBLM_JGCZBID='{0}'", sJGCZBID); string sSQL6 = string.Format("delete from XLXHJGCZBNR where XLXHJGCZBNR_JGCZBID='{0}'", sJGCZBID); string sSQL7 = string.Format("delete from XLXHJGCZBML where XLXHJGCZBML_JGCZBID='{0}'", sJGCZBID); string sSQL8 = string.Format("delete from XLXSCLQDWL where XLXSCLQDWL_JGCZBID='{0}'", sJGCZBID); db.ExecSQL(sSQL4); db.ExecSQL(sSQL5); db.ExecSQL(sSQL6); db.ExecSQL(sSQL7); db.ExecSQL(sSQL8); } base.AfterDelete(db, ref ActionIsDone); } protected override bool Master_BeforeDeleteAction(object sender, EventArgs e) { string sJGCZBID = grdContentGrid.SelectedDataKey["XLJGCZBML_JGCZBID"].ToString().Trim(); string sJGCBZLX = grdContentGrid.SelectedDataKey["XLJGCZBML_CZBLX"].ToString().Trim(); string sSQL = ""; if (sJGCBZLX.Equals("A") || sJGCBZLX.Equals("B")) { sSQL = string.Format("select top 1 XLXSCLQD_JGCZBID from XLXSCLQD where XLXSCLQD_JGCZBID='{0}'", sJGCZBID); if (CMISproDataBase.ExistsRecord("DBERP", sSQL)) { ShowMessage("当前尺重表存在材料清单记录,不允许删除!"); return false; } } else { sSQL = string.Format("select TOP 1 XLXHJGCZBML_JGCZBID from XLXHJGCZBML where XLXHJGCZBML_JGCZBID='{0}' and XLXHJGCZBML_JGCZBXH< 0 ", sJGCZBID); if (CMISproDataBase.ExistsRecord("DBERP", sSQL)) { ShowMessage("已经存在涵盖范围,不允许删除!"); return false; } sSQL = string.Format("select top 1 XLJGCZBNR_JGCZBID from XLJGCZBNR where XLJGCZBNR_JGCZBID='{0}'", sJGCZBID); if (CMISproDataBase.ExistsRecord("DBERP", sSQL)) { ShowMessage("当前尺重表已存在导入内容,不允许删除!"); return false; } sSQL = string.Format("select top 1 XLXHJGCZBNR_JGCZBID from XLXHJGCZBNR where XLXHJGCZBNR_JGCZBID='{0}'", sJGCZBID); if (CMISproDataBase.ExistsRecord("DBERP", sSQL)) { ShowMessage("当前尺重表已生成型号内容,不允许删除!"); return false; } sSQL = string.Format("select top 1 XLXHJGCZBML_JGCZBID from XLXHJGCZBML where XLXHJGCZBML_JGCZBID='{0}' and XLXHJGCZBML_JGCZBXH>0 ", sJGCZBID); if (CMISproDataBase.ExistsRecord("DBERP", sSQL)) { ShowMessage("当前尺重表已处理过结构工艺,不允许删除!"); return false; } } return base.Master_BeforeDeleteAction(sender, e); } protected override bool Master_AfterDeleteAction(object sender, EventArgs e) { if (!base.Master_AfterDeleteAction(sender, e)) { return false; } base.InitEntityByCondition(); entity.EntityTable.QuerySelSql = GetQuerySQL(); entity.GridDataBind(grdContentGrid, tSession); grdContentGrid.SelectedIndex = -1; return true; } protected override void moduleGV_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { LinkPageParam.AddString("XLJGCZBML_JGCZBID", grdContentGrid.DataKeys[e.Row.RowIndex]["XLJGCZBML_JGCZBID"].ToString().Trim()); } base.moduleGV_RowDataBound(sender, e); } #endregion #region 自定义事件 private string GetQuerySQL() { StringBuilder sSQL = new StringBuilder(); // RTRIM(XLJGCZBML_XLTXID)||'|'||RTRIM(XLCPTX_CPTXMC) as XLJGCZBML_XLTXID,RTRIM(XLJGCZBML_CPYT)||'|'||RTRIM(XLCPYT_CPYTMC) as XLJGCZBML_CPYT,XLJGCZBML_QYRQ, "); sSQL.AppendLine(" SELECT XLJGCZBML_JGCZBID,XLJGCZBML_JGCZBMC,XLJGCZBML_FZR,XLJGCZBML_CZBJLDW, "); sSQL.AppendLine(" XLJGCZBML_XLGGDW, isnull(XLJGCZBML_CZBLX,' ') as XLJGCZBML_CZBLX,XLJGCZBML_GGHLX, "); sSQL.AppendLine(" XLJGCZBML_JGCZBBBID,XLJGCZBML_EXCEL,XLJGCZBML_SHEET, "); sSQL.AppendLine(" XLJGCZBML_XLBZBN,XLJGCZBML_DYDJBN,XLJGCZBML_XLXHBN,RTRIM(XLJGCZBML_GYFLBM)||'|'||RTRIM(XLSCGYBB_SCGYMC) as XLJGCZBML_GYFLBM, XLJGCZBML_GYFLBM as GYFLBM, "); sSQL.AppendLine(" RTRIM(XLJGCZBML_CPMLID)||'|'||RTRIM(XLXSCPML_CPMLMC) as XLJGCZBML_CPMLID,XLJGCZBML_WHRID,XLJGCZBML_WHR,XLJGCZBML_WHSJ "); sSQL.AppendLine(" FROM XLJGCZBML "); sSQL.AppendLine(" left join XLXSCPML on XLXSCPML_CPMLID= XLJGCZBML_CPMLID "); sSQL.AppendLine(" left join XLSCGYBB on XLSCGYBB_GYFLBM= XLJGCZBML_GYFLBM and XLSCGYBB_GYBBH = 1 "); sSQL.AppendLine(" where 1 = 1 "); //此处不可以使用trim()防止将" "过滤掉 if (!CurQueryEntity.FieldByName("CZBLXList").Value.Equals("")) { sSQL.AppendLine(" and " + CMISproDataBase.GetWhereEqual("isnull(XLJGCZBML_CZBLX,' ')", CurQueryEntity.FieldByName("CZBLXList").Value)); } if (!string.IsNullOrEmpty(CurQueryEntity.FieldByName("FZR").Value.Trim())) { sSQL.AppendLine(" and XLJGCZBML_FZR like :pFZR "); entity.Param.Add("pFZR", "%" + CurQueryEntity.FieldByName("FZR").Value.Trim() + "%"); } sSQL.AppendLine("order by XLJGCZBML_JGCZBID"); return sSQL.ToString(); } #endregion #region 控件事件 protected void btnHGFW_Click(object sender, EventArgs e) { if (grdContentGrid.SelectedIndex < 0) { ShowMessage("请选择处理记录!"); return; } string sJGCZBID = grdContentGrid.DataKeys[grdContentGrid.SelectedIndex]["XLJGCZBML_JGCZBID"].ToString().Trim(); string sCZBLX = grdContentGrid.DataKeys[grdContentGrid.SelectedIndex]["XLJGCZBML_CZBLX"].ToString().Trim(); string sGYFLBM = grdContentGrid.DataKeys[grdContentGrid.SelectedIndex]["GYFLBM"].ToString().Trim(); string sXLXHBN = grdContentGrid.DataKeys[grdContentGrid.SelectedIndex]["XLJGCZBML_XLXHBN"].ToString().Trim(); string sXLBZBN = grdContentGrid.DataKeys[grdContentGrid.SelectedIndex]["XLJGCZBML_XLBZBN"].ToString().Trim(); string sDYDJBN = grdContentGrid.DataKeys[grdContentGrid.SelectedIndex]["XLJGCZBML_DYDJBN"].ToString().Trim(); if (!CMISproDataBase.ExistsRecord("DBERP", string.Format("select 1 from XLJGCZBML where XLJGCZBML_JGCZBID='{0}'", sJGCZBID))) { ShowMessage("当前记录已不存在,请刷新后重试!"); return; } TPageParams pageParams = new TPageParams(); pageParams.CallAction = TPageCallAction.pcaBrowse; pageParams.UrlPath = "XLJGCZB_XHMLList.aspx"; pageParams.Title = "涵盖范围"; pageParams.AddString("LX", "HGFW"); pageParams.AddString("JGCZBID", sJGCZBID); pageParams.AddString("CZBLX", sCZBLX); pageParams.AddString("GYFLBM", sGYFLBM); //表内表外 pageParams.AddString("XLXHBN", sXLXHBN); pageParams.AddString("XLBZBN", sXLBZBN); pageParams.AddString("DYDJBN", sDYDJBN); OpenModuleDialog(101421008, pageParams); } protected void btnXHML_Click(object sender, EventArgs e) { if (grdContentGrid.SelectedIndex < 0) { ShowMessage("请选择处理记录!"); return; } string sJGCZBID = grdContentGrid.DataKeys[grdContentGrid.SelectedIndex]["XLJGCZBML_JGCZBID"].ToString().Trim(); string sCZBLX = grdContentGrid.DataKeys[grdContentGrid.SelectedIndex]["XLJGCZBML_CZBLX"].ToString().Trim(); string sGYFLBM = grdContentGrid.DataKeys[grdContentGrid.SelectedIndex]["GYFLBM"].ToString().Trim(); string sXLXHBN = grdContentGrid.DataKeys[grdContentGrid.SelectedIndex]["XLJGCZBML_XLXHBN"].ToString().Trim(); string sXLBZBN = grdContentGrid.DataKeys[grdContentGrid.SelectedIndex]["XLJGCZBML_XLBZBN"].ToString().Trim(); string sDYDJBN = grdContentGrid.DataKeys[grdContentGrid.SelectedIndex]["XLJGCZBML_DYDJBN"].ToString().Trim(); if (!CMISproDataBase.ExistsRecord("DBERP", string.Format("select 1 from XLJGCZBML where XLJGCZBML_JGCZBID='{0}'", sJGCZBID))) { ShowMessage("当前记录已不存在,请刷新后重试!"); return; } TPageParams pageParams = new TPageParams(); pageParams.CallAction = TPageCallAction.pcaBrowse; pageParams.UrlPath = "XLJGCZB_XHMLList.aspx"; pageParams.Title = "型号目录"; pageParams.AddString("LX", "XHML"); pageParams.AddString("JGCZBID", sJGCZBID); pageParams.AddString("CZBLX", sCZBLX); pageParams.AddString("GYFLBM", sGYFLBM); //表内表外 pageParams.AddString("XLXHBN", sXLXHBN); pageParams.AddString("XLBZBN", sXLBZBN); pageParams.AddString("DYDJBN", sDYDJBN); OpenModuleDialog(101421008, pageParams); } protected void btnCZBLM_Click(object sender, EventArgs e) { if (grdContentGrid.SelectedIndex < 0) { ShowMessage("请选择处理记录!"); return; } string sJGCZBID = grdContentGrid.DataKeys[grdContentGrid.SelectedIndex]["XLJGCZBML_JGCZBID"].ToString().Trim(); string sCZBLX = grdContentGrid.DataKeys[grdContentGrid.SelectedIndex]["XLJGCZBML_CZBLX"].ToString().Trim(); if (!sCZBLX.Equals("A")) { ShowMessage("仅A类尺重表可以设置尺重表栏目!"); return; } TPageParams pageParams = new TPageParams(); pageParams.CallAction = TPageCallAction.pcaBrowse; pageParams.UrlPath = "XLJGCZB_LMSZList.aspx"; pageParams.AddString("JGCZBID", sJGCZBID); OpenModuleDialog(101421008, pageParams); } #endregion } }