Exemplo n.º 1
0
        public JsonResult SavePOSMItem(POSMItemVM posmnew)
        {
            bool   status = false;
            string mes    = "";

            if (ModelState.IsValid)
            {
                try
                {
                    POSMItem pi = new POSMItem();
                    {
                        //var V = db.UnionPayments.Max(p => p.MoneyReceiptNo);
                        pi.PosmID   = posmnew.PosmID;
                        pi.PosmName = posmnew.PosmName;
                        db.POSMItems.Add(pi);
                    }
                    var WarehouseNumber = db.Warehouses;
                    foreach (var v in WarehouseNumber)
                    {
                        POSMStock pStock = new POSMStock();
                        {
                            pStock.WarehouseId         = v.WarehouseID;
                            pStock.POSMItemID          = posmnew.PosmID;
                            pStock.OnHandQty           = 0;
                            pStock.ReceivedQty         = 0;
                            pStock.IssuedQty           = 0;
                            pStock.ReturnedFreshQty    = 0;
                            pStock.ReturnedDefectedQty = 0;
                            pStock.DestroyedQty        = 0;
                            db.POSMStocks.Add(pStock);
                        }
                    }
                    db.SaveChanges();
                    status = true;
                    return(new JsonResult {
                        Data = new { status = status, mes = mes }
                    });
                }
                catch (Exception ex)
                {
                    return(Json(new { status = "error", message = "Product ID Not Found" }));
                    //throw ex;
                }
            }
            else
            {
                status = false;
            }
            return(new JsonResult {
                Data = new { status = status, mes = mes }
            });                                                                 //, v = v } };
        }
Exemplo n.º 2
0
        public JsonResult UpdatePOSMItem(POSMItemVM updatePO)
        {
            bool   status = false;
            string mes    = "";

            if (ModelState.IsValid)
            {
                try
                {
                    var result = db.POSMItems.SingleOrDefault(x => x.PosmID == updatePO.PosmID);
                    if (result != null)
                    {
                        // CashSettlement uc = new CashSettlement();
                        result.PosmName = updatePO.PosmName;
                    }
                    //db.POSMItems.Add(pi);
                    db.SaveChanges();
                    status = true;
                    return(new JsonResult {
                        Data = new { status = status, mes = mes }
                    });
                }
                catch (Exception ex)
                {
                    return(Json(new { status = "error", message = "Product ID Not Found" }));
                    //throw ex;
                }
            }
            else
            {
                status = false;
            }
            return(new JsonResult {
                Data = new { status = status, mes = mes }
            });                                                                 //, v = v } };
        }