public RNItemList GetRNItem(int?RIId)
        {
            PetaPoco.Database db = null;
            var        dbConn    = DataContext.Database.Connection;
            RNItemList user      = new RNItemList();

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

            finally
            {
                if (dbConn != null)
                {
                    dbConn.Close();
                }
            }
            return(user);
        }
Ejemplo n.º 2
0
        public ActionResult AddRNItem(int?RIId)
        {
            StoreService service = new StoreService();
            RNItemList   Product = new RNItemList();

            ViewBag.GRN = new SelectList(AllGRNs(), "Value", "Text");

            if (RIId != null)
            {
                Product = service.GetRNItem(RIId);
            }
            ViewBag.GRNI = new SelectList(AllGRNItem(Product.GRNId), "Value", "Text");
            return(PartialView("_AddRNItem", Product));
        }
Ejemplo n.º 3
0
        public int UpdateRNItem(RNItemList user)
        {
            int id = 0;

            try
            {
                id = _repository.UpdateRNItem(user);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(id);
        }
Ejemplo n.º 4
0
        public RNItemList GetRNItem(int?RIId)
        {
            RNItemList user = new RNItemList();

            try
            {
                user = _repository.GetRNItem(RIId);
            }

            catch (Exception ex)
            {
                throw;
            }

            return(user);
        }
Ejemplo n.º 5
0
        public ActionResult SaveRNItem(RNItemList product)
        {
            int          id      = 0;
            StoreService service = new StoreService();

            try
            {
                if (product.RIId > 0)
                {
                    id = service.UpdateRNItem(product);
                    return(Json(new { Status = true, Id = id, Message = "Record updated successfully" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    id = service.AddRNItem(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));
            }
        }
        public int AddRNItem(RNItemList 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_AddRNItem " + " @GRNId,@RNId,@GIId,@RIQuantity,@RIDescription,@RIUnitPrice; select @@ret;",
                                            new
                {
                    @GRNId         = user.GRNId,
                    @RNId          = user.RNId,
                    @GIId          = user.GIId,
                    @RIQuantity    = user.RIQuantity,
                    @RIDescription = user.RIDescription,
                    @RIUnitPrice   = user.RIUnitPrice
                });
            }
            catch (Exception ex)
            {
            }

            finally
            {
                if (dbConn != null)
                {
                    dbConn.Close();
                }
            }
            return(id);
        }