Пример #1
0
        public ActionResult SaveAjax(string c_title, long?c_brand, string c_code, string c_currency, decimal?c_stock_price, decimal?c_sale_price, int?c_unit)
        {
            EAP.Logic.DictResponse res  = new EAP.Logic.DictResponse();
            Z01Product             data = new Z01Product();

            data.Title        = c_title;
            data.BrandID      = c_brand;
            data.Currency     = c_currency;
            data.PriceStock   = c_stock_price;
            data.PriceList    = c_sale_price;
            data.PriceSelling = c_sale_price;
            data.UnitID       = c_unit;
            data.TenantID     = _tenant.TenantID;
            data.Creator      = _user.UserID;
            data.Code         = c_code.Trim();
            if (c_code.IsNotNullOrEmpty())
            {
                if (db.Exists <Z01Product>("Code=@Code", db.CreateParameter("Code", c_code.Trim())))
                {
                    res._state   = false;
                    res._message = "编号重复,请核对";
                    return(Content(res.ToJson()));
                }
            }
            var bid = db.Insert(data);

            res._state = true;
            res._data.Add("title", c_title);
            res._data.Add("id", bid);
            return(Content(res.ToJson()));
        }
Пример #2
0
        public ActionResult SaveAjaxAdmin(long c_id, string c_title, string c_code, long?c_brand, string c_currency, decimal?c_stock_price, decimal?c_sale_price, int?c_unit)
        {
            EAP.Logic.DictResponse res  = new EAP.Logic.DictResponse();
            Z01Product             data = new Z01Product();

            data.ProductID    = c_id;
            data.Title        = c_title;
            data.BrandID      = c_brand;
            data.Currency     = c_currency;
            data.PriceStock   = c_stock_price;
            data.PriceList    = c_sale_price;
            data.PriceSelling = c_sale_price;
            data.UnitID       = c_unit;
            data.Updater      = _user.UserID;
            data.Code         = c_code;
            var bid = db.Update(data);

            //更新库存的进货价格
            if (db.Exists <Z10Cabbage.Entity.Z10OrderItem>("ProductID=@proid", db.CreateParameter("proid", c_id)))
            {
                res._state   = false;
                res._message = "该商品已经进入订单系统,库存价格未修改,请使用其他方法修订。";
            }
            else
            {
                string sql = "update Z10DepotProductDetail set PriceStock=@xprice where ProductID=@proid";
                db.ExecuteNonQuery(sql, db.CreateParameter("xprice", c_stock_price ?? 0), db.CreateParameter("proid", c_id));
                res._state = true;
            }
            return(Content(res.ToJson()));
        }
Пример #3
0
        public ActionResult Details(System.Int64 id)
        {
            if ((_crud & Zippy.SaaS.Entity.CRUD.Read) != Zippy.SaaS.Entity.CRUD.Read)
            {
                return(RedirectToAction("NoPermission", "Error"));
            }
            Z01Product entity = Z01ProductHelper.Create(db, id);

            return(View(entity));
        }
Пример #4
0
        public ActionResult OrderHistory(long id)
        {
            ViewBag._user = _user;
            Z01Product product = db.FindUnique <Z01Product>(id);
            var        items   = db.Take <EAP.Logic.Z10.View.V_OrderItemDetail>("ProductID=@ProductID and DeleteFlag=@not_delete and (OrderType&@Sale)=@Sale  order by ItemID desc",
                                                                                db.CreateParameter("ProductID", id), db.CreateParameter("not_delete", (int)EAP.Logic.DeleteFlags.Normal), db.CreateParameter("Sale", (int)EAP.Logic.Z10.OrderTypes.Sale));

            ViewBag._product = product;
            ViewBag._brand   = db.FindUnique <Z01Brand>(product.BrandID);
            return(View(items));
        }
