#region 功能说明 /* * 参数说明: * 注意事项: * 更新记录: */ #endregion 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_MISPRO.Data; using GThinking.N_PUBLIC; using System.Text; using GThinking.N_MISPRO.Utility; namespace GThinking.N_XLXSBJ { public partial class YWYList : SingleGridBase { XSY entity = new XSY(); XSY_M qryEntity = new XSY_M(); #region Page类事件继承 protected void Page_Load(object sender, EventArgs e) { this.UMID = 100860006; this.UMName = "线缆销售报价销售员"; this.CurMaster = Master; this.ModuleGV = grdContentGrid; this.CurEntity = entity; this.CurQueryEntity = qryEntity; this.sURLTarget = "YWYInfo.aspx"; this.sQueryURLTarget = "YWYQuery.aspx"; this.PageHeight = 600; this.PageWidth = 750; base.DataKeyNames = new string[] { "XSY_TXY" }; if (!IsPostBack) { CurQueryEntity.FieldByName("PXFS").Value = "XM"; } base.InitPage(); if (!IsPostBack) { Master_OnStandardQuery(null, null); } } #endregion #region 模板事件继承 protected override void Master_OnStandardQuery(object sender, EventArgs e) { base.InitEntityByCondition(); entity.EntityTable.QuerySelSql = GetSQL(); base.Master_OnStandardQuery(sender, e); entity.GridDataBind(grdContentGrid, tSession); } protected override void BeforeDelete(TDatabase db, ref bool ActionIsDone) { entity.Param.Add("XSY_TXY", this.grdContentGrid.SelectedDataKey["XSY_TXY"].ToString().Trim()); base.BeforeDelete(db, ref ActionIsDone); } protected override bool Master_BeforeDeleteAction(object sender, EventArgs e) { bool bReturn = base.Master_BeforeDeleteAction(sender, e); return bReturn; } protected override bool Master_AfterDeleteAction(object sender, EventArgs e) { if (!base.Master_AfterDeleteAction(sender, e)) return false; base.InitEntityByCondition(); entity.EntityTable.QuerySelSql = GetSQL(); entity.GridDataBind(grdContentGrid, tSession); grdContentGrid.SelectedIndex = -1; return true; } protected override void moduleGV_Sorting(object sender, GridViewSortEventArgs e) { base.moduleGV_Sorting(sender, e); } protected override void moduleGV_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if ((e.Row.Cells[7].Text.Trim() != "") && (e.Row.Cells[7].Text.Trim() != " ")) { e.Row.Cells[7].Text = GetDQXX(e.Row.Cells[7].Text.Trim()); } LinkPageParam.AddString("XSY_TXY", grdContentGrid.DataKeys[e.Row.RowIndex]["XSY_TXY"].ToString().Trim()); } base.moduleGV_RowDataBound(sender, e); } protected override void moduleGV_PageIndexChanging(object sender, GridViewPageEventArgs e) { base.InitEntityByCondition(); entity.EntityTable.QuerySelSql = GetSQL(); grdContentGrid.SelectedIndex = -1; base.moduleGV_PageIndexChanging(sender, e); } #endregion #region 自定义函数 private string GetSQL() { StringBuilder sSQL = new StringBuilder(); sSQL.AppendLine("select XSY_TXY, XSY_ZJM, XSY_ZZ, XSY_SJ, XSY_DH, XSY_WHR, XSY_WHRID, XSY_WHSJ, XSY_XSYBH, XSY_QYRQ, XSY_TYRQ, XSY_TYBZ,"); sSQL.AppendLine(" case isnull(XSY_BMID,' ') when ' ' then ' ' else rtrim(XSY_BMID)||'|'||BM_MC end as XSBM, "); sSQL.AppendLine(" case isnull(XSY_XSQYID,' ') when ' ' then ' ' else rtrim(XSY_XSQYID)||'|'||XSQY_XSQYMC end as XSQY, "); sSQL.AppendLine(" XSY_DQ, "); sSQL.AppendLine(" XSY_RSGWMC, XSY_SJXSYBH, SJ.SJXSYMC as SJXSYMC,"); sSQL.AppendLine(" XSY_RYID,XSY_GH,XSY_RYMC,case isnull(XSY_GH,' ') when ' ' then ' ' else rtrim(XSY_GH)||'|'||rtrim(XSY_RYMC) end as XSY_YH "); sSQL.AppendLine("from XSY "); sSQL.AppendLine("left join BM on BM_BMID=XSY_BMID "); sSQL.AppendLine("left join XSQY on XSQY_XSQYID=XSY_XSQYID "); //sSQL.AppendLine("left join KHDQ on KHDQ_DQID=XSY_DQ "); sSQL.AppendLine(" "); sSQL.AppendLine("left join (select XSY_TXY as SJXSYMC, XSY_XSYBH as XSYBH from XSY) SJ on SJ.XSYBH=XSY_SJXSYBH "); sSQL.AppendLine("where 1=1 "); if (!string.IsNullOrEmpty(CurQueryEntity.FieldByName("SFTY").Value.Trim())) { sSQL.AppendLine(" and isnull(XSY_TYBZ,'N') = :pSFTY "); entity.Param.Add("pSFTY", CurQueryEntity.FieldByName("SFTY").Value.Trim()); } if (!string.IsNullOrEmpty(CurQueryEntity.FieldByName("XSQY").Value.Trim())) { sSQL.AppendLine(" and " + CMISproDataBase.GetWhereLead("XSY_XSQYID", CurQueryEntity.FieldByName("XSQY").Value.Trim())); } if (!string.IsNullOrEmpty(CurQueryEntity.FieldByName("BMID").Value.Trim())) { sSQL.AppendLine(" and " + CMISproDataBase.GetWhereEqual("XSY_BMID", CurQueryEntity.FieldByName("BMID").Value.Trim())); } if (!string.IsNullOrEmpty(CurQueryEntity.FieldByName("XSYBM").Value.Trim())) { sSQL.AppendLine("and XSY_XSYBH like :pXSY_XSYBH "); entity.Param.Add("pXSY_XSYBH", "%" + CurQueryEntity.FieldByName("XSYBM").Value.ToString().Trim() + "%"); } if (!string.IsNullOrEmpty(CurQueryEntity.FieldByName("XSYXM").Value.Trim())) { sSQL.AppendLine("and XSY_TXY like :pXSY_TXY "); entity.Param.Add("pXSY_TXY", "%" + CurQueryEntity.FieldByName("XSYXM").Value.ToString().Trim() + "%"); } if (!string.IsNullOrEmpty(CurQueryEntity.FieldByName("SJXSYBM").Value.Trim())) { sSQL.AppendLine("and XSY_SJXSYBH like :pXSY_SJXSYBH "); entity.Param.Add("pXSY_SJXSYBH", "%" + CurQueryEntity.FieldByName("SJXSYBM").Value.ToString().Trim() + "%"); } if (!string.IsNullOrEmpty(CurQueryEntity.FieldByName("SJXSYXM").Value.Trim())) { sSQL.AppendLine("and SJXSYMC like :SJXSYMC "); entity.Param.Add("SJXSYMC", "%" + CurQueryEntity.FieldByName("SJXSYXM").Value.ToString().Trim() + "%"); } if (!string.IsNullOrEmpty(CurQueryEntity.FieldByName("GH").Value.Trim())) { sSQL.AppendLine(" and " + CMISproDataBase.GetWhereEqual("XSY_GH", CurQueryEntity.FieldByName("GH").Value.Trim())); } if (CurQueryEntity.FieldByName("PXFS").Value.Trim().Equals("XM")) { sSQL.AppendLine(" order by XSY_TXY"); } else if (CurQueryEntity.FieldByName("PXFS").Value.Trim().Equals("BH")) { sSQL.AppendLine(" order by XSY_XSYBH"); } else if (CurQueryEntity.FieldByName("PXFS").Value.Trim().Equals("QYXSY")) { sSQL.AppendLine(" order by XSY_XSQYID,XSY_XSYBH"); } else if (CurQueryEntity.FieldByName("PXFS").Value.Trim().Equals("BMXSY")) { sSQL.AppendLine(" order by XSY_BMID,XSY_XSYBH"); } else { sSQL.AppendLine(" order by XSY_TXY"); } return sSQL.ToString(); } private string GetDQXX(string sDQIDList) { string[] sDQIDs = sDQIDList.Trim().Split(','); string Result = ""; for (int i = 0; i < sDQIDs.Length; i++) { Result += sDQIDs[i].Trim() + "|" + GetDQMC(sDQIDs[i].Trim()) + ","; } return Result.TrimEnd(','); } private string GetDQMC(string sDQID) { TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); TSQL sql = new TSQL(dberp); sql.Add("select KHDQ_DQMC from KHDQ where KHDQ_DQID=:pDQID "); sql.ParamByName("pDQID").Value = sDQID.Trim(); DataSet ds = dberp.OpenDataSet(sql); string sDQMC = ""; if (ds.Tables[0].Rows.Count > 0) { sDQMC = ds.Tables[0].Rows[0][0].ToString().Trim(); } return sDQMC; } #endregion } }