protected void update() { if (GridGoods.GetModifiedDict().Count > 0) { Dictionary <int, Dictionary <string, object> > modifiedDict = GridGoods.GetModifiedDict(); if (modifiedDict.Count > 0) { string LisRowno = ""; foreach (int rowIndex in modifiedDict.Keys) { LisRowno += GridGoods.DataKeys[rowIndex][0].ToString() + "," + modifiedDict[rowIndex]["PDSL"] + "#"; } AddCookies(LisRowno); PageContext.RegisterStartupScript(Confirm.GetShowReference("数据已被修改是否保存?", String.Empty, MessageBoxIcon.Question, PageManager1.GetCustomEventReference("Confirm_OK"), PageManager1.GetCustomEventReference("Confirm_Cancel"))); } } else { page(tbxSEQNO.Text); } }
protected void bntSave_Click(object sender, EventArgs e) { List <CommandInfo> lci = new List <CommandInfo>(); Dictionary <int, Dictionary <string, object> > modifiedDict = GridGoods.GetModifiedDict(); bool update = false; foreach (int rowIndex in modifiedDict.Keys) { object[] keys = GridGoods.DataKeys[rowIndex]; String gdseq = keys[0].ToString(); String deptId = "0001"; if (DbHelperOra.Exists(string.Format("SELECT 1 FROM DOC_GOODS WHERE GDSEQ = '{0}' AND ISGZ='Y'", gdseq))) { Alert.Show(string.Format("商品【{0}】为高值商品,不允许设置为定数", keys[4].ToString()), "消息提示", MessageBoxIcon.Warning); return; } update = false; string uptSql = "UPDATE DOC_GOODSCFG SET "; string msg = "修改商品【" + gdseq + "】" + keys[1].ToString() + ":修改表DOC_GOODSCFG中字段"; if (modifiedDict[rowIndex].ContainsKey("HJCODE1") && !string.IsNullOrWhiteSpace(modifiedDict[rowIndex]["HJCODE1"].ToString())) { string sql_hw = @"select a.seqno, b.gdname, 'RK' flag from dat_rk_doc a, dat_rk_com b where a.seqno = b.seqno and a.flag in ('M', 'N') and b.gdseq = '{0}' and b.hwid = '{1}' union all select a.seqno, b.gdname, 'CK' flag from dat_ck_doc a, dat_ck_com b where a.seqno = b.seqno and a.flag in ('M', 'N') and b.gdseq = '{0}' and b.hwid = '{1}'"; DataTable dt = DbHelperOra.Query(string.Format(sql_hw, gdseq, modifiedDict[rowIndex]["HJCODE1"])).Tables[0]; if (dt != null && dt.Rows.Count > 0) { string msg_hw = "单据【" + dt.Rows[0]["SEQNO"].ToString() + "】中存在商品【" + dt.Rows[0]["GDNAME"].ToString() + "】,该单据还未审核,请检查!"; Alert.Show(msg_hw, "消息提示", MessageBoxIcon.Warning); return; } uptSql += " HJCODE1='" + modifiedDict[rowIndex]["HJCODE1"] + "',"; msg += "HWID=" + modifiedDict[rowIndex]["HJCODE1"] + ","; sql_hw = "UPDATE DAT_GOODSSTOCK SET HWID='" + modifiedDict[rowIndex]["HJCODE1"] + "' WHERE GDSEQ='" + gdseq + "' AND DEPTID='" + deptId + "'"; lci.Add(new CommandInfo(sql_hw, null)); update = true; } if (modifiedDict[rowIndex].ContainsKey("ZDKC")) { uptSql += " ZDKC='" + modifiedDict[rowIndex]["ZDKC"] + "',"; msg += "ZDKC=" + modifiedDict[rowIndex]["ZDKC"] + ","; update = true; } if (modifiedDict[rowIndex].ContainsKey("ZGKC")) { uptSql += " ZGKC='" + modifiedDict[rowIndex]["ZGKC"] + "',"; msg += "ZGKC=" + modifiedDict[rowIndex]["ZGKC"] + ","; update = true; } if (update) { uptSql = uptSql.TrimEnd(',') + " WHERE GDSEQ='" + gdseq + "' AND DEPTID='" + deptId + "'"; lci.Add(new CommandInfo(uptSql, null)); OperLog("商品信息批量更新", msg.TrimEnd(',')); } } if (update) { if (DbHelperOra.ExecuteSqlTran(lci)) { Alert.Show("商品信息修改成功!", "商品信息", MessageBoxIcon.Information); DataSearch(); } else { Alert.Show("商品信息修改失败!", "商品信息", MessageBoxIcon.Warning); } } }
protected override void billSave() { #region 检查有效性 if (("NR").IndexOf(ddlFLAG.SelectedValue) < 0) { Alert.Show("非新单不能保存!", "消息提示", MessageBoxIcon.Warning); return; } if (ddlISSD.SelectedValue != "Y") { Alert.Show("请首先锁定盘点单!"); return; } #endregion #region 取消原逻辑 //List<Dictionary<string, object>> newDict = GridGoods.GetNewAddedList().OrderBy(x => x["GDSEQ"]).ToList(); //List<Dictionary<string, object>> goodsData = new List<Dictionary<string, object>>(); ////判断是否有空行 //for (int i = 0; i < newDict.Count; i++) //{ // if (!string.IsNullOrWhiteSpace(newDict[i]["GDSEQ"].ToString()) && !string.IsNullOrWhiteSpace(newDict[i]["GDNAME"].ToString())) // { // goodsData.Add(newDict[i]); // } //} //if (PubFunc.StrIsEmpty(tbxSEQNO.Text)) //{ // tbxSEQNO.Text = BillSeqGet(); //} //MyTable mtType = new MyTable("dat_pd_doc"); //mtType.ColRow = PubFunc.FormDataHT(FormDoc); //mtType.ColRow["SEQNO"] = tbxSEQNO.Text; //mtType.ColRow["FLAG"] = "N";//所有单据在保存时单据状态一律为新增N //mtType.ColRow.Add("BILLTYPE", BillType); //mtType.ColRow.Add("SUBNUM", goodsData.Count); //List<CommandInfo> cmdList = new List<CommandInfo>(); //MyTable mtTypeMx = new MyTable("dat_pd_com"); ////先删除单据信息在插入 //cmdList.Add(mtType.DeleteCommand(""));//删除单据台头 //cmdList.Add(new CommandInfo("delete dat_pd_com where seqno='" + tbxSEQNO.Text + "'", null));//删除单据明细 //cmdList.AddRange(mtType.InsertCommand()); //for (int i = 0; i < goodsData.Count; i++) //{ // mtTypeMx.ColRow = PubFunc.GridDataGet(goodsData[i]); // mtTypeMx.ColRow.Add("SEQNO", tbxSEQNO.Text); // mtTypeMx.ColRow.Add("ROWNO", i + 1); // mtTypeMx.ColRow.Add("RQ_SC", mtTypeMx.ColRow["RQ_SCNAME"]); // mtTypeMx.ColRow.Add("YXQZ", mtTypeMx.ColRow["YXQZNAME"]); // mtTypeMx.ColRow["BZSL"] = Convert.ToDecimal(mtTypeMx.ColRow["PDSL"]) - Convert.ToDecimal(mtTypeMx.ColRow["KCSL"]); // mtTypeMx.ColRow["CYHSJE"] = Convert.ToDecimal(mtTypeMx.ColRow["BZSL"]) * Convert.ToDecimal(mtTypeMx.ColRow["HSJJ"]); // mtTypeMx.ColRow["CYBHSJE"] = Convert.ToDecimal(mtTypeMx.ColRow["BZSL"]) * Convert.ToDecimal(mtTypeMx.ColRow["BHSJJ"]); // mtTypeMx.ColRow.Remove("RQ_SCNAME"); // mtTypeMx.ColRow.Remove("YXQZNAME"); // mtTypeMx.ColRow.Remove("UNITNAME"); // cmdList.Add(mtTypeMx.Insert()); //} #endregion Dictionary <int, Dictionary <string, object> > modifiedDict = GridGoods.GetModifiedDict(); List <CommandInfo> cmdList = new List <CommandInfo>(); string Billno = tbxSEQNO.Text; string Sql = ""; if (modifiedDict.Count > 0) { foreach (int rowIndex in modifiedDict.Keys) { Sql = string.Format("UPDATE DAT_PD_COM SET PDSL = {0},BZSL = {0}-KCSL,CYHSJE= HSJJ*({0}-KCSL) WHERE SEQNO = '{1}' AND ROWNO = {2}", modifiedDict[rowIndex]["PDSL"], Billno, GridGoods.DataKeys[rowIndex][0].ToString()); cmdList.Add(new CommandInfo(Sql, null)); } } DbHelperOra.ExecuteSqlTran(cmdList); Alert.Show("单据保存成功"); billOpen(tbxSEQNO.Text); OperLog("盘点单据", "修改单据【" + tbxSEQNO.Text + "】"); }