Exemplo n.º 1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            using (BLLComBanner bll = new BLLComBanner())
            {
                ComBanner obj = new ComBanner();

                if (id > 0)
                {
                    obj    = bll.GetSingle(id);
                    obj.ID = id;
                }
                obj.ComBannerTypeID = Convert.ToInt32(ddlNewsType.SelectedValue);
                obj.BannerTitle     = txtDLName.Text.Trim().ToString();
                obj.BannerLink      = txtLink.Text.Trim().ToString();
                #region   产品图片(前台产品图片来源于此)
                try
                {
                    if (this.UploadImg.HasFile)
                    {
                        string extName = Path.GetExtension(UploadImg.FileName);
                        string virFileFullName;
                        string fileName;

                        WebCommon.GetUploadRandFileName(extName, out virFileFullName, out fileName);
                        UploadImg.SaveAs(StringPlus.MapPath(virFileFullName));

                        if (IsAllowedExtension(StringPlus.MapPath(virFileFullName)))
                        {
                            if (id > 0)
                            {//新增时无需删除
                                if (File.Exists(StringPlus.MapPath(bll.GetSingle(id).BannerPic)))
                                {
                                    File.Delete(StringPlus.MapPath(bll.GetSingle(id).BannerPic));
                                }
                            }
                            obj.BannerPic = virFileFullName;
                        }
                        else
                        {
                            if (File.Exists(StringPlus.MapPath(virFileFullName)))
                            {
                                File.Delete(StringPlus.MapPath(virFileFullName));
                            }
                            ShowMsg("请上传正确的图片(.jpg,.gif,.bmp,.png)");
                            return;
                        }
                    }
                    else
                    {
                        obj.BannerPic = Image1.ImageUrl.ToString();
                    }
                }
                catch (DevNetException ex)
                {
                    ExceptionManager.ShowErrorMsg(this, ex);
                    return;
                }
                #endregion

                bll.Save(obj);

                if (bll.IsFail)
                {
                    ExceptionManager.ShowErrorMsg(this, bll.DevNetException);
                }
                else
                {
                    JSMsg.ShowWinRedirect(this, "保存成功", "cpBannerSet.aspx");
                }
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            using (BLLProductType bll = new BLLProductType())
            {
                ProductType obj = new ProductType();

                if (id > 0)
                {
                    obj    = bll.GetSingle(id);
                    obj.ID = id;
                }
                obj.ProductTypeName = txtProductTypeName.Text.Trim().ToString();
                obj.AutoSort        = Convert.ToInt32(txtAutoSort.Text);
                obj.Remarks         = txtRemarks.Text.ToString();
                #region   产品图片(前台产品图片来源于此)
                try
                {
                    if (this.UploadImg.HasFile)
                    {
                        string extName = Path.GetExtension(UploadImg.FileName);
                        string virFileFullName;
                        string fileName;

                        WebCommon.GetUploadRandFileName(extName, out virFileFullName, out fileName);
                        UploadImg.SaveAs(StringPlus.MapPath(virFileFullName));

                        if (IsAllowedExtension(StringPlus.MapPath(virFileFullName)))
                        {
                            if (id > 0)
                            {//新增时无需删除
                                if (File.Exists(StringPlus.MapPath(bll.GetSingle(id).ProductTypePic)))
                                {
                                    File.Delete(StringPlus.MapPath(bll.GetSingle(id).ProductTypePic));
                                }
                            }
                            obj.ProductTypePic = virFileFullName;
                        }
                        else
                        {
                            if (File.Exists(StringPlus.MapPath(virFileFullName)))
                            {
                                File.Delete(StringPlus.MapPath(virFileFullName));
                            }
                            ShowMsg("请上传正确的图片(.jpg,.gif,.bmp,.png)");
                            return;
                        }
                    }
                    else
                    {
                        obj.ProductTypePic = Image1.ImageUrl.ToString();
                    }
                }
                catch (DevNetException ex)
                {
                    ExceptionManager.ShowErrorMsg(this, ex);
                    return;
                }
                #endregion
                if (rbtnIsChinese.Checked == true)
                {
                    obj.IsEnglish = 1;
                }
                else if (rbtnIsEnglish.Checked == true)
                {
                    obj.IsEnglish = 2;
                }
                else
                {
                    ShowMsg("请选择语言类别!");
                    return;
                }

                if (rbhave.Checked == true)
                {
                    obj.IsHaveSecondTpye = 1;
                }
                else if (rbno.Checked == true)
                {
                    obj.IsHaveSecondTpye = 2;
                }
                else
                {
                    ShowMsg("请是否有二级目录!");
                    return;
                }

                bll.Save(obj);

                if (bll.IsFail)
                {
                    ExceptionManager.ShowErrorMsg(this, bll.DevNetException);
                }
                else
                {
                    JSMsg.ShowWinRedirect(this, "保存成功", "cpProductTypeList.aspx");
                }
            }
        }
