ExcDeliveryManagNewJL.cs 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421
  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 Pur.Entity;
  11. using Core.Mes.Client.Comm.Control;
  12. using Pur.Entity.ck;
  13. using Infragistics.Win.UltraWinGrid;
  14. using System.Collections;
  15. using Core.Mes.Client.Comm.Tool;
  16. using com.hnshituo.pur.vo;
  17. using Core.Mes.Client.Comm.Server;
  18. using com.hnshituo.ck;
  19. using Pur.Pop_upWindow;
  20. using Infragistics.Win.UltraWinEditors;
  21. using Pur.configure;
  22. namespace Pur.ck
  23. {
  24. public partial class ExcDeliveryManagNewJL : FrmPmsBase
  25. {
  26. String WMmatcode = "";
  27. String WMsuppCode = "";
  28. String WMdeliveryCode = "";
  29. public ExcDeliveryManagNewJL()
  30. {
  31. InitializeComponent();
  32. try
  33. {
  34. string[] portnames = System.IO.Ports.SerialPort.GetPortNames(); //获取计算机串口数组
  35. if (portnames is Infragistics.Win.UltraWinGrid.Nullable || portnames.Length < 1)
  36. {
  37. portnames = new string[10] { "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "COM10" };
  38. }
  39. txt_com.DataSource = portnames;
  40. this.txt_com.SelectedIndex = 0;
  41. }
  42. catch (Exception eex3)
  43. {
  44. MessageBox.Show(eex3.Message);
  45. }
  46. }
  47. private void ExcDeliveryManagNewJL_Load(object sender, EventArgs e)
  48. {
  49. ck_isAllMeter.Checked = true;
  50. ck_Ctime.Checked = false;
  51. txt_CreateTimeS.Value = DateTime.Now.AddMonths(-1);
  52. txt_CreateTimeS.Enabled = false;
  53. txt_CreateTimeE.Value = Convert.ToDateTime(DateTime.Now.ToShortDateString()).AddHours(23).AddMinutes(59);
  54. txt_CreateTimeE.Enabled = false;
  55. Ck_Etime.Checked = true;
  56. txt_PlanedShipDateS.Value = DateTime.Now.AddDays(-3);
  57. txt_PlanedShipDateS.Enabled = true;
  58. txt_PlanedShipDateE.Value = Convert.ToDateTime(DateTime.Now.AddDays(3));
  59. txt_PlanedShipDateE.Enabled = true;
  60. txt_length.SelectedIndex = 0;
  61. ultraTabControl1.SelectedTab= ultraTabControl1.Tabs[0];
  62. txt_QtyJL.ReadOnly = false;
  63. txt_status.SelectedIndex = 1;//默认待发送计量委托
  64. GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0], new string[] {});
  65. GridHelper.SetExcludeColumnsActive(ultraGrid2.DisplayLayout.Bands[0], new string[] {});
  66. GridHelper.SetExcludeColumnsActive(ultraGrid3.DisplayLayout.Bands[0], new string[] {});
  67. GridHelper.SetExcludeColumnsActive(ultraGrid4.DisplayLayout.Bands[0], new string[] {});
  68. ultraExpandableGroupBox4.Expanded = true;
  69. Get_ExcSubM();
  70. }
  71. #region toolbar工具栏
  72. /// <summary>
  73. /// 菜单栏
  74. /// </summary>
  75. /// <param name="sender"></param>
  76. /// <param name="ToolbarKey"></param>
  77. public override void ToolBar_Click(object sender, string ToolbarKey)
  78. {
  79. switch (ToolbarKey)
  80. {
  81. case "Query":
  82. Get_ExcSubM();
  83. break;
  84. case "Close":
  85. this.Close();
  86. break;
  87. }
  88. }
  89. /// <summary>
  90. /// 查询
  91. /// </summary>
  92. private void Get_ExcSubM()
  93. {
  94. try
  95. {
  96. //查询待计量的通知单头
  97. this.Cursor = Cursors.WaitCursor;
  98. clearSampleTabJL();
  99. if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[1])
  100. {
  101. dataSet1.Clear();
  102. Hashtable map = new Hashtable();
  103. map.Add("deliverySubId", txt_deliverySubId.Text.Trim());
  104. map.Add("orderId", txt_OrderId.Text.Trim());
  105. map.Add("supperId", txt_suppCode.Text.Trim());
  106. map.Add("validDataPurviewIds", this.ValidDataPurviewIds);
  107. map.Add("itemCode", txt_itemCode.Text.ToString().Trim());
  108. map.Add("itemName", txt_itemName.Text.ToString().Trim());
  109. if (ck_Ctime.Checked && !string.IsNullOrEmpty(txt_CreateTimeS.Text))
  110. {
  111. map.Add("createTimeBegin", Convert.ToDateTime(txt_CreateTimeS.Value));
  112. }
  113. if (ck_Ctime.Checked && !string.IsNullOrEmpty(txt_CreateTimeE.Text))
  114. {
  115. map.Add("createTimeEnd", Convert.ToDateTime(txt_CreateTimeE.Value));
  116. }
  117. if (Ck_Etime.Checked && !string.IsNullOrEmpty(txt_PlanedShipDateS.Text))
  118. {
  119. map.Add("planedShipDate", Convert.ToDateTime(txt_PlanedShipDateS.Value));
  120. }
  121. if (Ck_Etime.Checked && !string.IsNullOrEmpty(txt_PlanedShipDateE.Text))
  122. {
  123. map.Add("planedDeliveryDate", Convert.ToDateTime(txt_PlanedShipDateE.Value));
  124. }
  125. if (txt_status.SelectedIndex != -1)
  126. {
  127. map.Add("statusJL", txt_status.Value.ToString().Trim());
  128. }
  129. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "doQueryDeliverySubMList", new object[] { map });
  130. GridHelper.CopyDataToDatatable(dt, dataTable1, true);
  131. GridHelper.RefreshAndAutoSize(ultraGrid1);
  132. }
  133. else
  134. {
  135. dataSet2.Clear();
  136. //通知单头
  137. ExcDeliveryNoticeM EdnM = new ExcDeliveryNoticeM();
  138. EdnM.OrderId = txt_OrderId.Text.ToString().Trim();
  139. EdnM.NoticeId = txt_deliverySubId.Text.Trim();
  140. if (ck_Ctime.Checked)
  141. {
  142. if (txt_CreateTimeS.Text != "")
  143. {
  144. EdnM.CreateTime = Convert.ToDateTime(txt_CreateTimeS.Value);
  145. }
  146. if (txt_CreateTimeE.Text != "")
  147. {
  148. EdnM.DeleteTime = Convert.ToDateTime(txt_CreateTimeE.Value);
  149. }
  150. }
  151. if (Ck_Etime.Checked)
  152. {
  153. if (txt_PlanedShipDateS.Text != "")
  154. {
  155. EdnM.PlanedDeliveryDate = Convert.ToDateTime(txt_PlanedShipDateS.Value);
  156. }
  157. if (txt_PlanedShipDateE.Text != "")
  158. {
  159. EdnM.PlanedDeliveryDate = Convert.ToDateTime(txt_PlanedShipDateE.Value);
  160. }
  161. }
  162. EdnM.ValidDataPurviewIds = this.ValidDataPurviewIds;
  163. EdnM.SuppCode = txt_suppCode.Text.Trim();
  164. EdnM.UpdateName = txt_itemName.Text.Trim();
  165. EdnM.UpdateUserid = txt_itemCode.Text.Trim();
  166. if (txt_status.SelectedIndex != -1)
  167. {
  168. EdnM.DeleteUserid = txt_status.Value.ToString().Trim();//是否需要计量
  169. }
  170. DataTable dt10 = this.execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliveryNoticeMService", "find_Exc", new object[] { EdnM });
  171. GridHelper.CopyDataToDatatable(dt10, dataTable3, true);
  172. GridHelper.RefreshAndAutoSize(ultraGrid3);
  173. }
  174. }
  175. catch (Exception ex)
  176. {
  177. MessageUtil.ShowTips("查询送货单主表数据失败:" + ex.Message);
  178. }
  179. finally
  180. {
  181. this.Cursor = Cursors.Default;
  182. }
  183. }
  184. #endregion
  185. #region 界面事件
  186. /// <summary>
  187. /// 加载待计量送货单行
  188. /// </summary>
  189. /// <param name="sender"></param>
  190. /// <param name="e"></param>
  191. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  192. {
  193. WMmatcode = "";
  194. WMsuppCode = "";
  195. WMdeliveryCode = "";
  196. txt_message.Text = "";
  197. queryDeliverySubC("");
  198. }
  199. /// <summary>
  200. /// 加载待计量通知单头
  201. /// </summary>
  202. /// <param name="sender"></param>
  203. /// <param name="e"></param>
  204. private void ultraGrid3_AfterRowActivate(object sender, EventArgs e)
  205. {
  206. WMmatcode = "";
  207. WMsuppCode = "";
  208. WMdeliveryCode = "";
  209. txt_message.Text = "";
  210. queryNoticeC("");
  211. }
  212. /// <summary>
  213. /// 选择计量的送货单行
  214. /// </summary>
  215. /// <param name="sender"></param>
  216. /// <param name="e"></param>
  217. private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
  218. {
  219. //根据物送货单行不允许编辑数量
  220. try
  221. {
  222. if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[1])
  223. {
  224. WMmatcode = "";
  225. WMsuppCode = "";
  226. WMdeliveryCode = "";
  227. txt_message.Text = "";
  228. String strDeliverySubLineSqe = ultraGrid2.ActiveRow.GetCellValue("deliverySubLineSqe").ToString().Trim();
  229. // String strDeliverySubId = ultraGrid2.ActiveRow.Cells["DeliverySubId"].Value.ToString().Trim();
  230. //if (String.IsNullOrEmpty(strDeliverySubId))
  231. //{
  232. // MessageUtil.ShowTips("送货单号为空");
  233. //}
  234. if (String.IsNullOrEmpty(strDeliverySubLineSqe))
  235. {
  236. MessageUtil.ShowTips("送货单行号为空");
  237. }
  238. ExcDeliverySubC dsc = this.execute<ExcDeliverySubC>("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "findById", new object[] { strDeliverySubLineSqe });
  239. ExcDeliverySubM dsm = this.execute<ExcDeliverySubM>("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "findById", new object[] { dsc.DeliverySubId });
  240. //计量数据加载
  241. txt_QtyJL.Text = dsc.Qty + "";
  242. ck_meterFlag.Checked = dsc.MeteringFlag == null ? false : (dsc.MeteringFlag == "1" ? true : false);
  243. if (ck_meterFlag.Checked)
  244. {
  245. ck_meterFlag.Enabled = true;
  246. }
  247. else
  248. {
  249. ck_meterFlag.Enabled = true;
  250. }
  251. txt_carNumJL.Text = dsc.CarNum;
  252. txt_batchNo.Text = dsc.BatchNo;
  253. CoreResult crt = new CoreResult();
  254. if (dsc.ItemCode == "Y01010001")
  255. {
  256. crt.Resultcode = 0;
  257. crt.Resultmsg = "105";
  258. }
  259. else
  260. {
  261. crt = this.execute<CoreResult>("com.hnshituo.pur.jl.service.MeasureService", "getWMMatCode", new object[] { dsc.ItemCode });
  262. }
  263. CoreResult crt2 = this.execute<CoreResult>("com.hnshituo.pur.jl.service.MeasureService", "getWMSuppCode", new object[] { dsm.SuppCode });
  264. CoreResult crt3 = this.execute<CoreResult>("com.hnshituo.pur.jl.service.MeasureService", "getWMdeliveryCode", new object[] { dsm.DeliveryLocation });
  265. if (crt2.Resultcode != 0 || crt.Resultcode != 0 || crt3.Resultcode != 0)
  266. {
  267. if (crt.Resultcode != 0)
  268. {
  269. txt_message.Text = crt.Resultmsg + "\r\n";
  270. }
  271. else
  272. {
  273. WMmatcode = crt.Resultmsg;
  274. }
  275. if (crt2.Resultcode != 0)
  276. {
  277. txt_message.Text = txt_message.Text + crt2.Resultmsg + "\r\n";
  278. }
  279. else
  280. {
  281. WMsuppCode = crt2.Resultmsg;
  282. }
  283. if (crt3.Resultcode != 0)
  284. {
  285. txt_message.Text = txt_message.Text + crt3.Resultmsg + "\r\n";
  286. }
  287. else
  288. {
  289. WMdeliveryCode = crt3.Resultmsg;
  290. }
  291. return;
  292. }
  293. WMmatcode = crt.Resultmsg;
  294. WMsuppCode = crt2.Resultmsg;
  295. WMdeliveryCode = crt3.Resultmsg;
  296. }
  297. }
  298. catch (Exception ex)
  299. {
  300. MessageUtil.ShowTips(ex.Message);
  301. }
  302. }
  303. /// <summary>
  304. /// 选择计量的通知单行
  305. /// </summary>
  306. /// <param name="sender"></param>
  307. /// <param name="e"></param>
  308. private void ultraGrid4_AfterRowActivate(object sender, EventArgs e)
  309. {
  310. try
  311. {
  312. if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[0])
  313. {
  314. WMmatcode = "";
  315. WMsuppCode = "";
  316. WMdeliveryCode = "";
  317. txt_message.Text = "";
  318. //通知单行允许编辑数量
  319. String strNoticeLineSqe = ultraGrid4.ActiveRow.GetCellValue("noticeLineSqe").ToString().Trim();
  320. if (String.IsNullOrEmpty(strNoticeLineSqe))
  321. {
  322. MessageUtil.ShowTips("通知单行号为空");
  323. }
  324. ExcDeliveryNoticeC dsc = this.execute<ExcDeliveryNoticeC>("com.hnshituo.pur.ck.service.ExcDeliveryNoticeCService", "findById", new object[] { strNoticeLineSqe });
  325. ExcDeliveryNoticeM dsm = this.execute<ExcDeliveryNoticeM>("com.hnshituo.pur.ck.service.ExcDeliveryNoticeMService", "findById", new object[] { dsc.NoticeId });
  326. double dbcreatedQty = (double)(dsc.CreatedQty == null ? 0 : dsc.CreatedQty);
  327. Double canJLQty = (double)dsc.Qty - dbcreatedQty;
  328. //计量数据加载
  329. txt_QtyJL.Text = canJLQty + "";
  330. ck_meterFlag.Checked = dsc.MeteringFlag == null ? false : (dsc.MeteringFlag == "1" ? true : false);
  331. if (ck_meterFlag.Checked)
  332. {
  333. ck_meterFlag.Enabled = false;
  334. }
  335. else
  336. {
  337. ck_meterFlag.Enabled = true;
  338. }
  339. txt_carNumJL.Text = "";
  340. CoreResult crt = new CoreResult();
  341. if (dsc.ItemCode == "Y01010001")
  342. {
  343. crt.Resultcode = 0;
  344. crt.Resultmsg = "105";
  345. }
  346. else
  347. {
  348. crt = this.execute<CoreResult>("com.hnshituo.pur.jl.service.MeasureService", "getWMMatCode", new object[] { dsc.ItemCode });
  349. }
  350. CoreResult crt2 = this.execute<CoreResult>("com.hnshituo.pur.jl.service.MeasureService", "getWMSuppCode", new object[] { dsm.SuppCode });
  351. CoreResult crt3 = this.execute<CoreResult>("com.hnshituo.pur.jl.service.MeasureService", "getWMdeliveryCode", new object[] { dsm.DeliveryLocation });
  352. if (crt2.Resultcode != 0 || crt.Resultcode != 0 || crt3.Resultcode != 0)
  353. {
  354. if (crt.Resultcode != 0)
  355. {
  356. txt_message.Text = crt.Resultmsg + "\r\n";
  357. }
  358. else
  359. {
  360. WMmatcode = crt.Resultmsg;
  361. }
  362. if (crt2.Resultcode != 0)
  363. {
  364. txt_message.Text = txt_message.Text + crt2.Resultmsg + "\r\n";
  365. }
  366. else
  367. {
  368. WMsuppCode = crt2.Resultmsg;
  369. }
  370. if (crt3.Resultcode != 0)
  371. {
  372. txt_message.Text = txt_message.Text + crt3.Resultmsg + "\r\n";
  373. }
  374. else
  375. {
  376. WMdeliveryCode = crt3.Resultmsg;
  377. }
  378. return;
  379. }
  380. WMmatcode = crt.Resultmsg;
  381. WMsuppCode = crt2.Resultmsg;
  382. WMdeliveryCode = crt3.Resultmsg;
  383. }
  384. }
  385. catch (Exception ex)
  386. {
  387. MessageUtil.ShowTips("获取通知单行计量数据失败:" + ex.Message);
  388. }
  389. }
  390. /// <summary>
  391. /// 创建时间
  392. /// </summary>
  393. /// <param name="sender"></param>
  394. /// <param name="e"></param>
  395. private void ck_Ctime_CheckedChanged(object sender, EventArgs e)
  396. {
  397. txt_CreateTimeS.Enabled = ck_Ctime.Checked;
  398. txt_CreateTimeE.Enabled = ck_Ctime.Checked;
  399. }
  400. /// <summary>
  401. /// 交期控制
  402. /// </summary>
  403. /// <param name="sender"></param>
  404. /// <param name="e"></param>
  405. private void Ck_Etime_CheckedChanged(object sender, EventArgs e)
  406. {
  407. txt_PlanedShipDateS.Enabled = Ck_Etime.Checked;
  408. txt_PlanedShipDateE.Enabled = Ck_Etime.Checked;
  409. }
  410. /// <summary>
  411. /// 通知单还是送货单控制
  412. /// </summary>
  413. /// <param name="sender"></param>
  414. /// <param name="e"></param>
  415. private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
  416. {
  417. clearSampleTabJL();
  418. if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[0])
  419. {
  420. txt_QtyJL.ReadOnly = false;
  421. clearJL();
  422. queryNoticeC("");
  423. }
  424. else
  425. {
  426. clearJL();
  427. txt_QtyJL.ReadOnly = false;
  428. queryDeliverySubC("");
  429. }
  430. }
  431. //清卡计量编辑区
  432. private void clearJL()
  433. {
  434. txt_carNumJL.Clear();
  435. txt_length.SelectedIndex = 0;
  436. txt_batchNo.Clear();
  437. }
  438. /// <summary>
  439. /// 点击写卡
  440. /// </summary>
  441. /// <param name="sender"></param>
  442. /// <param name="e"></param>
  443. private void txt_addJL_Click(object sender, EventArgs e)
  444. {
  445. //if (ConnectCard() == false)
  446. //{
  447. // return;
  448. //}
  449. if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[0])
  450. {
  451. if (Write1() == true)
  452. {
  453. queryDeliverySubC("");
  454. }
  455. }
  456. else if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[1])
  457. {
  458. if (Write() == true)
  459. {
  460. queryNoticeC("");
  461. }
  462. }
  463. else
  464. {
  465. MessageUtil.ShowTips("请选择送货单或者通知单");
  466. }
  467. testConnectCard();
  468. //ReadCard();
  469. }
  470. /// <summary>
  471. /// 测试连接
  472. /// </summary>
  473. /// <param name="sender"></param>
  474. /// <param name="e"></param>
  475. private void btn_testConnectJL_Click(object sender, EventArgs e)
  476. {
  477. testConnectCard();
  478. }
  479. /// <summary>
  480. /// 读卡
  481. /// </summary>
  482. /// <param name="sender"></param>
  483. /// <param name="e"></param>
  484. private void btn_testReadJL_Click(object sender, EventArgs e)
  485. {
  486. ReadCard();
  487. }
  488. /// <summary>
  489. /// 清卡
  490. /// </summary>
  491. /// <param name="sender"></param>
  492. /// <param name="e"></param>
  493. private void btn_clearIC_Click(object sender, EventArgs e)
  494. {
  495. Clear_IC_ChuKuDaTa();
  496. }
  497. #endregion
  498. #region 读卡
  499. private TalentICTGXControl.TalentICTGXClass icClass;
  500. ///<summary>
  501. /// 连接
  502. /// </summary>
  503. /// <returns></returns>
  504. private bool getConnect()
  505. {
  506. try
  507. {
  508. txt_message.Text = "";
  509. if (icClass == null)
  510. {
  511. icClass = new TalentICTGXControl.TalentICTGXClass();
  512. //委托OnFindCard事件,icClass_OnFindCard是该事件要执行的方法。
  513. //此事件在当IC卡放到读卡器上时触发。
  514. icClass.OnFindCard += new TalentICTGXControl.ITalentICTGXEvents_OnFindCardEventHandler(icClass_OnFindCard);
  515. }
  516. //icClass.AlarmBeep(2);
  517. string txtCom = txt_com.SelectedItem.ToString();
  518. int comNum = (short)(short.Parse(txtCom.Replace("COM", "")) - 1);
  519. icClass.CommPort = comNum;
  520. if (!icClass.Active)
  521. {
  522. icClass.ToFindCard = true;
  523. // MessageUtil.ShowTips("ConnectCard.icClass.Active: " + icClass.Active);
  524. if (icClass.Active)
  525. {
  526. //MessageUtil.ShowTips("IC卡连接成功!");
  527. txt_message.Text = "IC卡连接成功!" + "\r\n";
  528. //AlarmBeep(int times)方法实现了让IC卡读卡器发出警示音,
  529. //参数为发出几次警示音。
  530. icClass.AlarmBeep(2);
  531. return true;
  532. }
  533. else
  534. {
  535. txt_message.Text = "IC卡连接失败!或请切换端口尝试" + "\r\n";
  536. return false;
  537. }
  538. }
  539. else
  540. {
  541. return true;
  542. }
  543. }
  544. catch (Exception e)
  545. {
  546. txt_message.Text = "IC卡连接失败!" + e.Message+"\r\n";
  547. return false;
  548. }
  549. }
  550. ///<summary>
  551. /// 关闭连接
  552. /// </summary>
  553. /// <returns></returns>
  554. private bool disConnect()
  555. {
  556. if (icClass.Active)
  557. {
  558. icClass.AlarmBeep(1);
  559. //设置Active属性为false,则断开与读卡器的连接。
  560. icClass.ToFindCard = false;
  561. icClass.Active = false;
  562. txt_message.Text =txt_message.Text+ "IC卡已断开与读卡器连接!" + "\r\n";
  563. return true;
  564. }
  565. else
  566. {
  567. return true;
  568. }
  569. }
  570. //出库清卡
  571. private void Clear_IC_ChuKuDaTa()
  572. {
  573. if (getConnect() == false)
  574. {
  575. return;
  576. }
  577. //车辆已经计量完成或者不计量则清卡,车辆没有计量完成则不清卡
  578. //清卡函数为 icClass.ClearCard
  579. if ((icClass.grossA == 0) || ((icClass.grossA > 0) && (!string.IsNullOrEmpty(icClass.grosstime)) && (icClass.tareA > 0) && (!string.IsNullOrEmpty(icClass.taretime))))
  580. {
  581. if (MessageUtil.ShowYesNoAndQuestion("确定清卡?") != DialogResult.Yes)
  582. {
  583. return;
  584. }
  585. if (icClass.ClearCard() == true)
  586. {
  587. txt_message.Text = txt_message.Text + "IC卡已清卡!" + "\r\n";
  588. }
  589. else
  590. {
  591. txt_message.Text = txt_message.Text + "IC卡已清卡!" + "\r\n";
  592. }
  593. icClass.AlarmBeep(1);
  594. }
  595. }
  596. /// <summary>
  597. /// 连接读卡器string txtCom = ultraComboEditor1.SelectedItem.ToString();
  598. /// </summary>
  599. /// <returns></returns>
  600. private bool ConnectCard()
  601. {
  602. try
  603. {
  604. txt_message.Text = "";
  605. if (icClass == null)
  606. {
  607. icClass = new TalentICTGXControl.TalentICTGXClass();
  608. //委托OnFindCard事件,icClass_OnFindCard是该事件要执行的方法。
  609. //此事件在当IC卡放到读卡器上时触发。
  610. icClass.OnFindCard += new TalentICTGXControl.ITalentICTGXEvents_OnFindCardEventHandler(icClass_OnFindCard);
  611. }
  612. //icClass.AlarmBeep(2);
  613. string txtCom = txt_com.SelectedItem.ToString();
  614. int comNum = (short)(short.Parse(txtCom.Replace("COM", "")) - 1);
  615. icClass.CommPort = comNum;
  616. if (icClass.Active)
  617. {
  618. icClass.Active = false;
  619. txt_message.Text = "初始连接中!" + "\r\n";
  620. }
  621. if (!icClass.Active)
  622. {
  623. icClass.ToFindCard = true;
  624. // MessageUtil.ShowTips("ConnectCard.icClass.Active: " + icClass.Active);
  625. if (icClass.Active)
  626. {
  627. //MessageUtil.ShowTips("IC卡连接成功!");
  628. txt_message.Text = "IC卡连接成功!" + "\r\n";
  629. //AlarmBeep(int times)方法实现了让IC卡读卡器发出警示音,
  630. //参数为发出几次警示音。
  631. icClass.AlarmBeep(2);
  632. return true;
  633. }
  634. else
  635. {
  636. txt_message.Text = "IC卡连接失败!或请切换端口尝试" + "\r\n";
  637. return false;
  638. }
  639. }
  640. else
  641. {
  642. txt_message.Text = "初始连接失败!" + "\r\n";
  643. return false;
  644. }
  645. }
  646. catch (Exception ex)
  647. {
  648. txt_message.Text = txt_message.Text+ex + "\r\n";
  649. return false;
  650. }
  651. }
  652. /// <summary>
  653. /// 测试连接读卡器string txtCom = ultraComboEditor1.SelectedItem.ToString();
  654. /// </summary>
  655. /// <returns></returns>
  656. private bool testConnectCard()
  657. {
  658. try
  659. {
  660. txt_message.Text = "";
  661. icClass = new TalentICTGXControl.TalentICTGXClass();
  662. //委托OnFindCard事件,icClass_OnFindCard是该事件要执行的方法。
  663. //此事件在当IC卡放到读卡器上时触发。
  664. icClass.OnFindCard += new TalentICTGXControl.ITalentICTGXEvents_OnFindCardEventHandler(icClass_OnFindCard);
  665. //icClass.AlarmBeep(2);
  666. string txtCom = txt_com.SelectedItem.ToString();
  667. int comNum = (short)(short.Parse(txtCom.Replace("COM", "")) - 1);
  668. icClass.CommPort = comNum;
  669. if (!icClass.Active)
  670. {
  671. icClass.ToFindCard = true;
  672. // MessageUtil.ShowTips("ConnectCard.icClass.Active: " + icClass.Active);
  673. if (icClass.Active)
  674. {
  675. //MessageUtil.ShowTips("IC卡连接成功!");
  676. txt_message.Text = "IC卡连接成功!" + "\r\n";
  677. //AlarmBeep(int times)方法实现了让IC卡读卡器发出警示音,
  678. //参数为发出几次警示音。
  679. icClass.AlarmBeep(2);
  680. return true;
  681. }
  682. else
  683. {
  684. txt_message.Text = "IC卡连接失败!或请切换端口尝试" + "\r\n";
  685. return false;
  686. }
  687. }
  688. else
  689. {
  690. icClass.AlarmBeep(1);
  691. //设置Active属性为false,则断开与读卡器的连接。
  692. icClass.ToFindCard = false;
  693. icClass.Active = false;
  694. txt_message.Text = "IC卡已断开与读卡器连接!" + "\r\n";
  695. return false;
  696. }
  697. }
  698. catch (Exception ex)
  699. {
  700. txt_message.Text = txt_message.Text + ex + "\r\n";
  701. return false;
  702. }
  703. }
  704. void icClass_OnFindCard()
  705. {
  706. icClass.OnFindCard -= new TalentICTGXControl.ITalentICTGXEvents_OnFindCardEventHandler(icClass_OnFindCard);
  707. icClass.OnDropCard += new TalentICTGXControl.ITalentICTGXEvents_OnDropCardEventHandler(icClass_OnDropCard);
  708. }
  709. void icClass_OnDropCard()
  710. {
  711. //将OnDropCard事件从委托链中删除,并加入OnFindCard事件到委托链中。
  712. //这样就实现了程序中自动寻卡的功能。
  713. icClass.OnDropCard -= new TalentICTGXControl.ITalentICTGXEvents_OnDropCardEventHandler(icClass_OnDropCard);
  714. icClass.OnFindCard += new TalentICTGXControl.ITalentICTGXEvents_OnFindCardEventHandler(icClass_OnFindCard);
  715. }
  716. //void icClass_OnConnect()
  717. //{
  718. // MessageUtil.ShowTips("icClass_OnConnect");
  719. //}
  720. //void icClass_OnError()
  721. //{
  722. // MessageUtil.ShowTips("icClass_OnError");
  723. //}
  724. /// <summary>
  725. /// 读卡
  726. /// </summary>
  727. /// <summary>
  728. /// 读IC卡信息
  729. /// </summary>
  730. private void ReadCard()
  731. {
  732. try
  733. {
  734. if (getConnect() == false)
  735. {
  736. return;
  737. }
  738. icClass.PrepareReadTemp();
  739. if (icClass.DoReadTemp(1, 39))
  740. {
  741. txt_message.Text = txt_message.Text+"读卡成功!" + "\r\n";
  742. }
  743. else
  744. {
  745. txt_message.Text = txt_message.Text + "读卡失败!" + "\r\n";
  746. }
  747. //if (icClass.DoReadTemp(1, 39))
  748. //{
  749. int count = icClass.RecordCount;
  750. //if (count == 0) //判断卡上的记录数
  751. //{
  752. // txt_message.Text = txt_message.Text + "读卡失败!" + "\r\n";
  753. // return "";
  754. //}
  755. //else
  756. //{
  757. // icCardNo = icClass.ICNo;
  758. //}
  759. string strDeliverySubLineSqe = icClass.poorder;//订单号(最好8位,现在计量表中没有8位的单号,避免单号重复)
  760. string suppCode=icClass.sourceunitcode;//供应商代码(计量系统)
  761. string suppName=icClass.sourceunit;//客户名称
  762. string itemCode=icClass.A_materialcode;//物料代码(计量系统)
  763. string itemName=icClass.A_material;//物料名称tg
  764. string deliveryLocationCode=icClass.targetunitcode ;//去向代码
  765. string deliveryLocation=icClass.targetunit;//去向名称
  766. string icCardNo = icClass.ICNo;
  767. string carNo = icClass.carno;
  768. String A_length = icClass.A_length;
  769. icClass.EndReadTemp();
  770. txt_message.Text = txt_message.Text + "卡号:" + icCardNo + "\r\n";
  771. txt_message.Text = txt_message.Text + "车号:" + carNo + "\r\n";
  772. disConnect();
  773. if (String.IsNullOrEmpty(icCardNo))
  774. {
  775. txt_message.Text =txt_message.Text+ "或请点击“连接”按钮重试" +"\r\n";
  776. return;
  777. }
  778. if (String.IsNullOrEmpty(carNo))
  779. {
  780. txt_message.Text = txt_message.Text + "若未读到信息请点击“连接”按钮重试" + "\r\n";
  781. }
  782. ExcDeliverySubC sub = new ExcDeliverySubC();
  783. sub.DeliverySubId = icCardNo;
  784. sub.DeliverySubLineSqe = strDeliverySubLineSqe;
  785. sub.CreateUserid = suppCode;
  786. sub.CreateName = suppName;
  787. sub.ItemCode = itemCode;
  788. sub.ItemName = itemName;
  789. sub.UpdateName = deliveryLocation;
  790. sub.UpdateUserid = deliveryLocationCode;
  791. sub.DeleteName = A_length;
  792. sub.CarNum = carNo;
  793. frmPopJLDaTaReview frm = new frmPopJLDaTaReview(this.ob, sub);
  794. frm.Text = "[" + icCardNo + "]" + "卡信息";
  795. frm.ShowDialog();
  796. // return icCardNo;
  797. }
  798. catch (Exception ex)
  799. {
  800. txt_message.Text = txt_message.Text+ex + "\r\n";
  801. //return "-1";
  802. }
  803. }
  804. /// <summary>
  805. /// 送货单写卡写IC卡信息
  806. /// </summary>
  807. /// <param name="doc"></param>
  808. /// <param name="carNo"></param>
  809. /// <returns></returns>
  810. ///
  811. private bool Write()
  812. {
  813. if (testCode() == false)
  814. {
  815. return false;
  816. }
  817. if (getConnect() == false)
  818. {
  819. return false;
  820. }
  821. if (icClass == null)
  822. {
  823. return false;
  824. }
  825. //if (icClass.IsIC == false)
  826. //{
  827. // MessageUtil.ShowTips("请放IC卡!" + icClass.IsIC);
  828. // return false;
  829. //}
  830. //else
  831. {
  832. if (ultraGrid2.ActiveRow == null)
  833. {
  834. MessageUtil.ShowTips("请选择发货单行进行操作!");
  835. return false;
  836. }
  837. String strDeliverySubLineSqe = ultraGrid2.ActiveRow.GetCellValue("deliverySubLineSqe").ToString().Trim();
  838. if (String.IsNullOrEmpty(strDeliverySubLineSqe))
  839. {
  840. MessageUtil.ShowTips("送货单行号为空");
  841. }
  842. ExcDeliverySubC dsc = this.execute<ExcDeliverySubC>("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "findById", new object[] { strDeliverySubLineSqe });
  843. if (dsc.MeteringFlag != "1")
  844. {
  845. if (MessageUtil.ShowYesNoAndQuestion("该物料不需要过磅,是否继续操作 ?") != DialogResult.Yes)
  846. {
  847. return false;
  848. }
  849. }
  850. if (dsc.Ismeter == "1")
  851. {
  852. if (MessageUtil.ShowYesNoAndQuestion("该物料已委托计量,确定再次写卡 ?") != DialogResult.Yes)
  853. {
  854. return false;
  855. }
  856. }
  857. String strDeliverySubId = dsc.DeliverySubId;
  858. if (String.IsNullOrEmpty(strDeliverySubId))
  859. {
  860. MessageUtil.ShowTips("送货单号为空");
  861. return false;
  862. }
  863. ExcDeliverySubM dsm = this.execute<ExcDeliverySubM>("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "findById", new object[] { strDeliverySubId });
  864. String suppCode = dsm.SuppCode;
  865. String suppName = dsm.SuppName;
  866. String deliveryLocationCode = dsm.DeliveryLocationCode;
  867. String deliveryLocation = dsm.DeliveryLocation;
  868. String itemCode = dsc.ItemCode;
  869. String itemName = dsc.ItemName;
  870. if (txt_carNumJL.Text.Trim() == "")
  871. {
  872. MessageUtil.ShowTips("车号不能为空!");
  873. txt_carNumJL.Focus();
  874. return false;
  875. }
  876. if (MessageUtil.ShowYesNoAndQuestion("确定生成供方:" + suppName + " 的计量委托?") != DialogResult.Yes)
  877. {
  878. return false;
  879. }
  880. icClass.PrepareWriteTemp();
  881. icClass.taskcode = "9";
  882. icClass.operatype = "9";//
  883. icClass.card_initflag = "3";//
  884. //icClass.totalcount = int.Parse(strDeliverySubLineSqe.Replace(orderId, "")); //送货单行号的序号
  885. icClass.carno = txt_carNumJL.Text.Trim();//车号
  886. icClass.poorder = strDeliverySubLineSqe;//订单号(最好8位,现在计量表中没有8位的单号,避免单号重复)
  887. icClass.A_materialcode = WMmatcode;//物料代码(计量系统)
  888. icClass.sourceunitcode = WMsuppCode;//供应商代码(计量系统)
  889. icClass.sourceunit = suppName;//客户名称
  890. icClass.A_material = itemName;//物料名称tg
  891. icClass.targetunitcode = WMdeliveryCode;//去向代码
  892. icClass.targetunit = deliveryLocation;//去向名称
  893. icClass.A_length = txt_length.Value.ToString().Trim();//是否每车刷卡 1:是(每次都要刷卡)0:否(此车只刷一次卡,长期有效)
  894. icClass.DoWriteTemp();
  895. if (icClass.Errored == true)
  896. {
  897. txt_message.Text = txt_message.Text + "写IC卡错误,请重新点击确认" + "\r\n";
  898. // MessageUtil.ShowTips("写IC卡错误,请重新点击确认!");
  899. return false;
  900. }
  901. if (icClass.Active)
  902. {
  903. icClass.AlarmBeep(3);
  904. txt_message.Text = txt_message.Text + "写IC卡完成" + "\r\n";
  905. //MessageUtil.ShowTips("写IC卡完成。");
  906. disConnect();
  907. //修改送货单行状态
  908. ExcDeliverySubC EdnC = new ExcDeliverySubC();
  909. EdnC.DeliverySubLineSqe = strDeliverySubLineSqe;
  910. EdnC.Ismeter = "1";
  911. EdnC.MeteringFlag = "1";
  912. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "doUpdate", new object[] { EdnC });
  913. }
  914. }
  915. return true;
  916. }
  917. /// <summary>
  918. /// 通知单行写卡写IC卡信息
  919. /// </summary>
  920. /// <param name="doc"></param>
  921. /// <param name="carNo"></param>
  922. /// <returns></returns>
  923. ///
  924. private bool Write1()
  925. {
  926. if (testCode() == false)
  927. {
  928. return false;
  929. }
  930. if (getConnect() == false)
  931. {
  932. return false;
  933. }
  934. if (icClass == null)
  935. {
  936. return false;
  937. }
  938. //if (icClass.IsIC == false)
  939. //{
  940. // MessageUtil.ShowTips("请放IC卡!" + icClass.IsIC);
  941. // return false;
  942. //}
  943. //else
  944. {
  945. if (ultraGrid4.ActiveRow == null)
  946. {
  947. MessageUtil.ShowTips("请选择通知单行进行操作!");
  948. return false;
  949. }
  950. String strNoticeLineSqe = ultraGrid4.ActiveRow.GetCellValue("noticeLineSqe").ToString().Trim();
  951. if (String.IsNullOrEmpty(strNoticeLineSqe))
  952. {
  953. MessageUtil.ShowTips("通知单行号为空");
  954. }
  955. ExcDeliveryNoticeC dsc = this.execute<ExcDeliveryNoticeC>("com.hnshituo.pur.ck.service.ExcDeliveryNoticeCService", "findById", new object[] { strNoticeLineSqe });
  956. if (dsc.MeteringFlag != "1")
  957. {
  958. if (MessageUtil.ShowYesNoAndQuestion("该物料不需要过磅,是否继续操作 ?") != DialogResult.Yes)
  959. {
  960. return false;
  961. }
  962. }
  963. if (txt_QtyJL.Value == null)
  964. {
  965. MessageUtil.ShowTips("请输入计量重量");
  966. }
  967. double dbCreateQty = Convert.ToDouble(txt_QtyJL.Value);
  968. double dbcreatedQty=(double)(dsc.CreatedQty == null ? 0 :dsc.CreatedQty);
  969. Double canJLQty = (double)dsc.Qty - dbcreatedQty;
  970. if (canJLQty<=0)
  971. {
  972. MessageUtil.ShowTips("已经全部生成送货单,或请采用送货单进行发送计量委托");
  973. return false;
  974. }
  975. if (dbCreateQty > canJLQty)
  976. {
  977. MessageUtil.ShowTips("该通知单行最大可编制:" + canJLQty);
  978. return false;
  979. }
  980. String strNoticeId = dsc.NoticeId;
  981. ExcDeliveryNoticeM dsm = this.execute<ExcDeliveryNoticeM>("com.hnshituo.pur.ck.service.ExcDeliveryNoticeMService", "findById", new object[] { strNoticeId });
  982. //准备数据写入
  983. ExcDeliverySubM sm = new ExcDeliverySubM();
  984. sm.NoticeId = strNoticeId;
  985. sm.Status = "1";
  986. sm.OrderId = dsm.OrderId;
  987. sm.DeliveryLocationCode = dsm.DeliveryLocationCode;
  988. sm.DeliveryLocation = dsm.DeliveryLocation;
  989. sm.SuppCode = dsm.SuppCode;
  990. sm.SuppName = dsm.SuppName;
  991. sm.PlanedDeliveryDate = DateTime.Now;
  992. sm.Validflag = "1";
  993. sm.CreateName = UserInfo.GetUserName();
  994. sm.CreateUserid = UserInfo.GetUserID();
  995. sm.CreateTime = DateTime.Now;
  996. sm.DeliveryCondition = dsm.DeliveryCondition;
  997. sm.BuyerDeptCode = UserInfo.GetDeptid();
  998. sm.DeliveryType = dsm.DeliveryType;
  999. sm.ReceiveType = dsc.ReceiveType;
  1000. List<ExcDeliverySubC> list = new List<ExcDeliverySubC>();
  1001. ExcDeliverySubC sc = new ExcDeliverySubC();
  1002. sc.NoticeId = strNoticeId;
  1003. sc.OrderId = dsc.OrderId;
  1004. sc.OrderLineSqe = dsc.OrderLineSqe;
  1005. sc.NoticeLineSqe = dsc.NoticeLineSqe;
  1006. sc.ItemCode = dsc.ItemCode;
  1007. sc.ItemDesc = dsc.ItemDesc;
  1008. sc.ItemDescE = dsc.ItemDescE;
  1009. sc.ItemName = dsc.ItemName;
  1010. sc.ItemUom = dsc.ItemUom;
  1011. sc.ItemUomId = dsc.ItemUomId;
  1012. sc.WeightUnit = dsc.WeightUnit;
  1013. sc.ItemUomConefficient = dsc.ItemUomConefficient;
  1014. sc.ItemUseUom = dsc.ItemUseUom;
  1015. sc.ItemAttr = dsc.ItemAttr;//物料属性
  1016. sc.ItemAttrId = dsc.ItemAttrId;//属性编码
  1017. sc.ItemStandardsCode = dsc.ItemStandardsCode;
  1018. sc.ItemStandardsId = dsc.ItemStandardsId;
  1019. sc.ItemUnique = dsc.ItemUnique;
  1020. sc.Qty = dbCreateQty;//送货数量
  1021. String strBatchNo = txt_batchNo.Text.Trim();
  1022. if (dsc.BatchFlag == "1")//批次控制
  1023. {
  1024. if (String.IsNullOrEmpty(strBatchNo))
  1025. {
  1026. MessageUtil.ShowTips("物料:" + dsc.ItemName + "为批次控制物料,请输入生成批次号!");
  1027. return false;
  1028. }
  1029. }
  1030. sc.BatchNo = strBatchNo;
  1031. if (String.IsNullOrEmpty(txt_carNumJL.Text.Trim()))
  1032. {
  1033. MessageUtil.ShowTips("请输入车号!");
  1034. return false;
  1035. }
  1036. String strCarNumC = txt_carNumJL.Text.Trim();
  1037. sc.CarNum = strCarNumC;
  1038. sc.ReceiveType = dsc.ReceiveType;
  1039. sc.BuyerName = dsc.BuyerName;
  1040. sc.MeteringFlag ="1";
  1041. sc.BatchFlag = dsc.BatchFlag;
  1042. sc.PcFlag = dsc.PcFlag;
  1043. sc.Ismeter = "1";
  1044. sc.CreateName = UserInfo.GetUserName();
  1045. sc.CreateUserid = UserInfo.GetUserID();
  1046. sc.CreateTime = DateTime.Now;
  1047. sc.Validflag = "1";
  1048. sc.Status = "1";//待收货
  1049. sc.ShippedQty = 0;
  1050. sc.ShipQty = 0;
  1051. sc.ReceivedQty = 0;
  1052. sc.PackageType = dsc.PackageType;
  1053. list.Add(sc);
  1054. if (MessageUtil.ShowYesNoAndQuestion("确定生成供方:" + dsm.SuppName + "的计量委托?") != DialogResult.Yes)
  1055. {
  1056. return false;
  1057. }
  1058. CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "insert_PC", new object[] { sm, list });
  1059. if (re.Resultcode != 0)
  1060. {
  1061. MessageUtil.ShowTips("发送计量委托失败:生成送货单失败" + re.Resultmsg);
  1062. return false;
  1063. }
  1064. String suppCode = dsm.SuppCode;
  1065. String suppName = dsm.SuppName;
  1066. String deliveryLocationCode = dsm.DeliveryLocationCode;
  1067. String deliveryLocation = dsm.DeliveryLocation;
  1068. String itemCode = dsc.ItemCode;
  1069. String itemName = dsc.ItemName;
  1070. String strDeliverySubId = re.Resultmsg;
  1071. String strDeliverySubLineSqe = re.Resultdata.ToString();
  1072. if (String.IsNullOrEmpty(strDeliverySubId))
  1073. {
  1074. MessageUtil.ShowTips("送货单号为空");
  1075. }
  1076. if (String.IsNullOrEmpty(strDeliverySubLineSqe))
  1077. {
  1078. MessageUtil.ShowTips("送货单行号为空");
  1079. }
  1080. icClass.PrepareWriteTemp();
  1081. icClass.taskcode = "9";
  1082. icClass.operatype = "9";//
  1083. icClass.card_initflag = "3";//
  1084. //icClass.totalcount = int.Parse(strDeliverySubLineSqe.Replace(orderId, "")); //送货单行号的序号
  1085. icClass.carno = txt_carNumJL.Text;//车号
  1086. icClass.poorder = strDeliverySubLineSqe;//订单号(最好8位,现在计量表中没有8位的单号,避免单号重复)
  1087. icClass.sourceunit = suppName;//客户名称
  1088. icClass.A_materialcode = WMmatcode;//物料代码(计量系统)
  1089. icClass.sourceunitcode = WMsuppCode;//供应商代码(计量系统)
  1090. icClass.A_material = itemName;//物料名称tg
  1091. icClass.targetunitcode = WMdeliveryCode;//去向代码
  1092. icClass.targetunit = deliveryLocation;//去向名称
  1093. icClass.A_length = txt_length.Value.ToString().Trim();//是否每车刷卡 1:是(每次都要刷卡)0:否(此车只刷一次卡,长期有效)
  1094. icClass.B_memo = memo.Text;
  1095. icClass.DoWriteTemp();
  1096. if (icClass.Errored == true)
  1097. {
  1098. txt_message.Text = txt_message.Text + "写IC卡错误,请重新点击确认" + "\r\n";
  1099. //MessageUtil.ShowTips("写IC卡错误,请重新点击确认!");
  1100. return false;
  1101. }
  1102. if (icClass.Active)
  1103. {
  1104. icClass.AlarmBeep(3);
  1105. txt_message.Text = txt_message.Text + "写IC卡完成,同时生成送货单:" +strDeliverySubId+ "\r\n";
  1106. // MessageUtil.ShowTips("写IC卡完成。");
  1107. disConnect();
  1108. }
  1109. }
  1110. return true;
  1111. }
  1112. private bool testCode()
  1113. {
  1114. if (WMmatcode.Trim() == "" || WMsuppCode.Trim() == "" || WMdeliveryCode.Trim() == "")
  1115. {
  1116. if (WMmatcode.Trim() == "")
  1117. {
  1118. txt_message.Text = txt_message.Text + "该物料编码未在计量系统维护,请联系计控维护" + "\r\n";
  1119. }
  1120. if (WMsuppCode.Trim() == "")
  1121. {
  1122. txt_message.Text = txt_message.Text + "该供方编码未在计量系统维护,请联系计控维护" + "\r\n";
  1123. }
  1124. if (WMdeliveryCode.Trim() == "")
  1125. {
  1126. txt_message.Text = txt_message.Text + "该交付地址未在计量系统维护,请联系计控维护" + "\r\n";
  1127. }
  1128. return false;
  1129. }
  1130. return true;
  1131. }
  1132. #endregion
  1133. #region 公共用函数
  1134. private bool testSubC(string strDeliverySubLineSqe)
  1135. {
  1136. ExcDeliverySubC dsc = this.execute<ExcDeliverySubC>("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "findById", new object[] { strDeliverySubLineSqe });
  1137. if (dsc == null)
  1138. {
  1139. MessageUtil.ShowTips("未发现送货单行:" + strDeliverySubLineSqe + "信息记录,可能已被删除,或请刷新界面重试");
  1140. return false;
  1141. }
  1142. if (dsc.Validflag != "1")
  1143. {
  1144. MessageUtil.ShowTips("送货单行:" + strDeliverySubLineSqe + "信息记录可能已被删除,或请刷新界面重试");
  1145. return false;
  1146. }
  1147. if (!String.IsNullOrEmpty(dsc.CheckNo))
  1148. {
  1149. MessageUtil.ShowTips("送货单行:" + strDeliverySubLineSqe + "已生成检化验委托,无需重复操作!");
  1150. return false;
  1151. }
  1152. return true;
  1153. }
  1154. //清空jl编辑区
  1155. private void clearSampleTabJL()
  1156. {
  1157. txt_QtyJL.Value = 0;
  1158. ck_meterFlag.Checked = false;
  1159. ck_meterFlag.Enabled = true;
  1160. txt_carNumJL.Clear();
  1161. }
  1162. /// <summary>
  1163. /// 校验检验号是否可以作废
  1164. /// </summary>
  1165. /// <param name="strCheckNo"></param>
  1166. /// <returns></returns>
  1167. private bool testSampleNo(string strCheckNo)
  1168. {
  1169. CheckconsignDetail detail = new CheckconsignDetail();
  1170. detail.CheckNo = strCheckNo;
  1171. List<CheckconsignDetail> list = this.execute<List<CheckconsignDetail>>("com.hnshituo.pur.ck.service.CheckconsignDetailService", "find", new object[] { detail, 0, 0 });
  1172. if (list != null)
  1173. {
  1174. if (list.Count > 0)
  1175. {
  1176. foreach (CheckconsignDetail det in list)
  1177. {
  1178. if (det.Flag != "-1")
  1179. {
  1180. MessageUtil.ShowTips("该检化验项委托可能已发送,不能作废!");
  1181. return false;
  1182. }
  1183. }
  1184. }
  1185. else
  1186. {
  1187. MessageUtil.ShowTips("未发现检化验号:" + strCheckNo + "检验项明细!");
  1188. return false;
  1189. }
  1190. }
  1191. else
  1192. {
  1193. MessageUtil.ShowTips("未发现检化验号:" + strCheckNo + "检验项明细!");
  1194. return false;
  1195. }
  1196. return true;
  1197. }
  1198. /// <summary>
  1199. /// 初检或者取消初检校验
  1200. /// </summary>
  1201. /// <param name="deliverySubId"></param>
  1202. /// <param name="p"></param>
  1203. /// <returns></returns>
  1204. private bool testDeliveryStatus(String deliverySubId, int p)
  1205. {
  1206. if (String.IsNullOrEmpty(deliverySubId))
  1207. {
  1208. MessageUtil.ShowTips("送货单行号为空,无法校验数据有效性");
  1209. return false;
  1210. }
  1211. ExcDeliverySubC subc = this.execute<ExcDeliverySubC>("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "findById", new object[] { deliverySubId });
  1212. if (subc == null)
  1213. {
  1214. MessageUtil.ShowTips("未发现送货单行:" + deliverySubId + "信息记录,可能已作废,或请刷新界面重试");
  1215. return false;
  1216. }
  1217. if (subc.Validflag != "1")
  1218. {
  1219. MessageUtil.ShowTips("未发现送货单行:" + deliverySubId + "信息记录,可能已作废,或请刷新界面重试");
  1220. return false;
  1221. }
  1222. String testStatus = subc.Status;
  1223. if (String.IsNullOrEmpty(subc.DeliverySubId))
  1224. {
  1225. MessageUtil.ShowTips("未找到送货单行的头信息");
  1226. return false;
  1227. }
  1228. ExcDeliverySubM subM = this.execute<ExcDeliverySubM>("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "findById", new object[] { subc.DeliverySubId });
  1229. if (subM == null)
  1230. {
  1231. MessageUtil.ShowTips("未发现送货单:" + subc.DeliverySubId + "信息记录,可能已作废,或请刷新界面重试");
  1232. return false;
  1233. }
  1234. if (subM.Validflag != "1")
  1235. {
  1236. MessageUtil.ShowTips("未发现送货单:" + subc.DeliverySubId + "信息记录,可能已作废,或请刷新界面重试");
  1237. return false;
  1238. }
  1239. if (subM.Status != "1")
  1240. {
  1241. MessageUtil.ShowTips("送货单:" + subc.DeliverySubId + "可能已经收货完成,或请刷新界面重试");
  1242. return false;
  1243. }
  1244. //完成初检校验
  1245. if (p == 1)
  1246. {
  1247. if (testStatus != "1")
  1248. {
  1249. MessageUtil.ShowTips("送货单行:" + deliverySubId + "可能已经初检完成,或请刷新界面重试");
  1250. return false;
  1251. }
  1252. }
  1253. //取消初检校验
  1254. else if (p == 2)
  1255. {
  1256. if (testStatus != "2" && testStatus != "3")
  1257. {
  1258. MessageUtil.ShowTips("送货单行:" + deliverySubId + "可能还未完成初检或已经(待检)入库,或请刷新界面重试");
  1259. return false;
  1260. }
  1261. }
  1262. else
  1263. {
  1264. MessageUtil.ShowTips("未知参数:" + p);
  1265. return false;
  1266. }
  1267. return true;
  1268. }
  1269. /// <summary>
  1270. /// 查询送货单行
  1271. /// </summary>
  1272. private void queryDeliverySubC(String tips)
  1273. {
  1274. try
  1275. {
  1276. dataTable2.Clear();
  1277. UltraGridRow uge = ultraGrid1.ActiveRow;
  1278. if (uge == null)
  1279. {
  1280. return;
  1281. }
  1282. String strDeliverySubId = uge.GetCellValue("deliverySubId").ToString().Trim();
  1283. if (String.IsNullOrEmpty(strDeliverySubId))
  1284. {
  1285. MessageUtil.ShowTips("送货单号为空");
  1286. }
  1287. if (tips != "0")
  1288. {
  1289. dataTable2.Clear();
  1290. ultraGrid2.Update();
  1291. }
  1292. ExcDeliverySubC EdSc = new ExcDeliverySubC();
  1293. EdSc.DeliverySubId = strDeliverySubId;
  1294. EdSc.Validflag = "1";
  1295. if (ck_isAllMeter.Checked)
  1296. {
  1297. EdSc.MeteringFlag = "1";
  1298. }
  1299. if (txt_status.SelectedIndex == 1)//待计量
  1300. {
  1301. EdSc.Ismeter = "0";
  1302. }
  1303. else if (txt_status.SelectedIndex == 2)//已经计量
  1304. {
  1305. EdSc.Ismeter = "1";
  1306. }
  1307. else//全部
  1308. {
  1309. //
  1310. }
  1311. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "Query_C", new object[] { EdSc });
  1312. GridHelper.CopyDataToDatatable(dt, dataTable2, true);
  1313. GridHelper.RefreshAndAutoSize(ultraGrid2);
  1314. }
  1315. catch (Exception ex)
  1316. {
  1317. MessageUtil.ShowTips("加载送货单行信息失败:" + ex);
  1318. }
  1319. }
  1320. /// <summary>
  1321. /// 查询通知单行
  1322. /// </summary>
  1323. private void queryNoticeC(String tips)
  1324. {
  1325. try
  1326. {
  1327. dataTable4.Clear();
  1328. UltraGridRow uge = ultraGrid3.ActiveRow;
  1329. if (uge == null)
  1330. {
  1331. return;
  1332. }
  1333. String strNoticeId = uge.Cells["NoticeId"].Value.ToString();
  1334. if (tips!= "0")
  1335. {
  1336. dataTable4.Clear();
  1337. ultraGrid4.Update();
  1338. }
  1339. ExcDeliveryNoticeC EdnC = new ExcDeliveryNoticeC();
  1340. EdnC.NoticeId = strNoticeId;
  1341. EdnC.Validflag = "1";
  1342. if (ck_isAllMeter.Checked)
  1343. {
  1344. EdnC.MeteringFlag = "1";
  1345. }
  1346. if (txt_status.SelectedIndex == 1)//待计量
  1347. {
  1348. EdnC.DeleteUserid = "0";
  1349. }
  1350. else if (txt_status.SelectedIndex == 2)//已经计量
  1351. {
  1352. EdnC.DeleteUserid = "1";
  1353. }
  1354. else//全部
  1355. {
  1356. //
  1357. }
  1358. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliveryNoticeCService", "find_EdnC", new object[] { EdnC });
  1359. GridHelper.CopyDataToDatatable(dt, dataTable4, true);
  1360. GridHelper.RefreshAndAutoSize(ultraGrid4);
  1361. }
  1362. catch (Exception ex)
  1363. {
  1364. MessageUtil.ShowTips("加载通知单行信息失败:" + ex);
  1365. }
  1366. }
  1367. #endregion
  1368. private void txt_length_TextChanged(object sender, EventArgs e)
  1369. {
  1370. if(txt_length.Text.ToString()=="每车刷卡")
  1371. {
  1372. txt_length.Value = "1";
  1373. }
  1374. else
  1375. {
  1376. txt_length.Value = "0";
  1377. }
  1378. }
  1379. }
  1380. }