public PartialViewResult Edit(string id)
        {
            view_DetailProduct obj = (new ProductService()).GetViewProductByID(id);

            if (obj == null)
            {
                obj = new view_DetailProduct();
            }
            return(PartialView("EditProduct", obj));
        }
예제 #2
0
        public int UpdateOrInsertProduct(view_DetailProduct objView)
        {
            tbl_Product obj = CloneFromView(objView);

            using (var db = _connectionData.OpenDbConnection())
            {
                if (obj.Id > 0)
                {
                    var query     = db.From <tbl_Product>().Where(e => e.Id == obj.Id);
                    var objUpdate = db.Select(query).SingleOrDefault();
                    if (objUpdate != null)
                    {
                        objUpdate.Name        = obj.Name;
                        objUpdate.Code        = obj.Code;
                        objUpdate.Description = obj.Description;
                        objUpdate.PriceOrder  = obj.PriceOrder;

                        objUpdate.SalePrice  = obj.SalePrice;
                        objUpdate.Status     = obj.Status;
                        objUpdate.SupplierID = obj.SupplierID;
                        objUpdate.UnitID     = obj.UnitID;

                        objUpdate.QuotaMinimize  = obj.QuotaMinimize;
                        objUpdate.ProductGroupID = obj.ProductGroupID;


                        return(db.Update(objUpdate));
                    }
                    return(-1);
                }
                else
                {
                    var queryCount = db.From <tbl_Unit>().Where(e => e.Name1 == obj.Name && e.SysHotelID == comm.GetHotelId()).Select(e => e.Id);
                    var objCount   = db.Count(queryCount);
                    if (objCount > 0)
                    {
                        return(comm.ERROR_EXIST);
                    }

                    obj.SysHotelID = comm.GetHotelId();
                    return((int)db.Insert(obj, selectIdentity: true));
                }
            }
        }
예제 #3
0
        public tbl_Product CloneFromView(view_DetailProduct objView)
        {
            var obj = InitEmpty();

            obj.Id   = objView.ID;
            obj.Name = objView.Name;
            obj.Code = objView.Code;

            obj.SysHotelID     = objView.SysHotelID;
            obj.PictureUrl     = objView.PictureUrl;
            obj.PriceOrder     = objView.PriceOrder;
            obj.SalePrice      = objView.SalePrice;
            obj.Status         = objView.Status;
            obj.SysHotelID     = objView.SysHotelID;
            obj.UnitID         = objView.UnitID;
            obj.Description    = objView.Description;
            obj.SupplierID     = objView.SupplierID;
            obj.ProductGroupID = objView.ProductGroupID;
            obj.QuotaMinimize  = objView.QuotaMinimize;

            return(obj);
        }
        public ActionResult Update(view_DetailProduct obj)
        {
            int result = (new ProductService()).UpdateOrInsertProduct(obj);

            return(Json(new { result = result }, JsonRequestBehavior.AllowGet));
        }