Пример #1
0
        public virtual IHttpActionResult Add(ProductTypeAddRequest request)
        {
            var entity = new ProductType
            {
            };
            var result = _productTypeService.Add(entity);

            if (result > 0)
            {
                return(Succeed(new ProductTypeAddResponse
                {
                    Id = entity.Id
                }, "新增成功"));
            }
            else
            {
                return(Fail("新增失败"));
            }
        }
Пример #2
0
        /// <summary>
        /// Add
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (VerificationHelper.IsInputBoxEmpty(txtProductTypeName))
            {
                return;
            }

            if (productTypeService.IsProductTypeNameExisted(txtProductTypeName.Text.Trim()))
            {
                MessageBox.Show("This " + txtProductTypeName.Text.Trim() + " already exists.");
            }
            else
            {
                var productType = new ProductType()
                {
                    ProductTypeName = txtProductTypeName.Text
                };

                productTypeService.Add(productType);
            }

            ResetUIInputtdData();
        }
Пример #3
0
        /// <summary>
        /// 添加类型
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_Click(object sender, EventArgs e)
        {
            string typename = this.txtTypeName.Text.Trim();

            if (typename.Length == 0)
            {
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('类型名称不能为空!');", true);
                return;
            }
            ProductType item = new ProductType();

            item.typeName = typename;

            item.parentId = 0;
            item.oneId    = Convert.ToInt32(ddlOne.SelectedValue);
            item.oneName  = ddlOne.SelectedItem.Text;
            if (item.oneId != 0)
            {
                item.parentId = item.oneId;
            }
            item.twoId   = Convert.ToInt32(ddlTwo.SelectedValue);
            item.twoName = ddlTwo.SelectedValue;
            if (item.twoId != 0)
            {
                item.parentId = item.twoId;
            }
            item.threeId   = Convert.ToInt32(ddlThree.SelectedValue);
            item.threeName = ddlThree.SelectedItem.Text;
            if (item.threeId != 0)
            {
                item.parentId = item.threeId;
            }
            item.fourId   = Convert.ToInt32(ddlFour.SelectedValue);
            item.fourName = ddlFour.SelectedItem.Text;
            if (item.fourId != 0)
            {
                item.parentId = item.fourId;
            }
            string spic = "";

            if (this.FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "")
            {
                if (!Directory.Exists(Server.MapPath(Global_Upload.NewsImgPath)))         //判断目录是否存在
                {
                    Directory.CreateDirectory(Server.MapPath(Global_Upload.NewsImgPath)); //创建目录
                }
                spic = DoClass.UploadFile(FileUpload1.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.NewsImgPath);

                if (spic == "-1")
                {
                    return;
                }
                else if (spic == "0")
                {
                    return;
                }
                else
                {
                    spic             = Global_Upload.NewsImgPath + spic;
                    this.lblUrl.Text = spic;
                }
            }
            if (this.FileUpload2.PostedFile != null && FileUpload2.PostedFile.FileName != "")
            {
                if (!Directory.Exists(Server.MapPath(Global_Upload.NewsImgPath)))         //判断目录是否存在
                {
                    Directory.CreateDirectory(Server.MapPath(Global_Upload.NewsImgPath)); //创建目录
                }
                spic = DoClass.UploadFile(FileUpload2.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.NewsImgPath);

                if (spic == "-1")
                {
                    return;
                }
                else if (spic == "0")
                {
                    return;
                }
                else
                {
                    spic = Global_Upload.NewsImgPath + spic;
                    this.lblUrl2.Text = spic;
                }
            }
            if (this.FileUpload3.PostedFile != null && FileUpload3.PostedFile.FileName != "")
            {
                if (!Directory.Exists(Server.MapPath(Global_Upload.NewsImgPath)))         //判断目录是否存在
                {
                    Directory.CreateDirectory(Server.MapPath(Global_Upload.NewsImgPath)); //创建目录
                }
                spic = DoClass.UploadFile(FileUpload3.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.NewsImgPath);

                if (spic == "-1")
                {
                    return;
                }
                else if (spic == "0")
                {
                    return;
                }
                else
                {
                    spic = Global_Upload.NewsImgPath + spic;
                    this.lblUrl3.Text = spic;
                }
            }
            item.imgUrl      = lblUrl.Text;
            item.diaryImg    = lblUrl2.Text;
            item.typeContent = "";
            item.typeDesc    = txtNameEn.Text.Trim();

            item.status = 0;

            item.remark  = lblUrl3.Text.Trim();
            item.addTime = DateTime.Now;

            if (Session["loginUser"] == null)
            {
                Response.Redirect("/admin/login.aspx");
                return;
            }
            AdminUser admin = Session["loginUser"] as AdminUser;

            item.addUser  = admin.id;
            item.infoType = 0;

            if (ViewState["mod"] != null)
            {
                item.id = Convert.ToInt32(ViewState["mod"]);
                ProductTypeService.Update(item);
            }
            else
            {
                int num = ProductTypeService.Add(item);
            }
            ViewState["mod"] = null;
            txtTypeName.Text = "";
            txtNameEn.Text   = "";
            sp.InitBindData(repInfo, this.pager1, "ProductType", "id", sear());
        }