private void btnThem_Click_1(object sender, EventArgs e)
        {
            ProductBLL productBLL = new ProductBLL();
            Product    product    = new Product();

            product.productname = txtProductname.Text;
            product.detail      = txtDetail.Text;
            product.price       = int.Parse(price.Value.ToString());
            product.amount      = int.Parse(amount.Value.ToString());

            /* Lấy Id từ commobox đưa vào cơ sở dữ liệu */
            Company s = (Company)comboCategory.SelectedItem;

            product.companyid = s.Id;

            /*Lấy Tên Ảnh đưa vào cơ sở dữ liệu*/
            product.image = path;
            try
            {
                File.Copy(fullpath, DBConnection.folder_product + path);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            productBLL.AddProduct(product);
            LoadListview();
        }
Beispiel #2
0
        public JsonResult SaveProduct(string product)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            Product p = serializer.Deserialize <Product>(product);

            try
            {
                if (p != null)
                {
                    if (p.ID == 0)
                    {
                        productBLL.AddProduct(p);
                    }
                    else
                    {
                        productBLL.EditProduct(p);
                    }
                    return(Json(true));
                }
                else
                {
                    return(Json(false));
                }
            }
            catch (Exception)
            {
                return(Json(false));
            }
        }
Beispiel #3
0
 public ActionResult AddProduct(Product product)
 {
     product.PostedBy    = Convert.ToInt32(Session["AccountId"]);
     product.IsAvailable = true;
     ViewBag.Message     = productBll.AddProduct(product);
     ViewBag.CategoryId  = new SelectList(categoryBll.GetCategories(), "Id", "CategoryName");
     return(View());
 }
Beispiel #4
0
 public IActionResult Create([Bind] Product product)
 {
     if (ModelState.IsValid)
     {
         _dB.AddProduct(product);
         return(RedirectToAction("Index"));
     }
     return(View(product));
 }
Beispiel #5
0
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            ProductInfo product = new ProductInfo();

            product.ID                = RequestHelper.GetQueryString <int>("ID");
            product.Name              = this.Name.Text;
            product.Spelling          = ChineseCharacterHelper.GetFirstLetter(this.Name.Text);
            product.Color             = RequestHelper.GetForm <string>("ProductColor");
            product.FontStyle         = this.FontStyle.Text;
            product.ProductNumber     = this.ProductNumber.Text;
            product.ClassID           = this.ProductClass.ClassIDList;
            product.Keywords          = this.Keywords.Text;
            product.BrandID           = this.BrandID.Text;
            product.MarketPrice       = Convert.ToDecimal(this.MarketPrice.Text);
            product.SendPoint         = Convert.ToInt32(this.SendPoint.Text);
            product.Photo             = this.Photo.Text;
            product.Summary           = this.Summary.Text;
            product.Introduction      = this.Introduction.Value;
            product.Weight            = Convert.ToInt32(this.Weight.Text);
            product.IsSpecial         = Convert.ToInt32(this.IsSpecial.Text);
            product.IsNew             = Convert.ToInt32(this.IsNew.Text);
            product.IsHot             = Convert.ToInt32(this.IsHot.Text);
            product.IsSale            = Convert.ToInt32(this.IsSale.Text);
            product.IsTop             = Convert.ToInt32(this.IsTop.Text);
            product.Remark            = this.Remark.Text;
            product.Accessory         = RequestHelper.GetForm <string>("RelationAccessoryID");
            product.RelationProduct   = RequestHelper.GetForm <string>("RelationProductID");
            product.RelationArticle   = RequestHelper.GetForm <string>("RelationArticleID");
            product.AllowComment      = Convert.ToInt32(this.AllowComment.Text);
            product.TotalStorageCount = Convert.ToInt32(this.TotalStorageCount.Text);
            product.LowerCount        = Convert.ToInt32(this.LowerCount.Text);
            product.UpperCount        = Convert.ToInt32(this.UpperCount.Text);
            product.AttributeClassID  = Convert.ToInt32(this.AttributeClassID.Text);
            product.StandardType      = Convert.ToInt32(this.StandardType.Text);
            product.AddDate           = RequestHelper.DateNow;
            string alertMessage = ShopLanguage.ReadLanguage("AddOK");

            if (product.ID == -2147483648)
            {
                base.CheckAdminPower("AddProduct", PowerCheckType.Single);
                int productID = ProductBLL.AddProduct(product);
                this.AddProductPhoto(productID);
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("Product"), productID);
            }
            else
            {
                base.CheckAdminPower("UpdateProduct", PowerCheckType.Single);
                ProductBLL.UpdateProduct(product);
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("Product"), product.ID);
                alertMessage = ShopLanguage.ReadLanguage("UpdateOK");
            }
            this.HanderAttribute(product);
            this.HanderMemberPrice(product.ID);
            this.HanderProductStandard(product);
            AdminBasePage.Alert(alertMessage, RequestHelper.RawUrl);
        }
