public static string OperateRecords(string ids, int op) { string[] array = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); using (BLLSuccessStories bll = new BLLSuccessStories()) { foreach (string id in array) { switch (op) { case 7: if (File.Exists(StringPlus.MapPath(bll.GetSingle(id).SSPic))) { File.Delete(StringPlus.MapPath(bll.GetSingle(id).SSPic)); if (File.Exists(StringPlus.MapPath(phoneImgUrl(bll.GetSingle(id).SSPic)))) { File.Delete(StringPlus.MapPath(phoneImgUrl(bll.GetSingle(id).SSPic))); } bll.Delete(id); } else { bll.Delete(id); } break; } } if (bll.IsFail) { return(ExceptionManager.GetErrorMsg(bll.DevNetException)); } } return(string.Empty); }
private void setInfo() { if (id > 0) { using (BLLSuccessStories bll = new BLLSuccessStories()) { SuccessStories cpinfor = bll.GetSingle(id); if (cpinfor != null) { ddlSuccessStoriesType.SelectedValue = cpinfor.SSType.ToString(); txtNewsTitle.Text = cpinfor.SSName; txtContent.Value = cpinfor.SSContent; txtRemarks.Text = cpinfor.Remarks; Image1.ImageUrl = cpinfor.SSPic.ToString(); txtAutoSort.Text = cpinfor.AutoSort.ToString(); if (cpinfor.IsEnglish == 1) { rbtnIsChinese.Checked = true; } else if (cpinfor.IsEnglish == 2) { rbtnIsEnglish.Checked = true; } } } } }
private void ShowMenu() { if (type == 14) { Title = "成功案例"; } else { Title = "生产设备"; } int IsEnglish = Session["isEnglish"] == null ? 1 : Convert.ToInt32(Session["isEnglish"]); string[] fileds = new string[] { "id", "IsEnglish" }; object[] values = new object[] { id, IsEnglish }; using (BLLSuccessStories BLL = new BLLSuccessStories()) { SuccessStories obj = new SuccessStories(); obj = BLL.GetSingle(fileds, values); if (obj != null) { lblTitle.Text = GetStrByLength(obj.SSName, 30); lblContent.Text = obj.SSContent; image.Src = obj.SSPic; } } using (BLLCompanyInformationType bll = new BLLCompanyInformationType()) { CompanyInformationType contype = bll.GetSingle(type); if (contype != null) { Title = contype.CompanyInformationName; } } }
private void ShowMenu() { int IsEnglish = Session["isEnglish"] == null ? 1 : Convert.ToInt32(Session["isEnglish"]); string[] fileds = new string[] { "id", "IsEnglish" }; object[] values = new object[] { id, IsEnglish }; using (BLLSuccessStories BLL = new BLLSuccessStories()) { SuccessStories obj = new SuccessStories(); obj = BLL.GetSingle(fileds, values); if (obj != null) { picpro.ImageUrl = obj.SSPic; lblTitle.Text = obj.SSName; lblContent.Text = obj.SSContent; } } }
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"); } } }