Пример #5
0
        public ActionResult Edit(System.Int64?id, string act)
        {
            Z01Product entity         = null;
            long       defaultBrandID = 0;

            if (id.HasValue && id > 0)
            {
                if (act == "detail")
                {
                    if ((_crud & Zippy.SaaS.Entity.CRUD.Read) != Zippy.SaaS.Entity.CRUD.Read)
                    {
                        return(RedirectToAction("NoPermission", "Error"));
                    }
                    ViewData["VTitle"]   = "查看产品信息";
                    ViewData["IsDetail"] = true;
                }
                else
                {
                    if ((_crud & Zippy.SaaS.Entity.CRUD.Update) != Zippy.SaaS.Entity.CRUD.Update)
                    {
                        return(RedirectToAction("NoPermission", "Error"));
                    }
                    ViewData["VTitle"] = "修改产品信息";
                }
                entity         = Z01ProductHelper.Create(db, id.Value);
                defaultBrandID = entity.BrandID ?? 0;
            }
            else
            {
                if ((_crud & Zippy.SaaS.Entity.CRUD.Create) != Zippy.SaaS.Entity.CRUD.Create)
                {
                    return(RedirectToAction("NoPermission", "Error"));
                }
                ViewData["VTitle"] = "新增产品";
                entity             = new Z01Product();
                try
                {
                    defaultBrandID = Request.Cookies["defaultBrandID"].Value.ToInt64();
                }
                catch { }
            }
            ViewData["UnitIDOptions"]  = Z01ProductHelper.GetUnitIDEntitiesHtmlOption(db, _tenant.TenantID.Value, entity.UnitID);
            ViewData["BrandIDOptions"] = Z01ProductHelper.GetBrandIDEntitiesHtmlOption(db, _tenant.TenantID.Value, defaultBrandID);
            ViewData["MoneyOptions"]   = EAP.Logic.Bus.HtmlHelper.CurrencySelectOptions(db);

            string returnUrl = Request["ReturnUrl"];

            if (returnUrl.IsNullOrEmpty())
            {
                returnUrl = "/" + _ContollerName;
            }
            ViewData["ReturnUrl"] = returnUrl;
            return(View(entity));
        }
Пример #6
0
        public ActionResult SetStatus(int id, int sts)
        {
            Z01Product data = new Z01Product();

            data.ProductID     = id;
            data.ProductStatus = sts;
            db.Update(data);

            EAP.Logic.DictResponse res = new EAP.Logic.DictResponse();
            res._state = true;
            return(Content(res.ToJson()));
        }
Пример #7
0
        public ActionResult Edit(System.Int64?id, Z01Product entity)
        {
            entity.ProductID = id;
            string formProductType = Request.Form["ProductType"];

            entity.ProductType = formProductType.ToEnumInt32();

            var ck_brandid = new System.Web.HttpCookie("defaultBrandID", (entity.BrandID ?? 0).ToString());

            ck_brandid.Expires = DateTime.Now.AddMinutes(20);
            Response.SetCookie(ck_brandid);
            ValidateZ01Product(entity);
            if (!ModelState.IsValid)
            {
                ViewData["UnitIDOptions"]  = Z01ProductHelper.GetUnitIDEntitiesHtmlOption(db, _tenant.TenantID.Value, entity.UnitID);
                ViewData["BrandIDOptions"] = Z01ProductHelper.GetBrandIDEntitiesHtmlOption(db, _tenant.TenantID.Value, entity.BrandID);
                ViewData["MoneyOptions"]   = EAP.Logic.Bus.HtmlHelper.CurrencySelectOptions(db);

                return(View(entity));
            }
            try
            {
                if (id.HasValue && id > 0)
                {
                    if ((_crud & Zippy.SaaS.Entity.CRUD.Update) != Zippy.SaaS.Entity.CRUD.Update)
                    {
                        return(RedirectToAction("NoPermission", "Error"));
                    }

                    db.Update(entity);
                }
                else
                {
                    if ((_crud & Zippy.SaaS.Entity.CRUD.Create) != Zippy.SaaS.Entity.CRUD.Create)
                    {
                        return(RedirectToAction("NoPermission", "Error"));
                    }
                    entity.ProductID = null;
                    entity.TenantID  = _tenant.TenantID;
                    int pkid = db.Insert(entity);
                }

                return(Return());
            }
            catch
            {
                return(View(entity));
            }
        }