Beispiel #6
0
 public IActionResult Create([Bind] Product product)
 {
     try
     {
         _dB.AddProduct(product);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
     return(Ok(product));
 }
Beispiel #7
0
        public dynamic AddProduct()
        {
            string     name      = Fun.Form("name");
            int        type      = Fun.Form("type", 0);
            string     mode      = Fun.Form("mode");
            decimal    price     = Fun.Form("price", 0);
            string     component = Fun.Form("component");
            string     num       = Fun.Form("num");
            string     info      = Fun.Form("info");
            string     img       = Fun.Form("img");
            ProductBLL bll       = new ProductBLL();

            if (!bll.AddProduct(name, type, mode, component, num, price, info, img))
            {
                return("失败");
            }
            else
            {
                return("成功");
            }
        }
        private void btnThem_Click(object sender, EventArgs e)
        {
            ProductBLL productBLL = new ProductBLL();
            Product    product    = new Product();

            product.productname = txtProductname.Text;
            product.detail      = txtDetail.Text;
            product.price       = int.Parse(price.Value.ToString());
            product.amount      = int.Parse(amount.Value.ToString());

            /* Lấy Id từ commobox đưa vào cơ sở dữ liệu */
            Category s = (Category)comboCategory.SelectedItem;

            product.categoryid = s.Id;

            /*Lấy Tên Ảnh đưa vào cơ sở dữ liệu*/
            product.image = path;
            try
            {
                int i = 1;
                while (File.Exists(DBConnection.folder_product + path))
                {
                    string[] temp = path.Split('.');
                    path = temp[0] + "-" + i + "." + temp[1];
                    i++;
                }
                File.Copy(fullpath, DBConnection.folder_product + path);

                productBLL.AddProduct(product);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            LoadListview();
        }
Beispiel #9
0
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            ProductInfo product = new ProductInfo();

            product.ID        = RequestHelper.GetQueryString <int>("ID");
            product.CompanyID = companyID;
            product.Name      = this.Name.Text;
            product.Spelling  = ChineseCharacterHelper.GetFirstLetter(this.Name.Text);
            product.Color     = RequestHelper.GetForm <string>("ProductColor");
            //product.FontStyle = this.FontStyle.Text;
            product.ProductNumber = this.ProductNumber.Text;
            product.ClassID       = this.ProductClass.ClassIDList;
            product.Keywords      = this.Keywords.Text;
            if (string.IsNullOrEmpty(RequestHelper.GetForm <string>("AllBrandID")))
            {
                product.BrandID = RequestHelper.GetIntsForm("BrandID");
            }
            else
            {
                product.BrandID = RequestHelper.GetIntsForm("AllBrandID");
            }
            product.MarketPrice      = Convert.ToDecimal(this.MarketPrice.Text);
            product.Photo            = this.Photo.Text;
            product.Summary          = this.Summary.Text;
            product.Introduction     = this.Introduction.Value;
            product.IsSpecial        = Convert.ToInt32(this.IsSpecial.Text);
            product.IsNew            = Convert.ToInt32(this.IsNew.Text);
            product.IsHot            = Convert.ToInt32(this.IsHot.Text);
            product.IsSale           = Convert.ToInt32(this.IsSale.Text);
            product.IsTop            = Convert.ToInt32(this.IsTop.Text);
            product.Remark           = this.Remark.Text;
            product.Accessory        = RequestHelper.GetForm <string>("RelationAccessoryID");
            product.RelationProduct  = RequestHelper.GetForm <string>("RelationProductID");
            product.RelationArticle  = RequestHelper.GetForm <string>("RelationArticleID");
            product.AllowComment     = Convert.ToInt32(this.AllowComment.Text);
            product.AttributeClassID = Convert.ToInt32(this.AttributeClassID.Text);
            product.StandardType     = Convert.ToInt32(this.StandardType.Text);
            product.AddDate          = RequestHelper.DateNow;
            product.Sort             = Convert.ToInt32(Sort.Text);
            product.Editor           = Editor.Text;
            int    productID    = 0;
            string alertMessage = ShopLanguage.ReadLanguage("AddOK");

            if (product.ID == -2147483648)
            {
                base.CheckAdminPower("AddProduct", PowerCheckType.Single);
                productID = ProductBLL.AddProduct(product);
                this.AddProductPhoto(productID);
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("Product"), productID);
            }
            else
            {
                base.CheckAdminPower("UpdateProduct", PowerCheckType.Single);
                //公司发生变化,删除旧的考试设置
                ProductInfo oldProduct = ProductBLL.ReadProduct(product.ID);
                if (product.CompanyID != ProductBLL.ReadProduct(product.ID).CompanyID)
                {
                    try
                    {
                        TestSettingBLL.DeleteTestSetting(TestSettingBLL.ReadCompanyTestSetting(oldProduct.CompanyID, product.ID).Id);
                    }
                    catch (Exception ex)
                    { }
                }
                ProductBLL.UpdateProduct(product);
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("Product"), product.ID);
                alertMessage = ShopLanguage.ReadLanguage("UpdateOK");
            }
            this.HanderAttribute(product);
            //this.HanderMemberPrice(product.ID);
            this.HanderProductStandard(product);
            if (product.ID == int.MinValue)
            {
                product.ID = productID;
            }
            this.HanderTestSetting(product);
            AdminBasePage.Alert(alertMessage, RequestHelper.RawUrl);
        }
