QCM0107.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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 Infragistics.Win.UltraWinGrid;
  11. using System.Collections;
  12. using Infragistics.Win;
  13. using System.IO;
  14. namespace Core.LZMes.Client.QCM
  15. {
  16. public partial class QCM0107 : FrmBase
  17. {
  18. public QCM0107()
  19. {
  20. InitializeComponent();
  21. }
  22. public override void ToolBar_Click(object sender, string ToolbarKey)
  23. {
  24. switch (ToolbarKey)
  25. {
  26. case "Query":
  27. this.DoQuery();
  28. break;
  29. case "Add":
  30. this.Add();
  31. break;
  32. case "Edit":
  33. this.Edit();
  34. break;
  35. }
  36. }
  37. private void DoQuery()
  38. {
  39. //查询
  40. try
  41. {
  42. this.dataSet1.Clear();
  43. string prod_line = "";
  44. if (this.comboBox3.Text.ToString() == "卷板")
  45. {
  46. prod_line = "JB1";
  47. }
  48. else if (this.comboBox3.Text.ToString() == "中厚板")
  49. {
  50. prod_line = "ZHB";
  51. }
  52. else if (this.comboBox3.Text.ToString() == "线棒")
  53. {
  54. prod_line = "XB1";
  55. }
  56. else if (this.comboBox3.Text.ToString() == "炼钢")
  57. {
  58. prod_line = "LG";
  59. }
  60. CoreClientParam ccp = new CoreClientParam();
  61. ccp.ServerName = "QCM.QCM01.QCM0106.QueryDefect";
  62. ccp.MethodName = "QueryMemo";
  63. ccp.ServerParams = new object[] { prod_line };
  64. ccp.SourceDataTable = this.dataSet1.Tables[0];
  65. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  66. }
  67. catch (Exception ex)
  68. {
  69. System.Diagnostics.Debug.WriteLine(ex.ToString());
  70. }
  71. }
  72. private void Add()
  73. {
  74. try
  75. {
  76. string prod_line = "";
  77. if (this.comboBox1.Text.ToString() == "卷板")
  78. {
  79. prod_line = "JB1";
  80. }
  81. else if (this.comboBox1.Text.ToString() == "中厚板")
  82. {
  83. prod_line = "ZHB";
  84. }
  85. else if (this.comboBox1.Text.ToString() == "线棒")
  86. {
  87. prod_line = "XB1";
  88. }
  89. else if (this.comboBox1.Text.ToString() == "炼钢")
  90. {
  91. prod_line = "LG";
  92. }
  93. CoreClientParam ccp = new CoreClientParam();
  94. ccp.ServerName = "QCM.QCM01.QCM0106.QueryDefect";
  95. ccp.MethodName = "AddMemo";
  96. ccp.ServerParams = new object[] { prod_line, this.textBox3.Text.ToString(),this.UserInfo.GetUserName().ToString(),
  97. this.textBox1.Text.ToString()};
  98. //ccp.SourceDataTable = this.dataSet1.Tables[0];
  99. this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  100. if (ccp.ReturnCode == 1)
  101. {
  102. MessageBox.Show("处理备注添加成功", "提示");
  103. }
  104. this.DoQuery();
  105. }
  106. catch (Exception ex)
  107. {
  108. System.Diagnostics.Debug.WriteLine(ex.ToString());
  109. }
  110. }
  111. private void Edit()
  112. {
  113. try
  114. {
  115. string prod_line = "";
  116. if (this.comboBox1.Text.ToString() == "卷板")
  117. {
  118. prod_line = "JB1";
  119. }
  120. else if (this.comboBox1.Text.ToString() == "中厚板")
  121. {
  122. prod_line = "ZHB";
  123. }
  124. else if (this.comboBox1.Text.ToString() == "线棒")
  125. {
  126. prod_line = "XB1";
  127. }
  128. else if (this.comboBox1.Text.ToString() == "炼钢")
  129. {
  130. prod_line = "LG";
  131. }
  132. CoreClientParam ccp = new CoreClientParam();
  133. ccp.ServerName = "QCM.QCM01.QCM0106.QueryDefect";
  134. ccp.MethodName = "EMemo";
  135. ccp.ServerParams = new object[] { prod_line, this.textBox3.Text.ToString(),this.UserInfo.GetUserName().ToString(),
  136. this.textBox1.Text.ToString()};
  137. //ccp.SourceDataTable = this.dataSet1.Tables[0];
  138. this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  139. if (ccp.ReturnCode == 1)
  140. {
  141. MessageBox.Show("处理备注修改成功", "提示");
  142. }
  143. this.DoQuery();
  144. }
  145. catch (Exception ex)
  146. {
  147. System.Diagnostics.Debug.WriteLine(ex.ToString());
  148. }
  149. }
  150. /*public string memo = "";
  151. private void button1_Click(object sender, EventArgs e)
  152. {
  153. foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
  154. {
  155. if (ugr.Cells["CHK"].Text.ToLower() == "true")
  156. {
  157. if (memo == "")
  158. {
  159. memo = ugr.Cells["MEMO"].Value.ToString();
  160. }
  161. else if (memo != "")
  162. {
  163. memo +=";"+ ugr.Cells["MEMO"].Value.ToString();
  164. }
  165. }
  166. }
  167. this.DialogResult = DialogResult.OK;
  168. }
  169. private void button2_Click(object sender, EventArgs e)
  170. {
  171. this.Close();
  172. }
  173. private void button3_Click(object sender, EventArgs e)
  174. {
  175. this.DoQuery();
  176. }
  177. private void button4_Click(object sender, EventArgs e)
  178. {
  179. this.Add();
  180. }*/
  181. private void QCM0107_Load(object sender, EventArgs e)
  182. {
  183. this.comboBox3.Text = "卷板";
  184. this.comboBox1.Text = "卷板";
  185. }
  186. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  187. {
  188. this.comboBox1.Text = this.ultraGrid1.ActiveRow.Cells["PLINE_CODE"].Text.ToString();
  189. this.textBox1.Text = this.ultraGrid1.ActiveRow.Cells["MEMO_CODE"].Text.ToString();
  190. this.textBox3.Text = this.ultraGrid1.ActiveRow.Cells["MEMO"].Text.ToString();
  191. }
  192. private void button1_Click(object sender, EventArgs e)
  193. {
  194. try
  195. {
  196. OpenFileDialog Ofd = new OpenFileDialog();
  197. Ofd.Title = "选择文件";
  198. //Ofd.Filter = "文件 (*.doc;*;docx;*.xls;*.xlsx;*.et;*.png;*.xml;*.jpg)|*.doc;*;docx;*.xls;*.xlsx;*.et;*.png;*.xml;*.jpg";
  199. Ofd.Filter = "文件 (*.xls;*.xlsx)|*.xls;*.xlsx";
  200. //Ofd.Filter = "文件 (*.*)|*.*";
  201. if (Ofd.ShowDialog() == DialogResult.OK)
  202. {
  203. this.textBox2.Text = Ofd.FileName.ToString();//选取文件路径
  204. }
  205. if (MessageBox.Show("确定上传?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
  206. return;
  207. FileStream read = new FileStream(this.textBox2.Text.Trim(), FileMode.Open, FileAccess.Read);
  208. byte[] byData = new byte[read.Length];
  209. read.Read(byData, 0, (int)read.Length);
  210. read.Close();
  211. if (byData == null) { MessageBox.Show("请先选择需要上传的文件!", "提示"); return; }
  212. //获取文件扩展名
  213. string[] str = this.textBox2.Text.Trim().Split('.');
  214. string extName = "." + str[str.Length - 1];
  215. CoreClientParam ccp = new CoreClientParam();
  216. //ccp.ServerName = "QCM.QCM01.QCM0106.ImportExcelUtil";
  217. ccp.ServerName = "QCM.QCM01.QCM0107.ImportEasyExcelUtil";
  218. ccp.MethodName = "dateImport";
  219. ccp.ServerParams = new object[] { byData, this.textBox2.Text.Trim(),this.UserInfo.GetUserName() };
  220. this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  221. if(ccp.ReturnCode == 1){
  222. MessageBox.Show("导入成功", "提示");
  223. }
  224. this.textBox2.Text = "";
  225. //this.DoQuery();
  226. }
  227. catch (Exception ex)
  228. {
  229. System.Diagnostics.Debug.WriteLine(ex.ToString());
  230. MessageBox.Show("上传失败,请选择正确的文件路径", "提示");
  231. }
  232. }
  233. }
  234. }