Пример #8
0
        public ActionResult Edit(System.Int64? id, string act)
        {
            Z01Product entity = null;
            long defaultBrandID = 0;
            if (id.HasValue && id > 0)
            {
                if (act == "detail")
                {
                    if ((_crud & Zippy.SaaS.Entity.CRUD.Read) != Zippy.SaaS.Entity.CRUD.Read) return RedirectToAction("NoPermission", "Error");
                    ViewData["VTitle"] = "查看产品信息";
                    ViewData["IsDetail"] = true;
                }
                else
                {
                    if ((_crud & Zippy.SaaS.Entity.CRUD.Update) != Zippy.SaaS.Entity.CRUD.Update) return RedirectToAction("NoPermission", "Error");
                    ViewData["VTitle"] = "修改产品信息";
                }
                entity = Z01ProductHelper.Create(db, id.Value);
                defaultBrandID = entity.BrandID ?? 0;
            }
            else
            {
                if ((_crud & Zippy.SaaS.Entity.CRUD.Create) != Zippy.SaaS.Entity.CRUD.Create) return RedirectToAction("NoPermission", "Error");
                ViewData["VTitle"] = "新增产品";
                entity = new Z01Product();
                try
                {
                    defaultBrandID = Request.Cookies["defaultBrandID"].Value.ToInt64();
                }
                catch { }
            }
            ViewData["UnitIDOptions"] = Z01ProductHelper.GetUnitIDEntitiesHtmlOption(db, _tenant.TenantID.Value, entity.UnitID);
            ViewData["BrandIDOptions"] = Z01ProductHelper.GetBrandIDEntitiesHtmlOption(db, _tenant.TenantID.Value, defaultBrandID);
            ViewData["MoneyOptions"] = EAP.Logic.Bus.HtmlHelper.CurrencySelectOptions(db);

            string returnUrl = Request["ReturnUrl"];
            if (returnUrl.IsNullOrEmpty()) returnUrl = "/" + _ContollerName;
            ViewData["ReturnUrl"] = returnUrl;
            return View(entity);
        }
Пример #9
0
 protected void ValidateZ01Product(Z01Product entity)
 {
     if (string.IsNullOrEmpty(entity.Title))
     {
         ModelState.AddModelError("Title required", "标题:必须填写");
     }
     else if (entity.Title.Length > 300)
     {
         ModelState.AddModelError("Title string length error", "标题:填写的内容太多");
     }
     if (!string.IsNullOrEmpty(entity.Brief) && entity.Brief.Length > 2000)
     {
         ModelState.AddModelError("Brief string length error", "商品简介:填写的内容太多");
     }
     if (!string.IsNullOrEmpty(entity.ImagePath) && entity.ImagePath.Length > 50)
     {
         ModelState.AddModelError("ImagePath string length error", "商品图片:填写的内容太多");
     }
     if (!string.IsNullOrEmpty(entity.Code) && entity.Code.Length > 50)
     {
         ModelState.AddModelError("Code string length error", "编码:填写的内容太多");
     }
 }
Пример #10
0
 /// <summary>
 /// 获取 [产品 的 产品] 的 [客户分类关系] 集合
 /// </summary>
 public static List <Z01CustomerInCategory> GetProductID_Z01CustomerInCategorys(Zippy.Data.IDalProvider db, Z01Product entity)
 {
     if (entity.ProductID.HasValue)
     {
         return(db.Take <Z01CustomerInCategory>("ProductID=@ProductID", db.CreateParameter("ProductID", entity.ProductID)));
     }
     return(new List <Z01CustomerInCategory>());
 }
Пример #11
0
        public static int Insert(Zippy.Data.IDalProvider db, Z01Product entity)
        {
            int rtn = db.Insert(entity);

            return(rtn);
        }
Пример #12
0
 public static int Update(Zippy.Data.IDalProvider db, Z01Product entity)
 {
     return(db.Update(entity));
 }
Пример #13
0
 /// <summary>
 /// 表示 [属性模板] 对应的实体
 /// </summary>
 public static PropertyTemplate GetPropertyTemplateEntity(Zippy.Data.IDalProvider db, Z01Product entity)
 {
     return(db.FindUnique <PropertyTemplate>("TemplateID=@TemplateID", db.CreateParameter("TemplateID", entity.PropertyTemplate)));
 }
