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; using GThinking.N_MISPRO.TableCache; using GThinking.N_WORKFLOW; using System.Drawing; using System.Collections.Generic; namespace GThinking.N_XLXSBJ { public partial class TBYS_ZDFXList : SingleGridBase { TBYS entity = new TBYS(); TBYS_ZDFX_M qryEntity = new TBYS_ZDFX_M(); protected void Page_Load(object sender, EventArgs e) { this.UMID = 100860168; this.UMName = "投标预审"; this.CurMaster = Master; this.ModuleGV = grdContentGrid; this.CurEntity = entity; this.CurQueryEntity = qryEntity; this.sQueryURLTarget = "TBYS_ZDFXQuery.aspx"; this.PageHeight = 500; this.PageWidth = 800; Master.EnableNewBtn = false; Master.EnableEditBtn = false; Master.EnableCopyBtn = false; Master.EnableDeleteBtn = false; Master.EnableViewBtn = false; Master.EnableWorkflowBtn = false; base.DataKeyNames = new string[] { "TBYSB_SPDH", "sBZSPDH" }; if (!IsPostBack) { CurQueryEntity.FieldByName("ND").Value = "2"; if (PageParam.ContainsKey("SPDH")) { CurQueryEntity.FieldByName("BZSPDH").Value = PageParam.GetRTrimString("SPDH").Trim(); } else if (PageParam.ContainsKey("BJDID")) { CurQueryEntity.FieldByName("BZSPDH").Value = PageParam.GetRTrimString("BJDID").Trim(); } InitCXTJ(); } base.InitPage(); if (!IsPostBack) { if (base.IsDefaultExecute) { Master_OnStandardQuery(null, null); } } } private void InitCXTJ() { if (PageParam.ContainsKey("SPDH")) { TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); TSQL SQL = new TSQL(dberp); SQL.Add(" select TBYSB_TBZT, TBYSB_XMMC from TBYSB where TBYSB_SPDH = :pSPDH "); SQL.ParamByName("pSPDH").Value = PageParam.GetRTrimString("SPDH").Trim(); DataSet ds = dberp.OpenDataSet(SQL); if (ds.Tables[0].Rows.Count > 0) { txtBZTBZT.Text = ds.Tables[0].Rows[0]["TBYSB_TBZT"].ToString().Trim(); txtBZXM.Text = ds.Tables[0].Rows[0]["TBYSB_XMMC"].ToString().Trim(); } } else if (PageParam.ContainsKey("BJDID")) { TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); TSQL SQL = new TSQL(dberp); SQL.Add(" select XLXSBJD_KH, XLXSBJD_XMMC from XLXSBJD where XLXSBJD_BJDID = :pBJDID "); SQL.ParamByName("pBJDID").Value = PageParam.GetRTrimString("BJDID").Trim(); DataSet ds = dberp.OpenDataSet(SQL); if (ds.Tables[0].Rows.Count > 0) { txtBZTBZT.Text = ds.Tables[0].Rows[0]["XLXSBJD_KH"].ToString().Trim(); txtBZXM.Text = ds.Tables[0].Rows[0]["XLXSBJD_XMMC"].ToString().Trim(); } } } 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 moduleGV_PageIndexChanging(object sender, GridViewPageEventArgs e) { base.InitEntityByCondition(); entity.EntityTable.QuerySelSql = GetSQL(); grdContentGrid.SelectedIndex = -1; base.moduleGV_PageIndexChanging(sender, e); } protected void btnCXCX_Click(object sender, EventArgs e) { entity.Param.Clear(); moduleGV_PageIndexChanging(null, null); } private string GetSQL() { string sBZSPDH = ""; if (PageParam.ContainsKey("SPDH")) sBZSPDH = PageParam.GetRTrimString("SPDH"); else sBZSPDH = CurQueryEntity.FieldByName("BZSPDH").Value.Trim(); string sTBZT = txtBZTBZT.Text.Trim(); string sXM = txtBZXM.Text.Trim(); StringBuilder sSQL = new StringBuilder(); sSQL.AppendLine("select TBYSB_SPDH, TBYSB_TBRQ, TBYSB_TBZT, TBYSB_XMMC, TBYSB_FQR, TBYSB_TBJE, :pSPDH as sBZSPDH, "); sSQL.AppendLine(" TBYSB_WHR,TBYSB_WHRID,TBYSB_WHSJ, "); sSQL.AppendLine(" case "); sSQL.AppendLine(" when (TBYSB_TBZT='" + sTBZT + "' and TBYSB_XMMC='" + sXM + "' and '" + sTBZT + "'<>'' and '" + sXM + "'<>'') then '客户,项目名称重复;' "); sSQL.AppendLine(" when (TBYSB_TBZT='" + sTBZT + "' and '" + sTBZT + "'<>'') then '客户重复;' "); sSQL.AppendLine(" when (TBYSB_XMMC='" + sXM + "' and '" + sXM + "'<>'') then '项目名称重复;' "); sSQL.AppendLine(" else ' ' end as ZDLX "); sSQL.AppendLine(" from TBYSB "); sSQL.AppendLine(" where TBYSB_SPDH <> :pSPDH "); if (string.IsNullOrEmpty(CurQueryEntity.FieldByName("ZDLX").Value.Trim())) { sSQL.AppendLine(" and ( "); sSQL.AppendLine(" (TBYSB_TBZT='" + sTBZT + "' and '" + sTBZT + "'<>'') "); sSQL.AppendLine(" or (TBYSB_XMMC='" + sXM + "' and '" + sXM + "'<>'') "); sSQL.AppendLine(" ) "); } if (!string.IsNullOrEmpty(CurQueryEntity.FieldByName("ZDLX").Value.Trim())) { string sQueryZDLX = CurQueryEntity.FieldByName("ZDLX").Value.Trim(); sSQL.AppendLine(" and ( "); string[] zdlxArray = sQueryZDLX.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < zdlxArray.Length; i++) { if (i > 0) { sSQL.AppendLine(" or "); } if (zdlxArray[i].Equals("2")) // 客户重复 { sSQL.AppendLine(" (TBYSB_TBZT='" + sTBZT + "' and '" + sTBZT + "'<>'') "); } else if (zdlxArray[i].Equals("3")) // 项目名称重复 { sSQL.AppendLine(" (TBYSB_XMMC='" + sXM + "' and '" + sXM + "'<>'') "); } } sSQL.AppendLine(" ) "); } if (!string.IsNullOrEmpty(CurQueryEntity.FieldByName("ZCSPDH").Value.Trim())) { sSQL.AppendLine(" and TBYSB_SPDH like :pZCSPDH "); entity.Param.Add("pZCSPDH", "%" + CurQueryEntity.FieldByName("ZCSPDH").Value.Trim() + "%"); } if (!string.IsNullOrEmpty(CurQueryEntity.FieldByName("STATE").Value.Trim())) { sSQL.AppendLine(" and " + CMISproDataBase.GetWhereEqual("TBYSB_WPID", CurQueryEntity.FieldByName("STATE").Value.Trim())); } sSQL.AppendLine(CMISproDataBase.GetTimeConditionSQL("TBYSB_TBRQ", CurQueryEntity.FieldByName("TBRQS").Value.ToString().Trim(), CurQueryEntity.FieldByName("TBRQZ").Value.ToString().Trim(), DateTimeType.dtDate, DateTimeType.dtDate)); if (!string.IsNullOrEmpty(CurQueryEntity.FieldByName("TBZT").Value.Trim())) { sSQL.AppendLine(" and TBYSB_TBZT like :pTBZT "); entity.Param.Add("pTBZT", "%" + CurQueryEntity.FieldByName("TBZT").Value.Trim() + "%"); } if (!string.IsNullOrEmpty(CurQueryEntity.FieldByName("XMMC").Value.Trim())) { sSQL.AppendLine(" and TBYSB_XMMC like :pXMMC "); entity.Param.Add("pXMMC", "%" + CurQueryEntity.FieldByName("XMMC").Value.Trim() + "%"); } double dND = CMISproConvert.StrToFloat(CurQueryEntity.FieldByName("ND").Value.Trim(), 1); if (dND != 0) { int dYF = (int)((dND - (int)dND) * 12); sSQL.AppendLine(" and TBYSB_TBRQ >= DATEADD(month,-" + dYF + ",DATEADD(year, -" + (int)dND + ", getdate())) "); } sSQL.AppendLine(" order by TBYSB_TBRQ desc, TBYSB_SPDH desc "); entity.Param.Add("pSPDH", sBZSPDH); return sSQL.ToString(); } protected void grdContentGrid_RowDoubleClick(object sender, GThinking.N_CONTROL.RowDoubleClickEventArgs e) { string sSPDH = grdContentGrid.DataKeys[grdContentGrid.SelectedIndex]["TBYSB_SPDH"].ToString().Trim(); string sBZSPDH = grdContentGrid.DataKeys[grdContentGrid.SelectedIndex]["sBZSPDH"].ToString().Trim(); TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); TSQL SQL = new TSQL(dberp); SQL.Add(" select TBYSB_WFID, TBYSB_WFINST from TBYSB where TBYSB_SPDH = :pSPDH "); SQL.ParamByName("pSPDH").Value = sSPDH; DataSet ds = dberp.OpenDataSet(SQL); string sWFID = ""; string sWFINST = ""; if (ds.Tables[0].Rows.Count > 0) { sWFID = ds.Tables[0].Rows[0]["TBYSB_WFID"].ToString().Trim(); sWFINST = ds.Tables[0].Rows[0]["TBYSB_WFINST"].ToString().Trim(); } TPageParams tpp = new TPageParams(); tpp.UrlPath = "TBYSInfo.aspx"; tpp.AddString("TBYSB_SPDH", sSPDH); tpp.AddString("WFID", sWFID); tpp.AddString("WFINST", sWFINST); tpp.CallAction = TPageCallAction.pcaBrowse; OpenDialog(tpp); } } }