#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; using System.Drawing; using GThinking.N_CONTROL; namespace GThinking.N_XLXSBJ { public partial class WLHQList : SingleGridBase { XLXSWLHQ entity = new XLXSWLHQ(); XLXSWLHQ_M qryEntity = new XLXSWLHQ_M(); #region Page类事件继承 protected void Page_Load(object sender, EventArgs e) { this.UMID = 100860032; this.UMName = "线缆销售报价物料行情"; this.CurMaster = Master; this.ModuleGV = grdContentGrid; this.CurEntity = entity; this.CurQueryEntity = qryEntity; this.sURLTarget = "WLHQInfo.aspx"; this.sQueryURLTarget = "WLHQQuery.aspx"; this.PageHeight = 600; this.PageWidth = 750; this.Master.EnableNewBtn = false; this.Master.EnableCopyBtn = false; this.Master.EnableDeleteBtn = false; base.sRefreshClientID = btnGRWJGRefer.ClientID; base.DataKeyNames = new string[] { "XLXSWLHQ_WLID", "XLXSWLHQ_YXQS", "HQJCL", "XLXSWLHQ_HSJG", "XLXSWLHQ_HSCGJG", "XLXSBJCL_TYBZ" }; if (!IsPostBack) { CurQueryEntity.FieldByName("CKRQ").Value = DateTime.Now.Date.ToString(); if (!string.IsNullOrEmpty(PageParam.GetRTrimString("XLXSCLHQ_BJCLID"))) { CurQueryEntity.FieldByName("BJCL").Value = PageParam.GetRTrimString("XLXSCLHQ_BJCLID"); } } grdContentGrid.FindColumnExByFieldName("XLXSWLHQ_WSJG").NumberDecimalPlace = XLBJDUtils.BJCLPriceDecimal; grdContentGrid.FindColumnExByFieldName("XLXSWLHQ_HSJG").NumberDecimalPlace = XLBJDUtils.BJCLPriceDecimal; grdContentGrid.FindColumnExByFieldName("XLXSWLHQ_WSJGF").NumberDecimalPlace = XLBJDUtils.BJCLPriceDecimal; grdContentGrid.FindColumnExByFieldName("XLXSWLHQ_HSJGF").NumberDecimalPlace = XLBJDUtils.BJCLPriceDecimal; grdContentGrid.FindColumnExByFieldName("XLXSWLHQ_WSCGJG").NumberDecimalPlace = XLBJDUtils.BJCLPriceDecimal; grdContentGrid.FindColumnExByFieldName("XLXSWLHQ_HSCGJG").NumberDecimalPlace = XLBJDUtils.BJCLPriceDecimal; base.InitPage(); this.Master.StandardEditButton.OnClientClick = ""; this.Master.StandardEditButton.Click += new EventHandler(StandardEditButton_Click); //权限控制 bool p_CanInsert = false; bool p_CanEdit = false; bool p_CanDelete = false; bool p_CanPrint = false; tSession.GetRights(this.UMID, out p_CanInsert, out p_CanEdit, out p_CanDelete, out p_CanPrint); string sBJU013 = GetOption("BJU013"); btnUpdatePrice.Enabled = false; if (sBJU013.Equals("1") || !p_CanEdit) { btnUpdatePrice.Enabled = false; } else { btnUpdatePrice.Enabled = true; } if (p_CanEdit) { btnPLTZ.Enabled = true; } else { btnPLTZ.Enabled = false; } if (!IsPostBack) { Master_OnStandardQuery(null, null); } } #endregion #region 模板事件继承 protected override void Master_OnStandardQuery(object sender, EventArgs e) { base.InitEntityByCondition(); //更新采购价格按钮仅查询条件参考日期为当天时可见 if (CMISproConvert.ConvertDate(CurQueryEntity.FieldByName("CKRQ").Value.Trim()).Equals(CMISproConvert.ConvertDate(DateTime.Now)) && XLXSWLHQ.CheckModule("100486007", tSession.UserId)) { btnUpdatePrice.Visible = true; } else { btnUpdatePrice.Visible = false; } //批量调整 if (CMISproConvert.ConvertDate(CurQueryEntity.FieldByName("CKRQ").Value.Trim()).Equals(CMISproConvert.ConvertDate(DateTime.Now))) { btnPLTZ.Visible = true; } else { btnPLTZ.Visible = false; } 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("OLD_XLXSWLHQ_WLID", this.grdContentGrid.SelectedDataKey["OLD_XLXSWLHQ_WLID"].ToString()); entity.Param.Add("OLD_XLXSWLHQ_YXQS", this.grdContentGrid.SelectedDataKey["XLXSWLHQ_YXQS"].ToString()); 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_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { LinkPageParam.AddString("XLXSWLHQ_WLID", grdContentGrid.DataKeys[e.Row.RowIndex]["XLXSWLHQ_WLID"].ToString().Trim()); LinkPageParam.AddString("XLXSWLHQ_YXQS", grdContentGrid.DataKeys[e.Row.RowIndex]["XLXSWLHQ_YXQS"].ToString().Trim()); //如果采购价格和材料价格同时为空,则行情价差率不需要标红 bool bNeedFlag = (CMISproConvert.StrToFloat(grdContentGrid.DataKeys[e.Row.RowIndex]["XLXSWLHQ_HSJG"].ToString().Trim()) == 0) && (CMISproConvert.StrToFloat(grdContentGrid.DataKeys[e.Row.RowIndex]["XLXSWLHQ_HSCGJG"].ToString().Trim()) == 0); int indexHQJCL = grdContentGrid.Columns.IndexOf(grdContentGrid.FindColumnByFieldName("HQJCL")) + 1; if (CMISproConvert.StrToFloat(grdContentGrid.DataKeys[e.Row.RowIndex]["HQJCL"].ToString().Trim()) <= 0 && !bNeedFlag) { e.Row.Cells[indexHQJCL].BackColor = System.Drawing.Color.Red;//第indexHQJCL列的颜色 } } 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 XLXSBJCLWL_WLID as XLXSWLHQ_WLID,WL_MC,WL_GG,WL_TZ, WL_CL, isnull(XLXSBJCL_ZZSL,0.0) as XLXSBJCL_ZZSL, rtrim(XLXSBJCL_BJCLID)||'|'||XLXSBJCL_BJCLMC as BJCL, "); sSQL.AppendLine(" isnull(XLXSWLHQ_WSJG,0.0) as XLXSWLHQ_WSJG ,isnull(XLXSWLHQ_HSJG,0.0) as XLXSWLHQ_HSJG ,XLXSWLHQ_YXQS,XLXSWLHQ_YXQZ,isnull(XLXSWLHQ_BZ, ' ') as XLXSWLHQ_BZ ,isnull(XLXSWLHQ_WHRID, ' ') as XLXSWLHQ_WHRID,isnull(XLXSWLHQ_WHR, ' ') as XLXSWLHQ_WHR , XLXSWLHQ_WHSJ, "); sSQL.AppendLine(" isnull(XLXSWLHQ_WSJGF,0.0) as XLXSWLHQ_WSJGF ,isnull(XLXSWLHQ_HSJGF,0.0) as XLXSWLHQ_HSJGF,isnull(XLXSWLHQ_WSCGJG,0.0) as XLXSWLHQ_WSCGJG ,isnull(XLXSWLHQ_HSCGJG,0.0) as XLXSWLHQ_HSCGJG,isnull(XLXSBJCL_TYBZ,'N') as XLXSBJCL_TYBZ, "); //“行情价差率%”计算公式改为:含税材料价格/含税采购价格-1,当行情价差率≤0时,标红警示。 sSQL.AppendLine(" case when isnull(XLXSWLHQ_HSCGJG,0.0) = 0.0 then 0.0 else RoundFix((isnull(XLXSWLHQ_HSJG,0.0) - isnull(XLXSWLHQ_HSCGJG,0.0))/isnull(XLXSWLHQ_HSCGJG,0.0),14)*100 end as HQJCL, "); sSQL.AppendLine(" XLXSBJCL_QYRQ,isnull(XLXSBJCL_TYBZ,'N') as XLXSBJCL_TYBZ,XLXSBJCL_TYRQ "); sSQL.AppendLine(" from XLXSBJCLWL left join "); sSQL.AppendLine(" ( "); sSQL.AppendLine(" select XLXSWLHQ_WLID,XLXSWLHQ_WSJG,XLXSWLHQ_HSJG,XLXSWLHQ_WSJGF,XLXSWLHQ_HSJGF,XLXSWLHQ_WSCGJG,XLXSWLHQ_HSCGJG,XLXSWLHQ_YXQS,XLXSWLHQ_YXQZ,XLXSWLHQ_BZ,XLXSWLHQ_WHRID,XLXSWLHQ_WHR,XLXSWLHQ_WHSJ "); sSQL.AppendLine(" from XLXSWLHQ, "); sSQL.AppendLine(" ( "); sSQL.AppendLine(" select XLXSWLHQ_WLID as WLID,max(XLXSWLHQ_YXQS) as maxYXQS "); sSQL.AppendLine(" from XLXSWLHQ "); sSQL.AppendLine(" where XLXSWLHQ_JGBID=' ' "); sSQL.AppendLine(" and XLXSWLHQ_YXQS<=:pCKRQ and (XLXSWLHQ_YXQZ is null or XLXSWLHQ_YXQZ>=:pCKRQ) "); entity.Param.Add("pCKRQ", CurQueryEntity.FieldByName("CKRQ").Value); sSQL.AppendLine(" group by XLXSWLHQ_WLID "); sSQL.AppendLine(" ) b "); sSQL.AppendLine(" where XLXSWLHQ_JGBID=' ' "); sSQL.AppendLine(" and XLXSWLHQ_WLID=WLID "); sSQL.AppendLine(" and XLXSWLHQ_YXQS=maxYXQS "); sSQL.AppendLine(" ) a on XLXSWLHQ_WLID=XLXSBJCLWL_WLID "); sSQL.AppendLine(" left join WL on WL_WLID = XLXSBJCLWL_WLID "); sSQL.AppendLine(" left join XLXSBJCL on XLXSBJCL_BJCLID = XLXSBJCLWL_BJCLID "); sSQL.AppendLine(" where isnull(XLXSBJCL_BJCLMC, ' ')<> ' ' and XLXSBJCL_BJHQ = '2' "); if (!CurQueryEntity.FieldByName("BJCLID").Value.Trim().Equals("")) { sSQL.AppendLine(" and XLXSBJCL_BJCLID like :BJCLID "); entity.Param.Add("BJCLID", "%" + CurQueryEntity.FieldByName("BJCLID").Value.Trim() + "%"); } if (!CurQueryEntity.FieldByName("BJCLMC").Value.Trim().Equals("")) { sSQL.AppendLine(" and XLXSBJCL_BJCLMC like :pBJCLMC "); entity.Param.Add("pBJCLMC", "%" + CurQueryEntity.FieldByName("BJCLMC").Value.Trim() + "%"); } if (!CurQueryEntity.FieldByName("BJCL").Value.Trim().Equals("")) { sSQL.AppendLine(" and XLXSBJCL_BJCLID = :pBJCL"); entity.Param.Add("pBJCL", CurQueryEntity.FieldByName("BJCL").Value.Trim()); } if (!CurQueryEntity.FieldByName("WLID").Value.Trim().Equals("")) { sSQL.AppendLine(" and XLXSBJCLWL_WLID like :pWLID "); entity.Param.Add("pWLID", "%" + CurQueryEntity.FieldByName("WLID").Value.Trim() + "%"); } if (!CurQueryEntity.FieldByName("WLMC").Value.Trim().Equals("")) { sSQL.AppendLine(" and WL_MC like :pWLMC "); entity.Param.Add("pWLMC", "%" + CurQueryEntity.FieldByName("WLMC").Value.Trim() + "%"); } if (!CurQueryEntity.FieldByName("GGXH").Value.Trim().Equals("")) { sSQL.AppendLine(" and WL_GG like :pGGXH "); entity.Param.Add("pGGXH", "%" + CurQueryEntity.FieldByName("GGXH").Value.Trim() + "%"); } if (!CurQueryEntity.FieldByName("TH").Value.Trim().Equals("")) { sSQL.AppendLine(" and WL_TZ like :pTH "); entity.Param.Add("pTH", "%" + CurQueryEntity.FieldByName("TH").Value.Trim() + "%"); } if (!CurQueryEntity.FieldByName("CZ").Value.Trim().Equals("")) { sSQL.AppendLine(" and WL_CL like :pCZ "); entity.Param.Add("pCZ", "%" + CurQueryEntity.FieldByName("CZ").Value.Trim() + "%"); } if (!CurQueryEntity.FieldByName("PSQK").Value.ToString().Trim().Equals("")) { string sWLIDList = ""; getPSCLWL(ref sWLIDList); if (CurQueryEntity.FieldByName("PSQK").Value.ToString().Trim().Equals("已派生材料物料")) { sSQL.AppendLine(" and " + GetWhereEqual("XLXSBJCLWL_WLID", sWLIDList)); } else if (CurQueryEntity.FieldByName("PSQK").Value.ToString().Trim().Equals("未派生材料物料")) { sSQL.AppendLine(" and " + GetWhereNotEqual("XLXSBJCLWL_WLID", sWLIDList)); } } if (CurQueryEntity.FieldByName("HQWS").Value.Trim().ToUpper().Equals("TRUE")) { sSQL.AppendLine(" and isnull(XLXSWLHQ_WLID,' ') = ' ' "); } if (!CurQueryEntity.FieldByName("XSTYCL").Value.Trim().ToUpper().Equals("TRUE")) { sSQL.AppendLine(" and isnull(XLXSBJCL_TYBZ,'N') <> 'Y' "); } sSQL.AppendLine(" order by XLXSWLHQ_WLID "); return sSQL.ToString(); } private void getPSCLWL(ref string sWLIDList) { base.InitEntityByCondition(); TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); TSQL SQL = new TSQL(dberp); SQL.Clear(); if (!CurQueryEntity.FieldByName("PSQK").Value.ToString().Trim().Equals("")) { SQL.Add(" select WLID00 from ( "); for (int i = 1; i <= 80; i++) { if (i != 1) { SQL.Add(" union all "); } SQL.Add(" select distinct ISNULL(XLXSCLQDWL_WLID" + i.ToString().PadLeft(2, '0') + ",' ') as WLID00 from XLXSCLQDWL where 1 = 1 "); } SQL.Add(" ) c where 1=1 and c.WLID00 <> ' ' "); DataSet ds = dberp.OpenDataSet(SQL); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (!ds.Tables[0].Rows[i][0].ToString().Trim().Equals("")) { sWLIDList = sWLIDList + ds.Tables[0].Rows[i][0].ToString().Trim() + ","; } } sWLIDList = sWLIDList.TrimStart(',').TrimEnd(','); } } } public string GetWhereEqual(string p_FieldName, string p_Values) { p_Values = p_Values.Replace(",", "' or " + p_FieldName + "='"); p_Values = p_FieldName + "='" + p_Values + "'"; p_Values = "(" + p_Values + ")"; return p_Values; } public string GetWhereNotEqual(string p_FieldName, string p_Values) { p_Values = p_Values.Replace(",", "' and " + p_FieldName + "<>'"); p_Values = p_FieldName + "<>'" + p_Values + "'"; p_Values = "(" + p_Values + ")"; return p_Values; } private void OpenInfo(TPageCallAction tpCallAction) { base.InitEntityByCondition(); string sWLID = grdContentGrid.DataKeys[grdContentGrid.SelectedIndex]["XLXSWLHQ_WLID"].ToString().Trim(); string sYXQS = grdContentGrid.DataKeys[grdContentGrid.SelectedIndex]["XLXSWLHQ_YXQS"].ToString().Trim(); TPageParams tpp = new TPageParams(); tpp.UrlPath = "WLHQInfo.aspx"; tpp.AddString("XLXSWLHQ_WLID", sWLID); tpp.AddString("XLXSWLHQ_YXQS", sYXQS); tpp.CallAction = tpCallAction; OpenDialog(tpp); } #endregion #region 控件事件 //关闭info页面自动刷新--sRefreshClientID protected void btnGRWJGRefer_Click(object sender, EventArgs e) { int tmpIndex = grdContentGrid.SelectedIndex; moduleGV_PageIndexChanging(null, null); grdContentGrid.SelectedIndex = tmpIndex; } protected void btnCallBack_Click(object sender, EventArgs e) { string[] RowsArry; if (string.IsNullOrEmpty(grdContentGrid.CheckedRowIndexs) && grdContentGrid.SelectedIndex <= -1) { return; } if (grdContentGrid.CheckBox && !String.IsNullOrEmpty(grdContentGrid.CheckedRowIndexs)) { RowsArry = grdContentGrid.CheckedRowIndexs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } else { RowsArry = new string[1]; RowsArry[0] = grdContentGrid.SelectedIndex.ToString(); } string sWLID = ""; bool bUpdate = false; bool bToday = true; string sCGU009 = GetOption(100486007, "CGU009"); string sBJU013 = GetOption("BJU013"); bool HasRights = XLXSWLHQ.CheckModule("100486007", tSession.UserId); double fZZSL = 13.0; double fWSJG = 0.0; double fHSJG = 0.0; double fWSJGF = 0.0; double fHSJGF = 0.0; double fWSCGJG = 0.0; double fHSCGJG = 0.0; TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); TSQL SQL = new TSQL(dberp); SQL.Clear(); //点击更新采购价格,先判断有没有当天的物料行情记录,若没有则自动插入当天的物料行情、再更新当天物料行情的采购价格;否则直接更新当天物料行情的采购价格 for (int i = 0; i < RowsArry.Length; i++) { sWLID = grdContentGrid.DataKeys[CMISproConvert.StrToInt(RowsArry[i])]["XLXSWLHQ_WLID"].ToString().Trim(); SQL.Clear(); SQL.Add("select XLXSWLHQ_WSJG,XLXSWLHQ_HSJG,XLXSWLHQ_WSJGF,XLXSWLHQ_HSJGF,XLXSWLHQ_WSCGJG,XLXSWLHQ_HSCGJG,XLXSBJCL_ZZSL from XLXSWLHQ "); SQL.Add(" left join XLXSBJCLWL on XLXSBJCLWL_WLID = XLXSWLHQ_WLID "); SQL.Add(" left join XLXSBJCL on XLXSBJCL_BJCLID = XLXSBJCLWL_BJCLID "); SQL.Add(" where XLXSWLHQ_JGBID =' ' and XLXSWLHQ_WLID = :pWLID order by XLXSWLHQ_YXQS desc "); SQL.ParamByName("pWLID").Value = sWLID; DataSet dsUpdate = dberp.OpenDataSet(SQL); if (dsUpdate.Tables[0].Rows.Count > 0) { bUpdate = true; fZZSL = CMISproConvert.StrToFloat(dsUpdate.Tables[0].Rows[0]["XLXSBJCL_ZZSL"].ToString().Trim()); fWSJG = CMISproConvert.StrToFloat(dsUpdate.Tables[0].Rows[0]["XLXSWLHQ_WSJG"].ToString().Trim()); fHSJG = CMISproConvert.StrToFloat(dsUpdate.Tables[0].Rows[0]["XLXSWLHQ_HSJG"].ToString().Trim()); fWSJGF = CMISproConvert.StrToFloat(dsUpdate.Tables[0].Rows[0]["XLXSWLHQ_WSJGF"].ToString().Trim()); fHSJGF = CMISproConvert.StrToFloat(dsUpdate.Tables[0].Rows[0]["XLXSWLHQ_HSJGF"].ToString().Trim()); fWSCGJG = CMISproConvert.StrToFloat(dsUpdate.Tables[0].Rows[0]["XLXSWLHQ_WSCGJG"].ToString().Trim()); fHSCGJG = CMISproConvert.StrToFloat(dsUpdate.Tables[0].Rows[0]["XLXSWLHQ_HSCGJG"].ToString().Trim()); SQL.Clear(); SQL.Add("select XLXSWLHQ_WSJG,XLXSWLHQ_HSJG,XLXSWLHQ_WSJGF,XLXSWLHQ_HSJGF,XLXSWLHQ_WSCGJG,XLXSWLHQ_HSCGJG from XLXSWLHQ "); SQL.Add(" where XLXSWLHQ_JGBID =' ' and XLXSWLHQ_YXQS = Convert(datetime,:pRQ) and XLXSWLHQ_WLID = :pWLID order by XLXSWLHQ_YXQS desc "); SQL.ParamByName("pRQ").Value = CMISproConvert.ConvertDate(DateTime.Now); SQL.ParamByName("pWLID").Value = sWLID; DataSet dsToday = dberp.OpenDataSet(SQL); if (dsToday.Tables[0].Rows.Count > 0) { bToday = true; fWSJG = CMISproConvert.StrToFloat(dsToday.Tables[0].Rows[0]["XLXSWLHQ_WSJG"].ToString().Trim()); fHSJG = CMISproConvert.StrToFloat(dsToday.Tables[0].Rows[0]["XLXSWLHQ_HSJG"].ToString().Trim()); fWSJGF = CMISproConvert.StrToFloat(dsToday.Tables[0].Rows[0]["XLXSWLHQ_WSJGF"].ToString().Trim()); fHSJGF = CMISproConvert.StrToFloat(dsToday.Tables[0].Rows[0]["XLXSWLHQ_HSJGF"].ToString().Trim()); fWSCGJG = CMISproConvert.StrToFloat(dsToday.Tables[0].Rows[0]["XLXSWLHQ_WSCGJG"].ToString().Trim()); fHSCGJG = CMISproConvert.StrToFloat(dsToday.Tables[0].Rows[0]["XLXSWLHQ_HSCGJG"].ToString().Trim()); } else { bToday = false; } } else { bUpdate = false; fWSJG = 0; fHSJG = 0; fWSJGF = 0; fHSJGF = 0; fWSCGJG = 0; fHSCGJG = 0; } if (fZZSL == 0) { fZZSL = 13.0; } //材料价格 //此处调整的材料价格已经过滤,都是无加工原料的 if (txtCallBackFlag.Value.Equals("CLJG")) { fHSJG = CMISproConvert.StrToFloat(txtCallBackNum.Value); fWSJG = NumberUtils.RoundX(fHSJG / (1 + fZZSL / 100.0), XLBJDUtils.BJCLPriceDecimal); if (!bUpdate || !bToday) { //=0 if (HasRights && !sBJU013.Equals("1")) { //含税 fHSCGJG = XLXSWLHQ.GetCGPri(true, sWLID, sCGU009); fWSCGJG = XLXSWLHQ.GetCGPri(false, sWLID, sCGU009); } } } //采购价格 else if (txtCallBackFlag.Value.Equals("CGJG")) { fHSCGJG = CMISproConvert.StrToFloat(txtCallBackNum.Value); fWSCGJG = NumberUtils.RoundX(fHSCGJG / (1 + fZZSL / 100.0), XLBJDUtils.BJCLPriceDecimal); } //有记录,不知道是不是今天的 if (bUpdate) { //更新数据 //不是今天的 if (!bToday) { SQL.Clear(); SQL.Add(" insert into XLXSWLHQ( "); SQL.Add(" XLXSWLHQ_WLID,XLXSWLHQ_JGBID, XLXSWLHQ_WSJG,XLXSWLHQ_HSJG, XLXSWLHQ_WSJGF,XLXSWLHQ_HSJGF, XLXSWLHQ_YXQS, XLXSWLHQ_YXQZ,"); SQL.Add(" XLXSWLHQ_HSCGJG,XLXSWLHQ_WSCGJG, "); SQL.Add(" XLXSWLHQ_BZ, XLXSWLHQ_WHRID, XLXSWLHQ_WHR, XLXSWLHQ_WHSJ )"); SQL.Add(" values("); SQL.Add(" :XLXSWLHQ_WLID,' ', :XLXSWLHQ_WSJG,:XLXSWLHQ_HSJG, :XLXSWLHQ_WSJGF, :XLXSWLHQ_HSJGF, :XLXSWLHQ_YXQS, :XLXSWLHQ_YXQZ,"); SQL.Add(" :XLXSWLHQ_HSCGJG,:XLXSWLHQ_WSCGJG, "); SQL.Add(" :XLXSWLHQ_BZ, :XLXSWLHQ_WHRID, :XLXSWLHQ_WHR, :XLXSWLHQ_WHSJ )"); SQL.ParamByName("XLXSWLHQ_WSJG").Value = fWSJG; SQL.ParamByName("XLXSWLHQ_HSJG").Value = fHSJG; SQL.ParamByName("XLXSWLHQ_WSJGF").Value = fWSJGF; SQL.ParamByName("XLXSWLHQ_HSJGF").Value = fHSJGF; SQL.ParamByName("XLXSWLHQ_WSCGJG").Value = fWSCGJG; SQL.ParamByName("XLXSWLHQ_HSCGJG").Value = fHSCGJG; SQL.ParamByName("XLXSWLHQ_YXQS").Value = CMISproConvert.ConvertDate(DateTime.Now); SQL.ParamByName("XLXSWLHQ_BZ").Value = ""; SQL.ParamByName("XLXSWLHQ_WHR").Value = tSession.UserName; SQL.ParamByName("XLXSWLHQ_WHRID").Value = tSession.UserId; SQL.ParamByName("XLXSWLHQ_WHSJ").Value = DateTime.Now; SQL.ParamByName("XLXSWLHQ_WLID").Value = sWLID; dberp.ExecSQL(SQL); //并找到最近的一条记录,若其有效期止为空就将其置为所保存记录的有效期始减一天。 SQL.Clear(); SQL.Add(" update XLXSWLHQ set XLXSWLHQ_YXQZ=dateadd(day,-1,:pYXQS) "); SQL.Add(" where XLXSWLHQ_JGBID=' '"); SQL.Add(" and XLXSWLHQ_WLID=:pWLID"); SQL.Add(" and XLXSWLHQ_YXQS="); SQL.Add(" ("); SQL.Add(" select max(XLXSWLHQ_YXQS) as maxYXQS"); SQL.Add(" from XLXSWLHQ"); SQL.Add(" where XLXSWLHQ_JGBID=' ' "); SQL.Add(" and XLXSWLHQ_WLID=:pWLID"); SQL.Add(" and XLXSWLHQ_YXQS<=dateadd(day,-1,:pYXQS) "); SQL.Add(" )"); SQL.Add(" and XLXSWLHQ_YXQZ is null "); SQL.ParamByName("pWLID").Value = sWLID; SQL.ParamByName("pYXQS").Value = CMISproConvert.ConvertDate(DateTime.Now); dberp.ExecSQL(SQL); } else { //直接更新今天的 SQL.Clear(); SQL.Add(" update XLXSWLHQ "); SQL.Add(" set XLXSWLHQ_WSJG = :XLXSWLHQ_WSJG,XLXSWLHQ_HSJG=:XLXSWLHQ_HSJG,XLXSWLHQ_HSJGF=:XLXSWLHQ_HSJGF,XLXSWLHQ_WSJGF=:XLXSWLHQ_WSJGF, "); SQL.Add(" XLXSWLHQ_HSCGJG=:XLXSWLHQ_HSCGJG,XLXSWLHQ_WSCGJG=:XLXSWLHQ_WSCGJG, "); SQL.Add(" XLXSWLHQ_YXQS = :XLXSWLHQ_YXQS, XLXSWLHQ_YXQZ = :XLXSWLHQ_YXQZ, XLXSWLHQ_BZ = :XLXSWLHQ_BZ, XLXSWLHQ_WHRID = :XLXSWLHQ_WHRID, XLXSWLHQ_WHR = :XLXSWLHQ_WHR, XLXSWLHQ_WHSJ = :XLXSWLHQ_WHSJ"); SQL.Add(" where XLXSWLHQ_JGBID =' ' and XLXSWLHQ_YXQS= :pRQ and XLXSWLHQ_WLID = :pWLID "); SQL.ParamByName("XLXSWLHQ_WSJG").Value = fWSJG; SQL.ParamByName("XLXSWLHQ_HSJG").Value = fHSJG; SQL.ParamByName("XLXSWLHQ_WSJGF").Value = fWSJGF; SQL.ParamByName("XLXSWLHQ_HSJGF").Value = fHSJGF; SQL.ParamByName("XLXSWLHQ_WSCGJG").Value = fWSCGJG; SQL.ParamByName("XLXSWLHQ_HSCGJG").Value = fHSCGJG; SQL.ParamByName("XLXSWLHQ_YXQS").Value = CMISproConvert.ConvertDate(DateTime.Now); SQL.ParamByName("XLXSWLHQ_BZ").Value = ""; SQL.ParamByName("XLXSWLHQ_WHR").Value = tSession.UserName; SQL.ParamByName("XLXSWLHQ_WHRID").Value = tSession.UserId; SQL.ParamByName("XLXSWLHQ_WHSJ").Value = DateTime.Now; SQL.ParamByName("pRQ").Value = CMISproConvert.ConvertDate(DateTime.Now); SQL.ParamByName("pWLID").Value = sWLID; dberp.ExecSQL(SQL); } } else { //完全无记录 SQL.Clear(); SQL.Add(" insert into XLXSWLHQ( "); SQL.Add(" XLXSWLHQ_WLID,XLXSWLHQ_JGBID, XLXSWLHQ_WSJG,XLXSWLHQ_HSJG, XLXSWLHQ_WSJGF,XLXSWLHQ_HSJGF, XLXSWLHQ_YXQS, XLXSWLHQ_YXQZ,"); SQL.Add(" XLXSWLHQ_HSCGJG,XLXSWLHQ_WSCGJG, "); SQL.Add(" XLXSWLHQ_BZ, XLXSWLHQ_WHRID, XLXSWLHQ_WHR, XLXSWLHQ_WHSJ )"); SQL.Add(" values("); SQL.Add(" :XLXSWLHQ_WLID,' ', :XLXSWLHQ_WSJG,:XLXSWLHQ_HSJG, :XLXSWLHQ_WSJGF, :XLXSWLHQ_HSJGF, :XLXSWLHQ_YXQS, :XLXSWLHQ_YXQZ,"); SQL.Add(" :XLXSWLHQ_HSCGJG,:XLXSWLHQ_WSCGJG, "); SQL.Add(" :XLXSWLHQ_BZ, :XLXSWLHQ_WHRID, :XLXSWLHQ_WHR, :XLXSWLHQ_WHSJ )"); SQL.ParamByName("XLXSWLHQ_WSJG").Value = fWSJG; SQL.ParamByName("XLXSWLHQ_HSJG").Value = fHSJG; SQL.ParamByName("XLXSWLHQ_WSJGF").Value = fWSJGF; SQL.ParamByName("XLXSWLHQ_HSJGF").Value = fHSJGF; SQL.ParamByName("XLXSWLHQ_WSCGJG").Value = fWSCGJG; SQL.ParamByName("XLXSWLHQ_HSCGJG").Value = fHSCGJG; SQL.ParamByName("XLXSWLHQ_YXQS").Value = CMISproConvert.ConvertDate(DateTime.Now); SQL.ParamByName("XLXSWLHQ_BZ").Value = ""; SQL.ParamByName("XLXSWLHQ_WHR").Value = tSession.UserName; SQL.ParamByName("XLXSWLHQ_WHRID").Value = tSession.UserId; SQL.ParamByName("XLXSWLHQ_WHSJ").Value = DateTime.Now; SQL.ParamByName("XLXSWLHQ_WLID").Value = sWLID; dberp.ExecSQL(SQL); } } ShowMessage("更新完成!"); btnGRWJGRefer_Click(null, null); } /* 当设置为0|不限时,无税材料价格、含税材料价格、无税采购价格、含税采购价格都能改。 当设置为1|材料行情时,只能修改无税材料价格、含税材料价格这两项。 当设置为2|采购行情时,只能修改无税采购价格、含税采购价格这两项。 */ //此采购价格为手动调整的采购价格,非最新进价 protected void btnPLTZ_DropDown(object sender, EventArgs e) { string sBJU013 = GetOption("BJU013"); btnPLTZ.Nodes.Clear(); if (sBJU013.Equals("1")) { btnPLTZ.Nodes.Add(new gtTreeNode("CLJG", "材料价格")); } else if (sBJU013.Equals("2")) { btnPLTZ.Nodes.Add(new gtTreeNode("CGJG", "采购价格")); } else if (sBJU013.Equals("0")) { btnPLTZ.Nodes.Add(new gtTreeNode("CLJG", "材料价格")); btnPLTZ.Nodes.Add(new gtTreeNode("CGJG", "采购价格")); } MenuAreaUpdate(); } protected void btnPLTZ_MenuItemClick(object sender, string ItemIndex) { string[] RowsArry; if (string.IsNullOrEmpty(grdContentGrid.CheckedRowIndexs) && grdContentGrid.SelectedIndex <= -1) { ShowMessage("请选择需要处理的记录!"); return; } if (string.IsNullOrEmpty(grdContentGrid.CheckedRowIndexs)) { string sTYBZ = grdContentGrid.DataKeys[grdContentGrid.SelectedIndex]["XLXSBJCL_TYBZ"].ToString().Trim(); if (sTYBZ.Equals("Y")) { ShowMessage("物料对应的报价材料已停用!"); return; } } else { foreach (string sIndex in grdContentGrid.CheckedRowIndexs.Split(',')) { int iCheckIndex = CMISproConvert.StrToInt(sIndex); string sTYBZ = grdContentGrid.DataKeys[iCheckIndex]["XLXSBJCL_TYBZ"].ToString().Trim(); string sWLID = grdContentGrid.DataKeys[iCheckIndex]["XLXSWLHQ_WLID"].ToString().Trim(); if (sTYBZ.Equals("Y")) { ShowMessage("物料[" + sWLID + "]对应的报价材料已停用!"); return; } } } if (grdContentGrid.CheckBox && !String.IsNullOrEmpty(grdContentGrid.CheckedRowIndexs)) { RowsArry = grdContentGrid.CheckedRowIndexs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } else { RowsArry = new string[1]; RowsArry[0] = grdContentGrid.SelectedIndex.ToString(); } //需要填写加工费维护价格,不允许批量调整的物料编码 string sWLIDList = ""; string sMes = ""; for (int i = 0; i < RowsArry.Length; i++) { sWLIDList = sWLIDList + grdContentGrid.DataKeys[CMISproConvert.StrToInt(RowsArry[i])]["XLXSWLHQ_WLID"].ToString().Trim() + ","; } sWLIDList = sWLIDList.TrimEnd(','); TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); TSQL SQL = new TSQL(dberp); SQL.Clear(); SQL.Add("select A.XLXSBJCL_BJCLID,A.XLXSBJCL_BJCLMC from XLXSBJCLWL "); SQL.Add(" left join XLXSBJCL A on A.XLXSBJCL_BJCLID = XLXSBJCLWL_BJCLID "); SQL.Add(" LEFT JOIN XLXSBJCL B ON A.XLXSBJCL_JGYBJCLID = B.XLXSBJCL_BJCLID "); SQL.Add(" where 1 = 1 and ISNULL(A.XLXSBJCL_JGYBJCLID, ' ') <> ' ' "); SQL.Add(" and " + CMISproDataBase.GetWhereEqual("XLXSBJCLWL_WLID", sWLIDList)); DataSet dsJGYBJCL = dberp.OpenDataSet(SQL); if (dsJGYBJCL.Tables[0].Rows.Count > 0) { sMes = "【" + dsJGYBJCL.Tables[0].Rows[0][0].ToString().Trim() + "|" + dsJGYBJCL.Tables[0].Rows[0][1].ToString().Trim() + "】"; ShowMessage(sMes + "下的物料应通过填写加工费维护价格,不允许批量调整!"); return; } txtCallBackFlag.Value = ""; txtCallBackNum.Value = ""; switch (ItemIndex) { case "CLJG": UpdatePrice_CLJG(); break; case "CGJG": UpdatePrice_CGJG(); break; } } private void UpdatePrice_CLJG() { TPageParams pageParams = new TPageParams(); pageParams.UrlPath = "WLHQ_PLSZInfo.aspx"; pageParams.AddString("FLAG", "CLJG"); pageParams.AddString("txtCallBackFlagCID", txtCallBackFlag.ClientID); pageParams.AddString("txtCallBackNumCID", txtCallBackNum.ClientID); pageParams.AddString("btnCallBackCID", btnCallBack.ClientID); OpenDialog(pageParams); } private void UpdatePrice_CGJG() { TPageParams pageParams = new TPageParams(); pageParams.UrlPath = "WLHQ_PLSZInfo.aspx"; pageParams.AddString("FLAG", "CGJG"); pageParams.AddString("txtCallBackFlagCID", txtCallBackFlag.ClientID); pageParams.AddString("txtCallBackNumCID", txtCallBackNum.ClientID); pageParams.AddString("btnCallBackCID", btnCallBack.ClientID); OpenDialog(pageParams); } //多选更新采购价格 protected void btnUpdatePrice_Click(object sender, EventArgs e) { string[] RowsArry; if (string.IsNullOrEmpty(grdContentGrid.CheckedRowIndexs) && grdContentGrid.SelectedIndex <= -1) { ShowMessage("请选择需要处理的记录!"); return; } if (string.IsNullOrEmpty(grdContentGrid.CheckedRowIndexs)) { string sTYBZ = grdContentGrid.DataKeys[grdContentGrid.SelectedIndex]["XLXSBJCL_TYBZ"].ToString().Trim(); if (sTYBZ.Equals("Y")) { ShowMessage("物料对应的报价材料已停用!"); return; } } else { foreach (string sIndex in grdContentGrid.CheckedRowIndexs.Split(',')) { int iCheckIndex = CMISproConvert.StrToInt(sIndex); string sTYBZ = grdContentGrid.DataKeys[iCheckIndex]["XLXSBJCL_TYBZ"].ToString().Trim(); string sWLXXID = grdContentGrid.DataKeys[iCheckIndex]["XLXSWLHQ_WLID"].ToString().Trim(); if (sTYBZ.Equals("Y")) { ShowMessage("物料[" + sWLXXID + "]对应的报价材料已停用!"); return; } } } if (grdContentGrid.CheckBox && !String.IsNullOrEmpty(grdContentGrid.CheckedRowIndexs)) { RowsArry = grdContentGrid.CheckedRowIndexs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } else { RowsArry = new string[1]; RowsArry[0] = grdContentGrid.SelectedIndex.ToString(); } string sMsg = "将用最新进价更新选中记录的采购价格,是否继续?"; Confirm.Register("IsQD", sMsg); Confirm.ShowBtnText = TConfirm.cBtnText.Yes_No; if (Confirm.GetValue("IsQD").Trim().Equals("")) { Confirm.Ask("IsQD"); return; } else if (Confirm.GetValue("IsQD").Trim().Equals("N")) { //表示进行了提示并选择了取消,直接返回或其他处理 Confirm.Clear(); return; } else if (Confirm.GetValue("IsQD").Trim().Equals("Y")) { //表示进行了提示并选择了确认 Confirm.Clear(); } string sWLID = ""; string sStrSQL = ""; string sCGU009 = GetOption(100486007, "CGU009"); bool bUpdate = false; bool bToday = true; double fWSJG = 0.0; double fHSJG = 0.0; double fWSJGF = 0.0; double fHSJGF = 0.0; double fWSCGJG = 0.0; double fHSCGJG = 0.0; //点击更新采购价格,先判断有没有当天的物料行情记录,若没有则自动插入当天的物料行情、再更新当天物料行情的采购价格;否则直接更新当天物料行情的采购价格 for (int i = 0; i < RowsArry.Length; i++) { TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); TSQL SQL = new TSQL(dberp); SQL.Clear(); sWLID = grdContentGrid.DataKeys[CMISproConvert.StrToInt(RowsArry[i])]["XLXSWLHQ_WLID"].ToString().Trim(); //若是加工料,则跳过更新。 SQL.Clear(); SQL.Add("select XLXSBJCLWL_BJCLID from XLXSBJCLWL "); SQL.Add(" where XLXSBJCLWL_WLID = :pWLID "); SQL.ParamByName("pWLID").Value = sWLID; DataSet dsWLID = dberp.OpenDataSet(SQL); if (dsWLID.Tables[0].Rows.Count > 0) { sStrSQL = String.Format("select top 1 XLXSBJCL_BJCLID FROM XLXSBJCL WHERE XLXSBJCL_BJCLID = '{0}' and isnull(XLXSBJCL_JGYBJCLID,' ') <> ' ' ", dsWLID.Tables[0].Rows[0][0].ToString().Trim()); if(CMISproDataBase.ExistsRecord("DBERP",sStrSQL)) { continue; } } SQL.Clear(); SQL.Add("select XLXSWLHQ_WSJG,XLXSWLHQ_HSJG,XLXSWLHQ_WSJGF,XLXSWLHQ_HSJGF,XLXSWLHQ_WSCGJG,XLXSWLHQ_HSCGJG from XLXSWLHQ "); SQL.Add(" where XLXSWLHQ_JGBID =' ' and XLXSWLHQ_WLID = :pWLID order by XLXSWLHQ_YXQS desc "); SQL.ParamByName("pWLID").Value = sWLID; DataSet dsUpdate = dberp.OpenDataSet(SQL); if (dsUpdate.Tables[0].Rows.Count > 0) { bUpdate = true; fWSJG = CMISproConvert.StrToFloat(dsUpdate.Tables[0].Rows[0]["XLXSWLHQ_WSJG"].ToString().Trim()); fHSJG = CMISproConvert.StrToFloat(dsUpdate.Tables[0].Rows[0]["XLXSWLHQ_HSJG"].ToString().Trim()); fWSJGF = CMISproConvert.StrToFloat(dsUpdate.Tables[0].Rows[0]["XLXSWLHQ_WSJGF"].ToString().Trim()); fHSJGF = CMISproConvert.StrToFloat(dsUpdate.Tables[0].Rows[0]["XLXSWLHQ_HSJGF"].ToString().Trim()); fWSCGJG = CMISproConvert.StrToFloat(dsUpdate.Tables[0].Rows[0]["XLXSWLHQ_WSCGJG"].ToString().Trim()); fHSCGJG = CMISproConvert.StrToFloat(dsUpdate.Tables[0].Rows[0]["XLXSWLHQ_HSCGJG"].ToString().Trim()); } else { bUpdate = false; fWSJG = 0; fHSJG = 0; fWSJGF = 0; fHSJGF = 0; fWSCGJG = 0; fHSCGJG = 0; } SQL.Clear(); SQL.Add("select XLXSWLHQ_WSJG,XLXSWLHQ_HSJG,XLXSWLHQ_WSJGF,XLXSWLHQ_HSJGF,XLXSWLHQ_WSCGJG,XLXSWLHQ_HSCGJG from XLXSWLHQ "); SQL.Add(" where XLXSWLHQ_JGBID =' ' and XLXSWLHQ_YXQS = Convert(datetime,:pRQ) and XLXSWLHQ_WLID = :pWLID order by XLXSWLHQ_YXQS desc "); SQL.ParamByName("pRQ").Value = CMISproConvert.ConvertDate(DateTime.Now); SQL.ParamByName("pWLID").Value = sWLID; DataSet dsToday = dberp.OpenDataSet(SQL); if (dsToday.Tables[0].Rows.Count > 0) { bToday = true; fWSJG = CMISproConvert.StrToFloat(dsToday.Tables[0].Rows[0]["XLXSWLHQ_WSJG"].ToString().Trim()); fHSJG = CMISproConvert.StrToFloat(dsToday.Tables[0].Rows[0]["XLXSWLHQ_HSJG"].ToString().Trim()); fWSJGF = CMISproConvert.StrToFloat(dsToday.Tables[0].Rows[0]["XLXSWLHQ_WSJGF"].ToString().Trim()); fHSJGF = CMISproConvert.StrToFloat(dsToday.Tables[0].Rows[0]["XLXSWLHQ_HSJGF"].ToString().Trim()); fWSCGJG = CMISproConvert.StrToFloat(dsToday.Tables[0].Rows[0]["XLXSWLHQ_WSCGJG"].ToString().Trim()); fHSCGJG = CMISproConvert.StrToFloat(dsToday.Tables[0].Rows[0]["XLXSWLHQ_HSCGJG"].ToString().Trim()); } else { bToday = false; } fHSCGJG = XLXSWLHQ.GetCGPri(true, sWLID, sCGU009); fWSCGJG = XLXSWLHQ.GetCGPri(false, sWLID, sCGU009); //有记录,不知道是不是今天的 if (bUpdate) { //更新数据 //不是今天的 if (!bToday) { SQL.Clear(); SQL.Add(" insert into XLXSWLHQ( "); SQL.Add(" XLXSWLHQ_WLID,XLXSWLHQ_JGBID, XLXSWLHQ_WSJG,XLXSWLHQ_HSJG, XLXSWLHQ_WSJGF,XLXSWLHQ_HSJGF, XLXSWLHQ_YXQS, XLXSWLHQ_YXQZ,"); SQL.Add(" XLXSWLHQ_HSCGJG,XLXSWLHQ_WSCGJG, "); SQL.Add(" XLXSWLHQ_BZ, XLXSWLHQ_WHRID, XLXSWLHQ_WHR, XLXSWLHQ_WHSJ )"); SQL.Add(" values("); SQL.Add(" :XLXSWLHQ_WLID,' ', :XLXSWLHQ_WSJG,:XLXSWLHQ_HSJG, :XLXSWLHQ_WSJGF, :XLXSWLHQ_HSJGF, :XLXSWLHQ_YXQS, :XLXSWLHQ_YXQZ,"); SQL.Add(" :XLXSWLHQ_HSCGJG,:XLXSWLHQ_WSCGJG, "); SQL.Add(" :XLXSWLHQ_BZ, :XLXSWLHQ_WHRID, :XLXSWLHQ_WHR, :XLXSWLHQ_WHSJ )"); SQL.ParamByName("XLXSWLHQ_WSJG").Value = fWSJG; SQL.ParamByName("XLXSWLHQ_HSJG").Value = fHSJG; SQL.ParamByName("XLXSWLHQ_WSJGF").Value = fWSJGF; SQL.ParamByName("XLXSWLHQ_HSJGF").Value = fHSJGF; SQL.ParamByName("XLXSWLHQ_WSCGJG").Value = fWSCGJG; SQL.ParamByName("XLXSWLHQ_HSCGJG").Value = fHSCGJG; SQL.ParamByName("XLXSWLHQ_YXQS").Value = CMISproConvert.ConvertDate(DateTime.Now); SQL.ParamByName("XLXSWLHQ_BZ").Value = ""; SQL.ParamByName("XLXSWLHQ_WHR").Value = tSession.UserName; SQL.ParamByName("XLXSWLHQ_WHRID").Value = tSession.UserId; SQL.ParamByName("XLXSWLHQ_WHSJ").Value = DateTime.Now; SQL.ParamByName("XLXSWLHQ_WLID").Value = sWLID; dberp.ExecSQL(SQL); //并找到最近的一条记录,若其有效期止为空就将其置为所保存记录的有效期始减一天。 SQL.Clear(); SQL.Add(" update XLXSWLHQ set XLXSWLHQ_YXQZ=dateadd(day,-1,:pYXQS) "); SQL.Add(" where XLXSWLHQ_JGBID=' '"); SQL.Add(" and XLXSWLHQ_WLID=:pWLID"); SQL.Add(" and XLXSWLHQ_YXQS="); SQL.Add(" ("); SQL.Add(" select max(XLXSWLHQ_YXQS) as maxYXQS"); SQL.Add(" from XLXSWLHQ"); SQL.Add(" where XLXSWLHQ_JGBID=' ' "); SQL.Add(" and XLXSWLHQ_WLID=:pWLID"); SQL.Add(" and XLXSWLHQ_YXQS<=dateadd(day,-1,:pYXQS) "); SQL.Add(" )"); SQL.Add(" and XLXSWLHQ_YXQZ is null "); SQL.ParamByName("pWLID").Value = sWLID; SQL.ParamByName("pYXQS").Value = CMISproConvert.ConvertDate(DateTime.Now); dberp.ExecSQL(SQL); } } else { //完全无记录 SQL.Clear(); SQL.Add(" insert into XLXSWLHQ( "); SQL.Add(" XLXSWLHQ_WLID,XLXSWLHQ_JGBID, XLXSWLHQ_WSJG,XLXSWLHQ_HSJG, XLXSWLHQ_WSJGF,XLXSWLHQ_HSJGF, XLXSWLHQ_YXQS, XLXSWLHQ_YXQZ,"); SQL.Add(" XLXSWLHQ_HSCGJG,XLXSWLHQ_WSCGJG, "); SQL.Add(" XLXSWLHQ_BZ, XLXSWLHQ_WHRID, XLXSWLHQ_WHR, XLXSWLHQ_WHSJ )"); SQL.Add(" values("); SQL.Add(" :XLXSWLHQ_WLID,' ', :XLXSWLHQ_WSJG,:XLXSWLHQ_HSJG, :XLXSWLHQ_WSJGF, :XLXSWLHQ_HSJGF, :XLXSWLHQ_YXQS, :XLXSWLHQ_YXQZ,"); SQL.Add(" :XLXSWLHQ_HSCGJG,:XLXSWLHQ_WSCGJG, "); SQL.Add(" :XLXSWLHQ_BZ, :XLXSWLHQ_WHRID, :XLXSWLHQ_WHR, :XLXSWLHQ_WHSJ )"); SQL.ParamByName("XLXSWLHQ_WSJG").Value = 0; SQL.ParamByName("XLXSWLHQ_HSJG").Value = 0; SQL.ParamByName("XLXSWLHQ_WSJGF").Value = 0; SQL.ParamByName("XLXSWLHQ_HSJGF").Value = 0; SQL.ParamByName("XLXSWLHQ_WSCGJG").Value = 0; SQL.ParamByName("XLXSWLHQ_HSCGJG").Value = 0; SQL.ParamByName("XLXSWLHQ_YXQS").Value = CMISproConvert.ConvertDate(DateTime.Now); SQL.ParamByName("XLXSWLHQ_BZ").Value = ""; SQL.ParamByName("XLXSWLHQ_WHR").Value = tSession.UserName; SQL.ParamByName("XLXSWLHQ_WHRID").Value = tSession.UserId; SQL.ParamByName("XLXSWLHQ_WHSJ").Value = DateTime.Now; SQL.ParamByName("XLXSWLHQ_WLID").Value = sWLID; dberp.ExecSQL(SQL); } //------------------------------------------ //今天的记录 或者 刚插入的 if (bToday || !bUpdate) { //直接更新今天的 SQL.Clear(); SQL.Add(" update XLXSWLHQ "); SQL.Add(" set XLXSWLHQ_WSJG = :XLXSWLHQ_WSJG,XLXSWLHQ_HSJG=:XLXSWLHQ_HSJG,XLXSWLHQ_HSJGF=:XLXSWLHQ_HSJGF,XLXSWLHQ_WSJGF=:XLXSWLHQ_WSJGF, "); SQL.Add(" XLXSWLHQ_HSCGJG=:XLXSWLHQ_HSCGJG,XLXSWLHQ_WSCGJG=:XLXSWLHQ_WSCGJG, "); SQL.Add(" XLXSWLHQ_YXQS = :XLXSWLHQ_YXQS, XLXSWLHQ_YXQZ = :XLXSWLHQ_YXQZ, XLXSWLHQ_BZ = :XLXSWLHQ_BZ, XLXSWLHQ_WHRID = :XLXSWLHQ_WHRID, XLXSWLHQ_WHR = :XLXSWLHQ_WHR, XLXSWLHQ_WHSJ = :XLXSWLHQ_WHSJ"); SQL.Add(" where XLXSWLHQ_JGBID =' ' and XLXSWLHQ_YXQS= :pRQ and XLXSWLHQ_WLID = :pWLID "); SQL.ParamByName("XLXSWLHQ_WSJG").Value = fWSJG; SQL.ParamByName("XLXSWLHQ_HSJG").Value = fHSJG; SQL.ParamByName("XLXSWLHQ_WSJGF").Value = fWSJGF; SQL.ParamByName("XLXSWLHQ_HSJGF").Value = fHSJGF; SQL.ParamByName("XLXSWLHQ_WSCGJG").Value = fWSCGJG; SQL.ParamByName("XLXSWLHQ_HSCGJG").Value = fHSCGJG; SQL.ParamByName("XLXSWLHQ_YXQS").Value = CMISproConvert.ConvertDate(DateTime.Now); SQL.ParamByName("XLXSWLHQ_BZ").Value = ""; SQL.ParamByName("XLXSWLHQ_WHR").Value = tSession.UserName; SQL.ParamByName("XLXSWLHQ_WHRID").Value = tSession.UserId; SQL.ParamByName("XLXSWLHQ_WHSJ").Value = DateTime.Now; SQL.ParamByName("pRQ").Value = CMISproConvert.ConvertDate(DateTime.Now); SQL.ParamByName("pWLID").Value = sWLID; dberp.ExecSQL(SQL); } } ShowMessage("更新完成!"); btnGRWJGRefer_Click(null, null); } protected void StandardEditButton_Click(object sender, EventArgs e) { if (grdContentGrid.SelectedIndex < 0) { ShowMessage("请选择处理记录!"); return; } string sTYBZ = grdContentGrid.DataKeys[grdContentGrid.SelectedIndex]["XLXSBJCL_TYBZ"].ToString().Trim(); if (sTYBZ.Equals("Y")) { ShowMessage("物料对应的报价材料已停用!"); return; } OpenInfo(TPageCallAction.pcaEdit); } #endregion } }