Exemplo n.º 3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            using (BLLProductDetail bll = new BLLProductDetail())
            {
                string        prourlname = "";
                ProductDetail obj        = new ProductDetail();
                if (id > 0)
                {
                    obj    = bll.GetSingle(id);
                    obj.ID = id;
                }
                else
                {
                    obj.IsFlag = 0;
                }
                obj.ProductName = txtProName.Text.ToString();
                //obj.ProductEngName = txtProEngName.Text.ToString();
                obj.ProTypeID = Convert.ToInt32(ddlProType.SelectedValue);
                if (ddlProType.SelectedValue == null || ddlProType.SelectedValue == "0")
                {
                    return;
                }
                if (IsHaveSecondType(Convert.ToInt32(ddlProType.SelectedValue)))
                {
                    obj.ProSecondTypeID = Convert.ToInt32(ddlProSecondType.SelectedValue);
                }
                obj.ProductContent = txtContent.Value;
                obj.AutoSort       = Convert.ToInt32(txtAutoSort.Text.Trim().ToString() == "" ? "0" : txtAutoSort.Text.Trim().ToString());
                obj.Remarks        = txtRemarks.Text.ToString();
                #region   产品图片(前台产品图片来源于此)
                try
                {
                    if (this.UploadImg.HasFile)
                    {
                        string extName = Path.GetExtension(UploadImg.FileName);
                        string virFileFullName;
                        string fileName;

                        WebCommon.GetUploadRandFileName(extName, out virFileFullName, out fileName);
                        #region Add Begin
                        int    ind       = fileName.IndexOf(".");
                        string ofileName = fileName.Substring(0, ind);
                        prourlname = extName;
                        #endregion
                        UploadImg.SaveAs(StringPlus.MapPath(virFileFullName));
                        #region Add Begin
                        HttpFileCollection files = Request.Files;
                        string             path  = Server.MapPath("../../Upload");
                        HttpPostedFile     file  = files[0];
                        if (file != null && file.ContentLength > 0)
                        {
                            if (rbthasPhone.Checked == true)
                            {
                                //string filename = this.UpLoadImage(file, path + "/", Convert.ToInt32(ConfigHelper.GetAppString("CompressionWidth").Trim()), Convert.ToInt32(ConfigHelper.GetAppString("CompressionHeight").Trim()), ofileName);
                                string filename = this.UpLoadImage(file, path + "/", Convert.ToInt32(imgWidth.Text.ToString()), Convert.ToInt32(imgHeight.Text.ToString()), ofileName);
                            }
                        }
                        #endregion
                        if (IsAllowedExtension(StringPlus.MapPath(virFileFullName)))
                        {
                            if (id > 0)
                            {//新增时无需删除
                                string filename = bll.GetSingle(id).ProductPic;
                                if (File.Exists(StringPlus.MapPath(bll.GetSingle(id).ProductPic)))
                                {
                                    File.Delete(StringPlus.MapPath(bll.GetSingle(id).ProductPic));
                                }
                                if (File.Exists(StringPlus.MapPath(bll.GetSingle(id).ProductPic)))
                                {
                                    File.Delete(StringPlus.MapPath(bll.GetSingle(id).ProductPic));
                                }
                            }
                            obj.ProductPic = virFileFullName;
                        }
                        else
                        {
                            if (File.Exists(StringPlus.MapPath(virFileFullName)))
                            {
                                File.Delete(StringPlus.MapPath(virFileFullName));
                            }
                            ShowMsg("请上传正确的图片(.jpg,.gif,.bmp,.png)");
                            return;
                        }
                    }
                    else
                    {
                        obj.ProductPic = Image1.ImageUrl.ToString();
                    }
                }
                catch (DevNetException ex)
                {
                    ExceptionManager.ShowErrorMsg(this, ex);
                    return;
                }
                #endregion
                if (rbtnIsChinese.Checked == true)
                {
                    obj.IsEnglish = 1;
                }
                else if (rbtnIsEnglish.Checked == true)
                {
                    obj.IsEnglish = 2;
                }
                else
                {
                    ShowMsg("请选择语言类别!");
                    return;
                }
                bll.Save(obj);
                if (bll.IsFail)
                {
                    ExceptionManager.ShowErrorMsg(this, bll.DevNetException);
                }
                else
                {
                    JSMsg.ShowWinRedirect(this, "保存成功", "cpProductList.aspx");
                }
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            using (BLLDownLoad bll = new BLLDownLoad())
            {
                DownLoad obj = new DownLoad();

                if (id > 0)
                {
                    obj    = bll.GetSingle(id);
                    obj.ID = id;
                }
                obj.DLName    = txtDLName.Text.Trim().ToString();
                obj.DLAddTime = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                obj.Remarks   = txtRemarks.Text.ToString();
                if (Session["admin"] != null)
                {
                    AdminUser adminuser = GetAdminUser();
                    if (adminuser != null)
                    {
                        obj.DLAddName = adminuser.TrueName.ToString();
                    }
                }

                if (rbtnIsChinese.Checked == true)
                {
                    obj.IsEnglish = 1;
                }
                else if (rbtnIsEnglish.Checked == true)
                {
                    obj.IsEnglish = 2;
                }
                else
                {
                    ShowMsg("请选择语言类别!");
                    return;
                }


                #region   产品图片(前台产品图片来源于此)
                try
                {
                    if (this.UploadDLAddress.HasFile)
                    {
                        string extName = Path.GetExtension(UploadDLAddress.FileName);
                        string virFileFullName;
                        string fileName;
                        WebCommon.GetUploadRandFileName(extName, out virFileFullName, out fileName);
                        if (UploadDLAddress.PostedFile.ContentLength < 5000000)//文件小于5M
                        {
                            UploadDLAddress.SaveAs(StringPlus.MapPath(virFileFullName));
                        }
                        else
                        {
                            ShowMsg("文件大小不能超过5M!");
                            return;
                        }
                        if (IsAllowedExtension(StringPlus.MapPath(virFileFullName)))
                        {
                            if (id > 0)
                            {//新增时无需删除
                                if (File.Exists(StringPlus.MapPath(bll.GetSingle(id).DLAddress)))
                                {
                                    File.Delete(StringPlus.MapPath(bll.GetSingle(id).DLAddress));
                                }
                            }
                            obj.DLAddress = virFileFullName;
                        }
                        else
                        {
                            if (File.Exists(StringPlus.MapPath(virFileFullName)))
                            {
                                File.Delete(StringPlus.MapPath(virFileFullName));
                            }
                            ShowMsg("此文件类型不可以上传");
                            return;
                        }
                    }
                    else
                    {
                        obj.DLAddress = lblDLAddress.Text;
                    }
                }
                catch (DevNetException ex)
                {
                    ExceptionManager.ShowErrorMsg(this, ex);
                    return;
                }
                #endregion

                bll.Save(obj);

                if (bll.IsFail)
                {
                    ExceptionManager.ShowErrorMsg(this, bll.DevNetException);
                }
                else
                {
                    JSMsg.ShowWinRedirect(this, "保存成功", "cpDownLoadList.aspx");
                }
            }
        }
