Пример #1
0
        public int AddPOItem(POItemList user)
        {
            int id = 0;

            PetaPoco.Database db = null;
            var dbConn           = DataContext.Database.Connection;

            try
            {
                dbConn.Open();
                db = new PetaPoco.Database(dbConn);
                db.EnableAutoSelect = false;
                id = db.ExecuteScalar <int>("declare @@ret INT; exec @@ret = usp_AddPOItem " + " @POId,@PROId,@PIDescription,@PIQuantity,@PIUnitPrice; select @@ret;",
                                            new
                {
                    @POId          = user.POId,
                    @PROId         = user.PROId,
                    @PIDescription = user.PIDescription,
                    @PIQuantity    = user.PIQuantity,
                    @PIUnitPrice   = user.PIUnitPrice
                });
            }
            catch (Exception ex)
            {
            }

            finally
            {
                if (dbConn != null)
                {
                    dbConn.Close();
                }
            }
            return(id);
        }
Пример #2
0
        public POItemList GetPOItem(int?PIID)
        {
            PetaPoco.Database db = null;
            var        dbConn    = DataContext.Database.Connection;
            POItemList user      = new POItemList();

            try
            {
                using (DataContext)
                {
                    dbConn.Open();
                    db = new PetaPoco.Database(dbConn);
                    db.EnableAutoSelect = false;
                    user = db.Query <POItemList>("exec usp_GetPOItem " + "@PIID",
                                                 new { PIID = PIID }).FirstOrDefault();
                    dbConn.Close();
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            finally
            {
                if (dbConn != null)
                {
                    dbConn.Close();
                }
            }
            return(user);
        }
Пример #3
0
        public JsonResult GetGRMItemsDetails(int?PIId)
        {
            PDService  service = new PDService();
            POItemList user    = new POItemList();

            user = service.GetPOItem(PIId);
            return(Json(new { up = user.PIUnitPrice, des = user.PIDescription, qty = user.PIQuantity }, JsonRequestBehavior.AllowGet));
        }
Пример #4
0
        public int UpdatePOItem(POItemList user)
        {
            int id = 0;

            try
            {
                id = _repository.UpdatePOItem(user);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(id);
        }
        public ActionResult AddProduct(int?PIId)
        {
            PDService  service = new PDService();
            POItemList Product = new POItemList();

            if (PIId != null)
            {
                Product = service.GetPOItem(PIId);
            }
            ViewBag.MainAssests = new SelectList(AllMainAssests(), "Value", "Text");
            ViewBag.SubAssests  = new SelectList(GetSubCatogoryForMC(Product.MCId), "Value", "Text");
            ViewBag.ProductName = new SelectList(GetProductForSC(Product.SCId), "Value", "Text");
            return(PartialView("_AddProduct", Product));
        }
Пример #6
0
        public POItemList GetPOItem(int?PIId)
        {
            POItemList user = new POItemList();

            try
            {
                user = _repository.GetPOItem(PIId);
            }

            catch (Exception ex)
            {
                throw;
            }

            return(user);
        }
        //public ActionResult ProductGrid(int? POId)
        //{
        //    try
        //    {
        //        PDService service = new PDService();
        //        PO user = new PO();
        //        user.POIList = service.GetPOItemList(POId);
        //        return PartialView("_ProductsGrid", user.POIList);
        //    }
        //    catch (Exception ex)
        //    {
        //        return Json(new { Status = false, Message = "Error Occured" }, JsonRequestBehavior.AllowGet);
        //    }
        //}

        public ActionResult SaveProduct(POItemList product)
        {
            int       id      = 0;
            PDService service = new PDService();

            try
            {
                if (product.PIId > 0)
                {
                    id = service.UpdatePOItem(product);
                    return(Json(new { Status = true, Id = id, Message = "Record updated successfully" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    id = service.AddPOItem(product);
                    return(Json(new { Status = true, Id = id, Message = "Record added successfully" }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Status = false, Message = "Error Occured" }, JsonRequestBehavior.AllowGet));
            }
        }