protected void btnThem_Click(object sender, EventArgs e) { string url = ""; if (Page.IsValid && UploadImg.HasFile && CheckFileType(UploadImg.FileName)) { string fileName = "img/item/" + UploadImg.FileName; string filePath = MapPath(fileName); UploadImg.SaveAs(filePath); Image1.ImageUrl = fileName; url = fileName; } if (txMauSac.Text == String.Empty && txSoLuong.Text == String.Empty && txGiaBan.Text == String.Empty) { Response.Write("<script>alert('Hãy nhập đủ dữ liệu!!')</script>"); ClientScript.RegisterStartupScript(this.GetType(), "alert", "ShowAdd();", true); } else { if (checkSP(txMauSac.Text, int.Parse(DropSize.SelectedValue.ToString()))) { Response.Write("<script>alert('Đã tồn tại sản phẩm')</script>"); ClientScript.RegisterStartupScript(this.GetType(), "alert", "ShowAdd();", true); } else { String sql = "Insert into CTSP(maSp,mausac,masize,giaban,soluongton,anh) values('" + masp + "',N'" + txMauSac.Text + "',N'" + DropSize.SelectedValue + "',N'" + txGiaBan.Text + "',N'" + txSoLuong.Text + "',N'" + url + "')"; DataTable data = KetNoi.Excutequerry(sql); Response.Write("<script>alert('Thêm thành công!!')</script>"); LoadGrCTSP(); } } }
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 (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 (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"); } } }
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"); } } }