Exemplo n.º 5
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string prourlname = "";

            using (BLLSuccessStories bll = new BLLSuccessStories())
            {
                SuccessStories obj = new SuccessStories();
                if (id > 0)
                {
                    obj = bll.GetSingle(id);
                }
                obj.SSType    = Convert.ToInt32(ddlSuccessStoriesType.SelectedValue);
                obj.SSName    = txtNewsTitle.Text.ToString();
                obj.SSContent = txtContent.Value;
                obj.Remarks   = txtRemarks.Text.ToString();
                obj.AutoSort  = Convert.ToInt32(txtAutoSort.Text.Trim().ToString() == "" ? "0" : txtAutoSort.Text.Trim().ToString());
                obj.AddTime   = Convert.ToDateTime(System.DateTime.Now.ToShortDateString());
                try
                {
                    if (this.UploadImg.HasFile)
                    {
                        string extName = Path.GetExtension(UploadImg.FileName);
                        string virFileFullName;
                        string fileName;
                        WebCommon.GetUploadRandFileName(extName, out virFileFullName, out fileName);
                        UploadImg.SaveAs(StringPlus.MapPath(virFileFullName));
                        int    ind       = fileName.IndexOf(".");
                        string ofileName = fileName.Substring(0, ind);
                        prourlname = extName;
                        UploadImg.SaveAs(StringPlus.MapPath(virFileFullName));
                        HttpFileCollection files = Request.Files;
                        string             path  = Server.MapPath("../../Upload");
                        HttpPostedFile     file  = files[0];
                        if (file != null && file.ContentLength > 0)
                        {
                            if (rbthasPhone.Checked == true)
                            {
                                //string filename = this.UpLoadImage(file, path + "/", Convert.ToInt32(ConfigHelper.GetAppString("CompressionWidth").Trim()), Convert.ToInt32(ConfigHelper.GetAppString("CompressionHeight").Trim()), ofileName);
                                string filename = this.UpLoadImage(file, path + "/", Convert.ToInt32(imgWidth.Text.ToString()), Convert.ToInt32(imgHeight.Text.ToString()), ofileName);
                            }
                        }
                        if (IsAllowedExtension(StringPlus.MapPath(virFileFullName)))
                        {
                            if (id > 0)
                            {//新增时无需删除
                                if (File.Exists(StringPlus.MapPath(bll.GetSingle(id).SSPic)))
                                {
                                    File.Delete(StringPlus.MapPath(bll.GetSingle(id).SSPic));
                                }
                            }
                            obj.SSPic = virFileFullName;
                        }
                        else
                        {
                            if (File.Exists(StringPlus.MapPath(virFileFullName)))
                            {
                                File.Delete(StringPlus.MapPath(virFileFullName));
                            }
                            ShowMsg("请上传正确的图片(.jpg,.gif,.bmp,.png)");
                            return;
                        }
                    }
                    else
                    {
                        obj.SSPic = Image1.ImageUrl.ToString();
                    }
                }
                catch (DevNetException ex)
                {
                    ExceptionManager.ShowErrorMsg(this, ex);
                    return;
                }
                if (rbtnIsChinese.Checked == true)
                {
                    obj.IsEnglish = 1;
                }
                else if (rbtnIsEnglish.Checked == true)
                {
                    obj.IsEnglish = 2;
                }
                else
                {
                    ShowMsg("请选择语言类别!");
                    return;
                }

                bll.Save(obj);

                if (bll.IsFail)
                {
                    ExceptionManager.ShowErrorMsg(this, bll.DevNetException);
                }
                else
                {
                    JSMsg.ShowWinRedirect(this, "保存成功", "cpSuccessStoriesList.aspx");
                }
            }
        }