1cd388a25d23b301d7fd80cd00888af5024aaf30.svn-base 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. using System;
  2. using System.Net;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Core.Mes.ClientFrameWork;
  10. namespace Core.Mes.ClientPurviewManager
  11. {
  12. public partial class frmQuestionFeedback : Core.Mes.ClientFrameWork.FrmBase
  13. {
  14. public frmQuestionFeedback()
  15. {
  16. InitializeComponent();
  17. }
  18. void doQuery()
  19. {
  20. string[] sArgs = new string[4];
  21. if (!chbxTime_Q.Checked && !chbxCreator_Q.Checked)
  22. {
  23. MessageBox.Show("至少选择1个查询条件!系统自动选择1个条件。");
  24. chbxTime_Q.Checked = true;
  25. }
  26. if (chbxTime_Q.Checked)
  27. {
  28. if (uldtpTime1_Q.DateTime > uldtpTime2_Q.DateTime)
  29. {
  30. uldtpTime1_Q.Focus();
  31. MessageBox.Show("请选择合理的时间范围!");
  32. return;
  33. }
  34. TimeSpan tspan = uldtpTime2_Q.DateTime - uldtpTime1_Q.DateTime;
  35. if (tspan.Days > 31)
  36. {
  37. uldtpTime1_Q.Focus();
  38. MessageBox.Show("不能查时间范围超过1个月的数据!");
  39. return;
  40. }
  41. sArgs[0] = uldtpTime1_Q.Text + " 00:00:00";
  42. sArgs[1] = uldtpTime2_Q.Text + " 23:59:59";
  43. }
  44. if (chbxCreator_Q.Checked)
  45. {
  46. if (txtCreator_Q.Text.Trim() == "")
  47. {
  48. txtCreator_Q.Focus();
  49. MessageBox.Show("请输入查询内容!");
  50. return;
  51. }
  52. sArgs[2] = txtCreator_Q.Text.Trim();
  53. }
  54. if (rdbtnAll.Checked)
  55. sArgs[3] = "All";
  56. else if (rdbtnNoReply.Checked)
  57. sArgs[3] = "NoReply";
  58. else if (rdbtnNoComplete.Checked)
  59. sArgs[3] = "NoComplete";
  60. else if (rdbtnComplete.Checked)
  61. sArgs[3] = "Complete";
  62. string err = "";
  63. object obj = ClientCommon._RemotingHelp.ExecuteMethod("PurviewManager", "Core.Mes.PurviewManager.QuestionReply", "getAllData",
  64. new object[] { sArgs },
  65. out err);
  66. if (obj != null)
  67. {
  68. ultraGrid1.DataSource = (DataSet)obj;
  69. }
  70. }
  71. void doAdd()
  72. {
  73. if (txtQuestion.Text.Trim() == "")
  74. {
  75. txtQuestion.Focus();
  76. MessageBox.Show("请输入内容!");
  77. return;
  78. }
  79. string[] sArgs = new string[8];
  80. sArgs[0] = ClientCommon._UserInfo.UserName;
  81. sArgs[1] = ClientCommon._UserInfo.UserDepName;
  82. sArgs[2] = txtQuestion.Text.Trim();
  83. sArgs[3] = ulcmeDepartment.Text.Trim();
  84. sArgs[4] = txtPrincipal.Text.Trim();
  85. sArgs[5] = ClientCommon.GetIp();
  86. sArgs[6] = mtxtPhono.Text;
  87. sArgs[7] = ulcmeQuestionType.Text;
  88. string err = "";
  89. object obj = ClientCommon._RemotingHelp.ExecuteMethod("PurviewManager", "Core.Mes.PurviewManager.QuestionReply", "addQuestion",
  90. new object[] { sArgs },
  91. out err);
  92. if ((int)obj > 0)
  93. {
  94. DataSet dset = (DataSet)ultraGrid1.DataSource;
  95. if (!rdbtnComplete.Checked)
  96. {
  97. DataRow newRow = dset.Tables[0].NewRow();
  98. newRow.ItemArray = new object[] { err, sArgs[0], sArgs[1], sArgs[2], sArgs[3], sArgs[4], DateTime.Now, "", null, sArgs[5], '0', sArgs[6], sArgs[7] };
  99. dset.Tables[0].Rows.InsertAt(newRow, 0);
  100. ultraGrid1.Rows[0].Activate();
  101. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow arow in ultraGrid1.Selected.Rows)
  102. arow.Selected = false;
  103. int idx = -1;
  104. if (ultraGrid1.Selected.Cells.Count > 0)
  105. idx = ultraGrid1.Selected.Cells[0].Column.Index;
  106. for (int i = 0; i < ultraGrid1.Selected.Cells.Count; i++)
  107. {
  108. ultraGrid1.Selected.Cells[i].Selected = false;
  109. }
  110. if (idx > -1)
  111. ultraGrid1.Rows[0].Cells[idx].Selected = true;
  112. }
  113. else
  114. {
  115. MessageBox.Show("操作成功!请更改查询条件后重新查询。");
  116. }
  117. }
  118. }
  119. void doEdit()
  120. {
  121. if (curTopRow == null)
  122. return;
  123. if (txtQuestion.Text.Trim() == "")
  124. {
  125. txtQuestion.Focus();
  126. MessageBox.Show("请输入内容!");
  127. return;
  128. }
  129. string[] sArgs = new string[6];
  130. sArgs[0] = curTopRow.Cells["ID_"].Text;
  131. sArgs[1] = txtQuestion.Text.Trim();
  132. sArgs[2] = ulcmeDepartment.Text.Trim();
  133. sArgs[3] = txtPrincipal.Text.Trim();
  134. sArgs[4] = mtxtPhono.Text;
  135. sArgs[5] = ulcmeQuestionType.Text;
  136. string err = "";
  137. object obj = ClientCommon._RemotingHelp.ExecuteMethod("PurviewManager", "Core.Mes.PurviewManager.QuestionReply", "editQuestion",
  138. new object[] { sArgs },
  139. out err);
  140. if ((int)obj > 0)
  141. {
  142. curTopRow.Cells["QUESTION"].Value = sArgs[1];
  143. curTopRow.Cells["DEPARTMENT"].Value = sArgs[2];
  144. curTopRow.Cells["PRINCIPAL"].Value = sArgs[3];
  145. curTopRow.Cells["PHONE"].Value = sArgs[4];
  146. curTopRow.Cells["QUESTIONTYPE"].Value = sArgs[5];
  147. }
  148. }
  149. void doDelete()
  150. {
  151. if (curTopRow == null)
  152. return;
  153. if (MessageBox.Show("您确定要删除?", "选择", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) ==
  154. DialogResult.No)
  155. return;
  156. string[] sArgs = new string[1];
  157. sArgs[0] = curTopRow.Cells["ID_"].Text;
  158. string err = "";
  159. object obj = ClientCommon._RemotingHelp.ExecuteMethod("PurviewManager", "Core.Mes.PurviewManager.QuestionReply", "delQuestion",
  160. new object[] { sArgs },
  161. out err);
  162. if ((int)obj > 0)
  163. {
  164. int idx = curTopRow.Index;
  165. curTopRow = null;
  166. doQuery();
  167. if (idx < ultraGrid1.Rows.Count)
  168. {
  169. ultraGrid1.Rows[idx].Activate();
  170. }
  171. else if (idx == ultraGrid1.Rows.Count && ultraGrid1.Rows.Count > 0)
  172. {
  173. ultraGrid1.Rows[idx - 1].Activate();
  174. }
  175. }
  176. }
  177. private void frmQuestionFeedback_Load(object sender, EventArgs e)
  178. {
  179. ulcmeQuestionType.SelectedIndex = 0;
  180. ultraGrid1.DisplayLayout.Override.MinRowHeight = 21;
  181. ultraGrid1.DisplayLayout.Bands[0].Override.HeaderAppearance.BackColor = System.Drawing.Color.LightSteelBlue;
  182. ultraGrid1.DisplayLayout.Bands[0].Override.RowSelectorAppearance.BackColor = System.Drawing.Color.LightSteelBlue;
  183. ultraGrid1.DisplayLayout.Bands[0].Override.RowAppearance.BackColor = Color.LightGray;
  184. ultraGrid1.DisplayLayout.Bands[1].Override.HeaderAppearance.BackColor = Color.FromArgb(233, 242, 199);
  185. ultraGrid1.DisplayLayout.Bands[1].Override.HeaderAppearance.BackColor2 = Color.FromArgb(170, 184, 131);
  186. ultraGrid1.DisplayLayout.Bands[1].Override.HeaderAppearance.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
  187. ultraGrid1.DisplayLayout.Bands[1].Override.RowSelectorAppearance.BackColor = Color.FromArgb(233, 242, 199);
  188. ultraGrid1.DisplayLayout.Bands[1].Override.RowSelectorAppearance.BackColor2 = Color.FromArgb(170, 184, 131);
  189. ultraGrid1.DisplayLayout.Bands[1].Override.RowSelectorAppearance.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
  190. ultraGrid1.DisplayLayout.Bands[1].Override.RowAppearance.BorderColor = Color.FromArgb(170, 184, 131);
  191. string err = "";
  192. object obj = ClientCommon._RemotingHelp.ExecuteMethod("PurviewManager", "Core.Mes.PurviewManager.UAM_DEPARTMENT", "SelectUAM_DEPARTMENT",
  193. new object[] { "" },
  194. out err);
  195. if (obj != null)
  196. {
  197. DataSet dset = (DataSet)obj;
  198. foreach (DataRow drow in dset.Tables[0].Rows)
  199. {
  200. ulcmeDepartment.Items.Add(drow["DEPARTMENTNAME"].ToString());
  201. }
  202. }
  203. uldtpTime1_Q.DateTime = uldtpTime1_Q.DateTime.AddDays(-2);
  204. doQuery();
  205. }
  206. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  207. {
  208. switch (e.Tool.Key)
  209. {
  210. case "tlbtnQuery": // ButtonTool
  211. doQuery();
  212. break;
  213. case "tlbtnAdd": // ButtonTool
  214. doAdd();
  215. break;
  216. case "tlbtnEdit": // ButtonTool
  217. doEdit();
  218. break;
  219. case "tlbtnDelete": // ButtonTool
  220. doDelete();
  221. break;
  222. case "tlbtnClose": // ButtonTool
  223. Close();
  224. break;
  225. }
  226. }
  227. Infragistics.Win.UltraWinGrid.UltraGridRow curTopRow = null;
  228. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  229. {
  230. Infragistics.Win.UltraWinGrid.UltraGridRow arow = ultraGrid1.ActiveRow;
  231. if (arow.Band.Index == 0)
  232. {
  233. if (arow != curTopRow)
  234. {
  235. curTopRow = arow;
  236. }
  237. }
  238. else
  239. {
  240. curTopRow = arow.ParentRow;
  241. }
  242. ultraToolbarsManager1.Tools["tlbtnEdit"].SharedProps.Enabled = (curTopRow.Cells["CREATOR"].Text.Trim() == ClientCommon._UserInfo.UserName && curTopRow.Cells["LASTANSWERER"].Text.Trim() == "");
  243. ultraToolbarsManager1.Tools["tlbtnDelete"].SharedProps.Enabled = (curTopRow.Cells["CREATOR"].Text.Trim() == ClientCommon._UserInfo.UserName && curTopRow.Cells["LASTANSWERER"].Text.Trim() == "");
  244. txtQuestion.Text = curTopRow.Cells["QUESTION"].Text.Trim();
  245. ulcmeDepartment.Text = curTopRow.Cells["DEPARTMENT"].Text.Trim();
  246. txtPrincipal.Text = curTopRow.Cells["PRINCIPAL"].Text.Trim();
  247. mtxtPhono.Text = curTopRow.Cells["PHONE"].Text.Trim();
  248. ulcmeQuestionType.Text = curTopRow.Cells["QUESTIONTYPE"].Text.Trim();
  249. }
  250. private void ultraGrid1_DoubleClickCell(object sender, Infragistics.Win.UltraWinGrid.DoubleClickCellEventArgs e)
  251. {
  252. if (curTopRow != null)
  253. {
  254. frmReply frmReply_1 = new frmReply(curTopRow.Cells["ID_"].Text, curTopRow.Cells["FLAG"].Value.ToString(), curTopRow.Cells["CREATOR"].Text, curTopRow.Cells["PRINCIPAL"].Text, curTopRow.Cells["QUESTION"].Text);
  255. frmReply_1.ShowDialog();
  256. string sID = curTopRow.Cells["ID_"].Text;
  257. doQuery();
  258. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow arow in ultraGrid1.Rows)
  259. {
  260. if (arow.Cells["ID_"].Text == sID)
  261. {
  262. arow.Activate();
  263. break;
  264. }
  265. }
  266. }
  267. }
  268. private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
  269. {
  270. if (e.Row.Band.Index == 0)
  271. {
  272. if (e.Row.Cells["FLAG"].Value.ToString() == "1")
  273. e.Row.Cells["QUESTION"].Appearance.ForeColor = Color.Green;
  274. else
  275. e.Row.Cells["QUESTION"].Appearance.ForeColor = Color.Black;
  276. }
  277. }
  278. }//class
  279. }