Beispiel #10
0
        public ActionResult AddProduct()
        {
            ViewBag.success = false;
            if (!AppData.IsManagerLogin)
            {
                return(Json(new { success = false, msg = "您未登录后台或会话已过期" }));
            }
            if (PrivilegeBLL.HasNotPrivilege(AppData.SessionUserID, 401))
            {
                return(Json(new { success = false, msg = "您没有执行该操作的权限" }));
            }

            Validation validation = new Validation();

            string     sCategories = validation.Get("categoryIds", false, "请选择商品类别", @"^\d+(\,\d+)*$", "请选择商品类别");
            ProductObj productObj  = new ProductObj();

            productObj.CategoryID             = validation.GetInt("categoryID");
            productObj.Name                   = validation.Get("name", false, "请填写商品名称");
            productObj.Type                   = validation.Get("type");
            productObj.Serial                 = validation.Get("serial");
            productObj.Model                  = validation.Get("model");
            productObj.Code                   = validation.Get("code");
            productObj.Material               = validation.Get("material");
            productObj.Weight                 = validation.Get("weight");
            productObj.Characteristic         = validation.Get("characteristic");
            productObj.Designer               = validation.Get("designer");
            productObj.Price                  = validation.GetDecimal("price");
            productObj.SpecialPrice           = validation.GetDecimal("specialPrice");
            productObj.IsRecommend            = validation.GetBool("isRecommend");
            productObj.IsOnSale               = validation.GetBool("isOnSale");
            productObj.IsNew                  = validation.GetBool("isNew");
            productObj.CanPurchasedSeparately = validation.GetBool("canPurchasedSeparately");
            productObj.Description            = HttpUtility.UrlDecode(validation.Get("description", false, "请填写商品描述"), Encoding.UTF8);
            productObj.Freight                = validation.GetDecimal("freight");
            productObj.Freight1               = validation.GetDecimal("freight1");
            productObj.Inventory              = validation.GetInt("inventory");
            productObj.Quantity               = productObj.Inventory;
            productObj.Tags                   = validation.Get("tags");
            productObj.Points                 = validation.GetInt("points");
            productObj.Sort                   = DateTime.Now;

            productObj.FreightModels = new List <int>();
            string freightModels = validation.Get("freightModels");
            var    fms           = freightModels.Split(',');

            for (int i = 0; i < fms.Length; i++)
            {
                if (!string.IsNullOrEmpty(fms[i]))
                {
                    productObj.FreightModels.Add(int.Parse(fms[i]));
                }
            }

            string strPics = validation.Get("pics", false, "请上传商品图片", @"\d+(,\d+)*", "参数错误");

            if (validation.HasError || productObj.CategoryID == 0)
            {
                return(Json(new { success = false, msg = "参数错误", errors = validation.GetErrors() }));
            }

            string[] cates = sCategories.Split(',');
            productObj.Categories = new List <int>();
            for (var i = 0; i < cates.Length; i++)
            {
                productObj.Categories.Add(int.Parse(cates[i]));
            }

            string[]          pics = strPics.Split(',');
            ProductPictureObj productPictureObj;

            productObj.ProductPictures = new List <ProductPictureObj>();
            for (int i = 0; i < pics.Length; i++)
            {
                productPictureObj           = new ProductPictureObj();
                productPictureObj.PictureID = int.Parse(pics[i]);
                productObj.ProductPictures.Add(productPictureObj);
            }

            ProductBLL productBLL = new ProductBLL();

            if (productBLL.IsProductExists(productObj.Name))
            {
                return(Json(new { success = false, msg = "该商品名称已存在!" }));
            }

            productBLL.AddProduct(productObj);

            if (productObj.ProductID != 0)
            {
                return(Json(new { success = true, id = productObj.ProductID }));
            }
            else
            {
                return(Json(new { success = false, msg = "抱歉,添加失败!" }));
            }
        }
Beispiel #11
0
 private void button1_Click(object sender, EventArgs e)
 {
     ProductBLL.AddProduct(textBox1.Text, (int)comboBox1.SelectedValue, (int)comboBox2.SelectedValue);
 }