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; } } }
// simple validation bool validationIsOk(SuccessStories story) { var ValidationIsOk = !string.IsNullOrEmpty(story.Story) && !string.IsNullOrEmpty(story.Cities) && !string.IsNullOrEmpty(story.ShortStory) && !string.IsNullOrEmpty(story.Image) && !string.IsNullOrEmpty(story.FirstCustomerName) && !string.IsNullOrEmpty(story.SecondCustomerName); return(ValidationIsOk); }
public IHttpActionResult CreateContact(SuccessStories story) { if (story.CustomerIdFirst == 0 || story.CustomerIdSecond == 0 || !validationIsOk(story)) { return(BadRequest()); } m_db.SuccessStories.Add(story); m_db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = story.Id }, story)); }
// GET /api/SuccessStories/1 public IHttpActionResult GetSuccessStory(long id) { SuccessStories story = m_db.SuccessStories.SingleOrDefault(st => st.Id == id); if (story == null) { return(NotFound()); } return(Ok(story)); }
public IHttpActionResult DeleteSuccessStory(long id) { SuccessStories CusStory = m_db.SuccessStories.Find(id); if (CusStory == null) { return(NotFound()); } m_db.SuccessStories.Remove(CusStory); m_db.SaveChanges(); return(Ok(CusStory)); }
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"); } } }