public HttpResponseBase KutiaoAddorReduce() { string jsonStr = String.Empty; _iinvd = new IinvdMgr(mySqlConnectionString); _iagMgr = new IialgMgr(mySqlConnectionString); Iinvd invd = new Iinvd(); iialg iag = new iialg(); IstockChange Icg = new IstockChange(); ProductItem Proitems = new ProductItem(); int results = 0; try { invd.row_id = Convert.ToInt32(Request.Params["row_id"]);//行號碼 int resultcount = 0; int kucuncount = Convert.ToInt32(Request.Params["benginnumber"]);//庫存數量 int tiaozhengcount = Convert.ToInt32(Request.Params["changenumber"]); int kucuntype = Convert.ToInt32(Request.Params["kutiaotype"]); if (!string.IsNullOrEmpty(Request.Params["item_id"]))//商品細項編號 { Icg.item_id = Convert.ToUInt32(Request.Params["item_id"]); Proitems.Item_Id = Icg.item_id; } int oldsumcount = _iinvd.GetProqtyByItemid(Convert.ToInt32(Icg.item_id));//總庫存 string iarc_id = ""; if (!string.IsNullOrEmpty(Request.Params["iarcid"])) { iarc_id = Request.Params["iarcid"];//庫調原因 } #region 庫存調整的時候,商品庫存也要調整 _proditemMgr = new ProductItemMgr(mySqlConnectionString); int item_stock = 0; #endregion if (kucuntype == 1)//表示選擇了加 { resultcount = kucuncount + tiaozhengcount; item_stock = tiaozhengcount; } else//表示選擇了減號 { resultcount = kucuncount - tiaozhengcount; item_stock = -tiaozhengcount; } Proitems.Item_Stock = item_stock; invd.prod_qty = resultcount;//此時為更改后的庫存 invd.change_dtim = DateTime.Now; invd.change_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id; Icg.sc_trans_type = 2; Icg.sc_num_old = oldsumcount; Icg.sc_time = DateTime.Now; Icg.sc_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id; if (!string.IsNullOrEmpty(Request.Params["po_id"])) { Icg.sc_cd_id = Request.Params["po_id"];//採購單編號 } if (!string.IsNullOrEmpty(Request.Params["doc_no"])) { Icg.sc_trans_id = Request.Params["doc_no"];//庫調單號 } if (!string.IsNullOrEmpty(Request.Params["remarks"])) { Icg.sc_note = Request.Params["remarks"];//備註 } _istockMgr = new IstockChangeMgr(mySqlConnectionString); int j = _iinvd.kucunTiaozheng(invd); //更改iloc表中的狀態並且在iialg表中插入數據 string path = "/WareHouse/KutiaoAddorReduce"; Caller call = new Caller(); call = (System.Web.HttpContext.Current.Session["caller"] as Caller); int k = 0; if (iarc_id == "NE" || iarc_id == "RF")//庫存調整-不改動前台庫存 { k = 1; } else { k = _proditemMgr.UpdateItemStock(Proitems, path, call); } int newsumcount = _iinvd.GetProqtyByItemid(Convert.ToInt32(Icg.item_id));//總庫存 Icg.sc_num_chg = newsumcount - oldsumcount; Icg.sc_num_new = newsumcount; Icg.sc_istock_why = 2; if (oldsumcount != newsumcount) { results = _istockMgr.insert(Icg); } else { results = 1; } if (j > 0 && results > 0 && k > 0) { jsonStr = "{success:true}"; } else { jsonStr = "{success:false}"; } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); jsonStr = "{success:false}"; } this.Response.Clear(); this.Response.Write(jsonStr); this.Response.End(); return this.Response; }