Пример #14
0
        public static Z01Product Create(Zippy.Data.IDalProvider db, Int64 _ProductID)
        {
            Z01Product rtn = db.FindUnique <Z01Product>(_ProductID);

            return(rtn);
        }
Пример #15
0
 protected void ValidateZ01Product(Z01Product entity)
 {
     if (string.IsNullOrEmpty(entity.Title))
         ModelState.AddModelError("Title required", "标题:必须填写");
     else if (entity.Title.Length > 300)
         ModelState.AddModelError("Title string length error", "标题:填写的内容太多");
     if (!string.IsNullOrEmpty(entity.Brief) && entity.Brief.Length > 2000)
         ModelState.AddModelError("Brief string length error", "商品简介:填写的内容太多");
     if (!string.IsNullOrEmpty(entity.ImagePath) && entity.ImagePath.Length > 50)
         ModelState.AddModelError("ImagePath string length error", "商品图片:填写的内容太多");
     if (!string.IsNullOrEmpty(entity.Code) && entity.Code.Length > 50)
         ModelState.AddModelError("Code string length error", "编码:填写的内容太多");
 }
Пример #16
0
        public ActionResult SetStatus(int id, int sts)
        {
            Z01Product data = new Z01Product();
            data.ProductID = id;
            data.ProductStatus = sts;
            db.Update(data);

            EAP.Logic.DictResponse res = new EAP.Logic.DictResponse();
            res._state = true;
            return Content(res.ToJson());
        }
Пример #17
0
 /// <summary>
 /// 表示 [属性模板] 对应的实体
 /// </summary>
 public static PropertyTemplate GetPropertyTemplateEntity(Zippy.Data.IDalProvider db, Z01Product entity)
 {
     return db.FindUnique<PropertyTemplate>("TemplateID=@TemplateID", db.CreateParameter("TemplateID", entity.PropertyTemplate));
 }
Пример #18
0
        public ActionResult Edit(System.Int64? id, Z01Product entity)
        {
            entity.ProductID = id;
            string formProductType = Request.Form["ProductType"];
            entity.ProductType = formProductType.ToEnumInt32();

            var ck_brandid = new System.Web.HttpCookie("defaultBrandID", (entity.BrandID ?? 0).ToString());
            ck_brandid.Expires = DateTime.Now.AddMinutes(20);
            Response.SetCookie(ck_brandid);
            ValidateZ01Product(entity);
            if (!ModelState.IsValid)
            {
                ViewData["UnitIDOptions"] = Z01ProductHelper.GetUnitIDEntitiesHtmlOption(db, _tenant.TenantID.Value, entity.UnitID);
                ViewData["BrandIDOptions"] = Z01ProductHelper.GetBrandIDEntitiesHtmlOption(db, _tenant.TenantID.Value, entity.BrandID);
                ViewData["MoneyOptions"] = EAP.Logic.Bus.HtmlHelper.CurrencySelectOptions(db);

                return View(entity);
            }
            try
            {
                if (id.HasValue && id > 0)
                {
                    if ((_crud & Zippy.SaaS.Entity.CRUD.Update) != Zippy.SaaS.Entity.CRUD.Update) return RedirectToAction("NoPermission", "Error");

                    db.Update(entity);
                }
                else
                {
                    if ((_crud & Zippy.SaaS.Entity.CRUD.Create) != Zippy.SaaS.Entity.CRUD.Create) return RedirectToAction("NoPermission", "Error");
                    entity.ProductID = null;
                    entity.TenantID = _tenant.TenantID;
                    int pkid = db.Insert(entity);

                }

                return Return();
            }
            catch
            {
                return View(entity);
            }
        }
Пример #19
0
 public static int Insert(Zippy.Data.IDalProvider db, Z01Product entity)
 {
     int rtn = db.Insert(entity);
     return rtn;
 }
Пример #20
0
 /// <summary>
 /// 表示 [标准计量单位] 对应的实体
 /// </summary>
 public static Z01Unit GetUnitIDEntity(Zippy.Data.IDalProvider db, Z01Product entity)
 {
     return db.FindUnique<Z01Unit>("UnitID=@UnitID", db.CreateParameter("UnitID", entity.UnitID));
 }
