UIN060220.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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. namespace Core.LZMes.Client.UIN
  12. {
  13. public partial class UIN060220 : FrmBase
  14. {
  15. public UIN060220()
  16. {
  17. InitializeComponent();
  18. }
  19. /// <summary>
  20. /// 初始化
  21. /// </summary>
  22. #region "Init"
  23. #endregion
  24. /// <summary>
  25. /// 操作方法 查询
  26. /// </summary>
  27. private void DoQuery()
  28. {
  29. try
  30. {
  31. this.dataSet1.Tables[0].Clear();
  32. string calNO = Convert.ToString(Common.FixDBManager.CheckNullStr(this.textOrdNO.Text));
  33. string DelToDateFrom = Convert.ToString(Common.FixDBManager.CheckNullStr(this.DelToDateFrom.DateTime.ToString("yyyyMMdd")));
  34. string DelToDateTo = Convert.ToString(Common.FixDBManager.CheckNullStr(this.DelToDateTo.DateTime.ToString("yyyyMMdd")));
  35. CoreClientParam ccp = new CoreClientParam();
  36. ccp.ServerName = "UIB.COM.ComDBQuery";
  37. ccp.MethodName = "doSimpleQuery";
  38. ArrayList paramArray = new ArrayList();
  39. paramArray.Add("UIN060220_REEL_NO.Select");
  40. paramArray.Add(DelToDateFrom);
  41. paramArray.Add(DelToDateTo);
  42. paramArray.Add(calNO);
  43. ccp.ServerParams = new object[] { paramArray };
  44. ccp.SourceDataTable = this.dataSet1.Tables[0];
  45. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  46. System.Diagnostics.Debug.WriteLine(this.dataSet1.Tables[0].ToString());
  47. //a为原料重量 b为成品重量
  48. double a1 = 0;
  49. double b1 = 0;
  50. double a2 = 0;
  51. double b2 = 0;
  52. double a3 = 0;
  53. double b3 = 0;
  54. double a4 = 0;
  55. double b4 = 0;
  56. double a5 = 0;
  57. double b5 = 0;
  58. double a6 = 0;
  59. double b6 = 0;
  60. double a7 = 0;
  61. double b7 = 0;
  62. double a8 = 0;
  63. double b8 = 0;
  64. for (int a = 0; a < this.ultraGrid1.Rows.Count; a++)
  65. {
  66. /*
  67. * author: zmz
  68. * 原料重量 成品重量根据订单厚度汇总
  69. * cc 订单厚度
  70. * aa 原料重量
  71. * bb 成品重量
  72. */
  73. double cc;
  74. double aa;
  75. double bb;
  76. if (this.ultraGrid1.Rows[a].Cells["INSTR_COIL_THK"].Text == "") cc = 0;
  77. else cc = double.Parse(this.ultraGrid1.Rows[a].Cells["INSTR_COIL_THK"].Value.ToString());
  78. if (this.ultraGrid1.Rows[a].Cells["ENT_COIL_WGT"].Text == "") aa = 0;
  79. else aa = double.Parse(this.ultraGrid1.Rows[a].Cells["ENT_COIL_WGT"].Value.ToString());
  80. if (this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text == "") bb = 0;
  81. else bb = double.Parse(this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Value.ToString());
  82. if (cc < 0.3)
  83. {
  84. a1 = a1 + aa;
  85. b1 = b1 + bb;
  86. }
  87. else if (cc < 0.35)
  88. {
  89. a2 = a2 + aa;
  90. b2 = b2 + bb;
  91. }
  92. else if (cc < 0.4)
  93. {
  94. a3 = a3 + aa;
  95. b3 = b3 + bb;
  96. }
  97. else if (cc < 0.45)
  98. {
  99. a4 = a4 + aa;
  100. b4 = b4 + bb;
  101. }
  102. else if (cc < 0.5)
  103. {
  104. a5 = a5 + aa;
  105. b5 = b5 + bb;
  106. }
  107. else if (cc < 0.6)
  108. {
  109. a6 = a6 + aa;
  110. b6 = b6 + bb;
  111. }
  112. else if (cc < 1.0)
  113. {
  114. a7 = a7 + aa;
  115. b7 = b7 + bb;
  116. }
  117. else if (cc < 2.0)
  118. {
  119. a8 = a8 + aa;
  120. b8 = b8 + bb;
  121. }
  122. }
  123. this.textBox1.Text = (a1 / 1000).ToString();
  124. this.textBox2.Text = (b1 / 1000).ToString();
  125. this.textBox3.Text = (a2 / 1000).ToString();
  126. this.textBox4.Text = (b2 / 1000).ToString();
  127. this.textBox5.Text = (a3 / 1000).ToString();
  128. this.textBox6.Text = (b3 / 1000).ToString();
  129. this.textBox7.Text = (a4 / 1000).ToString();
  130. this.textBox8.Text = (b4 / 1000).ToString();
  131. this.textBox9.Text = (a5 / 1000).ToString();
  132. this.textBox10.Text = (b5 / 1000).ToString();
  133. this.textBox11.Text = (a6 / 1000).ToString();
  134. this.textBox12.Text = (b6 / 1000).ToString();
  135. this.textBox13.Text = (a7 / 1000).ToString();
  136. this.textBox14.Text = (b7 / 1000).ToString();
  137. this.textBox15.Text = (a8 / 1000).ToString();
  138. this.textBox16.Text = (b8 / 1000).ToString();
  139. for (int a = 0; a < this.ultraGrid1.Rows.Count; a++)
  140. {
  141. string zl = Convert.ToString(Common.FixDBManager.CheckNullStr(this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text.ToString()));
  142. if (zl == "") zl="0";
  143. // double b = double.Parse(this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text.ToString());
  144. double b = double.Parse(zl);
  145. string c = this.ultraGrid1.Rows[a].Cells["OLD_SAMPL_NO"].Text.ToString();
  146. double h = double.Parse(this.ultraGrid1.Rows[a].Cells["ENT_COIL_WGT"].Value.ToString());
  147. for (int d = a + 1; d <= this.ultraGrid1.Rows.Count - 1; d++)
  148. {
  149. string zl2 = Convert.ToString(Common.FixDBManager.CheckNullStr(this.ultraGrid1.Rows[d].Cells["COIL_WGT"].Text.ToString()));
  150. if (zl2 == "") zl2 = "0";
  151. // double e = double.Parse(this.ultraGrid1.Rows[d].Cells["COIL_WGT"].Text.ToString());
  152. double e = double.Parse(zl2);
  153. string f = this.ultraGrid1.Rows[d].Cells["OLD_SAMPL_NO"].Text.ToString();
  154. if (f.Substring(0, 16) == c.Substring(0, 16))
  155. {
  156. b = b + e;
  157. a = d;
  158. }
  159. else break;
  160. }
  161. double g = b / h * 100;
  162. this.ultraGrid1.Rows[a].Cells["CHENGCAILV"].Value = g.ToString("f2");
  163. }
  164. }
  165. catch (Exception EX)
  166. {
  167. MessageBox.Show(EX.ToString());
  168. }
  169. }
  170. /// <summary>
  171. /// 操作方法 保存班次组信息
  172. /// </summary>
  173. private void DoSave()
  174. {
  175. try
  176. {
  177. string strQueryFlag = "Y";
  178. this.ultraGrid1.UpdateData();
  179. DataRow[] selectedRows = dataSet1.Tables[0].Select("CHK ='True'");
  180. for (int i = 0; i < selectedRows.Length; i++)
  181. {
  182. string regid = this.UserInfo.GetUserID();
  183. string regshift = this.UserInfo.GetUserOrder();
  184. string reggroup = this.UserInfo.GetUserGroup();
  185. string coilno = Convert.ToString(Common.FixDBManager.CheckNullStr(selectedRows[i]["OLD_SAMPL_NO"]));
  186. string cutEdgeYN = Convert.ToString(Common.FixDBManager.CheckNullStr(selectedRows[i]["CUT_EDGE_YN"]));
  187. string millDtime = Convert.ToString(Common.FixDBManager.CheckNullStr(selectedRows[i]["MILL_DTIME"]));
  188. string isHead = Convert.ToString(Common.FixDBManager.CheckNullStr(selectedRows[i]["ISHEAD"]));
  189. if (millDtime.Length != 14)//长度
  190. {
  191. strQueryFlag = "N";
  192. MessageBox.Show("警告,钢卷" + coilno + "录入的日期长度" + millDtime + "错误,禁止保存", "提示");
  193. return;
  194. }
  195. if (Convert.ToInt16(millDtime.Substring(4, 2)) > 12) //月
  196. {
  197. strQueryFlag = "N";
  198. MessageBox.Show("警告,钢卷" + coilno + "录入的日期【月】" + millDtime + "错误,禁止保存", "提示");
  199. return;
  200. }
  201. if (Convert.ToInt16(millDtime.Substring(6, 2)) > 31) //日
  202. {
  203. strQueryFlag = "N";
  204. MessageBox.Show("警告,钢卷" + coilno + "录入的日期【日】" + millDtime + "错误,禁止保存", "提示");
  205. return;
  206. }
  207. if (Convert.ToInt16(millDtime.Substring(8, 2)) > 24) //小时
  208. {
  209. strQueryFlag = "N";
  210. MessageBox.Show("警告,钢卷" + coilno + "录入的日期【时】" + millDtime + "错误,禁止保存", "提示");
  211. return;
  212. }
  213. if (Convert.ToInt16(millDtime.Substring(10, 2)) > 59)//分
  214. {
  215. strQueryFlag = "N";
  216. MessageBox.Show("警告,钢卷" + coilno + "录入的日期【分】" + millDtime + "错误,禁止保存", "提示");
  217. return;
  218. }
  219. if (Convert.ToInt16(millDtime.Substring(12, 2)) > 59)//秒
  220. {
  221. strQueryFlag = "N";
  222. MessageBox.Show("警告,钢卷" + coilno + "录入的日期【秒】" + millDtime + "错误,禁止保存", "提示");
  223. return;
  224. }
  225. CoreClientParam ccp = new CoreClientParam();
  226. ccp.ServerName = "UIB.COM.ComDBSave";
  227. ccp.MethodName = "doXmlSave";
  228. ArrayList paramArray = new ArrayList();
  229. paramArray.Add("UIN060220_shift.Update");
  230. paramArray.Add(regid);
  231. paramArray.Add(regshift);
  232. paramArray.Add(reggroup);
  233. paramArray.Add(cutEdgeYN);
  234. paramArray.Add(isHead);
  235. paramArray.Add(millDtime);
  236. paramArray.Add(coilno);
  237. ccp.ServerParams = new object[] { paramArray };
  238. ccp.SourceDataTable = this.dataSet1.Tables[0];
  239. this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  240. }
  241. if (strQueryFlag == "Y")
  242. {
  243. this.DoQuery();
  244. }
  245. }
  246. catch (Exception ex)
  247. {
  248. System.Diagnostics.Debug.WriteLine(ex.ToString());
  249. }
  250. }
  251. private void DoExport()
  252. {
  253. try
  254. {
  255. if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)
  256. {
  257. string fileName = this.saveFileDialog1.FileName;
  258. ultraGridExcelExporter1.Export(ultraGrid1, fileName);
  259. //System.Diagnostics.Process.Start(fileName);
  260. }
  261. }
  262. catch (Exception EX)
  263. {
  264. MessageBox.Show(EX.ToString());
  265. }
  266. }
  267. /// <summary>
  268. /// 事件方法:
  269. /// </summary>
  270. /// <param name="sender"></param>
  271. /// <param name="e"></param>
  272. #region "EVENT 事件"
  273. private void UIN060120_Load(object sender, EventArgs e)
  274. {
  275. }
  276. public override void ToolBar_Click(object sender, string ToolbarKey)
  277. {
  278. switch (ToolbarKey)
  279. {
  280. case "Query":
  281. this.DoQuery();
  282. break;
  283. case "Save":
  284. this.DoSave();
  285. break;
  286. case "Export":
  287. this.DoExport();
  288. break;
  289. case "Exit":
  290. this.Close();
  291. break;
  292. }
  293. }
  294. private void ComboCalNO_ValueChanged(object sender, EventArgs e)
  295. {
  296. this.DoQuery();
  297. }
  298. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  299. {
  300. try
  301. {
  302. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid1.Rows)
  303. {
  304. ugr.Cells["CHK"].Value = this.checkBox1.Checked;
  305. ugr.Update();
  306. }
  307. }
  308. catch (Exception ex)
  309. {
  310. System.Diagnostics.Debug.WriteLine(ex.ToString());
  311. }
  312. }
  313. #endregion
  314. }
  315. }