市长热线演示版

questionedit.aspx.cs 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Data;
  8. using HySoft.Common;
  9. namespace HySoft.BaseCallCenter.Web.askmanage
  10. {
  11. public partial class questionedit : System.Web.UI.Page
  12. {
  13. protected void Page_Load(object sender, EventArgs e)
  14. {
  15. if (!Page.IsPostBack)
  16. {
  17. try
  18. {
  19. LoginUser p_LoginUser = new LoginUser(this.Context);
  20. txtUserId.Value = p_LoginUser.UserID.ToString();
  21. }
  22. catch { }
  23. BindList();
  24. if (!string.IsNullOrEmpty(Request.QueryString["categoryid"]))
  25. {
  26. dropQuestionCategory.SelectedValue = Request.QueryString["categoryid"].Trim();
  27. }
  28. if (!string.IsNullOrEmpty(Request.QueryString["selecttype"]))
  29. {
  30. dropQuestionType.SelectedValue = Request.QueryString["selecttype"].Trim();
  31. }
  32. if (!string.IsNullOrEmpty(Request.QueryString["id"]))
  33. {
  34. txtId.Value = Request.QueryString["id"].Trim();
  35. InitObj(Request.QueryString["id"].Trim());
  36. }
  37. }
  38. }
  39. private void BindList()
  40. {
  41. DataTable dt = new DataTable();
  42. try
  43. {
  44. dropQuestionCategory.Items.Clear();
  45. dropQuestionCategory.Items.Add(new ListItem("请选择试题分类",""));
  46. dt = new BLL.T_Ask_QuestionCategory().GetAllList().Tables[0];
  47. foreach (DataRow dr in dt.Rows)
  48. {
  49. dropQuestionCategory.Items.Add(new ListItem(dr["F_CategoryName"].ToString().Trim(), dr["F_CategoryId"].ToString().Trim()));
  50. }
  51. }
  52. catch
  53. { }
  54. finally
  55. {
  56. dt.Clear();
  57. dt.Dispose();
  58. }
  59. }
  60. void InitObj(string id)
  61. {
  62. try
  63. {
  64. T_Ask_QuestionObj = new BLL.T_Ask_Question().GetModel(Convert.ToInt32(id));
  65. }
  66. catch (Exception ex)
  67. {
  68. }
  69. }
  70. private Model.T_Ask_Question T_Ask_QuestionObj
  71. {
  72. get
  73. {
  74. Model.T_Ask_Question model = new Model.T_Ask_Question();
  75. if (Request.QueryString["otype"].Trim() == "modify")
  76. {
  77. model.F_QuestionId = Convert.ToInt32(Request.QueryString["id"].Trim());
  78. }
  79. else
  80. {
  81. model.F_QuestionId = 0;
  82. }
  83. model.F_CategoryId = Convert.ToInt32(dropQuestionCategory.SelectedValue.Trim());
  84. model.F_Type = Convert.ToInt32(dropQuestionType.SelectedValue.Trim());
  85. model.F_Title = txtF_Title.Value.Trim();
  86. model.F_Content = "";
  87. model.F_CreateOn = DateTime.Now;
  88. model.F_SortModel = Convert.ToInt32(dropSortModel.SelectedValue.Trim());
  89. try
  90. {
  91. LoginUser p_LoginUser = new LoginUser(this.Context);
  92. model.F_CreateBy = p_LoginUser.UserID;
  93. }
  94. catch { }
  95. model.F_DeleteFlag = 0;
  96. return model;
  97. }
  98. set
  99. {
  100. if (value != null)
  101. {
  102. this.txtId.Value = value.F_QuestionId.ToString();
  103. dropQuestionCategory.SelectedValue = value.F_CategoryId.ToString();
  104. dropQuestionType.SelectedValue = value.F_Type.ToString();
  105. dropSortModel.SelectedValue = value.F_SortModel.ToString();
  106. txtF_Title.Value = value.F_Title;
  107. }
  108. }
  109. }
  110. protected void btnSubmit_Click(object sender, EventArgs e)
  111. {
  112. DataTable dt = new DataTable();
  113. try
  114. {
  115. string[] arr1 = new string[]{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"};
  116. string[] arr2 = new string[]{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T"};
  117. if (Request.QueryString["otype"] == "new")
  118. {
  119. Model.T_Ask_Question model=T_Ask_QuestionObj;
  120. #region 获取内容
  121. if (dropQuestionType.SelectedValue != "1")
  122. {
  123. string userid = "0";
  124. try
  125. {
  126. LoginUser p_LoginUser = new LoginUser(this.Context);
  127. userid = p_LoginUser.UserID.ToString();
  128. }
  129. catch { }
  130. dt = new BLL.T_Sys_TempItems().GetList(" F_TempName='T_Ask_QuestionItems' and F_UserId=" + userid + " ORDER BY ExpandIntField3 ").Tables[0];
  131. string content = "";
  132. int count = dt.Rows.Count;
  133. for (int i = 0; i < count; i++)
  134. {
  135. string vsort = "";
  136. if (dropSortModel.SelectedValue == "1")
  137. {
  138. vsort = arr2[i];
  139. }
  140. else
  141. {
  142. vsort = arr1[i];
  143. }
  144. content += vsort + "." + dt.Rows[i]["ExpandVchField1"].ToString().Trim() + ";";
  145. }
  146. model.F_Content = content;
  147. }
  148. #endregion
  149. int questionid=new BLL.T_Ask_Question().Add(model);
  150. if (questionid > 0)
  151. {
  152. #region 操作临时数据
  153. int count = dt.Rows.Count;
  154. for (int i = 0; i < count; i++)
  155. {
  156. Model.T_Ask_QuestionItems itemmodel = new Model.T_Ask_QuestionItems();
  157. itemmodel.F_QuestionId = questionid;
  158. itemmodel.F_ItemName = dt.Rows[i]["ExpandVchField1"].ToString().Trim();
  159. itemmodel.F_Sort = Convert.ToInt32(dt.Rows[i]["ExpandIntField3"].ToString().Trim());
  160. itemmodel.F_SortModel = Convert.ToInt32(dropSortModel.SelectedValue);
  161. int itemid=new BLL.T_Ask_QuestionItems().Add(itemmodel);
  162. if (itemid > 0)
  163. {
  164. new BLL.T_Sys_TempItems().Delete(Convert.ToInt32(dt.Rows[i]["F_Id"].ToString().Trim()));
  165. }
  166. }
  167. #endregion
  168. MessageBoxToWindow("新增成功", "新增提示", "success");
  169. }
  170. else
  171. {
  172. MessageBoxToWindow("新增失败", "新增提示!", "error");
  173. }
  174. }
  175. if (Request.QueryString["otype"] == "modify")
  176. {
  177. Model.T_Ask_Question model = T_Ask_QuestionObj;
  178. #region 获取内容
  179. if (dropQuestionType.SelectedValue != "1")
  180. {
  181. dt = new BLL.T_Ask_QuestionItems().GetList(" F_QuestionId=" + txtId.Value.Trim() + " ORDER BY F_Sort ").Tables[0];
  182. string content = "";
  183. int count = dt.Rows.Count;
  184. for (int i = 0; i < count; i++)
  185. {
  186. string vsort = "";
  187. if (dropSortModel.SelectedValue == "1")
  188. {
  189. vsort = arr2[i];
  190. }
  191. else
  192. {
  193. vsort = arr1[i];
  194. }
  195. content += vsort + "." + dt.Rows[i]["F_ItemName"].ToString().Trim() + ";";
  196. }
  197. model.F_Content = content;
  198. }
  199. #endregion
  200. if (new BLL.T_Ask_Question().Update(model))
  201. {
  202. MessageBoxToWindow("修改成功", "修改提示!", "success");
  203. }
  204. else
  205. {
  206. MessageBoxToWindow("修改失败!", "修改提示!", "error");
  207. }
  208. }
  209. }
  210. catch
  211. {
  212. MessageBoxToWindow("保存失败!", "保存提示!", "error");
  213. }
  214. finally
  215. {
  216. dt.Clear();
  217. dt.Dispose();
  218. }
  219. }
  220. #region 弹出对话框
  221. /// <summary>
  222. /// 弹出对话框
  223. /// </summary>
  224. /// <param name="title"></param>
  225. /// <param name="content"></param>
  226. /// <param name="type"></param>
  227. public void MessageBoxToWindow(string title, string content, string type)
  228. {
  229. string script = "";
  230. switch (type)
  231. {
  232. case "error"://失败
  233. type = "error";
  234. script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "');</script>";
  235. break;
  236. case "success"://成功
  237. type = "info";
  238. script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "',CloseThis);</script>";
  239. break;
  240. case "catch"://异常
  241. type = "warning";
  242. script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "');</script>";
  243. break;
  244. default:
  245. type = "question";
  246. break;
  247. }
  248. ClientScript.RegisterClientScriptBlock(this.GetType(), "", script);
  249. }
  250. #endregion
  251. }
  252. }