UIM010050.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  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 System.Collections;
  10. using CoreFS.CA06;
  11. using System.IO;
  12. namespace Core.LZMes.Client.UIM
  13. {
  14. public partial class UIM010050 : FrmBase
  15. {
  16. //钢卷号
  17. private string COIL_NO = "";
  18. public UIM010050()
  19. {
  20. InitializeComponent();
  21. }
  22. private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
  23. {
  24. }
  25. public override void ToolBar_Click(object sender, string ToolbarKey)
  26. {
  27. switch (ToolbarKey)
  28. {
  29. case "Query":
  30. this.DoQuery();
  31. break;
  32. case "Save":
  33. this.DoSave();
  34. break;
  35. }
  36. }
  37. /// <summary>
  38. /// 查询钢卷在系统中的位置
  39. /// </summary>
  40. private void DoQuery()
  41. {
  42. try
  43. {
  44. this.dataSet1.Tables[0].Clear();
  45. string coilNo = this.textBox1.Text.Trim();
  46. //外购卷入库可以直接调用热送入库查询钢卷信息
  47. CoreClientParam ccp = new CoreClientParam();
  48. ccp.ServerName = "UIM.UIM010040";
  49. ccp.MethodName = "queryCoilStatus";
  50. ccp.ServerParams = new object[] { coilNo };
  51. ccp.SourceDataTable = this.dataSet1.Tables[0];
  52. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  53. COIL_NO = coilNo;
  54. }
  55. catch (Exception EX)
  56. {
  57. MessageBox.Show(EX.ToString());
  58. }
  59. }
  60. /// <summary>
  61. /// 原料库外购卷入库
  62. /// </summary>
  63. private void DoSave()
  64. {
  65. if (textBox1.Text.Trim().Equals(""))
  66. {
  67. MessageBox.Show("钢卷号不能为空,请输入钢卷号!");
  68. textBox1.Focus();
  69. return;
  70. }
  71. if (this.ultraComboEditor3.SelectedIndex < 0)
  72. {
  73. MessageBox.Show("标准号不能为空,请选择标准号!");
  74. this.ultraComboEditor3.Focus();
  75. return;
  76. }
  77. if (this.ultraComboEditor4.SelectedIndex < 0)
  78. {
  79. MessageBox.Show("标准牍号不能为空,请选择标准牌号!");
  80. this.ultraComboEditor4.Focus();
  81. return;
  82. }
  83. if (this.ultraComboEditor5.SelectedIndex < 0)
  84. {
  85. MessageBox.Show("订单用途不能为空,请选择订单用途!");
  86. this.ultraComboEditor5.Focus();
  87. return;
  88. }
  89. if (this.ultraComboEditor1.SelectedIndex < 0)
  90. {
  91. MessageBox.Show("交货状态不能为空,请选择交货状态!");
  92. this.ultraComboEditor1.Focus();
  93. return;
  94. }
  95. if (this.textBox11.Text.Trim().Equals(""))
  96. {
  97. MessageBox.Show("厚度不能为空,请输入厚度!");
  98. this.textBox11.Focus();
  99. return;
  100. }
  101. if (this.textBox9.Text.Trim().Equals(""))
  102. {
  103. MessageBox.Show("宽度不能为空,请输入宽度!");
  104. this.textBox9.Focus();
  105. return;
  106. }
  107. if (this.textBox13.Text.Trim().Equals(""))
  108. {
  109. MessageBox.Show("长度不能为空,请输入长度!");
  110. this.textBox13.Focus();
  111. return;
  112. }
  113. if (this.textBox12.Text.Trim().Equals(""))
  114. {
  115. MessageBox.Show("重量不能为空,请输入重量!");
  116. this.textBox12.Focus();
  117. return;
  118. }
  119. if (this.textBox14.Text.Trim().Equals(""))
  120. {
  121. MessageBox.Show("外径不能为空,请输入外径!");
  122. this.textBox14.Focus();
  123. return;
  124. }
  125. if (this.textBox15.Text.Trim().Equals(""))
  126. {
  127. MessageBox.Show("内径不能为空,请输入内径!");
  128. this.textBox15.Focus();
  129. return;
  130. }
  131. if (this.textBox4.Text.Trim().Equals(""))
  132. {
  133. MessageBox.Show("炉号不能为空,请输入炉号!");
  134. this.textBox4.Focus();
  135. return;
  136. }
  137. string coilNo = textBox1.Text.Trim();
  138. CoreClientParam ccp = new CoreClientParam();
  139. ccp.ServerName = "UIM.UIM010050";
  140. ccp.MethodName = "queryColdCoilNo";
  141. ccp.ServerParams = new object[] { coilNo };
  142. ccp = this.ExecuteQuery(ccp, CoreInvokeType.Internal);
  143. if (ccp.ReturnObject != null)
  144. {
  145. int haveCoil = int.Parse(ccp.ReturnObject.ToString());
  146. if (haveCoil > 0)
  147. {
  148. MessageBox.Show("钢卷号在系统中已经存在,请重新输入!");
  149. textBox1.Focus();
  150. return;
  151. }
  152. }
  153. UIM010051 dlg = new UIM010051(this, 1);
  154. if (DialogResult.OK == dlg.ShowDialog(this))
  155. {
  156. string yardAddr = dlg.YARD_ADDR;//垛位
  157. string entryShift = this.UserInfo.GetUserGroup();//入库班次
  158. string entryGroup = this.UserInfo.GetUserOrder();//入库班组
  159. string entryDtime = this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMddHHmmss");//入库时间
  160. string reg_id = this.UserInfo.GetUserID();//操作人
  161. //入库操作信息
  162. string[] entryInfo = new string[] { yardAddr, entryShift, entryGroup, entryDtime, reg_id };
  163. string specAbbssym = ultraComboEditor3.Value.ToString();
  164. string specStlGrd = ultraComboEditor4.Value.ToString();
  165. string ordUseTp = ultraComboEditor5.Value.ToString();
  166. string prodNm = ultraComboEditor1.Value.ToString();
  167. double thk = double.Parse(textBox11.Text.Trim());
  168. double wth = double.Parse(textBox9.Text.Trim());
  169. double len = double.Parse(textBox12.Text.Trim());
  170. double wgt = double.Parse(textBox13.Text.Trim());
  171. double outida = double.Parse(textBox14.Text.Trim());
  172. double india = double.Parse(textBox15.Text.Trim());
  173. string chargeNo = textBox4.Text.Trim();
  174. //牌号 规格 炉号备注等信息
  175. string[] coilInfo = new string[] { specAbbssym, specStlGrd, ordUseTp, prodNm
  176. , thk.ToString(), wth.ToString(), len.ToString(), wgt.ToString(), outida.ToString(), india.ToString()
  177. , chargeNo};
  178. ArrayList qltyList = new ArrayList();//材质信息
  179. int qltySize = dataSet1.Tables[0].Rows.Count;
  180. for (int i = 0; i < qltySize; i++)
  181. {
  182. Infragistics.Win.UltraWinGrid.UltraGridRow uRow = ultraGrid1.Rows[i];
  183. if (null != uRow.Cells["QLTY_VALUE1"].Text && !uRow.Cells["QLTY_VALUE1"].Text.Trim().Equals(""))
  184. {
  185. string[] param = new string[5];
  186. param[0] = uRow.Cells["QLTY_CD_CFNM"].Text;
  187. param[1] = uRow.Cells["QLTY_VALUE1"].Text.Trim();
  188. param[2] = uRow.Cells["QLTY_VALUE2"].Text.Trim();
  189. param[3] = uRow.Cells["QLTY_VALUE3"].Text.Trim();
  190. param[4] = uRow.Cells["QLTY_VALUE4"].Text.Trim();
  191. qltyList.Add(param);
  192. }
  193. }
  194. ArrayList chemList = new ArrayList();//材质信息
  195. int chemSize = dataSet2.Tables[0].Rows.Count;
  196. for (int i = 0; i < chemSize; i++)
  197. {
  198. Infragistics.Win.UltraWinGrid.UltraGridRow uRow = ultraGrid2.Rows[i];
  199. if (null != uRow.Cells["CHEM_DIS_VALUE"].Text && !uRow.Cells["CHEM_DIS_VALUE"].Text.Trim().Equals(""))
  200. {
  201. string[] param = new string[3];
  202. param[0] = uRow.Cells["CHEM_CD"].Text;
  203. param[1] = uRow.Cells["CHEM_DIS_VALUE"].Text.Trim();
  204. param[2] = uRow.Cells["REMARK"].Text.Trim();
  205. chemList.Add(param);
  206. }
  207. }
  208. CoreClientParam ccp1 = new CoreClientParam();
  209. ccp1.ServerName = "UIM.UIM010050";
  210. ccp1.MethodName = "saveCoilYard";
  211. ccp1.ServerParams = new object[] { coilNo, entryInfo, coilInfo, qltyList, chemList };
  212. ccp1 = this.ExecuteNonQuery(ccp1, CoreInvokeType.Internal);
  213. }
  214. }
  215. private void UIM010050_Load(object sender, EventArgs e)
  216. {
  217. int size = 0;
  218. //标准号
  219. ArrayList specAbbsymList = this.queryCommFun("UIM.UIM010050", "querySpecAbbsymList");
  220. size = specAbbsymList.Count;
  221. Infragistics.Win.ValueListItem[] valueListItems1 = new Infragistics.Win.ValueListItem[size];
  222. for (int i = 0; i < size; i++)
  223. {
  224. Infragistics.Win.ValueListItem item = new Infragistics.Win.ValueListItem();
  225. Hashtable ht = (Hashtable)specAbbsymList[i];
  226. item.DataValue = ht["SPEC_ABBSYM"].ToString();
  227. item.DisplayText = ht["SPEC_ABBSYM"].ToString(); ;
  228. valueListItems1[i] = item;
  229. }
  230. this.ultraComboEditor3.Items.AddRange(valueListItems1);
  231. //标准牌号
  232. ArrayList specStlGrdList = this.queryCommFun("UIM.UIM010050", "querySpecStlGrdList");
  233. size = specStlGrdList.Count;
  234. Infragistics.Win.ValueListItem[] valueListItems2 = new Infragistics.Win.ValueListItem[size];
  235. for (int i = 0; i < size; i++)
  236. {
  237. Infragistics.Win.ValueListItem item = new Infragistics.Win.ValueListItem();
  238. Hashtable ht = (Hashtable)specStlGrdList[i];
  239. item.DataValue = ht["SPEC_STL_GRD"].ToString();
  240. item.DisplayText = ht["SPEC_STL_GRD"].ToString(); ;
  241. valueListItems2[i] = item;
  242. }
  243. this.ultraComboEditor4.Items.AddRange(valueListItems2);
  244. //订单用途
  245. ArrayList ordUseTyList = this.queryCommFun("UIM.UIM010050", "queryOrdUseTyList");
  246. size = ordUseTyList.Count;
  247. Infragistics.Win.ValueListItem[] valueListItems3 = new Infragistics.Win.ValueListItem[size];
  248. for (int i = 0; i < size; i++)
  249. {
  250. Infragistics.Win.ValueListItem item = new Infragistics.Win.ValueListItem();
  251. Hashtable ht = (Hashtable)ordUseTyList[i];
  252. item.DataValue = ht["SM_CD"].ToString();
  253. item.DisplayText = ht["SM_CFNM"].ToString(); ;
  254. valueListItems3[i] = item;
  255. }
  256. this.ultraComboEditor5.Items.AddRange(valueListItems3);
  257. //交货状态
  258. ArrayList prodNmList = this.queryCommFun("UIM.UIM010050", "queryProdNmList");
  259. size = prodNmList.Count;
  260. Infragistics.Win.ValueListItem[] valueListItems4 = new Infragistics.Win.ValueListItem[size];
  261. for (int i = 0; i < size; i++)
  262. {
  263. Infragistics.Win.ValueListItem item = new Infragistics.Win.ValueListItem();
  264. Hashtable ht = (Hashtable)prodNmList[i];
  265. item.DataValue = ht["PRDNM_CD"].ToString();
  266. item.DisplayText = ht["PRDNM_CD"].ToString(); ;
  267. valueListItems4[i] = item;
  268. }
  269. this.ultraComboEditor1.Items.AddRange(valueListItems4);
  270. //成份信息
  271. this.dataSet2.Tables[0].Clear();
  272. CoreClientParam ccp = new CoreClientParam();
  273. ccp.ServerName = "UIM.UIM010050";
  274. ccp.MethodName = "queryChemList";
  275. ccp.SourceDataTable = this.dataSet2.Tables[0];
  276. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  277. }
  278. private ArrayList queryCommFun(string serverName, string methodName)
  279. {
  280. CoreClientParam ccp = new CoreClientParam();
  281. ccp.ServerName = serverName;
  282. ccp.MethodName = methodName;
  283. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  284. ArrayList list = (ArrayList)ccp.ReturnObject;
  285. return list;
  286. }
  287. private void label2_Click(object sender, EventArgs e)
  288. {
  289. if (this.ultraComboEditor3.SelectedIndex < 0)
  290. {
  291. MessageBox.Show("标准号不能为空,请选择标准号!");
  292. this.ultraComboEditor3.Focus();
  293. return;
  294. }
  295. if (this.ultraComboEditor4.SelectedIndex < 0)
  296. {
  297. MessageBox.Show("标准牍号不能为空,请选择标准牌号!");
  298. this.ultraComboEditor4.Focus();
  299. return;
  300. }
  301. if (this.ultraComboEditor5.SelectedIndex < 0)
  302. {
  303. MessageBox.Show("订单用途不能为空,请选择订单用途!");
  304. this.ultraComboEditor5.Focus();
  305. return;
  306. }
  307. if (this.ultraComboEditor1.SelectedIndex < 0)
  308. {
  309. MessageBox.Show("交货状态不能为空,请选择交货状态!");
  310. this.ultraComboEditor1.Focus();
  311. return;
  312. }
  313. if (this.textBox11.Text.Trim().Equals(""))
  314. {
  315. MessageBox.Show("厚度不能为空,请输入厚度!");
  316. this.textBox11.Focus();
  317. return;
  318. }
  319. double thk = 0;
  320. try
  321. {
  322. thk = double.Parse(textBox11.Text.Trim());
  323. }
  324. catch (Exception ex)
  325. {
  326. MessageBox.Show("厚度输入错误,请重新输入厚度!");
  327. this.textBox11.Focus();
  328. return;
  329. }
  330. string prdNmCd = this.ultraComboEditor1.Value.ToString();
  331. string specAbbsym = this.ultraComboEditor3.Value.ToString();
  332. string specStlGrd = this.ultraComboEditor4.Value.ToString();
  333. string ordUseTp = this.ultraComboEditor5.Value.ToString();
  334. this.dataSet1.Tables[0].Clear();
  335. CoreClientParam ccp = new CoreClientParam();
  336. ccp.ServerName = "UIM.UIM010050";
  337. ccp.MethodName = "queryQltyList";
  338. ccp.ServerParams = new object[] { prdNmCd, specAbbsym, specStlGrd, ordUseTp, thk };
  339. ccp.SourceDataTable = this.dataSet1.Tables[0];
  340. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  341. }
  342. /// <summary>
  343. /// 查询区域中一行的垛位信息
  344. /// </summary>
  345. /// <param name="areayType"></param>
  346. /// <param name="areayNo"></param>
  347. /// <param name="yardCol"></param>
  348. internal void queryYardRows(int areaType, int areaNo, string yardCol)
  349. {
  350. this.dataSet4.Tables[0].Clear();
  351. CoreClientParam ccp = new CoreClientParam();
  352. ccp.ServerName = "UIM.UIM010070";
  353. ccp.MethodName = "queryYardRows";
  354. ccp.ServerParams = new object[] { areaType, areaNo, yardCol };
  355. ccp.SourceDataTable = this.dataSet4.Tables[0];
  356. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  357. }
  358. /// <summary>
  359. /// 查询区域中一行的垛位中钢卷信息
  360. /// </summary>
  361. /// <param name="areayType"></param>
  362. /// <param name="areayNo"></param>
  363. /// <param name="yardCol"></param>
  364. internal void queryYardRowCoils(int areaType, int areaNo, string yardCol)
  365. {
  366. this.dataSet3.Tables[0].Clear();
  367. CoreClientParam ccp = new CoreClientParam();
  368. ccp.ServerName = "UIM.UIM010070";
  369. ccp.MethodName = "queryYardRowCoils";
  370. ccp.ServerParams = new object[] { areaType, areaNo, yardCol };
  371. ccp.SourceDataTable = this.dataSet3.Tables[0];
  372. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  373. }
  374. internal int queryMinYardRow(int areaType, int areaNo, string yardCol)
  375. {
  376. int minRow = 1;
  377. CoreClientParam ccp = new CoreClientParam();
  378. ccp.ServerName = "UIM.UIM010070";
  379. ccp.MethodName = "queryMinYardRow";
  380. ccp.ServerParams = new object[] { areaType, areaNo, yardCol };
  381. ccp = this.ExecuteQuery(ccp, CoreInvokeType.Internal);
  382. if (ccp.ReturnObject != null)
  383. {
  384. minRow = int.Parse(ccp.ReturnObject.ToString());
  385. }
  386. return minRow;
  387. }
  388. /// <summary>
  389. /// 查询库存区域
  390. /// </summary>
  391. /// <param name="areaType"></param>
  392. /// <returns></returns>
  393. internal ArrayList queryYardAreas(int areaType)
  394. {
  395. CoreClientParam ccp = new CoreClientParam();
  396. ccp.ServerName = "UIM.UIM010040";
  397. ccp.MethodName = "queryYardAreas";
  398. ccp.ServerParams = new object[] { areaType };
  399. ccp = this.ExecuteQuery(ccp, CoreInvokeType.Internal);
  400. ArrayList retList = (ArrayList)ccp.ReturnObject;
  401. return retList;
  402. }
  403. /// <summary>
  404. /// 查询库存区分
  405. /// </summary>
  406. /// <param name="areaNo"></param>
  407. /// <returns></returns>
  408. internal ArrayList queryYardColsByArea(int areaNo)
  409. {
  410. CoreClientParam ccp = new CoreClientParam();
  411. ccp.ServerName = "UIM.UIM010040";
  412. ccp.MethodName = "queryYardColsByArea";
  413. ccp.ServerParams = new object[] { areaNo };
  414. ccp = this.ExecuteQuery(ccp, CoreInvokeType.Internal);
  415. ArrayList retList = (ArrayList)ccp.ReturnObject;
  416. return retList;
  417. }
  418. private void ultraGrid1_BeforeCellUpdate(object sender, Infragistics.Win.UltraWinGrid.BeforeCellUpdateEventArgs e)
  419. {
  420. Infragistics.Win.UltraWinGrid.UltraGrid grid = (Infragistics.Win.UltraWinGrid.UltraGrid)sender;
  421. string colKey = grid.ActiveCell.Column.Key;
  422. int index = grid.ActiveRow.Cells.IndexOf(colKey);
  423. if (index > 3 && (null == grid.ActiveRow.Cells[index - 1].Text || grid.ActiveRow.Cells[index - 1].Text.Trim().Equals("")))
  424. {
  425. MessageBox.Show("请按照实际值1、2、3、4的顺序输入材质信息!");
  426. return;
  427. }
  428. }
  429. private void button1_Click(object sender, EventArgs e)
  430. {
  431. try
  432. {
  433. OpenFileDialog Ofd = new OpenFileDialog();
  434. Ofd.Title = "选择文件";
  435. //Ofd.Filter = "文件 (*.doc;*;docx;*.xls;*.xlsx;*.et;*.png;*.xml;*.jpg)|*.doc;*;docx;*.xls;*.xlsx;*.et;*.png;*.xml;*.jpg";
  436. Ofd.Filter = "文件 (*.xls;*.xlsx)|*.xls;*.xlsx";
  437. //Ofd.Filter = "文件 (*.*)|*.*";
  438. if (Ofd.ShowDialog() == DialogResult.OK)
  439. {
  440. this.textBox2.Text = Ofd.FileName.ToString();//选取文件路径
  441. }
  442. if (MessageBox.Show("确定上传?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
  443. return;
  444. FileStream read = new FileStream(this.textBox2.Text.Trim(), FileMode.Open, FileAccess.Read);
  445. byte[] byData = new byte[read.Length];
  446. read.Read(byData, 0, (int)read.Length);
  447. read.Close();
  448. if (byData == null) { MessageBox.Show("请先选择需要上传的文件!", "提示"); return; }
  449. //获取文件扩展名
  450. string[] str = this.textBox2.Text.Trim().Split('.');
  451. string extName = "." + str[str.Length - 1];
  452. CoreClientParam ccp = new CoreClientParam();
  453. //ccp.ServerName = "QCM.QCM01.QCM0106.ImportExcelUtil";
  454. ccp.ServerName = "UIM.WGJ.ImportEasyExcelUtil";
  455. ccp.MethodName = "dateImport";
  456. ccp.ServerParams = new object[] { byData, this.textBox2.Text.Trim(),this.UserInfo.GetUserName() };
  457. this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  458. if(ccp.ReturnCode == 1){
  459. MessageBox.Show("导入成功", "提示");
  460. }
  461. this.textBox2.Text = "";
  462. //this.DoQuery();
  463. }
  464. catch (Exception ex)
  465. {
  466. System.Diagnostics.Debug.WriteLine(ex.ToString());
  467. MessageBox.Show("上传失败,请选择正确的文件路径", "提示");
  468. }
  469. }
  470. }
  471. }