private string removeInventory(HttpContext context) { try { using (AMSCM.Models.AMSCM amscm = new AMSCM.Models.AMSCM()) { AMSCM.Models.tbInventory inventory = amscm.tbInventory.Find(context.Request.Form["cnvcInvCode"]); amscm.tbInventory.Remove(inventory); AMSCM.Models.tbGoods tbGoods = amscm.tbGoods.Find(inventory.cnvcInvCode); if (tbGoods != null) { amscm.tbGoods.Remove(tbGoods); } amscm.SaveChanges(); } } catch (ArgumentNullException aex) { ExceptionPolicy.HandleException(aex, ServiceHelper.ExceptionPolicy); return(ServiceHelper.JsonSerializer <JEasyUIResult>(new JEasyUIResult(false, aex.Message))); } catch (DbUpdateException dex) { ExceptionPolicy.HandleException(dex, ServiceHelper.ExceptionPolicy); return(ServiceHelper.JsonSerializer <JEasyUIResult>(new JEasyUIResult(false, dex.Message))); } return(ServiceHelper.JsonSerializer <JEasyUIResult>(new JEasyUIResult(true, ""))); }
public static void SyncGoods(AMSCM.Models.tbInventory inv, AMSCM.Models.AMSCM amscm) { AMSCM.Models.tbGoods tbGoods = amscm.tbGoods.Find(inv.cnvcInvCode); if (inv.cnbSale) { if (tbGoods == null) { AMSCM.Models.tbGoods gs = new AMSCM.Models.tbGoods(); gs.vcGoodsID = inv.cnvcInvCode; gs.vcGoodsName = inv.cnvcInvName; gs.vcSpell = Helper.GetChineseSpell(inv.cnvcInvName); gs.nPrice = Convert.ToDecimal(inv.cnfRetailPrice); gs.nRate = 0; gs.iIgValue = -1; gs.cNewFlag = "0"; gs.vcComments = "存货档案添加同步"; amscm.tbGoods.Add(gs); } else { if (tbGoods.vcGoodsName != inv.cnvcInvName) { tbGoods.vcGoodsName = inv.cnvcInvName; tbGoods.vcSpell = Helper.GetChineseSpell(inv.cnvcInvName); } if (inv.cnfRetailPrice > 0) { tbGoods.nPrice = Convert.ToDecimal(inv.cnfRetailPrice); } tbGoods.vcComments = "存货档案修改同步"; } } else { if (tbGoods != null) { amscm.tbGoods.Remove(tbGoods); } } }