FrmFPRecall.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  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. using Core.Mes.Client.Comm.Server;
  13. using Core.Mes.Client.Comm.Control;
  14. using Core.Mes.Client.Comm.Tool;
  15. using Infragistics.Win.UltraWinEditors;
  16. using System.Text.RegularExpressions;
  17. using com.steering.mes.fprecall;
  18. namespace Core.StlMes.Client.MilCount
  19. {
  20. public partial class FrmFPRecall : FrmBase
  21. {
  22. public FrmFPRecall()
  23. {
  24. InitializeComponent();
  25. }
  26. /// <summary>
  27. /// 重写基类方法
  28. /// </summary>
  29. /// <param name="sender"></param>
  30. /// <param name="ToolbarKey"></param>
  31. public override void ToolBar_Click(object sender, string ToolbarKey)
  32. {
  33. switch (ToolbarKey)
  34. {
  35. case "doQuery":
  36. doQuery();
  37. break;
  38. case "doModify":
  39. Update();
  40. break;
  41. case "DoTB":
  42. DoTB();
  43. break;
  44. // break;
  45. //case "doResume":
  46. // this.doDeleteOrResume(false);
  47. // break;
  48. //case "Close":
  49. // this.Close();
  50. //break;
  51. }
  52. }
  53. private void doQuery()
  54. {
  55. string titleName = "";
  56. if (ultraCheckEditor2.Checked)
  57. {
  58. titleName = txt_lh.Text.Trim();
  59. DataTable dt = ServerHelper.GetData("com.steering.mes.fprecall.corefprecall.getLineList", new Object[] { titleName}, this.ob);
  60. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
  61. }
  62. else
  63. {
  64. DataTable dt = ServerHelper.GetData("com.steering.mes.fprecall.corefprecall.getLineList_all", null, this.ob);
  65. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
  66. }
  67. DataTable dt1 = ServerHelper.GetData("com.steering.mes.fprecall.corefprecall.getFPJY", null, this.ob);
  68. GridHelper.CopyDataToDatatable(ref dt1, ref this.dataTable2, true);
  69. GridHelper.RefreshAndAutoSize(this.ultraGrid1);
  70. GridHelper.RefreshAndAutoSize(this.ultraGrid2);
  71. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in ultraGrid1.Rows)
  72. {
  73. if (row.Cells["管判定支"].Value.ToString() == row.Cells["管计划总支"].Value.ToString() && row.Cells["管计划总支"].Value.ToString() != "")
  74. {
  75. row.Appearance.BackColor = Color.Bisque;
  76. }
  77. if (row.Cells["成品计划支"].Value.ToString() == row.Cells["管判定支"].Value.ToString())
  78. {
  79. row.Appearance.BackColor = Color.GreenYellow;
  80. }
  81. }
  82. //不同颜色区分是否有效数据
  83. //Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
  84. //for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  85. //{
  86. // row = ultraGrid2.Rows[i];
  87. // if (!row.Cells["VALIDFLAG"].Value.ToString().Equals("1"))
  88. // {
  89. // row.Appearance.ForeColor = Color.Red;
  90. // }
  91. // else
  92. // {
  93. // row.Appearance.ForeColor = Color.Black;
  94. // }
  95. //}
  96. //列自适应
  97. //GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid2, new UltraGridColumn[] {
  98. // ultraGrid2.DisplayLayout.Bands[0].Columns["MEMO"]
  99. //});
  100. }
  101. String ID = "";
  102. String PZzhi = "";
  103. String PZdun = "";
  104. String GPzhi = "";
  105. String GPdun = "";
  106. String Length = "";
  107. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  108. {
  109. Infragistics.Win.UltraWinGrid.UltraGridRow row = ultraGrid1.ActiveRow;
  110. if (row != null)
  111. {
  112. //STEELCODE,STEELNAME,STEELSTYLE
  113. ID = row.Cells["标识ID"].Value.ToString();
  114. txt_lcode.Text = row.Cells["上料炉号"].Value.ToString();
  115. Length = "";
  116. PZzhi = row.Cells["上料合计单倍尺支"].Value.ToString();
  117. PZdun = row.Cells["上料合计单倍尺吨"].Value.ToString();
  118. GPzhi = row.Cells["成品计划支"].Value.ToString();
  119. GPdun = row.Cells["成品计划吨"].Value.ToString();
  120. }
  121. }
  122. private void initJGDropDown(UltraComboEditor uce, string MethodId, string memberValue)
  123. {
  124. //初始化编辑区域下拉框
  125. DataTable dt = ServerHelper.GetData(MethodId, null, this.ob);
  126. if (dt != null && dt.Rows.Count > 0)
  127. {
  128. uce.DataSource = dt;
  129. uce.ValueMember = memberValue;
  130. }
  131. }
  132. private void FrmFPRecall_Load(object sender, EventArgs e)
  133. {
  134. InitCombo();
  135. txt_fz.Enabled = false;
  136. }
  137. private void InitCombo()
  138. {
  139. initJGDropDown(cmbGXType, "com.steering.mes.fprecall.corefprecall.getGXType", "GX_Detail");
  140. initJGDropDown(cmbleixing, "com.steering.mes.fprecall.corefprecall.getLeiXing", "FP_Detail");
  141. initJGDropDown(com_gx, "com.steering.mes.fprecall.corefprecall.getGX", "GXMC");
  142. }
  143. private void Update()
  144. {
  145. string para = @"^(\d+(\.\d+)?)|(\-1)$";//正则式
  146. Regex reg = new Regex(para);
  147. if (reg.IsMatch(txt_fd.Text) && reg.IsMatch(txt_fz.Text))
  148. {
  149. if (MessageUtil.ShowYesNoAndQuestion("是否确认修改?") == DialogResult.No)
  150. {
  151. return;
  152. }
  153. ArrayList list = new ArrayList();
  154. list.Add(ID.Trim());//cmbGradeType.Value
  155. list.Add(cmbleixing.Value);
  156. list.Add(txt_fz.Text.Trim());
  157. list.Add(txt_fd.Text.Trim());
  158. list.Add("");
  159. list.Add(com_gx.Value);
  160. list.Add(cmbGXType.Value);
  161. list.Add(ultraGrid1.ActiveRow.Cells["产出炉号"].Value.ToString());
  162. list.Add(ultraGrid1.ActiveRow.Cells["轧批号"].Value.ToString());
  163. list.Add(ultraGrid1.ActiveRow.Cells["外径"].Value.ToString());
  164. list.Add(ultraGrid1.ActiveRow.Cells["壁厚"].Value.ToString());
  165. list.Add(ultraGrid1.ActiveRow.Cells["上料炉号"].Value.ToString());
  166. list.Add(ultraGrid1.ActiveRow.Cells["计划年月"].Value.ToString());
  167. list.Add(ultraGrid1.ActiveRow.Cells["合同号"].Value.ToString());
  168. ArrayList list2 = new ArrayList();
  169. //cmbGradeType.Value
  170. list2.Add(ID.Trim());
  171. list2.Add(ultraGrid1.ActiveRow.Cells["轧批号"].Value.ToString());
  172. list2.Add(ultraGrid1.ActiveRow.Cells["产出炉号"].Value.ToString());
  173. if (cmbGXType.Value.ToString() == "穿孔前")
  174. {
  175. list2.Add(txt_fz.Text.Trim());
  176. list2.Add(txt_fd.Text.Trim());
  177. list2.Add("0");
  178. list2.Add("0");
  179. }
  180. else
  181. {
  182. list2.Add("0");
  183. list2.Add("0");
  184. list2.Add(txt_fz.Text.Trim());
  185. list2.Add(txt_fd.Text.Trim());
  186. }
  187. list2.Add(ultraGrid1.ActiveRow.Cells["计划年月"].Value.ToString());
  188. list2.Add(ultraGrid1.ActiveRow.Cells["上料炉号"].Value.ToString());
  189. list2.Add("20");
  190. ArrayList list3 = new ArrayList();
  191. //cmbGradeType.Value
  192. list3.Add(cmbGXType.Value.ToString());
  193. list3.Add(txt_fz.Text.Trim());
  194. list3.Add(txt_fd.Text.Trim());
  195. list3.Add(ID.Trim());
  196. ServerHelper.SetData("com.steering.mes.fprecall.corefprecall.update", new object[] { list, list2, list3 }, ob);
  197. MessageUtil.ShowTips("修改成功!");
  198. doQuery();
  199. }
  200. else
  201. {
  202. MessageBox.Show("请输入数字!");
  203. return;
  204. }
  205. }
  206. private void ultraCheckEditor1_CheckedChanged(object sender, EventArgs e)
  207. {
  208. if (ultraCheckEditor2.Checked)
  209. {
  210. txt_lh.ReadOnly = false;
  211. }
  212. else
  213. {
  214. txt_lh.ReadOnly = true;
  215. }
  216. }
  217. private void txt_fd_KeyPress(object sender, KeyPressEventArgs e)
  218. {
  219. //if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)8)
  220. //{
  221. // e.Handled = true;
  222. //}
  223. //else
  224. //{
  225. // MessageBox.Show("请输入数字!");
  226. //}
  227. }
  228. private void cmbGXType_ValueChanged(object sender, EventArgs e)
  229. {
  230. txt_fz.Enabled = true;
  231. txt_fz.Text = "";
  232. txt_fd.Text = "";
  233. }
  234. private void txt_fz_TextChanged(object sender, EventArgs e)
  235. {
  236. if (txt_fz.Text == "")
  237. {
  238. txt_fz.Text = "0";
  239. }
  240. if (cmbGXType.SelectedItem.DataValue.Equals("穿孔前"))
  241. {
  242. decimal dun = Int16.Parse(txt_fz.Text) * (decimal.Parse(PZdun) / Int16.Parse(PZzhi));
  243. dun = Math.Round(dun, 3);
  244. txt_fd.Text = dun.ToString();
  245. }
  246. else
  247. {
  248. decimal dun = Int16.Parse(txt_fz.Text) * (decimal.Parse(GPdun) / Int16.Parse(GPzhi));
  249. dun = Math.Round(dun, 3);
  250. txt_fd.Text = dun.ToString();
  251. }
  252. }
  253. private void DoTB()
  254. {
  255. ArrayList list = new ArrayList();
  256. FPPlan TB = new FPPlan();
  257. DateTime date_x = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
  258. String year_x = date_x.Year.ToString(); ;//date_x.Splite("-")[0].ToString();;
  259. String month_x = date_x.ToString("MM");
  260. String fin_date = year_x + month_x;
  261. if (chk_TB.Checked)
  262. {
  263. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in ultraGrid1.Rows)
  264. {
  265. if (Convert.ToBoolean(row.Cells["CHK"].Value))
  266. {
  267. TB.Gkx = "";
  268. TB.GPZ = row.Cells["品种"].Value.ToString();
  269. TB.GSteelGrade = row.Cells["钢种"].Value.ToString();
  270. TB.GSteelLevel = row.Cells["钢级"].Value.ToString();
  271. TB.LlDept = row.Cells["产线"].Value.ToString();
  272. TB.PDM = row.Cells["坯断面"].Value.ToString();
  273. TB.PLGPUnit = row.Cells["坯计划总支"].Value.ToString();
  274. TB.PLKind = row.Cells["坯料品种"].Value.ToString();
  275. TB.PSteelGrade = row.Cells["钢种"].Value.ToString();
  276. TB.PSteelLevel = row.Cells["钢级"].Value.ToString();
  277. TB.JZNY = fin_date;
  278. TB.SLGPWeight = row.Cells["坯计划总吨"].Value.ToString();
  279. TB.TARGET = row.Cells["目标"].Value.ToString();
  280. TB.WAIJING = row.Cells["外径"].Value.ToString();
  281. TB.BIHOU = row.Cells["壁厚"].Value.ToString();
  282. TB.CPUnit = row.Cells["管判定支"].Value.ToString();
  283. TB.CPWeight = row.Cells["管判定吨"].Value.ToString();
  284. TB.GPLode = row.Cells["上料炉号"].Value.ToString();
  285. TB.ZGLode = row.Cells["产出炉号"].Value.ToString();
  286. list.Add(TB);
  287. }
  288. }
  289. }
  290. else
  291. {
  292. //foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in ultraGrid1.Rows)
  293. //{
  294. // if (row.Cells["管判定支"].Value.ToString() == row.Cells["管计划总支"].Value.ToString() && row.Cells["管计划总支"].Value.ToString() != "")
  295. // {
  296. // TB.Gkx = "";
  297. // TB.GPZ = row.Cells["品种"].Value.ToString();
  298. // TB.GSteelGrade = row.Cells["钢种"].Value.ToString();
  299. // TB.GSteelLevel = row.Cells["钢级"].Value.ToString();
  300. // TB.LlDept = row.Cells["产线"].Value.ToString();
  301. // TB.PDM = row.Cells["坯断面"].Value.ToString();
  302. // TB.PLGPUnit = row.Cells["坯计划总支"].Value.ToString();
  303. // TB.PLKind = row.Cells["坯料品种"].Value.ToString();
  304. // TB.PSteelGrade = row.Cells["钢种"].Value.ToString();
  305. // TB.PSteelLevel = row.Cells["钢级"].Value.ToString();
  306. // TB.JZNY = fin_date;
  307. // TB.SLGPWeight = row.Cells["坯计划总吨"].Value.ToString();
  308. // TB.TARGET = row.Cells["目标"].Value.ToString();
  309. // TB.WAIJING = row.Cells["外径"].Value.ToString();
  310. // TB.BIHOU = row.Cells["壁厚"].Value.ToString();
  311. // TB.CPUnit = row.Cells["管判定支"].Value.ToString();
  312. // TB.CPWeight = row.Cells["管判定吨"].Value.ToString();
  313. // TB.GPLode = row.Cells["上料炉号"].Value.ToString();
  314. // TB.ZGLode = row.Cells["产出炉号"].Value.ToString();
  315. // list.Add(TB);
  316. // }
  317. //}
  318. }
  319. ServerHelper.SetData("com.steering.mes.fprecall.corefprecall.tb", new object[] { list }, ob);
  320. MessageUtil.ShowTips("提交成功!");
  321. doQuery();
  322. }
  323. }
  324. }