Exemplo n.º 1
0
 public StockInSkuAndPurchase(WarehouseInItem oInItem, PurchaseItem oPurchaseItem)
 {
     this.oInItem = oInItem;
     this.oPurchaseItem = oPurchaseItem;
 }
Exemplo n.º 2
0
        public string savePurchaseItem(string savecode, string saveprice1, string savequantity1, string saveamount1)
        {
            decimal saveprice;
            decimal savequantity;
            decimal saveamount;
            if (saveprice1 != "")
                saveprice = decimal.Parse(saveprice1);
            else
                saveprice = 0;

            if (savequantity1 != "")
                savequantity = decimal.Parse(savequantity1);
            else
                savequantity = 0;

            if (saveamount1 != "")
                saveamount = decimal.Parse(saveamount1);
            else
                saveamount = 0;

            var querySku = dbEntity.ProductInfoItems.Where(p => p.Code == savecode && p.OrgID == gOrgPurId && p.Deleted == false).SingleOrDefault();
            PurchaseItem queryPuritem ;
            if (querySku != null)
            {
                Guid gsku = querySku.Gid;
                queryPuritem = dbEntity.PurchaseItems.Include("Purchase").Include("SkuItem").Where(p => p.SkuID == gsku && p.PurID == gPurId).SingleOrDefault();
                if (queryPuritem != null)
                {
                    if (nCalmode == 0)
                    {
                        queryPuritem.Amount = saveamount;
                        queryPuritem.Quantity = savequantity;
                        queryPuritem.Price = saveamount/savequantity;
                    }
                    else if (nCalmode == 1)
                    {
                        queryPuritem.Quantity = savequantity;
                        queryPuritem.Price = saveprice;
                        queryPuritem.Amount = savequantity * saveprice;
                    }
                }
                else
                {
                    queryPuritem = new PurchaseItem();
                    queryPuritem.PurID = gPurId;
                    queryPuritem.SkuID = gsku;
                    if (nCalmode == 0)
                    {
                        queryPuritem.Amount = saveamount;
                        queryPuritem.Quantity = savequantity;
                        queryPuritem.Price = saveamount / savequantity;
                    }
                    else if (nCalmode == 1)
                    {
                        queryPuritem.Quantity = savequantity;
                        queryPuritem.Price = saveprice;
                        queryPuritem.Amount = savequantity * saveprice;
                    }
                    dbEntity.PurchaseItems.Add(queryPuritem);
                }

                dbEntity.SaveChanges();
            }
            return "success";
        }