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.Data; using GThinking.N_MISPRO.Utility; using System.Collections.Generic; using GThinking.N_MISPRO.Caching; namespace GThinking.N_XLXSBJ { public partial class JGBML_SelJGBList : SingleGridBase { JGBML_SelJGB entity = new JGBML_SelJGB(); protected void Page_Load(object sender, EventArgs e) { this.UMID = 100860018; this.UMName = "线缆销售报价价格目录"; this.CurMaster = Master; this.ModuleGV = ContentGrid; this.CurEntity = entity; this.PageHeight = 600; this.PageWidth = 750; base.DataKeyNames = new string[] { "XLXSJGB_JGBID" }; Master.EnableNewBtn = false; Master.EnableCopyBtn = false; Master.EnableViewBtn = false; Master.EnableEditBtn = false; Master.EnableDeleteBtn = false; Master.EnableQueryBtn = false; base.InitPage(); if (!IsPostBack) { Master_OnStandardQuery(null, null); } } #region 模板继承事件 protected override void Master_OnStandardQuery(object sender, EventArgs e) { base.Master_OnStandardQuery(sender, e); entity.EntityTable.QuerySelSql = GetQuerySql(); entity.GridDataBind(ContentGrid, tSession); } protected override void moduleGV_PageIndexChanging(object sender, GridViewPageEventArgs e) { entity.EntityTable.QuerySelSql = GetQuerySql(); ContentGrid.SelectedIndex = -1; base.moduleGV_PageIndexChanging(sender, e); } #endregion #region 自定义方法 private string GetQuerySql() { Dictionary dicJGBIDS = GetJGBIDS(PageParam.GetRTrimString("JGBID"), PageParam.GetRTrimString("MXBH")); string sSQL = " select XLXSJGB_JGBID,XLXSJGB_YXQS,XLXSJGB_YXQZ,XLXSJGB_JGBMC, "; if (dicJGBIDS.Count > 0) { string sJGBIDS = ""; sSQL += "case "; foreach (string sKey in dicJGBIDS.Keys) { if (!sJGBIDS.Equals("")) sJGBIDS += ","; sJGBIDS += "'" + sKey + "'"; sSQL += " when XLXSJGB_JGBID = '" + sKey + "' then " + dicJGBIDS[sKey]; } sSQL += " else 0 end as PX, "; sSQL += " case when XLXSJGB_JGBID in (" + sJGBIDS + ") then 'Y' else 'N' end as SY "; } else { sSQL += " 0 as PX, 'N' as SY "; } sSQL += " from XLXSJGB where XLXSJGB_MXBH='JGB' and XLXSJGB_TJYS='1' and XLXSJGB_JGBID<>'" + PageParam.GetRTrimString("JGBID") + "' "; if (!GetOption("BJU016").Equals("")) { sSQL += " and (isnull(XLXSJGB_CPMLID,' ')=' ' or " + CMISproDataBase.GetWhereEqual("XLXSJGB_CPMLID", GetOption("BJU016")) + ") "; } sSQL += " order by SY desc ,PX,XLXSJGB_YXQS desc,XLXSJGB_JGBID "; return sSQL; } private Dictionary GetJGBIDS(string sJGBID,string sMXBH) { Dictionary dicJGBIDS = new Dictionary(); TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); TSQL SQL = new TSQL(dberp); SQL.Clear(); SQL.Add(" select XLXSJGB_JGBIDS from XLXSJGB where XLXSJGB_JGBID = :pJGBID and XLXSJGB_MXBH = :pMXBH "); SQL.ParamByName("pJGBID").Value = sJGBID; SQL.ParamByName("pMXBH").Value = sMXBH; DataSet ds = dberp.OpenDataSet(SQL); if (ds.Tables[0].Rows.Count > 0) { string sJGBIDS = ds.Tables[0].Rows[0]["XLXSJGB_JGBIDS"].ToString().Trim(); if (!sJGBIDS.Equals("")) { int ipx = 1; foreach (string stJGBID in sJGBIDS.Split(',')) { if (!dicJGBIDS.ContainsKey(stJGBID)) dicJGBIDS.Add(stJGBID, ipx.ToString().Trim()); ipx++; } } } return dicJGBIDS; } #endregion #region 控件事件 protected void ContentGrid_RowDoubleClick(object sender, GThinking.N_CONTROL.RowDoubleClickEventArgs e) { TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); TSQL sql = new TSQL(dberp); string sYJGBID = PageParam.GetRTrimString("JGBID"); string sJGBID = ContentGrid.DataKeys[ContentGrid.SelectedIndex]["XLXSJGB_JGBID"].ToString().Trim(); Dictionary dicJGBIDS = GetJGBIDS(PageParam.GetRTrimString("JGBID"), PageParam.GetRTrimString("MXBH")); if (dicJGBIDS.ContainsKey(sJGBID)) dicJGBIDS.Remove(sJGBID); else { dicJGBIDS.Add(sJGBID, "0"); } string sJGBIDS = ""; if (dicJGBIDS.Count > 0) { foreach (string sKey in dicJGBIDS.Keys) { if (!sJGBIDS.Equals("")) sJGBIDS += ","; sJGBIDS += sKey; } } dberp.ExecSQL(string.Format("update XLXSJGB set XLXSJGB_JGBIDS = '{0}' where XLXSJGB_JGBID='{1}'", sJGBIDS, sYJGBID)); CacheNotify.TableIsUpdated("DBERP", "XLXSJGB"); moduleGV_PageIndexChanging(null, null); FormAreaUpdate(); } #endregion } }