FrmStuffMoveIn.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  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 Core.Mes.Client.Comm.Tool;
  10. using System.Collections;
  11. using Core.StlMes.Client.YdmStuffManage.Entity;
  12. using CoreFS.CA06;
  13. using Core.Mes.Client.Comm.Server;
  14. using Infragistics.Win.UltraWinGrid;
  15. using Infragistics.Win;
  16. using Core.Mes.Client.Comm.Format;
  17. using Core.Mes.Client.Comm.Control;
  18. using System.Threading;
  19. namespace Core.StlMes.Client.YdmStuffManage
  20. {
  21. public partial class FrmStuffMoveIn : FrmBase
  22. {
  23. private bool flag = false;
  24. public FrmStuffMoveIn()
  25. {
  26. InitializeComponent();
  27. try
  28. {
  29. string[] portnames = System.IO.Ports.SerialPort.GetPortNames(); //获取计算机串口数组
  30. if (portnames is Infragistics.Win.UltraWinGrid.Nullable || portnames.Length < 1)
  31. {
  32. portnames = new string[10] { "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "COM10" };
  33. }
  34. txtCom.DataSource = portnames;
  35. }
  36. catch (Exception eex3)
  37. {
  38. MessageBox.Show(eex3.Message);
  39. }
  40. }
  41. private TalentICTGXControl.TalentICTGXClass icClass;
  42. private string strInbound = "800703";//入库类型编码
  43. private string[] arr = null;
  44. private void FrmStuffMoveIn_Load(object sender, EventArgs e)
  45. {
  46. DateTime now = DateTime.Now;
  47. DateTime dt1 = new DateTime(now.Year, now.Month, 1);//当月第一天
  48. DateTime dt2 = dt1.AddMonths(1).AddDays(-1);//当月最后一天
  49. this.RegStartTime.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00");
  50. this.RegEndTime.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59");
  51. BaseMethod.InitCellPosition(ultraGrid1, new string[] { "ActWeight", "ActCount","Dimater", "ActLen", "FixNum", "FixLen" });
  52. BaseMethod.InitCellPosition(ultraGrid2, new string[] { "ActWeight", "ActCount","Dimater", "ActLen", "FixNum", "FixLen" });
  53. EntityHelper.ShowGridCaption<YdmGpInlistEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  54. EntityHelper.ShowGridCaption<YdmGpOutlistEntity1>(ultraGrid2.DisplayLayout.Bands[0]);
  55. EntityHelper.ShowGridCaption<YdmGpButtressEntity>(ultraGrid2.DisplayLayout.Bands[1]);
  56. arr = BaseMethod.WarehousePermissionsStore(this.ValidDataPurviewIds, this.ob);
  57. this.txtCom.SelectedIndex = 0;
  58. cmbLayNo.SelectedIndex = 0;
  59. initStorageNo();
  60. flag = true;
  61. }
  62. /// <summary>
  63. /// 加载仓库号
  64. /// </summary>
  65. private void initStorageNo()
  66. {
  67. BaseMethod.InitComboEditorWithParmArr(cmbStorageNo, "Core.LgMes.Server.Stuffmanage.FrmBaseInformation.doQueryStorageArr", "STORAGE_NO", this.ob, false, new object[]{arr});
  68. cmbStorageNo.SelectedIndex = 0;
  69. }
  70. private void cmbStorageNo_ValueChanged(object sender, EventArgs e)
  71. {
  72. //initLocation(this.cmbStorageNo.Value.ToString2());
  73. }
  74. /// <summary>
  75. /// 绑定料位
  76. /// </summary>
  77. private void initLocation(string storageNo)
  78. {
  79. //BaseMethod.InitComboEditorWithParmArr(cmbLocationNo, "Core.LgMes.Server.Stuffmanage.FrmBaseInformation.doQueryLocation", "LOCATION_NO", this.ob, false, storageNo);
  80. //cmbLocationNo.SelectedIndex = 0;
  81. //cmbLayNo.SelectedIndex = 0;
  82. }
  83. /// <summary>
  84. /// 重写基类方法
  85. /// </summary>
  86. /// <param name="sender"></param>
  87. /// <param name="ToolbarKey"></param>
  88. public override void ToolBar_Click(object sender, string ToolbarKey)
  89. {
  90. switch (ToolbarKey)
  91. {
  92. case"ReadCard":
  93. readData();
  94. break;
  95. case"QueryDoc":
  96. doQueryOutList1();
  97. break;
  98. case "Query":
  99. if (!CheckQuery()) return;
  100. doQueryData();
  101. break;
  102. case "Add":
  103. doAdd();
  104. break;
  105. case "Delete":
  106. doDelete();
  107. break;
  108. case"Print":
  109. printInDoc();
  110. break;
  111. case "PrintQR":
  112. printQRCode();
  113. break;
  114. case"Export":
  115. exportData();
  116. break;
  117. case "Close":
  118. close();
  119. break;
  120. }
  121. }
  122. /// <summary>
  123. /// 导出
  124. /// </summary>
  125. private void exportData()
  126. {
  127. if(ultraTabControl1.SelectedTab.Key.Equals("0"))
  128. {
  129. GridHelper.ulGridToExcel(ultraGrid2, "未接收实绩汇总");
  130. }else
  131. {
  132. GridHelper.ulGridToExcel(ultraGrid1, "收料实绩汇总");
  133. }
  134. }
  135. private void close()
  136. {
  137. this.Close();
  138. }
  139. /// <summary>
  140. /// 数据验证
  141. /// </summary>
  142. /// <returns></returns>
  143. private bool CheckQuery()
  144. {
  145. if (DataTimeUtil.JudgeTime(DateTime.Parse(RegStartTime.Value.ToString()), DateTime.Parse(RegEndTime.Value.ToString())) == 0)
  146. {
  147. MessageUtil.ShowTips("开始时间不能大于结束时间!");
  148. return false;
  149. }
  150. if (chkFurnace.Checked && string.IsNullOrEmpty(txtFurnace.Text.Trim()))
  151. {
  152. MessageBox.Show("请输入炉号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  153. return false;
  154. }
  155. if (chkDk.Checked && string.IsNullOrEmpty(txtOutList.Text.Trim()))
  156. {
  157. MessageUtil.ShowTips("请输入倒库/入库单号!");
  158. return false;
  159. }
  160. return true;
  161. }
  162. /// <summary>
  163. /// 读卡
  164. /// </summary>
  165. private void readData()
  166. {
  167. WaitingForm2 wf = new WaitingForm2("正在加载,请稍候....");
  168. try
  169. {
  170. string outDoc = "";
  171. if (!ConnectCard(wf))
  172. {
  173. disConnect();
  174. return;
  175. }
  176. icClass.PrepareReadTemp();
  177. //bool b = icClass.DoReadTemp(1, 39);
  178. if (icClass.DoReadTemp(1, 39))
  179. {
  180. int count = icClass.RecordCount;
  181. if (count == 0) //判断卡上的记录数
  182. {
  183. wf.Close();
  184. MessageUtil.ShowTips("IC卡无记录,请核实!");
  185. disConnect();
  186. return;
  187. }
  188. else
  189. {
  190. outDoc = icClass.taskid;
  191. }
  192. //disConnect();
  193. }
  194. else
  195. {
  196. wf.Close();
  197. MessageUtil.ShowTips("读取IC卡出现错误!");
  198. disConnect();
  199. return;
  200. }
  201. doQueryOutList(outDoc);
  202. }
  203. finally
  204. {
  205. disConnect();
  206. wf.Close();
  207. }
  208. }
  209. ///<summary>
  210. /// 关闭连接
  211. /// </summary>
  212. /// <returns></returns>
  213. private bool disConnect()
  214. {
  215. if (icClass.Active)
  216. {
  217. icClass.AlarmBeep(1);
  218. //设置Active属性为false,则断开与读卡器的连接。
  219. icClass.ToFindCard = false;
  220. icClass.Active = false;
  221. return true;
  222. }
  223. else
  224. {
  225. return true;
  226. }
  227. }
  228. /// <summary>
  229. /// 查询
  230. /// </summary>
  231. private void doQueryData()
  232. {
  233. doQueryInList();
  234. }
  235. /// <summary>
  236. /// 查询倒库实绩
  237. /// </summary>
  238. private void doQueryOutList(string outDoc)
  239. {
  240. ArrayList parm = new ArrayList();
  241. //if (chkRegTime.Checked)
  242. //{
  243. // strRegStart = RegStartTime.Value.ToString();
  244. // strRegEnd = RegEndTime.Value.ToString();
  245. //}
  246. //if (chkFurnace.Checked)
  247. //{
  248. // heatNo = this.txtFurnace.Text.Trim();
  249. //}
  250. //if (chkDk.Checked)
  251. //{
  252. // outDoc = this.txtOutList.Text.Trim();
  253. //}
  254. //parm.Add(heatNo);
  255. //parm.Add(outDoc);
  256. parm.Add(outDoc);
  257. List<YdmGpOutlistEntity1> listSource = EntityHelper.GetData<YdmGpOutlistEntity1>(
  258. "Core.LgMes.Server.Stuffmanage.FrmStuffMoveIn.doQueryOutList", new object[] { parm, arr }, this.ob);
  259. YmdGpOutlistEntitybindingSource.DataSource = listSource;
  260. }
  261. /// <summary>
  262. /// 查询倒库实绩
  263. /// </summary>
  264. private void doQueryOutList1()
  265. {
  266. string strRegStart = "";
  267. string strRegEnd = "";
  268. string heatNo = "";
  269. string outDoc = "";
  270. ArrayList parm = new ArrayList();
  271. if (chkRegTime.Checked)
  272. {
  273. strRegStart = RegStartTime.Value.ToString();
  274. strRegEnd = RegEndTime.Value.ToString();
  275. }
  276. if (chkFurnace.Checked)
  277. {
  278. heatNo = this.txtFurnace.Text.Trim();
  279. }
  280. if (chkDk.Checked)
  281. {
  282. outDoc = this.txtOutList.Text.Trim();
  283. }
  284. parm.Add(strRegStart);
  285. parm.Add(strRegEnd);
  286. parm.Add(heatNo);
  287. parm.Add(outDoc);
  288. List<YdmGpOutlistEntity1> listSource = EntityHelper.GetData<YdmGpOutlistEntity1>(
  289. "Core.LgMes.Server.Stuffmanage.FrmStuffMoveIn.doQueryOutList1", new object[] { parm, arr }, this.ob);
  290. YmdGpOutlistEntitybindingSource.DataSource = listSource;
  291. }
  292. void icClass_OnFindCard()
  293. {
  294. icClass.OnFindCard -= new TalentICTGXControl.ITalentICTGXEvents_OnFindCardEventHandler(icClass_OnFindCard);
  295. icClass.OnDropCard += new TalentICTGXControl.ITalentICTGXEvents_OnDropCardEventHandler(icClass_OnDropCard);
  296. }
  297. void icClass_OnDropCard()
  298. {
  299. //将OnDropCard事件从委托链中删除,并加入OnFindCard事件到委托链中。
  300. //这样就实现了程序中自动寻卡的功能。
  301. icClass.OnDropCard -= new TalentICTGXControl.ITalentICTGXEvents_OnDropCardEventHandler(icClass_OnDropCard);
  302. icClass.OnFindCard += new TalentICTGXControl.ITalentICTGXEvents_OnFindCardEventHandler(icClass_OnFindCard);
  303. }
  304. /// <summary>
  305. /// 连接读卡器
  306. /// </summary>
  307. /// <returns></returns>
  308. private bool ConnectCard(WaitingForm2 wf)
  309. {
  310. //if (icClass == null)
  311. //{
  312. // icClass = new TalentICTGXControl.TalentICTGXClass();
  313. // //委托OnFindCard事件,icClass_OnFindCard是该事件要执行的方法。
  314. // //此事件在当IC卡放到读卡器上时触发。
  315. // icClass.OnFindCard += new TalentICTGXControl.ITalentICTGXEvents_OnFindCardEventHandler(icClass_OnFindCard);
  316. //}
  317. icClass = IcReadWrite.getIcClass();
  318. int comNum = (short)(short.Parse(txtCom.Text.Replace("COM", "")) - 1);
  319. icClass.CommPort = comNum;
  320. if (!icClass.Active)
  321. {
  322. //利用ToFindCard属性连接读卡器,启动OnFindCard事件。
  323. icClass.ToFindCard = true;
  324. if (icClass.Active)
  325. {
  326. //AlarmBeep(int times)方法实现了让IC卡读卡器发出警示音,
  327. //参数为发出几次警示音。
  328. icClass.AlarmBeep(2);
  329. Thread.Sleep(500);
  330. return true;
  331. }
  332. else
  333. {
  334. wf.Close();
  335. MessageUtil.ShowTips("读卡器连接失败!或请切换端口尝试!");
  336. return false;
  337. }
  338. }
  339. return true;
  340. }
  341. /// <summary>
  342. /// 清卡
  343. /// </summary>
  344. private void clearCard()
  345. {
  346. WaitingForm2 wf = new WaitingForm2("正在加载,请稍候....");
  347. try
  348. {
  349. if (ConnectCard(wf) == false)
  350. {
  351. return;
  352. }
  353. icClass.ClearCard();
  354. icClass.AlarmBeep(1);
  355. }
  356. catch
  357. {
  358. }
  359. finally
  360. {
  361. disConnect();
  362. wf.Close();
  363. }
  364. }
  365. /// <summary>
  366. /// 查询收料实绩
  367. /// </summary>
  368. private void doQueryInList()
  369. {
  370. string strRegStart = "";
  371. string strRegEnd = "";
  372. string heatNo = "";
  373. string inDoc = "";
  374. ArrayList parm = new ArrayList();
  375. if (chkRegTime.Checked)
  376. {
  377. strRegStart = RegStartTime.Value.ToString();
  378. strRegEnd = RegEndTime.Value.ToString();
  379. }
  380. if (chkFurnace.Checked)
  381. {
  382. heatNo = this.txtFurnace.Text.Trim();
  383. }
  384. if (chkDk.Checked)
  385. {
  386. inDoc = this.txtOutList.Text.Trim();
  387. }
  388. parm.Add(heatNo);
  389. parm.Add(inDoc);
  390. List<YdmGpInlistEntity> listSource = EntityHelper.GetData<YdmGpInlistEntity>(
  391. "Core.LgMes.Server.Stuffmanage.FrmStuffMoveIn.douQueryInList", new object[] { parm, strRegStart, strRegEnd, arr }, this.ob);
  392. YmdGpInlistEntitybindingSource.DataSource = listSource;
  393. }
  394. /// <summary>
  395. /// 收料
  396. /// </summary>
  397. private void doAdd()
  398. {
  399. this.ultraGrid2.UpdateData();
  400. string storageNo = "";//仓库名称
  401. string locationNo = "";//料位
  402. string locationName = "";//料位名称
  403. string laryNo = "";//层号
  404. string departId = ClsLoad.GetDepartIdBySectionId(this.UserInfo.GetDeptid(), this.ob);
  405. string departMent = ClsLoad.GetDepartBySectionId(this.UserInfo.GetDeptid(), this.ob);
  406. if (cmbStorageNo.Text.Trim() != "")
  407. {
  408. storageNo = cmbStorageNo.Value.ToString();
  409. }
  410. else
  411. {
  412. MessageUtil.ShowTips("仓库不能为空,请选择仓库!");
  413. return;
  414. }
  415. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
  416. if (checkMagRows.Count() == 0)
  417. {
  418. MessageUtil.ShowTips("请勾选需要收料的倒库信息!");
  419. return;
  420. }
  421. ArrayList parmlist = new ArrayList();
  422. ArrayList locationList = new ArrayList();
  423. ArrayList possList = new ArrayList();
  424. var posslist = checkMagRows.Select(p => (YdmGpOutlistEntity1)p.ListObject).ToList();
  425. var grouplist = posslist.GroupBy(p => p.OutstockDoc + "," + p.OutType);
  426. grouplist.ToList().ForEach(p =>
  427. {
  428. YdmGpOutlistEntity1 tmp = new YdmGpOutlistEntity1();
  429. tmp.OutstockDoc = p.Key.Split(',')[0];
  430. tmp.OutType = p.Key.Split(',')[1];
  431. tmp.PlineCode = p.First().PlineCode;
  432. tmp.ActCount = p.Sum(q => q.ActCount);
  433. possList.Add(JSONFormat.Format(tmp));
  434. });
  435. foreach (UltraGridRow row in checkMagRows)
  436. {
  437. int m = 0;
  438. YdmGpOutlistEntity1 ydmOutList = (YdmGpOutlistEntity1)row.ListObject;
  439. string outListEntity = JSONFormat.Format(ydmOutList);
  440. parmlist.Add(outListEntity);
  441. IQueryable<UltraGridRow> childMagRows = row.ChildBands[0].Rows.AsQueryable().Where(" CHK1 = 'True'");
  442. if (childMagRows.Count() == 0)
  443. {
  444. MessageUtil.ShowTips("请勾选料位信息!");
  445. return;
  446. }
  447. ArrayList list = new ArrayList();
  448. foreach(UltraGridRow childRow in childMagRows)
  449. {
  450. YdmGpButtressEntity ydmGpButessTity = (YdmGpButtressEntity)childRow.ListObject;
  451. ydmGpButessTity.StorageNo = storageNo;
  452. if (!StringUtil.IsInt(ydmGpButessTity.ActCount) || ydmGpButessTity.ActCount == "")
  453. {
  454. MessageUtil.ShowTips("支数请输入整数!");
  455. return;
  456. }
  457. if (ydmGpButessTity.LocationNo.Equals("") || ydmGpButessTity.LaryNo.Equals(""))
  458. {
  459. MessageUtil.ShowTips(ydmOutList.JudgeStoveNo + "料位、层号不能为空!");
  460. return;
  461. }
  462. m = m + int.Parse(ydmGpButessTity.ActCount.ToString3());
  463. string ydmGpEntity = JSONFormat.Format(ydmGpButessTity);
  464. list.Add(ydmGpEntity);
  465. }
  466. if (!(int.Parse(ydmOutList.ActCount.ToString3()) == m))
  467. {
  468. MessageUtil.ShowTips(ydmOutList.JudgeStoveNo + "分配料位支数与出库单对应支数不符!");
  469. return;
  470. }
  471. locationList.Add(list);
  472. }
  473. if (MessageUtil.ShowYesNoAndQuestion("是否收料?") == DialogResult.No)
  474. {
  475. return;
  476. }
  477. //bool bt = WriteCard();
  478. //if (!bt)
  479. //{
  480. // return;
  481. //}
  482. CoreClientParam ccp = new CoreClientParam();
  483. ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmStuffMoveIn";
  484. ccp.MethodName = "doAddInListData";
  485. ccp.ServerParams = new object[] { parmlist, locationList, strInbound, this.UserInfo.GetUserName(), departId, departMent, this.UserInfo.GetDeptid(), this.UserInfo.GetDepartment(), arr, UserInfo.GetUserOrder(), UserInfo.GetUserGroup(), possList, storageNo };
  486. ccp = ob.ExecuteNonQuery(ccp,CoreInvokeType.Internal);
  487. if (ccp.ReturnCode != -1)
  488. {
  489. if (ccp.ReturnInfo.Equals("收料成功!"))
  490. {
  491. //doQueryOutList1();
  492. YmdGpOutlistEntitybindingSource.Clear();
  493. if ((!storageNo.Equals("LSG1") && !storageNo.Equals("TTH1")))
  494. {
  495. clearCard();
  496. }
  497. MessageUtil.ShowTips(ccp.ReturnInfo);
  498. }
  499. else
  500. {
  501. MessageUtil.ShowTips(ccp.ReturnInfo);
  502. }
  503. }
  504. }
  505. /// <summary>
  506. /// 打印收料单
  507. /// </summary>
  508. private void printInDoc()
  509. {
  510. this.ultraGrid1.UpdateData();
  511. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  512. if(checkMagRows.Count() == 0)
  513. {
  514. MessageUtil.ShowTips("请选择需要打印的信息!");
  515. return;
  516. }
  517. int groupCnt = checkMagRows.GroupBy(a => a.GetValue("InstockDoc")).Count();
  518. if (groupCnt > 1)
  519. {
  520. MessageUtil.ShowTips("同一入库单号才能同时打印入库单!");
  521. return;
  522. }
  523. string inDoc = checkMagRows.ToArray()[0].Cells["InstockDoc"].Value.ToString();//入库单号
  524. string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepGpInList.cpt&format=pdf&INSTOCK_DOC=" + inDoc;
  525. FrmExcel fre = new FrmExcel(this.ob, strurl);
  526. fre.AutoSize = true;
  527. fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  528. fre.WindowState = FormWindowState.Maximized;
  529. fre.Show();
  530. }
  531. /// <summary>
  532. /// 打印二维码
  533. /// </summary>
  534. private void printQRCode()
  535. {
  536. this.ultraGrid1.UpdateData();
  537. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  538. if (checkMagRows.Count() == 0)
  539. {
  540. MessageUtil.ShowTips("请选择需要打印的信息!");
  541. return;
  542. }
  543. int groupCnt = checkMagRows.GroupBy(a => a.GetValue("InstockDoc")).Count();
  544. if (groupCnt > 1)
  545. {
  546. MessageUtil.ShowTips("同一入库单号才能同时打印入库单!");
  547. return;
  548. }
  549. string inDoc = "R:" + checkMagRows.ToArray()[0].Cells["InstockDoc"].Value.ToString();//入库单号
  550. string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepGpOutList2.cpt&OUTSTOCK_DOC=" + inDoc;
  551. FrmExcel fre = new FrmExcel(this.ob, strurl);
  552. fre.AutoSize = true;
  553. fre.Text = "二维码";
  554. fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  555. fre.WindowState = FormWindowState.Maximized;
  556. fre.Show();
  557. }
  558. /// <summary>
  559. /// 撤销
  560. /// </summary>
  561. private void doDelete()
  562. {
  563. this.ultraGrid1.UpdateData();
  564. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  565. if (checkMagRows.Count() == 0)
  566. {
  567. MessageUtil.ShowTips("请勾选需要撤销的收料信息!");
  568. return;
  569. }
  570. ArrayList parm = new ArrayList();
  571. foreach (UltraGridRow uRow in checkMagRows)
  572. {
  573. YdmGpInlistEntity inListEntity = (YdmGpInlistEntity)uRow.ListObject;
  574. string inEntity = JSONFormat.Format(inListEntity);
  575. parm.Add(inEntity);
  576. }
  577. if (MessageUtil.ShowYesNoAndQuestion("是否确认撤销?") == DialogResult.No) return;
  578. CoreClientParam ccp = new CoreClientParam();
  579. ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmStuffMoveIn";
  580. ccp.MethodName = "deleteData";
  581. ccp.ServerParams = new object[] { parm};
  582. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  583. if (ccp.ReturnCode != -1)
  584. {
  585. if (ccp.ReturnInfo.Equals("撤销成功!"))
  586. {
  587. doQueryData();
  588. MessageUtil.ShowTips(ccp.ReturnInfo);
  589. }
  590. else
  591. {
  592. MessageUtil.ShowTips(ccp.ReturnInfo);
  593. }
  594. }
  595. else
  596. {
  597. MessageUtil.ShowTips(ccp.ReturnInfo);
  598. }
  599. }
  600. private void chkRegTime_CheckedChanged(object sender, EventArgs e)
  601. {
  602. this.RegStartTime.Enabled = this.chkRegTime.Checked;
  603. this.RegEndTime.Enabled = this.chkRegTime.Checked;
  604. }
  605. private void chkDk_CheckedChanged(object sender, EventArgs e)
  606. {
  607. this.txtOutList.Enabled = this.chkDk.Checked;
  608. }
  609. private void chkFurnace_CheckedChanged(object sender, EventArgs e)
  610. {
  611. this.txtFurnace.Enabled = this.chkFurnace.Checked;
  612. }
  613. private void ultraGrid2_AfterSelectChange(object sender, Infragistics.Win.UltraWinGrid.AfterSelectChangeEventArgs e)
  614. {
  615. foreach (UltraGridRow uRow in ultraGrid2.Selected.Rows)
  616. {
  617. if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
  618. {
  619. uRow.Cells["CHK"].Value = true;
  620. }
  621. }
  622. }
  623. private void ultraGrid1_AfterSelectChange(object sender, Infragistics.Win.UltraWinGrid.AfterSelectChangeEventArgs e)
  624. {
  625. foreach (UltraGridRow uRow in ultraGrid1.Selected.Rows)
  626. {
  627. if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
  628. {
  629. uRow.Cells["CHK"].Value = true;
  630. }
  631. }
  632. }
  633. private void FrmStuffMoveIn_Shown(object sender, EventArgs e)
  634. {
  635. if (toolMenu == null) return;
  636. if (toolMenu.Toolbars[0].Tools.Exists("Delete"))
  637. {
  638. toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = DefaultableBoolean.False;
  639. }
  640. if (toolMenu.Toolbars[0].Tools.Exists("Query"))
  641. {
  642. toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = DefaultableBoolean.False;
  643. }
  644. if (toolMenu.Toolbars[0].Tools.Exists("Print"))
  645. {
  646. toolMenu.Toolbars[0].Tools["Print"].InstanceProps.Visible = DefaultableBoolean.False;
  647. }
  648. if (toolMenu.Toolbars[0].Tools.Exists("PrintQR"))
  649. {
  650. toolMenu.Toolbars[0].Tools["PrintQR"].InstanceProps.Visible = DefaultableBoolean.False;
  651. }
  652. //if(toolMenu.Toolbars[0].Tools.Exists("Export"))
  653. //{
  654. // toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.False;
  655. //}
  656. }
  657. private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
  658. {
  659. if (ultraTabControl1.SelectedTab.Key == "0")
  660. {
  661. if (toolMenu == null) return;
  662. if (toolMenu.Toolbars[0].Tools.Exists("ReadCard"))
  663. {
  664. toolMenu.Toolbars[0].Tools["ReadCard"].InstanceProps.Visible = DefaultableBoolean.True;
  665. }
  666. if (toolMenu.Toolbars[0].Tools.Exists("QueryDoc"))
  667. {
  668. toolMenu.Toolbars[0].Tools["QueryDoc"].InstanceProps.Visible = DefaultableBoolean.True;
  669. }
  670. if (toolMenu.Toolbars[0].Tools.Exists("Query"))
  671. {
  672. toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = DefaultableBoolean.False;
  673. }
  674. if (toolMenu.Toolbars[0].Tools.Exists("Delete"))
  675. {
  676. toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = DefaultableBoolean.False;
  677. }
  678. if (toolMenu.Toolbars[0].Tools.Exists("Add"))
  679. {
  680. toolMenu.Toolbars[0].Tools["Add"].InstanceProps.Visible = DefaultableBoolean.True;
  681. }
  682. if (toolMenu.Toolbars[0].Tools.Exists("Print"))
  683. {
  684. toolMenu.Toolbars[0].Tools["Print"].InstanceProps.Visible = DefaultableBoolean.False;
  685. }
  686. if (toolMenu.Toolbars[0].Tools.Exists("PrintQR"))
  687. {
  688. toolMenu.Toolbars[0].Tools["PrintQR"].InstanceProps.Visible = DefaultableBoolean.False;
  689. }
  690. //if (toolMenu.Toolbars[0].Tools.Exists("Export"))
  691. //{
  692. // toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.False;
  693. //}
  694. this.chkRegTime.Text = "倒库时间";
  695. this.chkDk.Text = "倒库单号";
  696. this.ultraLabel3.Visible = true;
  697. //this.ultraLabel2.Visible = true;
  698. //this.ultraLabel1.Visible = true;
  699. this.cmbStorageNo.Visible = true;
  700. //this.cmbLocationNo.Visible = true;
  701. //this.cmbLayNo.Visible = true;
  702. }
  703. else
  704. {
  705. if (toolMenu == null) return;
  706. if (toolMenu.Toolbars[0].Tools.Exists("ReadCard"))
  707. {
  708. toolMenu.Toolbars[0].Tools["ReadCard"].InstanceProps.Visible = DefaultableBoolean.False;
  709. }
  710. if (toolMenu.Toolbars[0].Tools.Exists("Query"))
  711. {
  712. toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = DefaultableBoolean.True;
  713. }
  714. if (toolMenu.Toolbars[0].Tools.Exists("Delete"))
  715. {
  716. toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = DefaultableBoolean.True;
  717. }
  718. if (toolMenu.Toolbars[0].Tools.Exists("QueryDoc"))
  719. {
  720. toolMenu.Toolbars[0].Tools["QueryDoc"].InstanceProps.Visible = DefaultableBoolean.False;
  721. }
  722. if (toolMenu.Toolbars[0].Tools.Exists("Add"))
  723. {
  724. toolMenu.Toolbars[0].Tools["Add"].InstanceProps.Visible = DefaultableBoolean.False;
  725. }
  726. if (toolMenu.Toolbars[0].Tools.Exists("Print"))
  727. {
  728. toolMenu.Toolbars[0].Tools["Print"].InstanceProps.Visible = DefaultableBoolean.True;
  729. }
  730. if (toolMenu.Toolbars[0].Tools.Exists("PrintQR"))
  731. {
  732. toolMenu.Toolbars[0].Tools["PrintQR"].InstanceProps.Visible = DefaultableBoolean.True;
  733. }
  734. //if (toolMenu.Toolbars[0].Tools.Exists("Export"))
  735. //{
  736. // toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.True;
  737. //}
  738. this.chkRegTime.Text = "入库时间";
  739. this.chkDk.Text = "入库单号";
  740. this.ultraLabel3.Visible = false;
  741. this.ultraLabel2.Visible = false;
  742. this.ultraLabel1.Visible = false;
  743. this.cmbStorageNo.Visible = false;
  744. this.cmbLocationNo.Visible = false;
  745. this.cmbLayNo.Visible = false;
  746. }
  747. }
  748. private void cmbLocationNo_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  749. {
  750. this.ultraGrid2.UpdateData();
  751. DataTable dt = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmBaseInformation.doQueryLocation",
  752. new object[] { this.cmbStorageNo.Value.ToString2()}, ob);
  753. dt.Columns["LOCATION_NAME"].Caption = "料位名称";
  754. BaseInfoPopup baseInfo = new BaseInfoPopup(dt, "LOCATION_NAME", "LOCATION_NO");
  755. baseInfo.Shown += new EventHandler((a, b) =>
  756. {
  757. var actRow = baseInfo.UltraGrid1.Rows.AsQueryable().Where(
  758. c => c.GetValue("LOCATION_NO") == this.cmbLocationNo.Tag.ToString2()).FirstOrDefault();
  759. if (actRow != null) actRow.Activate();
  760. });
  761. if (baseInfo.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  762. {
  763. //cmbLocationNo.Tag = baseInfo.ChoicedRow.GetValue("LOCATION_NO");
  764. //cmbLocationNo.Text = baseInfo.ChoicedRow.GetValue("LOCATION_NAME");
  765. this.ultraGrid2.ActiveCell.Value = baseInfo.ChoicedRow.GetValue("LOCATION_NAME");
  766. this.ultraGrid2.ActiveCell.Row.Cells["LocationNo"].Value = baseInfo.ChoicedRow.GetValue("LOCATION_NO");
  767. }
  768. }
  769. private void ultraGrid2_AfterRowInsert(object sender, RowEventArgs e)
  770. {
  771. e.Row.Cells["LaryNo"].Value = cmbLayNo.Items[0].DataValue.ToString();
  772. }
  773. private void txtFurnace_KeyDown(object sender, KeyEventArgs e)
  774. {
  775. if (e.KeyValue == 13)
  776. {
  777. if (ultraTabControl1.SelectedTab.Key == "0")
  778. {
  779. doQueryOutList1();
  780. }
  781. else
  782. {
  783. doQueryData();
  784. }
  785. }
  786. }
  787. private void ultraGrid2_CellChange(object sender, CellEventArgs e)
  788. {
  789. this.ultraGrid2.UpdateData();
  790. if (this.ultraGrid2.ActiveRow.HasChild())
  791. {
  792. return;
  793. }
  794. if (e.Cell.Column.Key == "CHK1")
  795. {
  796. if (this.ultraGrid2.ActiveRow.Cells["CHK1"].Value.ToString().Equals("True"))
  797. {
  798. this.ultraGrid2.ActiveRow.Cells["ActCount"].Value = this.ultraGrid2.ActiveRow.ParentRow.Cells["ActCount"].Value.ToString();
  799. }
  800. }
  801. }
  802. }
  803. }