frmInclusionStandard.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Core.Mes.Client.Common;
  10. using Infragistics.Win;
  11. using Infragistics.Win.UltraWinGrid;
  12. using System.Collections;
  13. namespace Core.LgMes.Client.lgIntegrationQuery
  14. {
  15. public partial class frmInclusionStandard : Core.Mes.Client.Common.frmStyleBase
  16. {
  17. public frmInclusionStandard()
  18. {
  19. InitializeComponent();
  20. }
  21. private void frmInclusionStandard_Load(object sender, EventArgs e)
  22. {
  23. //过滤
  24. JJBStaticFunction.SetGridRowFilter(ref this.ultraGrid1, true);
  25. proc_GetSteel();
  26. ckbPH.Checked = false;
  27. cbbSteel.Enabled = false;
  28. proc_Query();
  29. }
  30. private UltraGridRow currRow = null;
  31. private ValueList vl = new ValueList();
  32. bool boolAddNew = false;
  33. public override void ToolBar_Click(object sender, string ToolbarKey)
  34. {
  35. switch (ToolbarKey)
  36. {
  37. case "Query":
  38. {
  39. proc_Query();
  40. JJBStaticFunction.SetRowEdit(ultraGrid1);
  41. this.toolMenu.Toolbars[0].Tools["Add"].SharedProps.Enabled = true;
  42. this.toolMenu.Toolbars[0].Tools["Delete"].SharedProps.Enabled = true;
  43. this.toolMenu.Toolbars[0].Tools["Update"].SharedProps.Enabled = true;
  44. break;
  45. }
  46. case "Add":
  47. {
  48. currRow = this.ultraGrid1.DisplayLayout.Bands[0].AddNew();
  49. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STL_GRD"].ValueList = vl;
  50. boolAddNew = true;
  51. this.toolMenu.Toolbars[0].Tools["Update"].SharedProps.Enabled = false;
  52. this.toolMenu.Toolbars[0].Tools["Delete"].SharedProps.Enabled = false;
  53. break;
  54. }
  55. case "Update":
  56. {
  57. this.toolMenu.Toolbars[0].Tools["Add"].SharedProps.Enabled = false;
  58. this.toolMenu.Toolbars[0].Tools["Delete"].SharedProps.Enabled = false;
  59. //修改只能修改操作时间5小时以内的数据
  60. if (ultraGrid1.ActiveRow != null)
  61. {
  62. /*string strNAME = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID().Trim();
  63. if (strNAME != "jsk000" && strNAME != "1")
  64. {
  65. string date1 = this.ultraGrid1.ActiveRow.Cells["Optdisp"].Value.ToString() + " " + this.ultraGrid1.ActiveRow.Cells["balestarttime"].Value.ToString();
  66. string date2 = DateTime.Now.ToString();
  67. DateTime dt1 = Convert.ToDateTime(date1);
  68. DateTime dt2 = Convert.ToDateTime(date2);
  69. TimeSpan timeSpan = dt2 - dt1;
  70. int sumtime = timeSpan.Hours;
  71. if (sumtime > 4)
  72. {
  73. MessageBox.Show("修改的数据行操作时间已超过5小时,不能修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  74. break;
  75. }
  76. //ultraGrid1.ActiveRow.Cells["memo"].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
  77. //ultraGrid1.ActiveRow.Cells["ex_mome"].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
  78. //ultraGrid1.ActiveRow.Cells["kr_number"].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
  79. }*/
  80. JJBStaticFunction.Update(ultraGrid1);
  81. boolAddNew = false;
  82. }
  83. else
  84. MessageBox.Show("请选择需要修改的数据行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  85. break;
  86. }
  87. case "Save":
  88. {
  89. SaveData();
  90. proc_Query();
  91. JJBStaticFunction.SetRowEdit(ultraGrid1);
  92. this.toolMenu.Toolbars[0].Tools["Add"].SharedProps.Enabled = true;
  93. this.toolMenu.Toolbars[0].Tools["Update"].SharedProps.Enabled = true;
  94. this.toolMenu.Toolbars[0].Tools["Delete"].SharedProps.Enabled = true;
  95. break;
  96. }
  97. case "Delete":
  98. {
  99. DeleteData();
  100. proc_Query();
  101. JJBStaticFunction.SetRowEdit(ultraGrid1);
  102. break;
  103. }
  104. case "Close":
  105. {
  106. this.Close();
  107. break;
  108. }
  109. }
  110. }
  111. /// <加载钢种>
  112. /// 加载钢种
  113. /// </加载钢种>
  114. private void proc_GetSteel()
  115. {
  116. try
  117. {
  118. string strErr = "";
  119. ArrayList arry = new ArrayList();
  120. arry.Add("LoadGetSteel.Query");
  121. CommonClientToServer ccs = new CommonClientToServer();
  122. ccs.ob = this.ob;
  123. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  124. if (strErr != "" || !(ds != null && ds.Tables.Count > 0))
  125. {
  126. MessageBox.Show("钢种加载失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  127. if (MessageBox.Show("是否重新加载钢种?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  128. proc_GetSteel();
  129. return;
  130. }
  131. cbbSteel.Items.Clear();
  132. vl = new ValueList();
  133. for (int i = 0; i < ds.Tables[0].Rows.Count; i++) //遍历所有行的信息
  134. {
  135. cbbSteel.Items.Add(ds.Tables[0].Rows[i]["steel"]);
  136. string steel = Convert.ToString(ds.Tables[0].Rows[i]["steel"]);
  137. vl.ValueListItems.Add(steel, steel);
  138. }
  139. cbbSteel.SelectedIndex = -1;
  140. }
  141. catch (Exception ex)
  142. {
  143. MessageBox.Show(ex.Message);
  144. }
  145. }
  146. private void proc_Query()
  147. {
  148. string sqlStr = "SELECT * FROM SCM_INCLUSION_INFO T WHERE 1=1 ", strErr = "";
  149. if (ckbPH.Checked)
  150. {
  151. sqlStr += "AND STL_GRD LIKE '%" + cbbSteel.Text.Trim() + "%'";
  152. }
  153. sqlStr += " ORDER BY CREATETIME DESC";
  154. CommonClientToServer cctos = new CommonClientToServer();
  155. cctos.ob = this.ob;
  156. DataSet ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBExecute",
  157. "doSimpleQuery", sqlStr, out strErr);
  158. if (!string.IsNullOrEmpty(strErr))
  159. {
  160. MessageBox.Show("失败:" + strErr + "!");
  161. return;
  162. }
  163. if (ds != null && ds.Tables.Count > 0)
  164. {
  165. this.dataTable1.Rows.Clear();
  166. if (ds.Tables[0].Rows.Count == 0) return;
  167. DataRow dr;
  168. for (int iRow = 0; iRow < ds.Tables[0].Rows.Count; iRow++)
  169. {
  170. dr = this.dataTable1.NewRow();
  171. for (int jCol = 0; jCol < ds.Tables[0].Columns.Count; jCol++)
  172. {
  173. if (this.dataTable1.Columns.Contains(ds.Tables[0].Columns[jCol].ColumnName))
  174. {
  175. dr[ds.Tables[0].Columns[jCol].ColumnName] = ds.Tables[0].Rows[iRow][jCol];
  176. }
  177. }
  178. this.dataTable1.Rows.Add(dr);
  179. }
  180. }
  181. }
  182. /// <summary>
  183. /// 保存标准
  184. /// </summary>
  185. private void SaveData()
  186. {
  187. try
  188. {
  189. this.ultraGrid1.UpdateData();
  190. UltraGridRow ugr = this.ultraGrid1.ActiveRow;
  191. CommonClientToServer cctos = new CommonClientToServer();
  192. cctos.ob = this.ob;
  193. string sqlStr = "",strErr = "";
  194. string ph = ugr .Cells["STL_GRD"].Text.Trim();
  195. string a = ugr .Cells["A"].Text.Trim();
  196. string b = ugr .Cells["B"].Text.Trim();
  197. string c = ugr .Cells["C"].Text.Trim();
  198. string d = ugr .Cells["D"].Text.Trim();
  199. if (boolAddNew == true)
  200. {
  201. sqlStr = "SELECT * FROM SCM_INCLUSION_INFO T WHERE 1=1 AND STL_GRD LIKE '%" + ph + "%'";
  202. DataSet ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBExecute",
  203. "doSimpleQuery", sqlStr, out strErr);
  204. if (!string.IsNullOrEmpty(strErr))
  205. {
  206. MessageBox.Show("查重失败:" + strErr + "!");
  207. return;
  208. }
  209. if (ds != null && ds.Tables[0].Rows.Count > 0)
  210. {
  211. MessageBox.Show("牌号重复录入,请核实,牌号必须唯一");
  212. return;
  213. }
  214. sqlStr = "INSERT INTO SCM_INCLUSION_INFO(STL_GRD,A,B,C,D,CREATETIME) VALUES('" + ph + "','" + a + "','" + b + "','" + c + "','" + d + "',SYSDATE)";
  215. }
  216. else
  217. {
  218. sqlStr = "UPDATE SCM_INCLUSION_INFO SET A = '" + a + "',B = '" + b + "',C = '" + c + "',D = '" + d + "' WHERE STL_GRD = '" + ph + "'";
  219. }
  220. cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBExecute",
  221. "ExcuteNoParameter", sqlStr, out strErr);
  222. if (!string.IsNullOrEmpty(strErr))
  223. {
  224. MessageBox.Show("记录新增失败:" + strErr + "!");
  225. return;
  226. }
  227. else
  228. {
  229. MessageBox.Show("保存成功");
  230. return;
  231. }
  232. }
  233. catch (System.Exception ex)
  234. {
  235. Console.WriteLine(ex.ToString());
  236. }
  237. }
  238. private void DeleteData()
  239. {
  240. try
  241. {
  242. this.ultraGrid1.UpdateData();
  243. UltraGridRow ugr = this.ultraGrid1.ActiveRow;
  244. CommonClientToServer cctos = new CommonClientToServer();
  245. cctos.ob = this.ob;
  246. string sqlStr = "", strErr = "";
  247. string ph = ugr.Cells["STL_GRD"].Text.Trim();
  248. sqlStr = "DELETE FROM SCM_INCLUSION_INFO WHERE STL_GRD = '" + ph + "'";
  249. if (MessageBox.Show("是否删除牌号:" + ph + "下的夹杂物标准?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  250. {
  251. return;
  252. }
  253. cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBExecute",
  254. "ExcuteNoParameter", sqlStr, out strErr);
  255. if (!string.IsNullOrEmpty(strErr))
  256. {
  257. MessageBox.Show("记录新增失败:" + strErr + "!");
  258. return;
  259. }
  260. else
  261. {
  262. MessageBox.Show("删除成功");
  263. return;
  264. }
  265. }
  266. catch (System.Exception ex)
  267. {
  268. Console.WriteLine(ex.ToString());
  269. }
  270. }
  271. private void ckbPH_CheckedChanged(object sender, EventArgs e)
  272. {
  273. if (ckbPH.Checked)
  274. cbbSteel.Enabled = true;
  275. else
  276. cbbSteel.Enabled = false;
  277. }
  278. }
  279. }