コード例 #1
0
        public ActionResult SaveLostProduct(int itemId, int qnty)
        {
            if (qnty > 0)
            {
                LostProduct lp = new LostProduct();
                lp.ItemID = itemId;
                if (qnty > 0)
                {
                    lp.LostQnty = qnty;

                    var ckItem = db.Items.FirstOrDefault(i => i.ItemID == itemId);
                    if (ckItem != null)
                    {
                        if (qnty < ckItem.AvailableQnty)
                        {
                            ckItem.AvailableQnty  -= qnty;
                            db.Entry(ckItem).State = EntityState.Modified;
                            db.SaveChanges();
                        }
                    }
                }
                lp.OutletID  = Convert.ToInt32(Session["OutletID"].ToString());
                lp.AddedBy   = HttpContext.User.Identity.Name;
                lp.AddedDate = DateTime.Now;
                lp.IsDeleted = false;
                db.LostProducts.Add(lp);
                db.SaveChanges();

                return(Json(true, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #2
0
        public void Insert(LostProduct lostProduct)
        {
            var param = new List <SqlParameter>
            {
                new SqlParameter("TransactionDetailID", lostProduct.TransactionDetailID),
                new SqlParameter("@LostQuantity ", lostProduct.LostQuantity),
                new SqlParameter("@Comment", lostProduct.Comment),
            };

            Insert(param.ToArray());
        }
コード例 #3
0
 public void Insert(LostProduct lostProduct)
 {
     _repository.Insert(lostProduct);
 }