public void BindData() { if (view_action == "notify") { Model.CommonQuestion cp = Factory.GetExecution().SelectByID <Model.CommonQuestion>(requestID); if (cp != null) { if (cp.Language == 1) { Chinese.Checked = true; } else if (cp.Language == 3) { English.Checked = true; } else if (cp.Language == 2) { Traditional.Checked = true; } txtTitle.Text = cp.Title; txtContentQuestion.Text = cp.ContentQuestion; txtContentAnswer.Text = cp.ContentAnswer; txtCreatePeople.Text = cp.CreatePeople; HomePageUploadImg.ImageUrl = WebSite.IMAGESERVER_WEBPATH + photoPath + cp.LogoUrl; HomePageUploadFileName.Text = cp.LogoUrl; txtKeywords.Text = cp.Keywords; txtDescription.Text = cp.Description; } } }
protected void btnSave_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtContentQuestion.Text.Trim())) { Common.MessageBox.ShowLayer(this, "问题内容不能为空", 2); return; } if (string.IsNullOrEmpty(txtContentAnswer.Text.Trim())) { Common.MessageBox.ShowLayer(this, "问题答案不能为空", 2); return; } if (view_action == "notify") { Model.CommonQuestion cp = Factory.GetExecution().SelectByID <Model.CommonQuestion>(requestID); if (cp != null) { cp.Language = Convert.ToInt32(Request.Form["language"]); cp.Title = txtTitle.Text; cp.ContentQuestion = txtContentQuestion.Text; cp.ContentAnswer = txtContentAnswer.Text; cp.CreatePeople = txtCreatePeople.Text; cp.LogoUrl = HomePageUploadFileName.Text; cp.CreatePeople = txtCreatePeople.Text; cp.UpdateTime = DateTime.Now; cp.Keywords = txtKeywords.Text.Trim(); cp.Description = txtDescription.Text.Trim(); bool flag = Factory.GetExecution().Update <Model.CommonQuestion>(cp); if (flag) { Common.MessageBox.ShowRedirect(this, "/TechnicalSupport/MemberToGroupList.aspx"); } } } else { Model.CommonQuestion cp = new Model.CommonQuestion(); cp.Language = Convert.ToInt32(Request.Form["language"]); cp.Title = txtTitle.Text; cp.ContentQuestion = txtContentQuestion.Text; cp.ContentAnswer = txtContentAnswer.Text; cp.CreatePeople = txtCreatePeople.Text; cp.LogoUrl = HomePageUploadFileName.Text; cp.CreatePeople = txtCreatePeople.Text; cp.UpdateTime = DateTime.Now; cp.CreateTime = DateTime.Now; cp.Keywords = txtKeywords.Text.Trim(); cp.Description = txtDescription.Text.Trim(); bool flag = Factory.GetExecution().Add <Model.CommonQuestion>(cp); if (flag) { Common.MessageBox.ShowRedirect(this, "/TechnicalSupport/MemberToGroupList.aspx"); } } } catch (Exception ex) { Common.MessageBox.ShowLayer(this, "添加失败!" + ex.Message, 2); } finally { BindData(); } }