Пример #21
0
        public ActionResult SaveAjaxAdmin(long c_id, string c_title, string c_code, long? c_brand, string c_currency, decimal? c_stock_price, decimal? c_sale_price, int? c_unit)
        {
            EAP.Logic.DictResponse res = new EAP.Logic.DictResponse();
            Z01Product data = new Z01Product();
            data.ProductID = c_id;
            data.Title = c_title;
            data.BrandID = c_brand;
            data.Currency = c_currency;
            data.PriceStock = c_stock_price;
            data.PriceList = c_sale_price;
            data.PriceSelling = c_sale_price;
            data.UnitID = c_unit;
            data.Updater = _user.UserID;
            data.Code = c_code;
            var bid = db.Update(data);

            //更新库存的进货价格
            if (db.Exists<Z10Cabbage.Entity.Z10OrderItem>("ProductID=@proid", db.CreateParameter("proid", c_id)))
            {
                res._state = false;
                res._message = "该商品已经进入订单系统,库存价格未修改,请使用其他方法修订。";
            }
            else
            {
                string sql = "update Z10DepotProductDetail set PriceStock=@xprice where ProductID=@proid";
                db.ExecuteNonQuery(sql, db.CreateParameter("xprice", c_stock_price ?? 0), db.CreateParameter("proid", c_id));
                res._state = true;
            }
            return Content(res.ToJson());
        }
Пример #22
0
 /// <summary>
 /// 表示 [标准计量单位] 对应的实体
 /// </summary>
 public static Z01Unit GetUnitIDEntity(Zippy.Data.IDalProvider db, Z01Product entity)
 {
     return(db.FindUnique <Z01Unit>("UnitID=@UnitID", db.CreateParameter("UnitID", entity.UnitID)));
 }
Пример #23
0
 /// <summary>
 /// 获取 [产品 的 产品] 的 [产品分类关系] 集合
 /// </summary>
 public static List<Z01ProductInCategory> GetProductID_Z01ProductInCategorys(Zippy.Data.IDalProvider db, Z01Product entity)
 {
     if (entity.ProductID.HasValue)
         return db.Take<Z01ProductInCategory>("ProductID=@ProductID", db.CreateParameter("ProductID", entity.ProductID));
     return new List<Z01ProductInCategory>();
 }
Пример #24
0
 /// <summary>
 /// 表示 [品牌] 对应的实体
 /// </summary>
 public static Z01Brand GetBrandIDEntity(Zippy.Data.IDalProvider db, Z01Product entity)
 {
     return db.FindUnique<Z01Brand>("BrandID=@BrandID", db.CreateParameter("BrandID", entity.BrandID));
 }
Пример #25
0
 public static int Update(Zippy.Data.IDalProvider db, Z01Product entity)
 {
     return db.Update(entity);
 }
Пример #26
0
 /// <summary>
 /// 表示 [品牌] 对应的实体
 /// </summary>
 public static Z01Brand GetBrandIDEntity(Zippy.Data.IDalProvider db, Z01Product entity)
 {
     return(db.FindUnique <Z01Brand>("BrandID=@BrandID", db.CreateParameter("BrandID", entity.BrandID)));
 }
Пример #27
0
 public ActionResult SaveAjax(string c_title, long? c_brand, string c_code, string c_currency, decimal? c_stock_price, decimal? c_sale_price, int? c_unit)
 {
     EAP.Logic.DictResponse res = new EAP.Logic.DictResponse();
     Z01Product data = new Z01Product();
     data.Title = c_title;
     data.BrandID = c_brand;
     data.Currency = c_currency;
     data.PriceStock = c_stock_price;
     data.PriceList = c_sale_price;
     data.PriceSelling = c_sale_price;
     data.UnitID = c_unit;
     data.TenantID = _tenant.TenantID;
     data.Creator = _user.UserID;
     data.Code = c_code.Trim();
     if (c_code.IsNotNullOrEmpty())
     {
         if (db.Exists<Z01Product>("Code=@Code", db.CreateParameter("Code", c_code.Trim())))
         {
             res._state = false;
             res._message = "编号重复,请核对";
             return Content(res.ToJson());
         }
     }
     var bid = db.Insert(data);
     res._state = true;
     res._data.Add("title", c_title);
     res._data.Add("id", bid);
     return Content(res.ToJson());
 }