UIC020110.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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 CoreFS.CA06;
  10. using System.Collections;
  11. using Infragistics.Win.UltraWinGrid;
  12. namespace Core.LZMes.Client.UIC
  13. {
  14. public partial class UIC020110 : FrmBase
  15. {
  16. public UIC020110()
  17. {
  18. InitializeComponent();
  19. }
  20. public override void ToolBar_Click(object sender, string ToolbarKey)
  21. {
  22. switch (ToolbarKey)
  23. {
  24. case "Query":
  25. this.DoQuery();
  26. break;
  27. case "Save":
  28. this.DoSave();
  29. break;
  30. case "Export":
  31. this.DoExport();
  32. break;
  33. case "Close":
  34. this.Close();
  35. break;
  36. }
  37. }
  38. private void DoQuery()
  39. {
  40. try
  41. {
  42. CoreClientParam ccp = new CoreClientParam();
  43. //查询
  44. this.dataSet1.Tables[0].Clear();
  45. ArrayList al = new ArrayList();
  46. al.Add("UIC020110_01.SELECT");
  47. al.Add(this.ultraComboEditor1.Text);//产线
  48. al.Add(this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd") );
  49. al.Add(this.ultraComboEditor2.Value.ToString());
  50. ccp = new CoreClientParam();
  51. ccp.ServerName = "UIB.COM.ComDBQuery";
  52. ccp.MethodName = "doSimpleQuery";
  53. ccp.ServerParams = new object[] { al };
  54. ccp.IfShowErrMsg = false;
  55. ccp.SourceDataTable = this.dataSet1.Tables[0];
  56. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  57. foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
  58. {
  59. if (ugr.Cells["TJ_NAME"].Text.IndexOf("计划产量") != -1 || ugr.Cells["TJ_NAME"].Text.IndexOf("日历时间") != -1
  60. || ugr.Cells["TJ_NAME"].Text.IndexOf("停轧时间") != -1
  61. || ugr.Cells["TJ_NAME"].Text.IndexOf("计划时间") != -1 || ugr.Cells["TJ_NAME"].Text.IndexOf("1.计划检修") != -1
  62. || ugr.Cells["TJ_NAME"].Text.IndexOf("2.设备申请") != -1 || ugr.Cells["TJ_NAME"].Text.IndexOf("3.计划换辊、刀") != -1
  63. || ugr.Cells["TJ_NAME"].Text.IndexOf("故障时间") != -1 || ugr.Cells["TJ_NAME"].Text.IndexOf("1.酸轧车间") != -1
  64. || ugr.Cells["TJ_NAME"].Text.IndexOf("2.准备车间") != -1 || ugr.Cells["TJ_NAME"].Text.IndexOf("3.新冶公司") != -1
  65. || ugr.Cells["TJ_NAME"].Text.IndexOf("4.自动化部") != -1 || ugr.Cells["TJ_NAME"].Text.IndexOf("5.二十冶") != -1
  66. || ugr.Cells["TJ_NAME"].Text.IndexOf("6.设备部") != -1 || ugr.Cells["TJ_NAME"].Text.IndexOf("7.停机时间") != -1
  67. || ugr.Cells["TJ_NAME"].Text.IndexOf("8.外部") != -1 || ugr.Cells["TJ_NAME"].Text.IndexOf("2.新冶公司") != -1
  68. || ugr.Cells["TJ_NAME"].Text.IndexOf("3.自动化部") != -1 || ugr.Cells["TJ_NAME"].Text.IndexOf("5.设备部") != -1 || ugr.Cells["TJ_NAME"].Text.IndexOf("6.停机时间") != -1
  69. ||ugr.Cells["TJ_NAME"].Text.IndexOf("连退车间") != -1 || ugr.Cells["TJ_NAME"].Text.IndexOf("5.宝冶") != -1
  70. ||ugr.Cells["TJ_NAME"].Text.IndexOf("停机水消耗(循环水)") != -1 ||ugr.Cells["TJ_NAME"].Text.IndexOf("停机开始时间") != -1 ||ugr.Cells["TJ_NAME"].Text.IndexOf("停机结束时间") != -1
  71. || ugr.Cells["TJ_NAME"].Text.IndexOf("4.福盈公司") != -1 || ugr.Cells["TJ_NAME"].Text.IndexOf("停轧时间") != -1
  72. || ugr.Cells["TJ_NAME"].Text.IndexOf("电耗") != -1 || ugr.Cells["TJ_NAME"].Text.IndexOf("水消耗(循环水)") != -1)
  73. {
  74. ugr.Appearance.ForeColor = Color.Red;
  75. }
  76. else if (ugr.Cells["TJ_NAME"].Text.ToString() == "液压油" || ugr.Cells["TJ_NAME"].Text.ToString() == "润滑油220" || ugr.Cells["TJ_NAME"].Text.ToString() == "润滑油320")
  77. {
  78. ugr.Appearance.ForeColor = Color.Blue;
  79. }
  80. }
  81. if (this.ultraComboEditor1.Text == "热轧")
  82. {
  83. for (int a = 0; a < this.ultraGrid1.Rows.Count; a++)
  84. {
  85. if (a > 3 && a < 35)
  86. {
  87. this.ultraGrid1.Rows[a].Appearance.ForeColor = Color.Red;
  88. }
  89. }
  90. }
  91. }
  92. catch (Exception ex)
  93. {
  94. System.Diagnostics.Debug.WriteLine(ex.ToString());
  95. }
  96. }
  97. private void DoExport()
  98. {
  99. try
  100. {
  101. if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)
  102. {
  103. string fileName = this.saveFileDialog1.FileName;
  104. ultraGridExcelExporter1.Export(ultraGrid1, fileName);
  105. System.Diagnostics.Process.Start(fileName);
  106. }
  107. }
  108. catch (Exception EX)
  109. {
  110. MessageBox.Show(EX.ToString());
  111. }
  112. }
  113. private void DoSave()
  114. {
  115. try
  116. {
  117. if (this.UserInfo.GetUserGroup() == 0 + "")
  118. {
  119. MessageBox.Show("常白班人员禁止对数据进行操作" ,"警告");
  120. return;
  121. }
  122. if (MessageBox.Show("确认保存?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
  123. return;
  124. ArrayList al = new ArrayList();
  125. ArrayList list = null;
  126. string num1 = "";//日历时间
  127. string num2 = "";//停轧时间
  128. string strBC = "";//班次
  129. string strTime = "";
  130. string strProdLine = "";
  131. foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
  132. {
  133. if (ugr.Cells["TJ_NAME"].Text == "日历时间")
  134. {
  135. num1 = ugr.Cells["TJ_RESULT"].Text.Trim();
  136. strBC = ugr.Cells["TJ_BC"].Value.ToString().Trim();
  137. }
  138. else if (ugr.Cells["TJ_NAME"].Text == "停轧时间")
  139. num2 = ugr.Cells["TJ_RESULT"].Text.Trim();
  140. if (ugr.Cells["MODIFY_FLAG"].Text == "Y")
  141. {
  142. strTime = ugr.Cells["TJ_DTIME"].Text.Trim();
  143. strProdLine = ugr.Cells["PROD_LINE"].Text.Trim();
  144. list = new ArrayList();
  145. list.Add("UIC020110_01.UPDATE");
  146. list.Add(ugr.Cells["TJ_RESULT"].Text.Trim());
  147. list.Add(ugr.Cells["TJ_DEMO"].Text.Trim());
  148. list.Add(this.UserInfo.GetUserName());
  149. list.Add(ugr.Cells["PROD_LINE"].Text.Trim());
  150. list.Add(ugr.Cells["TJ_DTIME"].Text.Trim());
  151. list.Add(ugr.Cells["TJ_BC"].Value.ToString().Trim());
  152. list.Add(ugr.Cells["TJ_NAME"].Text.Trim());
  153. al.Add(list);
  154. }
  155. }
  156. //对实际作业时间进行处理,日历时间-停轧时间
  157. list = new ArrayList();
  158. list.Add("UIC020110_01.UPDATE");
  159. if (num1 != "" && num2 != "")
  160. list.Add(double.Parse(num1) - double.Parse(num2));
  161. else
  162. list.Add("");
  163. list.Add("min");
  164. list.Add(this.UserInfo.GetUserName());
  165. list.Add(strProdLine);//产线
  166. list.Add(strTime);//时间
  167. list.Add(strBC);//班次
  168. list.Add("实际作业时间");
  169. al.Add(list);
  170. if (al.Count == 0)
  171. {
  172. MessageBox.Show("没有修改的数据(红色行),保存无效", "提示");
  173. return;
  174. }
  175. CoreClientParam ccp = new CoreClientParam();
  176. ccp.ServerName = "UIB.COM.ComDBSave";
  177. ccp.MethodName = "doXmlSave";
  178. ccp.ServerParams = new object[] { al };
  179. ccp.IfShowErrMsg = false;
  180. ccp =this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  181. ccp = new CoreClientParam();
  182. Hashtable ht = new Hashtable();
  183. ht.Add("i1", this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd"));
  184. ht.Add("o2", "");
  185. ccp.ServerName = "UIB.COM.ComDBProcedure";
  186. ccp.MethodName = "doXmlProcedure";
  187. ccp.ServerParams = new object[] { "UIC010001_02.CALL", ht };
  188. this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  189. this.DoQuery();
  190. }
  191. catch (Exception ex)
  192. {
  193. System.Diagnostics.Debug.WriteLine(ex.ToString());
  194. MessageBox.Show("系统发生异常,请与管理员联系", "提示");
  195. }
  196. }
  197. //private string checkSJZYSJ(string date)
  198. // private void checkSJZYSJ()
  199. // {
  200. // CoreClientParam ccp = new CoreClientParam();
  201. // Hashtable ht = new Hashtable();
  202. // ht.Add("i1", this.ComboProdLine.Text);//产线
  203. // ht.Add("i2", this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd"));//录入时间
  204. // ht.Add("i3",this.ultraComboEditor2.Value.ToString());//班组
  205. // ht.Add("o4", "");
  206. // ccp.ServerName = "UIB.COM.ComDBProcedure";
  207. // ccp.MethodName = "doXmlProcedure";
  208. // ccp.ServerParams = new object[] { "UIC020110_02.CALL", ht };
  209. // CoreClientParam ccpResult = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  210. // }
  211. private void DoInsertRow()
  212. {
  213. try
  214. {
  215. if (this.UserInfo.GetUserGroup() == 0 + "")
  216. {
  217. MessageBox.Show("常白班人员禁止对数据进行操作", "警告");
  218. return;
  219. }
  220. if (this.ultraDateTimeEditor3.DateTime.ToString("yyyyMMdd") == "" || this.ComboProdLine.Text == "")
  221. {
  222. MessageBox.Show("请在编辑区域选择正确的日期和产线");
  223. return;
  224. }
  225. if (MessageBox.Show("确认增加【" + strBC + "】的日志数据?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
  226. return;
  227. CoreClientParam ccp = new CoreClientParam();
  228. Hashtable ht = new Hashtable();
  229. ht.Add("i1", this.ComboProdLine.Text);//产线
  230. ht.Add("i2", this.UserInfo.GetUserName());//用户名
  231. ht.Add("i3", this.ultraDateTimeEditor3.DateTime.ToString("yyyyMMdd") );
  232. ht.Add("i4", this.UserInfo.GetUserGroup());
  233. ht.Add("o5", "");
  234. ccp.ServerName = "UIB.COM.ComDBProcedure";
  235. ccp.MethodName = "doXmlProcedure";
  236. ccp.ServerParams = new object[] { "UIC020110_01.CALL", ht };
  237. CoreClientParam ccpResult = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  238. ArrayList al = ccpResult.ReturnObject as ArrayList;
  239. if (al[0].ToString() != "YY")
  240. {
  241. //ugr.Cells["CHEM_CD"].Appearance.BackColor = Color.Blue;
  242. MessageBox.Show(ComboProdLine .Text+ this.strBC + al[0].ToString(), "提示");
  243. return;
  244. }
  245. this.ultraDateTimeEditor1.Value = this.ultraDateTimeEditor3.Value.ToString();
  246. this.ultraComboEditor2.Value = this.UserInfo.GetUserGroup();
  247. this.ultraComboEditor1.Value = this.ComboProdLine.Value.ToString();
  248. this.DoQuery();
  249. }
  250. catch (Exception ex)
  251. {
  252. System.Diagnostics.Debug.WriteLine(ex.ToString());
  253. }
  254. }
  255. string strBC = "";//班组
  256. private void UIC020110_Load(object sender, EventArgs e)
  257. {
  258. try
  259. {
  260. this.ultraComboEditor1.SelectedIndex = 0;
  261. this.ultraComboEditor2.Value = this.UserInfo.GetUserGroup();//0;
  262. this.ComboProdLine.SelectedIndex = 0;
  263. if (this.UserInfo.GetUserGroup() == 0 + "")
  264. strBC = "常白班";
  265. else if (this.UserInfo.GetUserGroup() == 1 + "")
  266. strBC = "甲班";
  267. else if (this.UserInfo.GetUserGroup() == 2 + "")
  268. strBC = "乙班";
  269. else if (this.UserInfo.GetUserGroup() == 3 + "")
  270. strBC = "丙班";
  271. else if (this.UserInfo.GetUserGroup() == 4 + "")
  272. strBC = "丁班";
  273. this.labelBC.Text = "提醒:当前登录班组为" + strBC + ",非" + strBC + "人员禁止增加该班的数据。";
  274. }
  275. catch (Exception ex)
  276. {
  277. System.Diagnostics.Debug.WriteLine(ex.ToString());
  278. }
  279. }
  280. private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  281. {
  282. try
  283. {
  284. this.ultraGrid1.ActiveRow.Appearance.ForeColor = Color.Red;//红色
  285. this.ultraGrid1.ActiveRow.Appearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True;//设置为粗体
  286. this.ultraGrid1.ActiveRow.Cells["MODIFY_FLAG"].Value = "Y";
  287. this.ultraGrid1.Update();
  288. }
  289. catch (Exception ex)
  290. {
  291. System.Diagnostics.Debug.WriteLine(ex.ToString());
  292. }
  293. }
  294. private void ultraGrid1_KeyUp(object sender, KeyEventArgs e)
  295. {
  296. try
  297. {
  298. if(e.KeyCode != Keys.Enter)
  299. return;
  300. if (this.ultraGrid1.ActiveCell == null)
  301. return;
  302. string keyName = this.ultraGrid1.ActiveCell.Column.Key;
  303. this.ultraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.NextRow);
  304. this.ultraGrid1.ActiveRow.Cells[keyName].Activated = true;
  305. this.ultraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode);
  306. }
  307. catch (Exception ex)
  308. {
  309. System.Diagnostics.Debug.WriteLine(ex.ToString());
  310. }
  311. }
  312. private void button1_Click(object sender, EventArgs e)
  313. {
  314. this.DoInsertRow();
  315. }
  316. }
  317. }