QCM0108.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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 QCM0108 : FrmBase
  17. {
  18. public QCM0108()
  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 "Del":
  33. this.Del();
  34. break;
  35. }
  36. }
  37. private void DoQuery()
  38. {
  39. //查询
  40. try
  41. {
  42. this.dataSet1.Clear();
  43. Hashtable ht = new Hashtable();
  44. ht.Add("USERNAME", this.UserInfo.GetUserName());
  45. CoreClientParam ccp = new CoreClientParam();
  46. ccp.ServerName = "QCM.JHY01.JHY0102.QuerryJhyQtly";
  47. ccp.MethodName = "getLWGSTEEL";
  48. ccp.ServerParams = new object[] { ht };
  49. ccp.SourceDataTable = this.dataSet1.Tables[0];
  50. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  51. }
  52. catch (Exception ex)
  53. {
  54. System.Diagnostics.Debug.WriteLine(ex.ToString());
  55. }
  56. }
  57. public void doSteel()
  58. {
  59. this.dataSet2.Clear();
  60. Hashtable ht = new Hashtable();
  61. ht.Add("USERNAME", this.UserInfo.GetUserName());
  62. CoreClientParam ccp = new CoreClientParam();
  63. ccp.ServerName = "QCM.JHY01.JHY0102.QuerryJhyQtly";//调用java地址
  64. ccp.MethodName = "getBZSTEEL";//调用的方法
  65. ccp.ServerParams = new object[] { ht };
  66. ccp.SourceDataTable = this.dataSet2.Tables[0];
  67. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  68. DataTable dt = new DataTable();
  69. dt.Columns.Add("STEEL_CODE");
  70. dt.Columns.Add("STEEL_NAME");
  71. for (int i = 0; i < ccp.SourceDataTable.Rows.Count; i++)
  72. {
  73. DataRow dr = dt.NewRow();
  74. dr[0] = ccp.SourceDataTable.Rows[i]["STEEL_CODE"].ToString();
  75. dr[1] = ccp.SourceDataTable.Rows[i]["STEEL_NAME"].ToString();
  76. dt.Rows.Add(dr);
  77. }
  78. this.comboBox1.DataSource = dt;
  79. this.comboBox1.DisplayMember = "STEEL_CODE";
  80. this.comboBox1.ValueMember = "STEEL_NAME";
  81. }
  82. private void Add()
  83. {
  84. try
  85. {
  86. string steel = this.comboBox1.Text.Trim().ToString();
  87. if (String.IsNullOrEmpty(steel))
  88. {
  89. this.alert("请输入新增的牌号!!!");
  90. return;
  91. }
  92. Hashtable ht = new Hashtable();
  93. ht.Add("USERID", this.UserInfo.GetUserID());
  94. ht.Add("USERNAME", this.UserInfo.GetUserName());
  95. ht.Add("STEEL", steel);
  96. CoreClientParam ccp = new CoreClientParam();
  97. ccp.ServerName = "QCM.JHY01.JHY0102.UpdateInfo";
  98. ccp.MethodName = "AddLWGSTEEL";
  99. ccp.ServerParams = new object[] { ht };
  100. this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  101. if (ccp.ReturnCode != -1)
  102. {
  103. MessageBox.Show("新增成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.None);
  104. }
  105. this.DoQuery();
  106. }
  107. catch (Exception ex)
  108. {
  109. System.Diagnostics.Debug.WriteLine(ex.ToString());
  110. }
  111. }
  112. private void Del()
  113. {
  114. try
  115. {
  116. UltraGridRow row = this.ultraGrid1.ActiveRow;
  117. if (row == null)
  118. {
  119. this.alert("没有牌号可删除!");
  120. return;
  121. }
  122. Hashtable ht = new Hashtable();
  123. ht.Add("USERID", this.UserInfo.GetUserID());
  124. ht.Add("USERNAME", this.UserInfo.GetUserName());
  125. ht.Add("STEEL", row.Cells["STEEL_NAME"].Value.ToString());
  126. CoreClientParam ccp = new CoreClientParam();
  127. ccp.ServerName = "QCM.JHY01.JHY0102.UpdateInfo";
  128. ccp.MethodName = "delLWGSTEEL";
  129. ccp.ServerParams = new object[] { ht, };
  130. this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  131. if (ccp.ReturnCode != -1)
  132. {
  133. MessageBox.Show("删除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.None);
  134. }
  135. this.DoQuery();
  136. }
  137. catch (Exception ex)
  138. {
  139. System.Diagnostics.Debug.WriteLine(ex.ToString());
  140. }
  141. }
  142. private void QCM0108_Load(object sender, EventArgs e)
  143. {
  144. this.comboBox3.Text = "螺纹钢";
  145. ValueList v1 = new ValueList();
  146. v1.ValueListItems.Add("1", "有效");
  147. v1.ValueListItems.Add("0", "无效");
  148. this.ultraGrid1.DisplayLayout.Bands[0].Columns["YN_LOG"].ValueList = v1.Clone();
  149. }
  150. private void button1_Click(object sender, EventArgs e)
  151. {
  152. try
  153. {
  154. OpenFileDialog Ofd = new OpenFileDialog();
  155. Ofd.Title = "选择文件";
  156. //Ofd.Filter = "文件 (*.doc;*;docx;*.xls;*.xlsx;*.et;*.png;*.xml;*.jpg)|*.doc;*;docx;*.xls;*.xlsx;*.et;*.png;*.xml;*.jpg";
  157. Ofd.Filter = "文件 (*.xls;*.xlsx)|*.xls;*.xlsx";
  158. //Ofd.Filter = "文件 (*.*)|*.*";
  159. if (Ofd.ShowDialog() == DialogResult.OK)
  160. {
  161. this.textBox2.Text = Ofd.FileName.ToString();//选取文件路径
  162. }
  163. if (MessageBox.Show("确定上传?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
  164. return;
  165. FileStream read = new FileStream(this.textBox2.Text.Trim(), FileMode.Open, FileAccess.Read);
  166. byte[] byData = new byte[read.Length];
  167. read.Read(byData, 0, (int)read.Length);
  168. read.Close();
  169. if (byData == null) { MessageBox.Show("请先选择需要上传的文件!", "提示"); return; }
  170. //获取文件扩展名
  171. string[] str = this.textBox2.Text.Trim().Split('.');
  172. string extName = "." + str[str.Length - 1];
  173. CoreClientParam ccp = new CoreClientParam();
  174. //ccp.ServerName = "QCM.QCM01.QCM0106.ImportExcelUtil";
  175. ccp.ServerName = "QCM.QCM01.QCM0108.ImportEasyExcelUtil";
  176. ccp.MethodName = "dateImport";
  177. ccp.ServerParams = new object[] { byData, this.textBox2.Text.Trim(),this.UserInfo.GetUserName() };
  178. this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  179. if(ccp.ReturnCode == 1){
  180. MessageBox.Show("导入成功", "提示");
  181. }
  182. this.textBox2.Text = "";
  183. //this.DoQuery();
  184. }
  185. catch (Exception ex)
  186. {
  187. System.Diagnostics.Debug.WriteLine(ex.ToString());
  188. MessageBox.Show("上传失败,请选择正确的文件路径", "提示");
  189. }
  190. }
  191. private void button2_Click(object sender, EventArgs e)
  192. {
  193. this.doSteel();
  194. }
  195. }
  196. }