FrmProcessFlowCard.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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.Entity;
  5. using CoreFS.CA06;
  6. using Infragistics.Win.UltraWinGrid;
  7. using System;
  8. using System.Collections;
  9. using System.Collections.Generic;
  10. using System.ComponentModel;
  11. using System.Data;
  12. using System.Drawing;
  13. using System.Drawing.Printing;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Threading;
  17. using System.Windows.Forms;
  18. using System.IO;
  19. namespace Core.StlMes.Client.ZGMil.Report
  20. {
  21. public partial class FrmProcessFlowCard : FrmBase
  22. {
  23. private string departm = "";
  24. //private string plineCode = "";
  25. private string[] plineCode = null;
  26. public FrmProcessFlowCard()
  27. {
  28. InitializeComponent();
  29. this.IsLoadUserView = true;
  30. }
  31. private void FrmProcessFlowCard_Load(object sender, EventArgs e)
  32. {
  33. NativeMethodNew na = new NativeMethodNew(this.ob);
  34. departm = UserInfo.GetDepartment();
  35. //plineCode = na.GetPCode(departm);//获取 用户 对应的产线
  36. plineCode = na.GetPCodePline(this.ValidDataPurviewIds);
  37. /* try
  38. {
  39. //20250828 获取本地打印机
  40. // 清空ComboBox现有项
  41. comboBox1.Items.Clear();
  42. // 获取所有已安装的打印机
  43. foreach (string printer in PrinterSettings.InstalledPrinters)
  44. {
  45. comboBox1.Items.Add(printer);
  46. }
  47. // 如果有打印机,选择第一项
  48. if (comboBox1.Items.Count > 0)
  49. {
  50. comboBox1.SelectedIndex = 0;
  51. }
  52. }
  53. catch (Exception ex)
  54. {
  55. MessageBox.Show($"加载打印机列表时出错: {ex.Message}");
  56. }*/
  57. }
  58. /// <summary>
  59. /// 重写基类方法
  60. /// </summary>
  61. /// <param name="sender"></param>
  62. /// <param name="ToolbarKey"></param>
  63. public override void ToolBar_Click(object sender, string ToolbarKey)
  64. {
  65. switch (ToolbarKey)
  66. {
  67. case "Query":
  68. doQuery();
  69. break;
  70. case "Close":
  71. this.Close();
  72. break;
  73. case "Excel":
  74. doExcel();
  75. break;
  76. }
  77. }
  78. private void chkDate_CheckedChanged(object sender, EventArgs e)
  79. {
  80. if (chkScph.Checked) { txtLotNo.Enabled = true; } else { txtLotNo.Enabled = false; }
  81. if (chkLh.Checked) { txtJutNo.Enabled = true; } else { txtJutNo.Enabled = false; }
  82. }
  83. private void doQuery()
  84. {
  85. ArrayList list = new ArrayList();
  86. string strLotNo = "";
  87. string strJuNo = "";
  88. if (chkScph.Checked)
  89. {
  90. if (txtLotNo.Text.Trim() == "")
  91. {
  92. MessageUtil.ShowTips("请输入生产批号!");
  93. return;
  94. }
  95. else
  96. {
  97. strLotNo = txtLotNo.Text.ToString();
  98. }
  99. }
  100. if (chkLh.Checked)
  101. {
  102. if (txtJutNo.Text.Trim() == "")
  103. {
  104. MessageUtil.ShowTips("请输入炉号!");
  105. return;
  106. }
  107. else
  108. {
  109. strJuNo = txtJutNo.Text.ToString();
  110. }
  111. }
  112. System.Data.DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.report.FrmProcessFlowCard.queryMinResult", new Object[] { strLotNo, strJuNo, plineCode }, this.ob);
  113. GridHelper.CopyDataToDatatable(dt, this.dataTable1, true);
  114. }
  115. private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
  116. {
  117. e.Row.Cells["CARD"].Value = "打印";
  118. }
  119. private void ultraGrid1_ClickCellButton(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  120. {
  121. UltraGridRow row = ultraGrid1.ActiveRow;
  122. if (row == null) return;
  123. string plineNo = row.Cells["PLINE_CODE"].Value.ToString();//产线
  124. string plineName = row.Cells["PLINE_NAME"].Value.ToString();//产线
  125. string juNo = row.Cells["JUDGE_STOVE_NO"].Value.ToString();
  126. string url = "";
  127. //if (plineNo == "C009" || plineNo == "C017")
  128. //{
  129. // url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilMobileCardSon.cpt&__bypagesize__=false&JudgeStoveNo=" + juNo + "";
  130. //}
  131. //else if (plineNo == "C008" || plineNo == "C010")
  132. //{
  133. // MessageUtil.ShowTips(plineName+"暂无模板!"); return;
  134. //}
  135. //else
  136. //{
  137. // MessageUtil.ShowTips("无产线!"); return;
  138. //}
  139. if (plineNo.Equals("C072"))
  140. {
  141. url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilMobileCardSon.cpt&op=view&JudgeStoveNo=" + juNo + "";
  142. }
  143. else
  144. {
  145. url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilMobileCardSon.cpt&op=view&JudgeStoveNo=" + juNo + "";
  146. }
  147. FrmRepExcel fre = new FrmRepExcel(this.ob, url);
  148. //fre.AutoSize = true;
  149. fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  150. fre.Text = "工艺流动卡";
  151. fre.ShowDialog();
  152. }
  153. private void card_pathT_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  154. {
  155. if (ultraGrid1.ActiveRow == null) return;
  156. UltraGridRow row = ultraGrid1.ActiveRow;
  157. if (e.Button.Key.Equals("CK"))
  158. {
  159. FormFileDown down = new FormFileDown(this.ob, row.Cells["CARD_PATH"].Text);
  160. down.ShowDialog();
  161. }
  162. else
  163. {
  164. string filePath = "MESServer/" + "CARD" + "/" + row.Cells["PLINE_CODE"].Text + "/" + row.Cells["JUDGE_STOVE_NO"].Text + "/";
  165. FormFileDown down = new FormFileDown(this.ob, filePath);
  166. down.CtrlFileDown1.FilePath = filePath;
  167. List<FileBean> list = new List<FileBean>();
  168. FileBean bean = new FileBean();
  169. OpenFileDialog file = new OpenFileDialog();
  170. file.Multiselect = true;
  171. DialogResult drStat;
  172. drStat = file.ShowDialog();
  173. if (drStat == DialogResult.OK)
  174. {
  175. foreach (string fileName in file.FileNames)
  176. {
  177. bean = new FileBean();
  178. string filena = System.IO.Path.GetFileName(fileName);
  179. bean.setFileName(filena);
  180. bean.setPathName(filePath);
  181. bean.setFile(FileHelper.FileToArray(fileName));
  182. list.Add(bean);
  183. }
  184. bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
  185. if (isSuccess)
  186. {
  187. Thread.Sleep(100); //等待一下下
  188. DoUpdateFilePath(filePath, true);
  189. }
  190. else
  191. {
  192. MessageBox.Show("上传失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
  193. }
  194. }
  195. }
  196. }
  197. private void DoUpdateFilePath(string filePath, bool showTips)
  198. {
  199. var ccp = new CoreClientParam
  200. {
  201. ServerName = "com.steering.mes.zgmil.report.FrmProcessFlowCard",
  202. MethodName = "DoUpdateFilePath",
  203. ServerParams = new object[]
  204. {
  205. ultraGrid1.ActiveRow.Cells["JUDGE_STOVE_NO"].Text,
  206. filePath
  207. }
  208. };
  209. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  210. if (ccp.ReturnCode != -1 && showTips)
  211. {
  212. MessageUtil.ShowTips(ccp.ReturnInfo);
  213. if (ccp.ReturnInfo.Contains("成功!"))
  214. doQuery();
  215. }
  216. else if (!showTips)
  217. {
  218. doQuery();
  219. }
  220. }
  221. //批量打印
  222. private void button1_Click(object sender, EventArgs e)
  223. {
  224. try
  225. {
  226. foreach (UltraGridRow row in ultraGrid1.Rows)
  227. {
  228. if (Convert.ToBoolean(row.Cells["CHC"].Text) == true)
  229. {
  230. string plineNo = row.Cells["PLINE_CODE"].Value.ToString();//产线
  231. string plineName = row.Cells["PLINE_NAME"].Value.ToString();//产线
  232. string juNo = row.Cells["JUDGE_STOVE_NO"].Value.ToString();
  233. string url = "";
  234. if (plineNo.Equals("C072"))
  235. {
  236. url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilMobileCardSon.cpt&op=view&JudgeStoveNo=" + juNo + "";
  237. }
  238. else
  239. {
  240. url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilMobileCardSon.cpt&op=view&JudgeStoveNo=" + juNo + "";
  241. }
  242. FrmRepExcel fre = new FrmRepExcel(this.ob, url);
  243. fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  244. fre.Text = "工艺流动卡";
  245. fre.ShowDialog();
  246. }
  247. }
  248. }
  249. catch (Exception ex)
  250. {
  251. MessageBox.Show($"打印时出错: {ex.Message}");
  252. }
  253. }
  254. private void doExcel()
  255. {
  256. }
  257. }
  258. }