示例#1
0
 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, "")));
 }
示例#2
0
 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);
         }
     }
 }
示例#3
0
        private string updateInventory(HttpContext context)
        {
            try
            {
                using (AMSCM.Models.AMSCM amscm = new AMSCM.Models.AMSCM())
                {
                    AMSCM.Models.tbInventory inventory = amscm.tbInventory.Find(context.Request.Form["cnvcInvCode"]);
                    inventory.cnbProductBill = context.Request.Form["cnbProductBill"] == "on" ? true : false;// Convert.ToBoolean(context.Request.Form["cnbProductBill"]);
                    //inventory.cnvcInvCode = context.Request.Form["cnvcInvCode"];
                    inventory.cnvcInvName = context.Request.Form["cnvcInvName"];
                    inventory.cnvcInvStd  = context.Request.Form["cnvcInvStd"];
                    //inventory.cnvcInvCCode = context.Request.Form["cnvcInvCCode"];
                    inventory.cnbSale     = context.Request.Form["cnbSale"] == "on"?true:false;        //Convert.ToBoolean(context.Request.Form["cnbSale"]);
                    inventory.cnbPurchase = context.Request.Form["cnbPurchase"] == "on"?true:false;    //Convert.ToBoolean(context.Request.Form["cnbPurchase"]);
                    inventory.cnbSelf     = context.Request.Form["cnbSelf"] == "on"?true:false;        //Convert.ToBoolean(context.Request.Form["cnbSelf"]);
                    inventory.cnbComsume  = context.Request.Form["cnbComsume"] == "on" ? true : false; // Convert.ToBoolean(context.Request.Form["cnbComsume"]);
                    if (context.Request.Form["cniInvCCost"] != "")
                    {
                        inventory.cniInvCCost = Convert.ToDecimal(context.Request.Form["cniInvCCost"]);
                    }
                    if (context.Request.Form["cniInvNCost"] != "")
                    {
                        inventory.cniInvNCost = Convert.ToDecimal(context.Request.Form["cniInvNCost"]);
                    }
                    if (context.Request.Form["cniSafeNum"] != "")
                    {
                        inventory.cniSafeNum = Convert.ToDecimal(context.Request.Form["cniSafeNum"]);
                    }
                    if (context.Request.Form["cniLowSum"] != "")
                    {
                        inventory.cniLowSum = Convert.ToDecimal(context.Request.Form["cniLowSum"]);
                    }
                    if (context.Request.Form["cndSDate"] != "")
                    {
                        inventory.cndSDate = Convert.ToDateTime(context.Request.Form["cndSDate"]);
                    }
                    if (context.Request.Form["cndEDate"] != "")
                    {
                        inventory.cndEDate = Convert.ToDateTime(context.Request.Form["cndEDate"]);
                    }
                    inventory.cnvcCreatePerson = context.Request.Form["cnvcCreatePerson"];
                    inventory.cnvcModifyPerson = context.Request.Form["cnvcModifyPerson"];
                    //if (context.Request.Form["cndModifyDate"] != "")
                    inventory.cndModifyDate     = DateTime.Now;//Convert.ToDateTime(context.Request.Form["cndModifyDate"]);
                    inventory.cnvcValueType     = context.Request.Form["cnvcValueType"];
                    inventory.cnvcGroupCode     = context.Request.Form["cnvcGroupCode"];
                    inventory.cnvcComUnitCode   = context.Request.Form["cnvcComUnitCode"];
                    inventory.cnvcSAComUnitCode = context.Request.Form["cnvcSAComUnitCode"];
                    inventory.cnvcPUComUnitCode = context.Request.Form["cnvcPUComUnitCode"];
                    inventory.cnvcSTComUnitCode = context.Request.Form["cnvcSTComUnitCode"];
                    //inventory.cnvcProduceUnitCode = context.Request.Form["cnvcProduceUnitCode"];
                    if (context.Request.Form["cnfRetailPrice"] != "")
                    {
                        inventory.cnfRetailPrice = Convert.ToDecimal(context.Request.Form["cnfRetailPrice"]);
                    }
                    inventory.cnvcShopUnitCode = context.Request.Form["cnvcShopUnitCode"];
                    inventory.cnvcFeel         = context.Request.Form["cnvcFeel"];
                    inventory.cnvcOrganise     = context.Request.Form["cnvcOrganise"];
                    inventory.cnvcColor        = context.Request.Form["cnvcColor"];
                    inventory.cnvcTaste        = context.Request.Form["cnvcTaste"];
                    if (context.Request.Form["cnnExpire"] != "")
                    {
                        inventory.cnnExpire = Convert.ToInt32(context.Request.Form["cnnExpire"]);
                    }
                    if (context.Request.Form["cnnDue"] != "")
                    {
                        inventory.cnnDue = Convert.ToInt32(context.Request.Form["cnnDue"]);
                    }

                    ServiceHelper.SyncGoods(inventory, amscm);
                    amscm.SaveChanges();
                }
            }
            catch (NullReferenceException nex)
            {
                ExceptionPolicy.HandleException(nex, ServiceHelper.ExceptionPolicy);
                return(ServiceHelper.JsonSerializer <JEasyUIResult>(new JEasyUIResult(false, nex.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, "")));
        }