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 XLXLGGList : SingleGridBase { XLXLGG entity = new XLXLGG(); XLXLGG_M queryentity = new XLXLGG_M(); protected void Page_Load(object sender, EventArgs e) { this.UMID = 101421010; this.UMName = "线缆规格"; this.CurMaster = Master; this.ModuleGV = grdContentGrid; this.CurEntity = entity; this.sURLTarget = "XLXLGGInfo.aspx"; this.CurQueryEntity = queryentity; this.sQueryURLTarget = "XLXLGGQuery.aspx"; this.PageHeight = 700; this.PageWidth = 500; this.CanDeleteCheckedRows = true; base.DataKeyNames = new string[] { "XLGGB_XLGGID", "XLGGB_XLGGJDGZ" }; this.Master.EnableNewBtn = false; this.Master.EnableCopyBtn = false; this.Master.EnableViewBtn = false; this.Master.EnableDeleteBtn = false; base.InitPage(); // this.ModuleGV.OnClientDblClick = "return false;"; if (!IsPostBack) { if (base.IsDefaultExecute) { 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) { base.BeforeDelete(db, ref ActionIsDone); } protected override bool Master_BeforeDeleteAction(object sender, EventArgs e) { 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("XLGGB_XLGGID", grdContentGrid.DataKeys[e.Row.RowIndex]["XLGGB_XLGGID"].ToString().Trim()); LinkPageParam.AddString("XLGGB_XLGGJDGZ", grdContentGrid.DataKeys[e.Row.RowIndex]["XLGGB_XLGGJDGZ"].ToString().Trim()); } base.moduleGV_RowDataBound(sender, e); } #endregion #region 自定义事件 private string GetQuerySQL() { StringBuilder sSQL = new StringBuilder(); sSQL.AppendLine(" select XLGGB_XH,XLGGB_XLGGID,XLGGB_GGZXS,XLGGB_XXJGID,XLGGB_DTJMZHID,XLGGB_XLGGJDGZ,XLGGB_XLGGDW, "); sSQL.AppendLine(" XLXXJGB_SFXD1,XLXXJGB_SL1,XLDTJMZHB_DTJM1,XLXXJGB_SFXD2,XLXXJGB_SL2,XLDTJMZHB_DTJM2, "); sSQL.AppendLine(" XLXXJGB_SFXD3,XLXXJGB_SL3,XLDTJMZHB_DTJM3,XLXXJGB_SFXD4,XLXXJGB_SL4,XLDTJMZHB_DTJM4, "); sSQL.AppendLine(" XLXXJGB_SFXD5,XLXXJGB_SL5,XLDTJMZHB_DTJM5,XLGGB_GGZJM "); sSQL.AppendLine(" from XLGGB "); sSQL.AppendLine(" left join XLXXJGB on XLXXJGB_XXJGID=XLGGB_XXJGID "); sSQL.AppendLine(" left join XLDTJMZHB on XLDTJMZHB_DTJMZHID=XLGGB_DTJMZHID "); sSQL.AppendLine(" where 1 = 1 "); if (!string.IsNullOrEmpty(CurQueryEntity.FieldByName("XXJGID").Value.Trim())) { sSQL.AppendLine(" and XLXXJGB_XXJGID = :pXXJGID "); entity.Param.Add("pXXJGID", CurQueryEntity.FieldByName("XXJGID").Value.Trim()); } //左匹配 右匹配 全匹配 if (!string.IsNullOrEmpty(CurQueryEntity.FieldByName("XLGGID").Value.Trim())) { string tmp =CurQueryEntity.FieldByName("XLGGID").Value.Trim(); if ((tmp.StartsWith("!") || tmp.StartsWith("!")) && (tmp.EndsWith("!") || tmp.EndsWith("!"))) { tmp = tmp.TrimStart('!').TrimEnd('!'); sSQL.AppendLine(" and XLGGB_XLGGID = :pXLGGID "); entity.Param.Add("pXLGGID", tmp); } else if (tmp.StartsWith("!") || tmp.StartsWith("!")) { tmp = tmp.TrimStart('!'); sSQL.AppendLine(" and XLGGB_XLGGID like :pXLGGID "); entity.Param.Add("pXLGGID", tmp + "%"); } else if (tmp.EndsWith("!") || tmp.EndsWith("!")) { tmp = tmp.TrimEnd('!'); sSQL.AppendLine(" and XLGGB_XLGGID like :pXLGGID "); entity.Param.Add("pXLGGID", "%" + tmp); } else { tmp = tmp.TrimStart('!').TrimEnd('!'); sSQL.AppendLine(" and XLGGB_XLGGID like :pXLGGID "); entity.Param.Add("pXLGGID", "%" + tmp + "%"); } } if (!string.IsNullOrEmpty(CurQueryEntity.FieldByName("ZXJM").Value.Trim())) { sSQL.AppendLine(" and XLDTJMZHB_DTJM1 = :pZXJM "); entity.Param.Add("pZXJM", CurQueryEntity.FieldByName("ZXJM").Value.Trim()); } sSQL.AppendLine("order by XLGGB_XH"); return sSQL.ToString(); } #endregion #region 控件事件 protected void btnPX_MenuItemClick(object sender, string ItemIndex) { int index = Int32.Parse(ItemIndex); switch (index) { case 0: sort_XXJGDTJM(); break; case 1: sort_XZDTGSJM(); break; } } //0-芯线结构(升序) + 导体截面(升序) private void sort_XXJGDTJM() { TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); TSQL SQL = new TSQL(dberp); try { if (dberp.DriverName == "ORACLE") { SQL.Clear(); SQL.Add("select XLGGB_XLGGID as XLGGID, "); SQL.Add(" row_number() over(order by XLGGB_XXJGID,XLDTJMZHB_DTJM1,XLDTJMZHB_DTJM2,XLDTJMZHB_DTJM3,XLDTJMZHB_DTJM4,XLDTJMZHB_DTJM5,XLDTJMZHB_DTJM6,XLDTJMZHB_DTJM7) as XH "); SQL.Add("from XLGGB "); SQL.Add("left join XLDTJMZHB on XLDTJMZHB_DTJMZHID=XLGGB_DTJMZHID "); DataSet ds = dberp.OpenDataSet(SQL); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { UpdateXLGGID_XH(ds.Tables[0].Rows[i]["XLGGID"].ToString().Trim(), ds.Tables[0].Rows[i]["XH"].ToString().Trim()); } } moduleGV_PageIndexChanging(null, null); FormAreaUpdate(); } else { dberp.BeginTrans(); SQL.Clear(); SQL.Add("update XLGGB set XLGGB_XH=A.XH "); SQL.Add("from "); SQL.Add("( select XLGGB_XLGGID as XLGGID, "); SQL.Add(" row_number() over(order by XLGGB_XXJGID,XLDTJMZHB_DTJM1,XLDTJMZHB_DTJM2,XLDTJMZHB_DTJM3,XLDTJMZHB_DTJM4,XLDTJMZHB_DTJM5,XLDTJMZHB_DTJM6,XLDTJMZHB_DTJM7) as XH "); SQL.Add(" from XLGGB "); SQL.Add(" left join XLDTJMZHB on XLDTJMZHB_DTJMZHID=XLGGB_DTJMZHID ) A "); SQL.Add(" where XLGGB_XLGGID=A.XLGGID "); dberp.ExecSQL(SQL); moduleGV_PageIndexChanging(null, null); FormAreaUpdate(); dberp.CommitTrans(); } } catch (Exception ex) { dberp.RollbackTrans(); ShowMessage(ex.Message); return; } } //1-线组数(升序)+导体根数(升序)+导体截面(升序) private void sort_XZDTGSJM() { TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); TSQL SQL = new TSQL(dberp); try { if (dberp.DriverName == "ORACLE") { SQL.Clear(); SQL.Add("select XLGGB_XLGGID as XLGGID, "); SQL.Add(" row_number() over(order by XLXXJGB_SFXD7,XLXXJGB_SFXD6,XLXXJGB_SFXD5,XLXXJGB_SFXD4,XLXXJGB_SFXD3,XLXXJGB_SFXD2,XLXXJGB_SFXD1,"); SQL.Add(" XLXXJGB_SL7,XLXXJGB_SL6,XLXXJGB_SL5,XLXXJGB_SL4,XLXXJGB_SL3,XLXXJGB_SL2,XLXXJGB_SL1, "); SQL.Add(" XLDTJMZHB_DTJM1,XLDTJMZHB_DTJM2,XLDTJMZHB_DTJM3,XLDTJMZHB_DTJM4,XLDTJMZHB_DTJM5,XLDTJMZHB_DTJM6,XLDTJMZHB_DTJM7 ) as XH "); SQL.Add("from XLGGB "); SQL.Add("left join XLXXJGB on XLXXJGB_XXJGID=XLGGB_XXJGID "); SQL.Add("left join XLDTJMZHB on XLDTJMZHB_DTJMZHID=XLGGB_DTJMZHID "); DataSet ds = dberp.OpenDataSet(SQL); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { UpdateXLGGID_XH(ds.Tables[0].Rows[i]["XLGGID"].ToString().Trim(), ds.Tables[0].Rows[i]["XH"].ToString().Trim()); } } moduleGV_PageIndexChanging(null, null); FormAreaUpdate(); } else { dberp.BeginTrans(); SQL.Clear(); SQL.Add("update XLGGB set XLGGB_XH=A.XH "); SQL.Add("from "); SQL.Add("( select XLGGB_XLGGID as XLGGID,"); SQL.Add(" row_number()over(order by XLXXJGB_SFXD7,XLXXJGB_SFXD6,XLXXJGB_SFXD5,XLXXJGB_SFXD4,XLXXJGB_SFXD3,XLXXJGB_SFXD2,XLXXJGB_SFXD1, "); SQL.Add(" XLXXJGB_SL7,XLXXJGB_SL6,XLXXJGB_SL5,XLXXJGB_SL4,XLXXJGB_SL3,XLXXJGB_SL2,XLXXJGB_SL1, "); SQL.Add(" XLDTJMZHB_DTJM1,XLDTJMZHB_DTJM2,XLDTJMZHB_DTJM3,XLDTJMZHB_DTJM4,XLDTJMZHB_DTJM5,XLDTJMZHB_DTJM6,XLDTJMZHB_DTJM7)as XH "); SQL.Add(" from XLGGB "); SQL.Add(" left join XLXXJGB on XLXXJGB_XXJGID=XLGGB_XXJGID "); SQL.Add(" left join XLDTJMZHB on XLDTJMZHB_DTJMZHID=XLGGB_DTJMZHID) A "); SQL.Add(" where XLGGB_XLGGID=A.XLGGID "); dberp.ExecSQL(SQL); moduleGV_PageIndexChanging(null, null); FormAreaUpdate(); dberp.CommitTrans(); } } catch (Exception ex) { dberp.RollbackTrans(); ShowMessage(ex.Message); return; } } private void UpdateXLGGID_XH(string sXLGGID, string sXH) { TDatabase dberp1 = TContextDatabases.GetDatabase("DBERP"); TSQL SQL = new TSQL(dberp1); SQL.Clear(); SQL.Add(" update XLGGB set XLGGB_XH=:pXH where XLGGB_XLGGID=:pXLGGID "); SQL.ParamByName("pXH").Value = CMISproConvert.StrToFloat(sXH); SQL.ParamByName("pXLGGID").Value = sXLGGID; dberp1.ExecSQL(SQL); } //支持 模糊* 模糊× 模糊/ 正则. protected void btnCLQDDR_Click(object sender, EventArgs e) { TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); TSQL SQL = new TSQL(dberp); try { dberp.BeginTrans(); SQL.Clear(); SQL.Add("insert into XLGGB "); SQL.Add("(XLGGB_XLGGID,XLGGB_QYRQ,XLGGB_TYRQ,XLGGB_TYBZ,XLGGB_WHR,XLGGB_WHRID,XLGGB_WHSJ,XLGGB_XH) "); SQL.Add("select distinct replace(XLXSCLQD_XLGGID,'*','×') as XLGGID,:pWHSJ, null, 'N', :pWHR,:pWHRID,:pWHSJ,0 "); SQL.Add(" from XLXSCLQD "); SQL.Add("where 1 = 1 and not exists(select 1 from XLGGB where replace(XLGGB_XLGGID,'×','*')=replace(XLXSCLQD_XLGGID,'×','*') ) "); SQL.Add(" and (XLXSCLQD_XLGGID like '%*%' or XLXSCLQD_XLGGID like '%×%' "); SQL.Add(" or XLXSCLQD_XLGGID like '%/%') "); SQL.Add(" and ISNULL(XLXSCLQD_WPID,'ZZZZ') ='ZZZZ' "); SQL.ParamByName("pWHR").Value = tSession.UserName; SQL.ParamByName("pWHRID").Value = tSession.UserId; SQL.ParamByName("pWHSJ").Value = DateTime.Now.ToString(); dberp.ExecSQL(SQL); moduleGV_PageIndexChanging(null, null); FormAreaUpdate(); dberp.CommitTrans(); ShowMessage("导入成功!"); } catch (Exception ex) { dberp.RollbackTrans(); ShowMessage(ex.Message); return; } } protected void btnJGBDR_Click(object sender, EventArgs e) { TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); TSQL SQL = new TSQL(dberp); try { dberp.BeginTrans(); SQL.Clear(); SQL.Add("insert into XLGGB "); SQL.Add("(XLGGB_XLGGID,XLGGB_QYRQ,XLGGB_TYRQ,XLGGB_TYBZ,XLGGB_WHR,XLGGB_WHRID,XLGGB_WHSJ,XLGGB_XH) "); SQL.Add("select distinct replace(XLXSJGBMX_XLGGID,'*','×') as XLGGID,:pWHSJ, null, 'N',:pWHR,:pWHRID,:pWHSJ,0 "); SQL.Add(" from XLXSJGBMX "); SQL.Add("where isnull(XLXSJGBMX_XLGGID,' ') <> ' ' and not exists(select 1 from XLGGB where replace(XLGGB_XLGGID,'×','*')=replace(XLXSJGBMX_XLGGID,'×','*') ) "); SQL.Add(" and (XLXSJGBMX_XLGGID like '%*%' or XLXSJGBMX_XLGGID like '%×%' "); SQL.Add(" or XLXSJGBMX_XLGGID like '%/%') "); SQL.ParamByName("pWHR").Value = tSession.UserName; SQL.ParamByName("pWHRID").Value = tSession.UserId; SQL.ParamByName("pWHSJ").Value = DateTime.Now.ToString(); dberp.ExecSQL(SQL); moduleGV_PageIndexChanging(null, null); FormAreaUpdate(); dberp.CommitTrans(); ShowMessage("导入成功!"); } catch (Exception ex) { dberp.RollbackTrans(); ShowMessage(ex.Message); return; } } protected void btnRefresh_Click(object sender, EventArgs e) { moduleGV_PageIndexChanging(null, null); } #endregion } }