ComBaseWell.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using CoreFS.CA06;
  5. using System;
  6. using System.Collections;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.Windows.Forms;
  10. namespace Core.StlMes.Client.Qcm
  11. {
  12. public partial class ComBaseWell : FrmBase
  13. {
  14. private string errMessage = "";
  15. public ComBaseWell()
  16. {
  17. InitializeComponent();
  18. }
  19. public override void ToolBar_Click(object sender, string ToolbarKey)
  20. {
  21. switch (ToolbarKey)
  22. {
  23. case "Query":
  24. DoQuery();
  25. break;
  26. case "Add":
  27. DoAdd();
  28. break;
  29. case "Update":
  30. DoUpdate();
  31. break;
  32. case "Delete":
  33. DoDelete();
  34. break;
  35. case "Resume":
  36. DoResume();
  37. break;
  38. case "Close":
  39. this.Close();
  40. break;
  41. }
  42. }
  43. /// <summary>
  44. /// 查询
  45. /// </summary>
  46. private void DoQuery()
  47. {
  48. string validFlag = "1";
  49. if (this.ultraCheckEditor1.Checked)
  50. validFlag = "0";
  51. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBaseWell.getComBaseWellData", new Object[] { validFlag }, this.ob);
  52. if (dt != null && dt.Rows.Count > 0)
  53. {
  54. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
  55. SetUltraGridStyle();
  56. }
  57. }
  58. /// <summary>
  59. ///检查 增加数据
  60. /// </summary>
  61. /// <returns></returns>
  62. private ArrayList CheckAddColumns()
  63. {
  64. ArrayList list = new ArrayList();
  65. string wellCode = this.ultraTextEditor1.Text.Trim().ToString();
  66. if (wellCode.Length == 0 || wellCode.Length > 20 || !StringUtil.IsOnlyLetterAndDigit(wellCode))
  67. {
  68. errMessage = "产能井代码:1-20位有效数字与字母组成";
  69. return null;
  70. }
  71. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBaseWell.checkComBaseWell", new Object[] { wellCode }, this.ob);
  72. if (dt != null && dt.Rows.Count > 0)
  73. {
  74. errMessage = "存在相同的产能井代码";
  75. return null;
  76. }
  77. string wellName = this.ultraTextEditor2.Text.Trim().ToString();
  78. if (wellName.Length == 0 || wellName.Length > 100)
  79. {
  80. errMessage = "产能井代码:1-50字母或者汉字组成";
  81. return null;
  82. }
  83. string weight = this.ultraTextEditor3.Text.Trim().ToString();
  84. if (weight.Length == 0 || !StringUtil.IsNumber(weight))
  85. {
  86. errMessage = "最大产能:数字组成,不能为空";
  87. return null;
  88. }
  89. string memo = this.ultraTextEditor4.Text.Trim().ToString();
  90. string userName = UserInfo.GetUserName();
  91. list.Add(wellCode);
  92. list.Add(wellName);
  93. list.Add(weight);
  94. list.Add(memo);
  95. list.Add(userName);
  96. return list;
  97. }
  98. /// <summary>
  99. /// 增加
  100. /// </summary>
  101. private void DoAdd()
  102. {
  103. ArrayList listParams = CheckAddColumns();
  104. if (listParams == null)
  105. {
  106. MessageBox.Show(errMessage, "提示");
  107. return;
  108. }
  109. int count = ServerHelper.SetData("com.steering.pss.qcm.ComBaseWell.addComBaseWell", new Object[] { listParams }, this.ob);
  110. if (count > 0)
  111. {
  112. DoQuery();
  113. }
  114. }
  115. private ArrayList CheckUpdate()
  116. {
  117. ArrayList list = new ArrayList();
  118. string wellName = this.ultraTextEditor2.Text.Trim().ToString();
  119. if (wellName.Length == 0 || wellName.Length > 100)
  120. {
  121. errMessage = "产能井代码:1-50字母或者汉字组成";
  122. return null;
  123. }
  124. string weight = this.ultraTextEditor3.Text.Trim().ToString();
  125. if (weight.Length == 0 || !StringUtil.IsNumber(weight))
  126. {
  127. errMessage = "最大产能:数字组成,不能为空";
  128. return null;
  129. }
  130. string memo = this.ultraTextEditor4.Text.Trim().ToString();
  131. string userName = UserInfo.GetUserName();
  132. string wellCode = this.ultraTextEditor1.Text.Trim().ToString();
  133. if (wellCode.Length == 0 || wellCode.Length > 20 || !StringUtil.IsOnlyLetterAndDigit(wellCode))
  134. {
  135. errMessage = "产能井代码:1-20位有效数字与字母组成";
  136. return null;
  137. }
  138. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBaseWell.checkComBaseWell", new Object[] { wellCode }, this.ob);
  139. if (dt == null || dt.Rows.Count == 0)
  140. {
  141. errMessage = "不存在的产能井代码";
  142. return null;
  143. }
  144. list.Add(wellName);
  145. list.Add(weight);
  146. list.Add(memo);
  147. list.Add(userName);
  148. list.Add(wellCode);
  149. return list;
  150. }
  151. /// <summary>
  152. /// 修改
  153. /// </summary>
  154. private void DoUpdate()
  155. {
  156. ArrayList listParams = CheckUpdate();
  157. if (listParams == null)
  158. {
  159. MessageBox.Show(errMessage, "提示");
  160. return;
  161. }
  162. string wellCode = this.ultraTextEditor1.Text.Trim().ToString();
  163. int count = ServerHelper.SetData("com.steering.pss.qcm.ComBaseWell.updateBaseWell", new Object[] { listParams }, this.ob);
  164. if (count > 0)
  165. {
  166. DoQuery();
  167. Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
  168. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  169. {
  170. row = ultraGrid1.Rows[i];
  171. if (row.Cells["WELL_CODE"].Value.ToString().Equals(wellCode))
  172. {
  173. row.Activate();
  174. break;
  175. }
  176. }
  177. }
  178. else
  179. {
  180. MessageBox.Show("修改失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  181. }
  182. }
  183. /// <summary>
  184. /// 删除
  185. /// </summary>
  186. private void DoDelete()
  187. {
  188. if (MessageBox.Show("删除记录,您是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  189. {
  190. return;
  191. }
  192. string wellCode = ultraTextEditor1.Text.Trim().ToString();
  193. string deleteName = UserInfo.GetUserName();
  194. string validflag = ultraGrid1.DisplayLayout.ActiveRow.Cells["VALIDFLAGNAME"].Text.Trim().ToString();
  195. if (wellCode.Length == 0 || validflag.Equals("无效"))
  196. {
  197. MessageBox.Show("请选取删除有效记录或者请输入删除人!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  198. return;
  199. }
  200. int count = ServerHelper.SetData("com.steering.pss.qcm.ComBaseWell.deleteComBaseWell", new Object[] { deleteName, wellCode }, this.ob);
  201. if (count > 0)
  202. {
  203. DoQuery();
  204. SetActiveRow(wellCode);
  205. }
  206. else
  207. {
  208. MessageBox.Show("删除失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  209. return;
  210. }
  211. }
  212. /// <summary>
  213. /// 恢复数据
  214. /// </summary>
  215. private void DoResume()
  216. {
  217. if (MessageBox.Show("恢复记录,您是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  218. {
  219. return;
  220. }
  221. string wellCode = ultraTextEditor1.Text.Trim().ToString();
  222. string validflag = ultraGrid1.DisplayLayout.ActiveRow.Cells["VALIDFLAGNAME"].Text.Trim().ToString();
  223. if (wellCode.Length == 0 || validflag.Equals("有效"))
  224. {
  225. MessageBox.Show("请选取需要恢复的无效记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  226. return;
  227. }
  228. int count = ServerHelper.SetData("com.steering.pss.qcm.ComBaseWell.resumeComBaseWell", new Object[] { wellCode }, this.ob);
  229. if (count > 0)
  230. {
  231. DoQuery();
  232. SetActiveRow(wellCode);
  233. }
  234. else
  235. {
  236. MessageBox.Show("恢复失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  237. return;
  238. }
  239. }
  240. /// <summary>
  241. /// 激活行编辑区赋值
  242. /// </summary>
  243. /// <param name="sender"></param>
  244. /// <param name="e"></param>
  245. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  246. {
  247. this.ultraTextEditor1.Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["WELL_CODE"].Text.ToString();
  248. this.ultraTextEditor2.Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["WELL_NAME"].Text.ToString();
  249. this.ultraTextEditor3.Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["WEIGHT"].Text.ToString();
  250. this.ultraTextEditor4.Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["MEMO"].Text.ToString();
  251. }
  252. /// <summary>
  253. /// 设置ultraGrid1行颜色
  254. /// </summary>
  255. private void SetUltraGridStyle()
  256. {
  257. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  258. {
  259. Infragistics.Win.UltraWinGrid.UltraGridRow row = ultraGrid1.Rows[i];
  260. if (!row.Cells["VALIDFLAGNAME"].Value.ToString().Equals("有效"))
  261. {
  262. row.Appearance.ForeColor = Color.Red;
  263. }
  264. else
  265. {
  266. row.Appearance.ForeColor = Color.Black;
  267. }
  268. }
  269. }
  270. private void SetActiveRow(string wellCode)
  271. {
  272. Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
  273. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  274. {
  275. row = ultraGrid1.Rows[i];
  276. if (row.Cells["WELL_CODE"].Value.ToString().Equals(wellCode))
  277. {
  278. row.Activate();
  279. break;
  280. }
  281. }
  282. }
  283. ///// <summary>
  284. ///// 操作数项
  285. ///// </summary>
  286. ///// <returns></returns>
  287. //private ComBaseWellObject GetOptionData()
  288. //{
  289. // ComBaseWellObject cbw = new ComBaseWellObject();
  290. // cbw.WellCode = ultraTextEditor1.Text.Trim().ToString();
  291. // cbw.WellName = ultraTextEditor2.Text.Trim().ToString();
  292. // cbw.Weight = ultraTextEditor3.Text.Trim().ToString();
  293. // cbw.Memo = ultraTextEditor4.Text.Trim().ToString();
  294. // return cbw;
  295. //}
  296. //private void DoAdd1()
  297. //{
  298. // ComBaseWellObject cbw = GetOptionData();
  299. // cbw.CreateName = UserInfo.GetUserName();
  300. // cbw.CreateTime = System.DateTime.Now.ToString();
  301. // int count = ServerHelper.SetData("com.steering.pss.qcm.ComBaseWell.addComBaseWell1", new Object[] { JSONFormat.Format(cbw) }, this.ob);
  302. //}
  303. }
  304. }