FrmBcDateWaitingDecision.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using Core.StlMes.Client.ZGMil.Common;
  5. using Core.StlMes.Client.ZGMil.Entity;
  6. using Core.StlMes.Client.ZGMil.ResultConrtrol;
  7. using Core.StlMes.Client.ZGMil.Signature;
  8. using CoreFS.CA06;
  9. using Infragistics.Win;
  10. using Infragistics.Win.UltraWinGrid;
  11. using System;
  12. using System.Collections;
  13. using System.Collections.Generic;
  14. using System.ComponentModel;
  15. using System.Data;
  16. using System.Drawing;
  17. using System.Linq;
  18. using System.Text;
  19. using System.Windows.Forms;
  20. namespace Core.StlMes.Client.ZGMil.Report
  21. {
  22. public partial class FrmBcDateWaitingDecision : FrmBase
  23. {
  24. private string departm = "";
  25. private string plineCode = "";
  26. private string Process = "";//参数
  27. private string[] arrId;//数据权限
  28. private DataTable _dtPline = null;
  29. public FrmBcDateWaitingDecision()
  30. {
  31. InitializeComponent();
  32. this.IsLoadUserView = true;
  33. }
  34. /// <summary>
  35. /// 重写基类方法
  36. /// </summary>
  37. /// <param name="sender"></param>
  38. /// <param name="ToolbarKey"></param>
  39. public override void ToolBar_Click(object sender, string ToolbarKey)
  40. {
  41. switch (ToolbarKey)
  42. {
  43. case "Query":
  44. doQuery();
  45. break;
  46. case "Save":
  47. doSave();
  48. break;
  49. case "Export":
  50. ExportData();
  51. break;
  52. case "Close":
  53. this.Close();
  54. break;
  55. }
  56. }
  57. private void doSave()
  58. {
  59. ultraGrid1.UpdateData();
  60. ArrayList parm = new ArrayList();
  61. IQueryable<UltraGridRow> uGrid = ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  62. if (uGrid.Count() == 0)
  63. {
  64. MessageUtil.ShowTips("请选择要保存的数据!");
  65. return;
  66. }
  67. foreach (UltraGridRow uRow in uGrid)
  68. {
  69. ArrayList list = new ArrayList();
  70. list.Add(uRow.Cells["WAITING_DECISION_MEMO"].Value.ToString());
  71. list.Add(uRow.Cells["IS_VISIBLE"].Value.ToString());
  72. if (Process.Equals("G"))
  73. {
  74. list.Add(uRow.Cells["MEMO2"].Value.ToString());
  75. }
  76. list.Add(uRow.Cells["JUDGE_STOVE_NO"].Value.ToString());
  77. list.Add(uRow.Cells["HEAT_PLAN_NO"].Value.ToString());
  78. parm.Add(list);
  79. }
  80. int count = ServerHelper.SetData("com.steering.mes.zgmil.report.FrmMilDateStatistics.saveFrmBcDateWaitingDecision", new object[] { parm, Process }, this.ob);
  81. MessageUtil.ShowTips("保存成功!");
  82. doQuery();
  83. }
  84. /// <summary>
  85. /// 查询
  86. /// </summary>
  87. private void doQuery()
  88. {
  89. ultraGrid1.UpdateData();
  90. dataTable2.Clear();
  91. string date = "";
  92. string endDate = "";
  93. string JudgeStoveNo = "";
  94. string LotNo = "";
  95. string ContractNo = "";
  96. string plineCode = "";
  97. string VALIDFLAG = "";
  98. string IsVisible = "";
  99. string Factory = "";
  100. if (chkDate.Checked)
  101. {
  102. if (DataTimeUtil.JudgeTime(DateTime.Parse(cmbDate.Value.ToString()), DateTime.Parse(cmbEndDate.Value.ToString())) == 0)
  103. {
  104. MessageUtil.ShowTips("您所选择的日期区域不对,请重新选择!");
  105. return;
  106. }
  107. else
  108. {
  109. date = cmbDate.Value.ToString();
  110. endDate = cmbEndDate.Value.ToString();
  111. }
  112. }
  113. if (chkJudgeStoveNo.Checked)
  114. {
  115. if (uteJudgeStoveNo.Text.Trim() == "")
  116. {
  117. JudgeStoveNo = "";
  118. }
  119. else
  120. {
  121. JudgeStoveNo = uteJudgeStoveNo.Value.ToString();
  122. }
  123. }
  124. if (chkLotNo.Checked)
  125. {
  126. if (uteLotNo.Text.Trim() == "")
  127. {
  128. LotNo = "";
  129. }
  130. else
  131. {
  132. LotNo = uteLotNo.Value.ToString();
  133. }
  134. }
  135. if (chkContractNo.Checked)
  136. {
  137. if (uteContractNo.Text.Trim() == "")
  138. {
  139. ContractNo = "";
  140. }
  141. else
  142. {
  143. ContractNo = uteContractNo.Value.ToString();
  144. }
  145. }
  146. if (chkPlineCode.Checked)
  147. {
  148. //if (this.cobPlineCode.CheckedItems.Count > 0)
  149. //{
  150. // plineCode = this.cobPlineCode.CheckedItems.Select(p => p.DataValue.ToString()).Aggregate((a, b) => a + (a == "" ? "" : "','") + b);
  151. //}
  152. plineCode = ultraTextEditor1.Tag.ToString().Replace(",","', '");
  153. }
  154. if (chkVALIDFLAG.Checked)
  155. {
  156. VALIDFLAG = cobVALIDFLAG.Value.ToString();
  157. }
  158. if (chkIsVisible.Checked)
  159. {
  160. IsVisible = cobIsVisible.Value.ToString();
  161. }
  162. if (chkFactory.Checked)
  163. {
  164. if (this.cobFactory.CheckedItems.Count > 0)
  165. {
  166. Factory = this.cobFactory.CheckedItems.Select(p => p.DataValue.ToString()).Aggregate((a, b) => a + (a == "" ? "" : "','") + b);
  167. }
  168. }
  169. WaitingForm2 wf = new WaitingForm2("正在加载,请稍候....");
  170. DataTable dt = ZGServerHelper.GetData("com.steering.mes.zgmil.report.FrmMilDateStatistics.getFrmBcDateWaitingDecision", new Object[] { date, endDate, JudgeStoveNo, LotNo, ContractNo, plineCode, Process, VALIDFLAG, IsVisible, Factory }, this.ob);
  171. if (dt.Rows.Count > 0)
  172. {
  173. GridHelper.CopyDataToDatatable(dt, this.dataTable2, true);
  174. GridHelper.RefreshAndAutoSize(this.ultraGrid1);
  175. }
  176. wf.Close();
  177. }
  178. /// <summary>
  179. /// 查询条件
  180. /// </summary>
  181. /// <param name="sender"></param>
  182. /// <param name="e"></param>
  183. private void chkDate_CheckedChanged(object sender, EventArgs e)
  184. {
  185. if (chkDate.Checked) { cmbDate.Enabled = true; } else { cmbDate.Enabled = false; }
  186. if (chkDate.Checked) { cmbEndDate.Enabled = true; } else { cmbEndDate.Enabled = false; }
  187. if (chkLotNo.Checked) { uteLotNo.Enabled = true; } else { uteLotNo.Enabled = false; }
  188. if (chkJudgeStoveNo.Checked) { uteJudgeStoveNo.Enabled = true; } else { uteJudgeStoveNo.Enabled = false; }
  189. if (chkContractNo.Checked) { uteContractNo.Enabled = true; } else { uteContractNo.Enabled = false; }
  190. if (chkPlineCode.Checked) { cobPlineCode.Enabled = true; } else { cobPlineCode.Enabled = false; }
  191. if (chkVALIDFLAG.Checked) { cobVALIDFLAG.Enabled = true; } else { cobVALIDFLAG.Enabled = false; }
  192. if (chkIsVisible.Checked) { cobIsVisible.Enabled = true; } else { cobIsVisible.Enabled = false; }
  193. if (chkFactory.Checked) { cobFactory.Enabled = true; } else { cobFactory.Enabled = false; }
  194. }
  195. private void FrmBcDateWaitingDecision_Load(object sender, EventArgs e)
  196. {
  197. cmbDate.Value = DateTime.Parse(DateTime.Today.ToString());
  198. NativeMethodNew na = new NativeMethodNew(this.ob);
  199. departm = UserInfo.GetDepartment();
  200. //plineCode = na.GetPCode(departm);//获取 用户 对应的产线
  201. arrId = this.ValidDataPurviewIds;//获取数据权限
  202. DateTime now = DateTime.Now;
  203. DateTime date = new DateTime(now.Year, now.Month, 1);
  204. cmbDate.Value = DateTime.Parse(date.ToString("yyyy-MM-dd"));
  205. cmbEndDate.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
  206. Process = this.CustomInfo.ToString();//参数
  207. _dtPline = ServerHelper.GetData("com.steering.mes.zgmil.report.FrmMilDateStatistics.JudgeBaseInfo", new object[] { Process }, ob);
  208. //_dtPline.AcceptChanges();
  209. string strPlineNames = string.Join(",", _dtPline.Rows.Cast<DataRow>().Select(a => a["plineName"].ToString()).ToArray());
  210. string strPineCodes = string.Join(",", _dtPline.Rows.Cast<DataRow>().Select(a => a["plineCode"].ToString()).ToArray());
  211. ultraTextEditor1.Text = strPlineNames;
  212. ultraTextEditor1.Tag = strPineCodes;
  213. if (Process != "G")
  214. {
  215. this.chkFactory.Visible = false;
  216. this.cobFactory.Visible = false;
  217. this.ultraGrid1.DisplayLayout.Bands[0].Columns["is_flag"].Width = 0;
  218. ultraGrid1.DisplayLayout.Bands[0].Columns["XXZ"].Hidden = true;
  219. ultraGrid1.DisplayLayout.Bands[0].Columns["XXD"].Hidden = true;
  220. ultraGrid1.DisplayLayout.Bands[0].Columns["INSTOCK_TIME"].Hidden = true;
  221. ultraGrid1.DisplayLayout.Bands[0].Columns["LXZ"].Hidden = true;
  222. ultraGrid1.DisplayLayout.Bands[0].Columns["LXD"].Hidden = true;
  223. }
  224. //加载产线
  225. DataTable ds = ServerHelper.GetData("com.steering.mes.zgmil.report.FrmMilDateStatistics.doQueryPlineCode", new object[] { Process, arrId }, ob);
  226. if (ds != null && ds.Rows.Count > 0)
  227. {
  228. cobPlineCode.DataSource = ds;
  229. cobPlineCode.ValueMember = "PLINE_CODE";
  230. cobPlineCode.DisplayMember = "PLINE_NAME";
  231. }
  232. //加载查加工部的厂
  233. DataTable df = ServerHelper.GetData("com.steering.mes.zgmil.report.FrmMilDateStatistics.doQueryFactory", new object[] { }, ob);
  234. if (df != null && df.Rows.Count > 0)
  235. {
  236. cobFactory.DataSource = df;
  237. cobFactory.ValueMember = "BASECODE";
  238. cobFactory.DisplayMember = "BASENAME";
  239. }
  240. }
  241. /// <summary>
  242. /// 导出
  243. /// </summary>
  244. private void ExportData()
  245. {
  246. if (Process == "E")
  247. {
  248. GridHelper.ulGridToExcel(ultraGrid1, "镦拔扩生产按炉跟踪判定情况");
  249. }
  250. if (Process == "F")
  251. {
  252. GridHelper.ulGridToExcel(ultraGrid1, "热处理生产按炉跟踪判定情况");
  253. }
  254. if (Process == "G")
  255. {
  256. GridHelper.ulGridToExcel(ultraGrid1, "加工线生产按炉跟踪判定情况");
  257. }
  258. }
  259. private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  260. {
  261. ChoicePlineFrm frm = new ChoicePlineFrm(_dtPline, ultraTextEditor1.Tag.ToString2(), this.ob);
  262. if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  263. {
  264. ultraTextEditor1.Text = frm.ChoicePlineName;
  265. ultraTextEditor1.Tag = frm.ChoicePlineCode;
  266. }
  267. }
  268. private void ultraGrid1_InitializeLayout(object sender, InitializeLayoutEventArgs e)
  269. {
  270. }
  271. //private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  272. //{
  273. // UltraGridRow uRow = this.ultraGrid1.ActiveRow;
  274. // if (uRow == null)
  275. // {
  276. // return;
  277. // }
  278. // //doQueryJudgeBath(uRow.Cells["HeatPlanNo"].Text, uRow.Cells["JudgeStoveNo"].Text, uRow.Cells["JugdeApplyCode"].Text);
  279. //// List<QcmZgJugdeApplyEntity> listSource = EntityHelper.GetData<QcmZgJugdeApplyEntity>(
  280. ////"com.steering.mes.zgmil.report.FrmMilDateStatistics.doQueryQcmZgApplyData", new object[] { uRow.Cells["JUDGE_STOVE_NO"].Text }, this.ob);
  281. // DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.report.FrmMilDateStatistics.doQueryQcmZgApplyData", new object[] { uRow.Cells["JUDGE_STOVE_NO"].Text }, ob);
  282. // if (dt != null && dt.Rows.Count > 0)
  283. // {
  284. // ultraGrid1.DisplayLayout.Bands[0].Columns["is_flag"].Header.Caption = "前工序是否紧急放行";
  285. // foreach (UltraGridRow row in this.ultraGrid1.Rows)
  286. // {
  287. // row.Cells["is_flag"].Value = "是";
  288. // }
  289. // }
  290. // else
  291. // {
  292. // ultraGrid1.DisplayLayout.Bands[0].Columns["is_flag"].Header.Caption = "前工序是否紧急放行";
  293. // foreach (UltraGridRow row in this.ultraGrid1.Rows)
  294. // {
  295. // row.Cells["is_flag"].Value = "否";
  296. // }
  297. // }
  298. //}
  299. }
  300. }