frmCkInBillNewTest.cs 108 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375
  1. using System;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Windows.Forms;
  11. using CoreFS.CA06;
  12. using Pur.Entity.configureEntity;
  13. using Core.Mes.Client.Comm.Control;
  14. using System.Collections;
  15. using com.hnshituo.pur.vo;
  16. using Infragistics.Win.UltraWinEditors;
  17. using Infragistics.Win;
  18. using Pur.Entity.ck;
  19. using Core.Mes.Client.Comm.Tool;
  20. using Pur.configure;
  21. using Pur.Pop_upWindow;
  22. using Infragistics.Win.UltraWinGrid;
  23. using Pur.require_plan;
  24. using Core.Mes.Client.Comm.Server;
  25. using Pur.Entity;
  26. using Pur.PublicTools;
  27. using com.hnshituo.ck;
  28. namespace Pur.ck
  29. {
  30. public partial class frmCkInBillNewTest : FrmPmsBase
  31. {
  32. Hashtable ht = new Hashtable();//存放库区对应的库位
  33. String strCoustomInfo = "";//若有值,则需单独配置物料接收界面
  34. public frmCkInBillNewTest()
  35. {
  36. InitializeComponent();
  37. }
  38. private void frmCkInBillNew_Shown(object sender, System.EventArgs e)
  39. {
  40. this.ToolBarItemEnable(this, "conFirmation", true);
  41. this.ToolBarItemEnable(this, "confirmation1", true);
  42. this.ToolBarItemEnable(this, "QuitCkRecBill", false);
  43. }
  44. private void frmCkInBillNew_Load(object sender, EventArgs e)
  45. {
  46. strCoustomInfo = this.CustomInfo == null ? "" : this.CustomInfo.ToString().Trim();
  47. if (String.IsNullOrEmpty(strCoustomInfo))
  48. {
  49. QcreateTime_BeginJL.Value = DateTime.Now.AddMonths(-1);
  50. QcreateTime_BeginSJ.Value = DateTime.Now.AddMonths(-1);
  51. }
  52. else
  53. {
  54. QcreateTime_BeginJL.Value = DateTime.Now.AddDays(-3);
  55. QcreateTime_BeginSJ.Value = DateTime.Now.AddDays(-3);
  56. }
  57. QcreateTime_EndJL.Value = DateTime.Now.AddDays(2);
  58. QcreateTime_BeginJL.Enabled = true;
  59. QcreateTime_EndJL.Enabled = true;
  60. ck_createtimeJL.Checked = true;
  61. QcreateTime_EndSJ.Value = DateTime.Now.AddDays(2);
  62. QcreateTime_BeginSJ.Enabled = true;
  63. QcreateTime_EndSJ.Enabled = true;
  64. ck_createtimeSJ.Checked = true;
  65. txt_shuttTimeStart_JL.Value = DateTime.Now.AddDays(-3);
  66. txt_shuttTimeEnd_JL.Value = DateTime.Now.AddDays(1);
  67. txt_shuttTimeStart_JL.Enabled = false;
  68. txt_shuttTimeEnd_JL.Enabled = false;
  69. ck_shutt_JL.Checked = false;
  70. //初始化加载价格政策
  71. BalanceBasepriceM pm = new BalanceBasepriceM();
  72. pm.Flag = "2";
  73. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.balance.service.BalanceBasepriceMService", "doQureyBasePriceM", new object[] { pm });
  74. cbxJGZC.DataSource = dt;
  75. cbxJGZC.DisplayMember = "name";
  76. cbxJGZC.ValueMember = "id";
  77. PublicPur.InitCellEdit(new UltraGrid[] { GridSubDJL }, new string[] { "Check", "INVPOS", "numException","invPosException", "remarkException","CheckStatu","CheckResult", "KZQTY", "PACKAGEUNIT", "PACKAGEQTY", "ITEMUOMCONEFFICIENT", "JLQTY" });
  78. QstatusJL.SelectedIndex = 0;
  79. QstatusSJ.SelectedIndex = 0;
  80. GridSubDJL.Cursor = Cursors.Default;
  81. GridSubDSJ.Cursor = Cursors.Default;
  82. }
  83. #region toolbar工具栏
  84. public override void ToolBar_Click(object sender, string ToolbarKey)
  85. {
  86. switch (ToolbarKey)
  87. {
  88. case "Query":
  89. Get_PUR_EXC_DELIVERY_M("");
  90. break;
  91. case "conFirmation"://待检入库
  92. instock("1");
  93. break;
  94. case "confirmation1"://正式入库
  95. instock("2");
  96. break;
  97. case "QuitCkRecBill"://撤销入库
  98. QuitCkRecBill();
  99. break;
  100. case "doExcel"://导出excel
  101. doExcel();
  102. break;
  103. case "doSplit"://拆分送货行
  104. doSplit();
  105. break;
  106. case "ESC":
  107. this.Close();
  108. break;
  109. }
  110. }
  111. /// <summary>
  112. /// 查询送货通知单主表
  113. /// </summary>
  114. private void Get_PUR_EXC_DELIVERY_M(String strsubId)
  115. {
  116. //清空数据
  117. try
  118. {
  119. this.Cursor=Cursors.WaitCursor;
  120. publicPms.clearOldData(panel_JL, new string[] { });
  121. publicPms.clearOldData(panel_sj, new string[] { });
  122. JHY.Clear();
  123. JLdata.Clear();
  124. exception.Clear();
  125. inbill.Clear();
  126. if(ultraTabControl1.SelectedTab.Key=="2")
  127. {
  128. subMJL.Clear();
  129. subDJL.Clear();
  130. doQueryM("1", "2", strsubId);
  131. }
  132. else if(ultraTabControl1.SelectedTab.Key=="3")
  133. {
  134. subMSJ.Clear();
  135. subDSJ.Clear();
  136. doQueryM("", "3", strsubId);
  137. }
  138. else{
  139. MessageUtil.ShowTips("未知参数");
  140. }
  141. }
  142. catch(Exception ex)
  143. {
  144. MessageUtil.ShowTips("加载数据失败:"+ex.Message);
  145. }
  146. finally
  147. {
  148. this.Cursor=Cursors.Default;
  149. }
  150. }
  151. /// <summary>
  152. /// 正式入库单
  153. /// </summary>
  154. private void setCkInBllList()
  155. {
  156. instock("1");
  157. }
  158. /// <summary>
  159. /// 待检入库
  160. /// </summary>
  161. private void setWaitChk_CkInBllList()
  162. {
  163. instock("2");
  164. }
  165. /// <summary>
  166. /// 撤销入库
  167. /// </summary>
  168. private void QuitCkRecBill()
  169. {
  170. UltraGrid ug = null;
  171. if (ultraTabControl1.SelectedTab.Key == "3")//计量
  172. {
  173. ug = GridSubDSJ;
  174. }
  175. else
  176. {
  177. MessageUtil.ShowTips("请选择需撤销入库的实绩");
  178. return;
  179. }
  180. ug.UpdateData();
  181. if (ug.Rows.Count <= 0)
  182. {
  183. MessageUtil.ShowTips("无可操作送货单行");
  184. return;
  185. }
  186. ArrayList aledsc = new ArrayList();
  187. ExcDeliverySubC edsc1 = new ExcDeliverySubC();
  188. ExcDeliverySubM edsM = new ExcDeliverySubM();
  189. foreach (UltraGridRow ugr in ug.Rows)
  190. {
  191. if (ugr.Hidden || !(bool)ugr.Cells["Check"].Value)
  192. { continue; }
  193. ExcDeliverySubC edsc = new ExcDeliverySubC();
  194. String strSubSqe = ugr.Cells["DeliverySubLineSqe"].Value.ToString().Trim();
  195. edsc.DeliverySubLineSqe = strSubSqe;
  196. if (!testDeliveryStatus(strSubSqe, 3, ref edsc1,ref edsM))
  197. {
  198. return;
  199. }
  200. edsc.UpdateName = UserInfo.GetUserName();
  201. edsc.UpdateUserid = UserInfo.GetUserID();
  202. edsc.UpdateTime = DateTime.Now;
  203. aledsc.Add(edsc);
  204. }
  205. if (aledsc.Count <= 0)
  206. {
  207. MessageUtil.ShowTips("请勾选送货单");
  208. return;
  209. }
  210. if (MessageUtil.ShowYesNoAndQuestion("确定撤销勾选的" + aledsc.Count + "条送货单行的入库记录?") == DialogResult.No)
  211. {
  212. return;
  213. }
  214. CoreResult crt = this.GetJsonService().execute<CoreResult>("com.hnshituo.pur.ck.service.CkInBillService", "QuitCkRecBill", new object[] { aledsc,strCoustomInfo});
  215. if (crt.Resultcode != 0)
  216. {
  217. MessageUtil.ShowTips("撤销入库失败 " + crt.Resultmsg);
  218. return;
  219. }
  220. MessageUtil.ShowTips("撤销入库成功");
  221. //循环判断此送货单是否全部收货,全部收货则关闭收货单
  222. Get_PUR_EXC_DELIVERY_M("");
  223. }
  224. /// <summary>
  225. /// 导出Excel
  226. /// </summary>
  227. private void doExcel()
  228. {
  229. try
  230. {
  231. this.Cursor = Cursors.Default;
  232. if (ultraTabControl1.SelectedTab.Key == "2")
  233. {
  234. if (GridSubDJL.Rows.Count <= 0)
  235. {
  236. MessageUtil.ShowTips("无可导出明细!");
  237. return;
  238. }
  239. ArrayList alUltraGrid = new ArrayList();
  240. alUltraGrid.Add(GridSubDJL);
  241. ArrayList alSheeft = new ArrayList();
  242. alSheeft.Add("计量待入库明细");
  243. GridHelper.ulGridToExcel(alUltraGrid, alSheeft, "计量待入库明细");
  244. }
  245. else
  246. {
  247. if (GridSubDSJ.Rows.Count <= 0)
  248. {
  249. MessageUtil.ShowTips("无可导出明细!");
  250. return;
  251. }
  252. ArrayList alUltraGrid = new ArrayList();
  253. alUltraGrid.Add(GridSubDSJ);
  254. ArrayList alSheeft = new ArrayList();
  255. alSheeft.Add("已入库明细");
  256. GridHelper.ulGridToExcel(alUltraGrid, alSheeft, "已入库明细");
  257. }
  258. }
  259. catch (Exception e)
  260. {
  261. MessageUtil.ShowTips("导出失败" + e.Message);
  262. }
  263. finally
  264. {
  265. this.Cursor = Cursors.Default;
  266. }
  267. }
  268. private DateTime setCreateTimeStart(Object value)
  269. {
  270. DateTime time = Convert.ToDateTime(value);
  271. DateTime endtime = new DateTime(time.Year, time.Month, time.Day, 0, 0, 0);
  272. return endtime;
  273. }
  274. private DateTime setCreateTimeEnd(Object value) {
  275. DateTime time = Convert.ToDateTime(value);
  276. DateTime endtime = new DateTime(time.Year, time.Month, time.Day,23,59,59);
  277. return endtime;
  278. }
  279. #endregion
  280. private void doSplit()
  281. {
  282. double QtyUse = 0;
  283. ArrayList list = new ArrayList();
  284. foreach (UltraGridRow ugr2 in GridJL_JL.Rows)
  285. {
  286. ExcDeliverySubC subc = new ExcDeliverySubC();
  287. subc.Qty = Math.Round(double.Parse("1"), 3);
  288. subc.Matchid = ugr2.Cells["matchid"].Value.ToString();
  289. QtyUse = QtyUse + (double)subc.Qty;
  290. list.Add(subc);
  291. }
  292. if (MessageUtil.ShowYesNoAndQuestion("确定拆分送货单行") == DialogResult.No)
  293. {
  294. return;
  295. }
  296. ExcDeliverySubC subcNew = new ExcDeliverySubC();
  297. subcNew.DeliverySubLineSqe = GridSubMJL.ActiveRow.Cells["DELIVERYSUBID"].Value.ToString2() + "001";
  298. subcNew.CreateUserid = UserInfo.GetUserID();
  299. subcNew.CreateTime = DateTime.Now;
  300. subcNew.CreateName = UserInfo.GetUserName();
  301. CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "doSplit", new object[] { list, subcNew });
  302. if (rt.Resultcode != 0)
  303. {
  304. MessageUtil.ShowTips("操作失败:" + rt.Resultmsg);
  305. return;
  306. }
  307. else
  308. {
  309. getCheckdSubMCol(GridSubMJL, "2");
  310. MessageUtil.ShowTips("操作成功");
  311. return;
  312. }
  313. }
  314. private void GridSubMJL_CellChange(object sender, CellEventArgs e)
  315. {
  316. if (e.Cell.Column.Key == "CHK")
  317. {
  318. UltraGridRow chkRow = e.Cell.Row;
  319. foreach (UltraGridRow row in GridSubMJL.Rows)
  320. {
  321. if (row.Cells["Chk"].Value.ToString() == "True" && row != chkRow)
  322. {
  323. row.Cells["Chk"].Value = "False";
  324. row.Update();
  325. }
  326. }
  327. getCheckdSubMCol(GridSubMJL, "2");
  328. }
  329. }
  330. private void GridSubMSJ_CellChange(object sender, CellEventArgs e)
  331. {
  332. if (e.Cell.Column.Key == "CHK")
  333. {
  334. getCheckdSubMCol(GridSubMSJ, "3");
  335. }
  336. }
  337. /// <summary>
  338. /// 计量grid
  339. /// </summary>
  340. /// <param name="sender"></param>
  341. /// <param name="e"></param>
  342. private void GridSubDJL_CellChange(object sender, CellEventArgs e)
  343. {
  344. GridSubDJL.UpdateData();
  345. UltraGridRow ugr = e.Cell.Row;
  346. if (e.Cell.Column.Key == "CheckStatu")//选择判定结果
  347. {
  348. if (e.Cell.Value.ToString() == "0")
  349. {
  350. setCellColor(ugr, System.Drawing.Color.FromArgb(255, 255, 128), "InvPosException", "RemarkException", "CheckStatu", "KZQTY", "PACKAGEUNIT", "PACKAGEQTY", "ITEMUOMCONEFFICIENT", "JLQTY");
  351. //ugr.Cells["INNUM"].Value = 0;//入库量=收货量
  352. //ugr.Cells["numException"].Value = ugr.Cells["SHIPQTY"].Value;//待处置量
  353. getJlInNum(ugr);
  354. }
  355. else
  356. {
  357. setCellColor(ugr, System.Drawing.Color.FromArgb(255, 255, 128), "INVPOS", "CheckStatu", "KZQTY", "PACKAGEUNIT", "PACKAGEQTY", "ITEMUOMCONEFFICIENT", "JLQTY");
  358. //ugr.Cells["INNUM"].Value = ugr.Cells["SHIPQTY"].Value;//入库量=收货量
  359. //ugr.Cells["numException"].Value = 0;//待处置量
  360. getJlInNum(ugr);
  361. }
  362. }
  363. if (e.Cell.Column.Key == "KZQTY" || e.Cell.Column.Key == "ITEMUOMCONEFFICIENT" || e.Cell.Column.Key == "JLQTY")//口杂
  364. {
  365. if (e.Cell.Column.Key == "JLQTY")
  366. {
  367. ugr.Cells["SHIPQTY"].Value = ugr.Cells["JLQTY"].Value;
  368. }
  369. getJlInNum(ugr);
  370. }
  371. if (e.Cell.Column.Key == "PACKAGEQTY")
  372. {
  373. getInNum(ugr, "1");
  374. }
  375. if (e.Cell.Column.Key == "INVPOS")//选择储位
  376. {
  377. GridSubDJL.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand);
  378. //comm.RefreshAndAutoSizeExceptColumns(ultraGrid1);
  379. }
  380. }
  381. /// <summary>
  382. ///
  383. /// </summary>
  384. /// <param name="sender"></param>
  385. /// <param name="e"></param>
  386. private void GridJL_CellChange(object sender, CellEventArgs e)
  387. {
  388. //匹配的料型是否一致
  389. if (e.Cell.Column.Key == "Check")
  390. foreach (UltraGridRow ugr2 in GridJL_JL.Rows)
  391. {
  392. if ((bool)ugr2.Cells["Check"].Value)
  393. {
  394. if (e.Cell.Row.Cells["materielRule"].Value.ToString() == ugr2.Cells["materielRule"].Value.ToString() && e.Cell.Row != ugr2)
  395. {
  396. comm.ConfirmOption("勾选匹配的计量料型必须一致");
  397. e.Cell.Row.Cells["Check"].Value = false;
  398. return;
  399. }
  400. }
  401. }
  402. }
  403. private void ck_createtimeJL_CheckedChanged(object sender, System.EventArgs e)
  404. {
  405. QcreateTime_BeginJL.Enabled = ck_createtimeJL.Checked;
  406. QcreateTime_EndJL.Enabled = ck_createtimeJL.Checked;
  407. }
  408. private void ck_createtimeSJ_CheckedChanged(object sender, System.EventArgs e)
  409. {
  410. QcreateTime_BeginSJ.Enabled = ck_createtimeSJ.Checked;
  411. QcreateTime_EndSJ.Enabled = ck_createtimeSJ.Checked;
  412. }
  413. private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
  414. {
  415. publicPms.clearOldData(panel_sj, new string[] { });
  416. publicPms.clearOldData(panel_JL, new string[] { });
  417. JHY.Clear();
  418. JLdata.Clear();
  419. exception.Clear();
  420. if (ultraTabControl1.SelectedTab.Key == "1" || ultraTabControl1.SelectedTab.Key == "2")
  421. {
  422. this.ToolBarItemEnable(this, "conFirmation", true);
  423. this.ToolBarItemEnable(this, "confirmation1", true);
  424. this.ToolBarItemEnable(this, "QuitCkRecBill", false);
  425. }
  426. else
  427. {
  428. this.ToolBarItemEnable(this, "conFirmation", false);
  429. this.ToolBarItemEnable(this, "confirmation1", false);
  430. this.ToolBarItemEnable(this, "QuitCkRecBill", true);
  431. }
  432. }
  433. private void GridSubMSJ_AfterHeaderCheckStateChanged(object sender, AfterHeaderCheckStateChangedEventArgs e)
  434. {
  435. if (e.Column.Key == "CHK")
  436. {
  437. getCheckdSubMCol(GridSubMSJ, "3");
  438. }
  439. }
  440. private void GridSubMJL_AfterHeaderCheckStateChanged(object sender, AfterHeaderCheckStateChangedEventArgs e)
  441. {
  442. if (e.Column.Key == "CHK")
  443. {
  444. getCheckdSubMCol(GridSubMJL, "2");
  445. }
  446. }
  447. #region 行按钮
  448. /// <summary>
  449. /// 计量信息筛选
  450. /// </summary>
  451. /// <param name="sender"></param>
  452. /// <param name="e"></param>
  453. private void btn_JL_select_Click(object sender, System.EventArgs e)
  454. {
  455. UltraGridRow ugr = GridSubDJL.ActiveRow;
  456. if (ugr == null)
  457. {
  458. MessageUtil.ShowTips("请选择一个送货单的物料");
  459. return;
  460. }
  461. String sordSqe = ugr.GetCellValue("ORDERLINESQE").ToString().Trim();
  462. ArrayList list1 = new ArrayList();
  463. list1.Add(sordSqe);
  464. DataTable dtjl = getJLData((string[])list1.ToArray(typeof(string)));
  465. if (dtjl != null && dtjl.Rows.Count > 0)
  466. {
  467. GridHelper.CopyDataToDatatable(dtjl, DTJL, true);
  468. GridHelper.RefreshAndAutoSize(GridJHY_JL);
  469. }
  470. }
  471. /// <summary>
  472. /// 单个匹配送货单行
  473. /// </summary>
  474. /// <param name="sender"></param>
  475. /// <param name="e"></param>
  476. private void btn_JL_sure_Click(object sender, System.EventArgs e)
  477. {
  478. if (ultraTabControl1.SelectedTab.Key != "2")
  479. {
  480. MessageUtil.ShowTips("请选择计量入库界面");
  481. return;
  482. }
  483. UltraGridRow ugr1 = GridSubDJL.ActiveRow;
  484. if (ugr1 == null)
  485. {
  486. MessageUtil.ShowTips("请选择需匹配的送货单行");
  487. return;
  488. }
  489. UltraGridRow ugr2 = GridJL_JL.ActiveRow;
  490. if (ugr2 == null)
  491. {
  492. MessageUtil.ShowTips("请选择进行匹配的磅单");
  493. return;
  494. }
  495. String strSubSqe = ugr1.GetCellValue("DELIVERYSUBLINESQE").ToString().Trim();
  496. double numJLQTY = 0;
  497. double numTARE = 0;//皮重
  498. double numGROSS = 0; //毛重
  499. string strSUTTLETIME = "";//计量时间
  500. String strMaterielRule = "";
  501. double numKZQTY = 0;
  502. double b_txt_deduction2 = 0.00;//扣机铁
  503. double b_txt_deduction3 = 0.00;//扣超长
  504. double b_txt_deduction4 = 0.00;//扣轻薄
  505. Double.TryParse(ugr2.Cells["suttle"].Value.ToString().Trim(), out numJLQTY);
  506. Double.TryParse(ugr2.Cells["deduction"].Value.ToString().Trim(), out numKZQTY);
  507. Double.TryParse(ugr2.Cells["deduction2"].Value.ToString().Trim(), out b_txt_deduction2);//扣机铁
  508. Double.TryParse(ugr2.Cells["deduction3"].Value.ToString().Trim(), out b_txt_deduction3);//扣超长
  509. Double.TryParse(ugr2.Cells["deduction4"].Value.ToString().Trim(), out b_txt_deduction4);//扣轻薄
  510. Double.TryParse(ugr2.Cells["TARE"].Value.ToString().Trim(), out numTARE);//皮重
  511. Double.TryParse(ugr2.Cells["GROSS"].Value.ToString().Trim(), out numGROSS);//毛重
  512. string strmatchid = ugr2.Cells["matchid"].Value.ToString().Trim();//绑单号
  513. strMaterielRule = ugr2.Cells["materielRule"].Value.ToString().Trim();//废钢料型
  514. strSUTTLETIME = ugr2.Cells["SUTTLETIME"].Value.ToString().Trim();//计量时间
  515. int i = 0;
  516. String strSubSqe2 = "";
  517. foreach (UltraGridRow row in GridSubDJL.Rows)
  518. {
  519. if (row.GetCellValue("DELIVERYSUBLINESQE").ToString().Trim() != strSubSqe || row.GetCellValue("matchid").ToString().Trim() == "strmatchid")
  520. {
  521. strSubSqe2 = row.GetCellValue("DELIVERYSUBLINESQE").ToString().Trim();
  522. i = i + 1;
  523. }
  524. }
  525. if (i >= 1)
  526. {
  527. if (MessageUtil.ShowYesNoAndQuestion("送货单行:" + strSubSqe2 + "已绑定该磅单,确定重复绑定?") != DialogResult.Yes)
  528. {
  529. return;
  530. }
  531. }
  532. ugr1.Cells["JLQTY"].Value = numJLQTY;//净重
  533. ugr1.Cells["KZQTY"].Value = numKZQTY;//净扣杂
  534. ugr1.Cells["deduction2"].Value = b_txt_deduction2;//扣机铁
  535. ugr1.Cells["deduction3"].Value = b_txt_deduction3;//扣超长
  536. ugr1.Cells["deduction4"].Value = b_txt_deduction4;//扣轻薄
  537. ugr1.Cells["TARE"].Value = numTARE;//皮重
  538. ugr1.Cells["GROSS"].Value = numGROSS;//毛重
  539. ugr1.Cells["SUTTLETIME"].Value = strSUTTLETIME;//计量时间
  540. ugr1.Cells["CheckResult"].Value = strMaterielRule;//废钢料型
  541. ugr1.Cells["matchid"].Value = strmatchid;//绑单号
  542. GridSubDJL.UpdateData();
  543. }
  544. /// <summary>
  545. /// 批量确定
  546. /// </summary>
  547. /// <param name="sender"></param>
  548. /// <param name="e"></param>
  549. private void btn_JL_sure_all_Click(object sender, System.EventArgs e)
  550. {
  551. bindJLItems();
  552. }
  553. private void ck_shutt_JL_CheckedChanged(object sender, System.EventArgs e)
  554. {
  555. txt_shuttTimeStart_JL.Enabled = ck_shutt_JL.Checked;
  556. txt_shuttTimeEnd_JL.Enabled = ck_shutt_JL.Checked;
  557. }
  558. #endregion
  559. #region 公共方法
  560. /// <summary>
  561. /// 查询方法
  562. /// </summary>
  563. /// <param name="strIsMeter">是否计量</param>
  564. /// <param name="tab">加载数据页面</param>
  565. /// <param name="subId">是否激活</param>
  566. private void doQueryM(String strIsMeter,String tab,String subId)
  567. {
  568. //ht.Clear();
  569. //ht_CheckStatu.Clear();
  570. Hashtable map = new Hashtable();
  571. if (tab == "2")
  572. {
  573. map.Clear();
  574. map.Add("deliverySubId", QsubIdJL.Text.Trim());
  575. map.Add("suppName", QsuppNameJL.Text.Trim());
  576. map.Add("orderId", QorderIdJL.Text);
  577. map.Add("invPhysicName", QInphysicJL.Text.Trim());
  578. map.Add("deliveryLocation", QLocationJL.Text.Trim());
  579. if (String.IsNullOrEmpty(strCoustomInfo))
  580. {
  581. map.Add("statusRK", QstatusJL.Value == null ? "" : QstatusJL.Value.ToString().Trim());
  582. }
  583. else
  584. {
  585. map.Add("statusEx", QstatusJL.Value == null ? "" : QstatusJL.Value.ToString().Trim());
  586. map.Add("itemCodeEx", strCoustomInfo);
  587. }
  588. if (ck_createtimeJL.Checked)
  589. {
  590. if (QcreateTime_BeginJL.Value != null)//创建开始时间
  591. {
  592. map.Add("createTimeBegin", setCreateTimeStart(QcreateTime_BeginJL.Value));
  593. }
  594. if (QcreateTime_EndJL.Value != null)//创建结束时间
  595. {
  596. map.Add("createTimeEnd", setCreateTimeEnd(QcreateTime_EndJL.Value));
  597. }
  598. }
  599. }
  600. else if (tab == "3")
  601. {
  602. map.Clear();
  603. map.Add("deliverySubId", QsubIdSJ.Text.Trim());
  604. map.Add("suppName", QsuppNameSJ.Text.Trim());
  605. map.Add("orderId", QorderIdSJ.Text);
  606. map.Add("invPhysicName", QInphysicSJ.Text.Trim());
  607. map.Add("deliveryLocation", QLocationSJ.Text.Trim());
  608. if (String.IsNullOrEmpty(strCoustomInfo))
  609. {
  610. map.Add("statusRK", QstatusSJ.Value == null ? "" : QstatusSJ.Value.ToString().Trim());
  611. }
  612. else
  613. {
  614. map.Add("statusEx", QstatusSJ.Value == null ? "" : QstatusSJ.Value.ToString().Trim());
  615. map.Add("itemCodeEx", strCoustomInfo);
  616. }
  617. if (ck_createtimeSJ.Checked)
  618. {
  619. if (QcreateTime_BeginSJ.Value != null)//创建开始时间
  620. {
  621. map.Add("createTimeBegin", setCreateTimeStart(QcreateTime_BeginJL.Value));
  622. }
  623. if (QcreateTime_EndSJ.Value != null)//创建结束时间
  624. {
  625. map.Add("createTimeEnd", setCreateTimeEnd(QcreateTime_EndJL.Value));
  626. }
  627. }
  628. }
  629. else
  630. {
  631. MessageUtil.ShowTips("未知页面");
  632. }
  633. map.Add("meteringFlag", strIsMeter);
  634. DataTable dt = this.GetJsonService().execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "doQueryDeliverySubMList", new object[] { map });
  635. if (dt != null && dt.Rows.Count > 0)
  636. {
  637. if (tab == "2")
  638. {
  639. GridHelper.CopyDataToDatatable(dt, DTsubMJL, true);
  640. GridHelper.RefreshAndAutoSize(GridSubMJL);
  641. if (String.IsNullOrEmpty(subId))
  642. {
  643. publicPms.doActiveSelRow(GridSubMJL, "DELIVERYSUBID", subId);
  644. }
  645. }
  646. else if (tab == "3")
  647. {
  648. GridHelper.CopyDataToDatatable(dt, DTsubMSJ, true);
  649. GridHelper.RefreshAndAutoSize(GridSubMSJ);
  650. if (String.IsNullOrEmpty(subId))
  651. {
  652. publicPms.doActiveSelRow(GridSubMSJ, "DELIVERYSUBID", subId);
  653. }
  654. }
  655. else
  656. {
  657. MessageUtil.ShowTips("未知页面");
  658. }
  659. }
  660. }
  661. //public static List<UltraGridRow> UltraGridGetChooseRows(UltraGrid grid, string columnName = "CHK")
  662. //{
  663. // grid.UpdateData();
  664. // List<UltraGridRow> list = new List<UltraGridRow>();
  665. // RowsCollection rows = grid.Rows;
  666. // foreach (var item in rows)
  667. // {
  668. // try
  669. // {
  670. // if (Convert.ToBoolean(item.Cells[columnName].Value) == true && item.Hidden == false && item.IsFilteredOut == false)
  671. // {
  672. // list.Add(item);
  673. // }
  674. // }
  675. // catch { }
  676. // }
  677. // return list;
  678. //}
  679. private void getCheckdSubMCol(UltraGrid grid, String tab)
  680. {
  681. try
  682. {
  683. IQueryable<UltraGridRow> uGridss = null;
  684. this.Cursor = Cursors.WaitCursor;
  685. grid.UpdateData();
  686. ExcDeliverySubC edsc = new ExcDeliverySubC();
  687. List<string> l = new List<string>();
  688. // List<UltraGridRow> list= UltraGridGetChooseRows(grid);
  689. if(tab=="2"){
  690. uGridss = GridSubMJL.Rows.AsQueryable().Where(" CHK = 'True'");
  691. }else if(tab=="3"){
  692. uGridss = GridSubMSJ.Rows.AsQueryable().Where(" CHK = 'True'");
  693. }
  694. //获取库区库位
  695. foreach (UltraGridRow ugr in uGridss)
  696. {
  697. String strDeliverySubId = ugr.GetCellValue("DeliverySubId").ToString().Trim();
  698. if (tab != "3")
  699. {
  700. String strInvPhysic = ugr.GetCellValue("invPhysic").ToString().Trim();
  701. String strInvPhysicName = ugr.GetCellValue("InvPhysicName").ToString().Trim();
  702. if (String.IsNullOrEmpty(strInvPhysic) || String.IsNullOrEmpty(strInvPhysicName))
  703. {
  704. MessageUtil.ShowTips("送货单:" + strDeliverySubId + "交付地址未绑定库区,无法办理入库,请维护库区和地址挂接关系基础数据,请注意");
  705. ugr.Cells["CHK"].Value = false;
  706. ugr.Cells["CHK"].Activation = Activation.Disabled;
  707. ugr.Appearance.BackColor = Color.WhiteSmoke;
  708. continue;
  709. }
  710. if (!ht.ContainsKey(strInvPhysic))
  711. {
  712. DataTable tt = getInvPosdt(strInvPhysic);
  713. if (tt == null || tt.Rows.Count <= 0)
  714. {
  715. ugr.Cells["CHK"].Value = false;
  716. ugr.Cells["CHK"].Activation = Activation.Disabled;
  717. ugr.Appearance.BackColor = Color.WhiteSmoke;
  718. MessageUtil.ShowTips("送货单:" + strDeliverySubId + "对应的库区:" + strInvPhysicName + "无入库储位,无法办理入库,请维护库区和储位挂接关系基础数据,请注意");
  719. continue;
  720. }
  721. ht.Add(strInvPhysic, tt);
  722. }
  723. }
  724. l.Add(strDeliverySubId);
  725. }
  726. if (l.Count >= 1)
  727. {
  728. edsc.Col = l.ToArray();
  729. Get_PUR_EXC_DELIVERY_C(edsc, tab);
  730. }
  731. }
  732. catch (Exception ex)
  733. {
  734. MessageUtil.ShowTips("加载送货单行失败:" + ex.Message);
  735. }
  736. finally
  737. {
  738. this.Cursor = Cursors.Default;
  739. }
  740. }
  741. /// <summary>
  742. /// 查询送货通知单行表
  743. /// </summary>
  744. private void Get_PUR_EXC_DELIVERY_C(ExcDeliverySubC EdC, string tab)
  745. {
  746. JHY.Clear();
  747. JLdata.Clear();
  748. exception.Clear();
  749. JHY.Clear();
  750. if(tab=="2")//过磅
  751. {
  752. publicPms.clearOldData(panel_JL, new string[] { });
  753. DTsubDJL.Rows.Clear();
  754. JLdata.Clear();
  755. EdC.MeteringFlag = "1";
  756. if (String.IsNullOrEmpty(strCoustomInfo))
  757. {
  758. EdC.Status = QstatusJL.Value == null ? "" : QstatusJL.Value.ToString().Trim();
  759. }
  760. else
  761. {
  762. EdC.UpdateUserid = QstatusJL.Value == null ? "" : QstatusJL.Value.ToString().Trim();
  763. EdC.ItemCode = strCoustomInfo;
  764. }
  765. }
  766. else if (tab == "3")//实绩
  767. {
  768. publicPms.clearOldData(panel_sj, new string[] { });
  769. DTsubDSJ.Rows.Clear();
  770. if (String.IsNullOrEmpty(strCoustomInfo))
  771. {
  772. EdC.Status = QstatusSJ.Value == null ? "" : QstatusSJ.Value.ToString().Trim();
  773. }
  774. else
  775. {
  776. EdC.UpdateUserid = QstatusSJ.Value == null ? "" : QstatusSJ.Value.ToString().Trim();
  777. EdC.ItemCode = strCoustomInfo;
  778. }
  779. }
  780. else
  781. {
  782. MessageUtil.ShowTips("页面参数错误");
  783. return;
  784. }
  785. EdC.Validflag = "1";
  786. DataTable dt = this.GetJsonService().execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "Query_C", new object[] { EdC });
  787. EdC.UpdateUserid = strCoustomInfo;
  788. if (tab == "2")//过磅
  789. {
  790. GridHelper.CopyDataToDatatable(dt, DTsubDJL, true);
  791. foreach (UltraGridRow ugr in GridSubDJL.Rows)//过磅
  792. {
  793. ugr.Cells["Check"].Value = true;
  794. ugr.Cells["CheckStatu"].Value = "1";//判定结果默认为合格
  795. bindDropDown(ugr);//绑定库位
  796. }
  797. bindCheckItems(DTsubDJL);//绑定检化验结果
  798. bindJLItems();//绑定计量结果
  799. bindPrice();//绑定含税,不含税价格
  800. foreach (UltraGridRow ugr in GridSubDJL.Rows)//过磅
  801. {
  802. getJlInNum(ugr);//自动计算入库量
  803. //queryCountInNum(ugr);//查询当月累入
  804. }
  805. GridSubDJL.UpdateData();
  806. //设置可编辑的行
  807. GridHelper.RefreshAndAutoSize(GridSubDJL);
  808. }
  809. else
  810. {
  811. GridHelper.CopyDataToDatatable(dt, DTsubDSJ, true);
  812. foreach (UltraGridRow ugr in GridSubDSJ.Rows)//实绩
  813. {
  814. getInNum(ugr, "1");
  815. }
  816. GridHelper.RefreshAndAutoSize(GridSubDSJ);
  817. }
  818. }
  819. //查询当月累入
  820. //private void queryCountInNum(UltraGridRow ugr) {
  821. // if (ugr == null)
  822. // { return; }
  823. // Hashtable map = new Hashtable();
  824. // String supCode = ugr.Cells["SUPPCODE"].Value.ToString();
  825. // String checkResult = ugr.Cells["CheckResult"].Value.ToString();
  826. // map.Add("supCode", supCode);
  827. // map.Add("CheckResult", checkResult);
  828. // DataTable dt = this.GetJsonService().execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "Query_C", new object[] { map });
  829. //}
  830. /// <summary>
  831. /// 入库送货单行状态校验
  832. /// </summary>
  833. /// <param name="deliverySubId"></param>
  834. /// <param name="p"></param>
  835. /// <returns></returns>
  836. private bool testDeliveryStatus(String deliverySubId, int p, ref ExcDeliverySubC subc, ref ExcDeliverySubM subM)
  837. {
  838. if (String.IsNullOrEmpty(deliverySubId))
  839. {
  840. MessageUtil.ShowTips("送货单行号为空,无法校验数据有效性");
  841. return false;
  842. }
  843. subc = this.GetJsonService().execute<ExcDeliverySubC>("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "findById", new object[] { deliverySubId });
  844. if (subc == null)
  845. {
  846. MessageUtil.ShowTips("未发现送货单行:" + deliverySubId + " 信息记录,可能已作废,或请刷新界面重试");
  847. return false;
  848. }
  849. if (subc.Validflag != "1")
  850. {
  851. MessageUtil.ShowTips("未发现送货单行:" + deliverySubId + " 信息记录,可能已作废,或请刷新界面重试");
  852. return false;
  853. }
  854. String testStatus = subc.Status;
  855. if (String.IsNullOrEmpty(subc.DeliverySubId))
  856. {
  857. MessageUtil.ShowTips("未找到送货单行的头信息");
  858. return false;
  859. }
  860. subM = this.GetJsonService().execute<ExcDeliverySubM>("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "findById", new object[] { subc.DeliverySubId });
  861. if (subM == null)
  862. {
  863. MessageUtil.ShowTips("未发现送货单:" + subc.DeliverySubId + " 信息记录,可能已作废,或请刷新界面重试");
  864. return false;
  865. }
  866. if (subM.Validflag != "1")
  867. {
  868. MessageUtil.ShowTips("未发现送货单:" + subc.DeliverySubId + " 信息记录,可能已作废,或请刷新界面重试");
  869. return false;
  870. }
  871. //待检入库
  872. if (p == 1)
  873. {
  874. if (subM.ReceiveType == "110107")//JIT
  875. {
  876. if (testStatus != "3")
  877. {
  878. MessageUtil.ShowTips("送货单行:" + deliverySubId + " 为JIT入库,可能还未完成复检,或请刷新界面重试");
  879. return false;
  880. }
  881. }
  882. else if (subM.ReceiveType == "110101")
  883. {
  884. if (testStatus != "2")
  885. {
  886. MessageUtil.ShowTips("送货单行:" + deliverySubId + " 为非JIT,可能还未完成初检,或请刷新界面重试");
  887. return false;
  888. }
  889. }
  890. if (subc.MeteringFlag == "1")
  891. {
  892. if (subc.Ismeter == "0")
  893. {
  894. MessageUtil.ShowTips("物料:" + subc.ItemName + " 为计重物料,请先计量");
  895. return false;
  896. }
  897. }
  898. if (subc.PcFlag == "1")
  899. {
  900. if (String.IsNullOrEmpty(subc.CheckNo))
  901. {
  902. MessageUtil.ShowTips("物料:" + subc.ItemName + " 为检化验物料,请生成检化验委托并做好取样和检验准备");
  903. return false;
  904. }
  905. }
  906. }
  907. //正式入库
  908. else if (p == 2)
  909. {
  910. if (subM.ReceiveType == "110107")//JIT
  911. {
  912. if (testStatus != "3"&&testStatus != "4")
  913. {
  914. MessageUtil.ShowTips("送货单行:" + deliverySubId + " 为JIT入库,还未复检或者待检,或请刷新界面重试");
  915. return false;
  916. }
  917. }
  918. else if (subM.ReceiveType == "110101")
  919. {
  920. if (testStatus != "2" && testStatus != "4")
  921. {
  922. MessageUtil.ShowTips("送货单行:" + deliverySubId + " 为非JIT,可能还未初检或待检,或请刷新界面重试");
  923. return false;
  924. }
  925. }
  926. if (subc.MeteringFlag == "1")
  927. {
  928. if (subc.Ismeter == "0")
  929. {
  930. MessageUtil.ShowTips("物料:" + subc.ItemName + " 为计重物料,请先计量");
  931. return false;
  932. }
  933. }
  934. if (subc.PcFlag == "1")
  935. {
  936. if (String.IsNullOrEmpty(subc.CheckNo))
  937. {
  938. MessageUtil.ShowTips("物料:" + subc.ItemName + " 为检化验物料,请生成检化验委托并做好取样和检验准备");
  939. return false;
  940. }
  941. }
  942. }
  943. //正式入库(废钢)
  944. else if (p == 4)
  945. {
  946. if (testStatus != "1" && testStatus != "2" && testStatus != "3" && testStatus != "4")
  947. {
  948. MessageUtil.ShowTips("送货单行:" + deliverySubId + " 已入库,或请刷新界面重试");
  949. return false;
  950. }
  951. if (subc.MeteringFlag == "1")
  952. {
  953. //if (subc.Ismeter == "0")
  954. //{
  955. // MessageUtil.ShowTips("物料:" + subc.ItemName + " 为计重物料,请先计量");
  956. // return false;
  957. //}
  958. }
  959. if (subc.PcFlag == "1")
  960. {
  961. if (String.IsNullOrEmpty(subc.CheckNo))
  962. {
  963. MessageUtil.ShowTips("物料:" + subc.ItemName + " 为检化验物料,请生成检化验委托并做好取样和检验准备");
  964. return false;
  965. }
  966. }
  967. }
  968. //撤销入库
  969. else if (p == 3)
  970. {
  971. if (testStatus != "5" && testStatus != "4")
  972. {
  973. MessageUtil.ShowTips("送货单行:" + deliverySubId + " 还未入库或者已结算,或请刷新界面重试");
  974. return false;
  975. }
  976. }
  977. else
  978. {
  979. MessageUtil.ShowTips("未知参数:" + p);
  980. return false;
  981. }
  982. return true;
  983. }
  984. /// <summary>
  985. /// 获取库区库库位数据
  986. /// </summary>
  987. /// <param name="strPhysic"></param>
  988. /// <returns></returns>
  989. private DataTable getInvPosdt(string strPhysic)
  990. {
  991. string strInvPhysic = strPhysic;
  992. ActualSeatPosEntity PosEntity = new ActualSeatPosEntity();
  993. PosEntity.Validflag = "1";
  994. PosEntity.InvPhysic = strInvPhysic;
  995. DataTable dt = this.GetJsonService().execute<DataTable>("com.hnshituo.pur.configure.service.ActualSeatPosService", "find", new object[] { PosEntity, 0, 0 });
  996. return dt;
  997. }
  998. /// <summary>
  999. /// 绑定当前行的库位,绑定判定结果下拉列表数据源(储位和判断等级)
  1000. /// </summary>
  1001. private void bindDropDown(UltraGridRow ugr)
  1002. {
  1003. try
  1004. {
  1005. //绑定储位
  1006. if (ugr.Cells["INVPOS"].EditorComponent == null || ugr.Cells["InvPosException"].EditorComponent == null)
  1007. {
  1008. String strInvphysic = ugr.Cells["DELETEUSERID"].Value.ToString().Trim();
  1009. if (!String.IsNullOrEmpty(strInvphysic))
  1010. {
  1011. DataTable dt = null;
  1012. if (ht[strInvphysic] != null)
  1013. {
  1014. dt = (DataTable)ht[strInvphysic];
  1015. }
  1016. if (ugr.Cells["INVPOS"].EditorComponent == null)
  1017. {
  1018. UltraComboEditor ucbe = getNewUltraComboEditor();
  1019. comm.setUltraComboEditorBind(ucbe, dt, "invPosName", "invPos");
  1020. ugr.Cells["INVPOS"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  1021. ugr.Cells["INVPOS"].EditorComponent = ucbe;
  1022. if (dt.Rows.Count > 0 && ugr.Cells["INVPOS"].Value.ToString() == "")
  1023. {
  1024. ugr.Cells["INVPOS"].Value = dt.Rows[0]["invPos"].ToString();
  1025. }
  1026. }
  1027. if (ugr.Cells["InvPosException"].EditorComponent == null)
  1028. {
  1029. //待处置库位
  1030. UltraComboEditor ucbe1 = getNewUltraComboEditor();
  1031. comm.setUltraComboEditorBind(ucbe1, dt, "invPosName", "invPos");
  1032. ugr.Cells["InvPosException"].EditorComponent = ucbe1;
  1033. ugr.Cells["InvPosException"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  1034. }
  1035. }
  1036. }
  1037. //绑定判定结果
  1038. ugr.Cells["CheckStatu"].EditorComponent = cmbCheck;
  1039. }
  1040. catch (System.Exception ex)
  1041. {
  1042. MessageUtil.ShowTips("加载送货单行:" + ugr.GetCellValue("DELIVERYSUBLINESQE") + "入库可选储位和可判定等级失败:" + ex.Message);
  1043. ugr.Cells["Check"].Value = false;
  1044. ugr.Cells["Check"].Activation = Activation.Disabled;
  1045. ugr.Appearance.BackColor = Color.WhiteSmoke;
  1046. }
  1047. }
  1048. /// <summary>
  1049. /// 批量绑定检化验结果
  1050. /// </summary>
  1051. private void bindCheckItems(DataTable dtsub)
  1052. {
  1053. ArrayList al = comm.getDtGroupBy_reAl(dtsub, "CHECKNO");
  1054. for (int i = 0; i < al.Count; )
  1055. {
  1056. if (al[i] == null)
  1057. {
  1058. al.RemoveAt(i);
  1059. }
  1060. else
  1061. {
  1062. i++;
  1063. }
  1064. }
  1065. if (al.Count == 0)
  1066. {
  1067. return;
  1068. }
  1069. CheckconsignBaseinfo cb = new CheckconsignBaseinfo();
  1070. cb.CheckNos = (string[])al.ToArray(typeof(string));
  1071. DataTable dt = this.GetJsonService().execute<DataTable>("com.hnshituo.pur.jhy.service.CheckconsignBaseinfo_jhyService", "doQuery_Baseinfo", new object[] { cb });
  1072. //DataTable dt = this.GetJsonService().execute<DataTable>("com.hnshituo.pur.utils.service.UtilsService", "readData1", new object[] { cb });
  1073. if (dt == null || dt.Rows.Count <= 0)
  1074. {
  1075. return;
  1076. }
  1077. for (int i = 0; i < dtsub.Rows.Count; i++)
  1078. {
  1079. DataRow dr = dtsub.Rows[i];
  1080. foreach (DataRow dr1 in dt.Rows)
  1081. {
  1082. if (dr["CHECKNO"].ToString() == dr1["CHECKNO"].ToString())
  1083. {
  1084. dr["CHECKUSERNAME"] = dr1["JUDGENAME"];//判断人
  1085. dr["CHECKDATE"] = dr1["JUDGETIME"];//判断人
  1086. //判定结果
  1087. if (dr1["judgelevelcode"].ToString() == "" || dr1["judgelevelcode"].ToString() == "无")
  1088. {
  1089. if (dr1["judgelevelcode"].ToString() == "1")
  1090. {
  1091. dr["CheckStatu"] = "1";
  1092. }
  1093. else if (dr1["judgelevelcode"].ToString() == "0")
  1094. {
  1095. dr["CheckStatu"] = "0";
  1096. }
  1097. else
  1098. {
  1099. dr["CheckStatu"] = "1";
  1100. }
  1101. }
  1102. break;
  1103. }
  1104. }
  1105. }
  1106. }
  1107. /// <summary>
  1108. /// 批量绑定计量结果
  1109. /// </summary>
  1110. private void bindJLItems()
  1111. {
  1112. if (ultraTabControl1.SelectedTab.Key != "2")
  1113. {
  1114. MessageUtil.ShowTips("请选择计量入库界面");
  1115. return;
  1116. }
  1117. double numJLQTY = 0;
  1118. double numTARE = 0;//皮重
  1119. double numGROSS = 0; //毛重
  1120. string strSUTTLETIME = "";//计量时间
  1121. String strMaterielRule = "";
  1122. double numKZQTY = 0;
  1123. double b_txt_deduction2 = 0.00;//扣机铁
  1124. double b_txt_deduction3 = 0.00;//扣超长
  1125. double b_txt_deduction4 = 0.00;//扣轻薄
  1126. ArrayList al = comm.getDtGroupBy_reAl(DTsubDJL, "ORDERLINESQE");
  1127. for (int i = 0; i < al.Count; )
  1128. {
  1129. if (al[i] == null)
  1130. {
  1131. al.RemoveAt(i);
  1132. }
  1133. else
  1134. {
  1135. i++;
  1136. }
  1137. }
  1138. if (al.Count == 0)
  1139. {
  1140. return;
  1141. }
  1142. Hashtable ht = new Hashtable();
  1143. ht.Add("ordernos", (string[])al.ToArray(typeof(string)));
  1144. ht.Add("updateUserid", "5");
  1145. DataTable subc = this.execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "Query_C", new object[] { ht });
  1146. ArrayList matchids = new ArrayList();
  1147. for (int i = 0; i < subc.Rows.Count; i++)
  1148. {
  1149. matchids.Add(subc.Rows[i]["MATCHID"].ToString2());
  1150. }
  1151. if (matchids.Count > 0)
  1152. {
  1153. ht.Add("matchidsnNotIn", (string[])matchids.ToArray(typeof(string)));
  1154. }
  1155. DataTable dt = this.GetJsonService().execute<DataTable>("com.hnshituo.pur.utils.service.UtilsService", "readData", new object[] { ht });
  1156. if (dt == null || dt.Rows.Count <= 0)
  1157. {
  1158. return;
  1159. }
  1160. foreach (UltraGridRow row in GridSubDJL.Rows)
  1161. {
  1162. String strORDERLINESQE = row.GetCellValue("matchid").ToString().Trim();
  1163. foreach (DataRow dr1 in dt.Rows)
  1164. {
  1165. if (strORDERLINESQE == dr1["matchid"].ToString())
  1166. {
  1167. Double.TryParse(dr1["suttle"].ToString().Trim(), out numJLQTY);
  1168. Double.TryParse(dr1["deduction"].ToString().Trim(), out numKZQTY);
  1169. Double.TryParse(dr1["deduction2"].ToString().Trim(), out b_txt_deduction2);//扣机铁
  1170. Double.TryParse(dr1["deduction3"].ToString().Trim(), out b_txt_deduction3);//扣超长
  1171. Double.TryParse(dr1["deduction4"].ToString().Trim(), out b_txt_deduction4);//扣轻薄
  1172. Double.TryParse(dr1["TARE"].ToString().Trim(), out numTARE);//皮重
  1173. Double.TryParse(dr1["GROSS"].ToString().Trim(), out numGROSS);//毛重
  1174. string strmatchid = dr1["matchid"].ToString().Trim();//绑单号
  1175. strMaterielRule = dr1["materielRule"].ToString().Trim();//废钢料型
  1176. strSUTTLETIME = dr1["SUTTLETIME"].ToString().Trim();//计量时间
  1177. row.Cells["JLQTY"].Value = numJLQTY;//净重
  1178. row.Cells["SHIPQTY"].Value = numJLQTY;//收货量=净重
  1179. row.Cells["KZQTY"].Value = numKZQTY;//净扣杂
  1180. row.Cells["deduction2"].Value = b_txt_deduction2;//扣机铁
  1181. row.Cells["deduction3"].Value = b_txt_deduction3;//扣超长
  1182. row.Cells["deduction4"].Value = b_txt_deduction4;//扣轻薄
  1183. row.Cells["TARE"].Value = numTARE;//皮重
  1184. row.Cells["GROSS"].Value = numGROSS;//毛重
  1185. row.Cells["SUTTLETIME"].Value = strSUTTLETIME;//计量时间
  1186. row.Cells["CheckResult"].Value = strMaterielRule;//废钢料型
  1187. row.Cells["matchid"].Value = strmatchid;//绑单号
  1188. }
  1189. }
  1190. }
  1191. GridSubDJL.UpdateData();
  1192. }
  1193. /// <summary>
  1194. /// 计算非计量入库量
  1195. /// </summary>
  1196. /// <param name="ugr"></param>
  1197. /// <param name="tips">1:修改采购,2修改库存</param>
  1198. private void getInNum(UltraGridRow ugr,String strTips)
  1199. {
  1200. if (ugr == null)
  1201. { return; }
  1202. double b_SHIPQTY = 0;//收货量
  1203. double b_ReceivedQty = 0;//入库量_实绩
  1204. double b_InNum = 0;//入库量_编制
  1205. double b_weightQty = 0;//库存数量
  1206. double b_ITEMUOMCONEFFICIENT = 0;
  1207. double.TryParse(ugr.Cells["SHIPQTY"].Value.ToString(), out b_SHIPQTY);//收获量
  1208. double.TryParse(ugr.Cells["INNUM"].Value.ToString(), out b_InNum);//入库量_编制
  1209. double.TryParse(ugr.Cells["RECEIVEDQTY"].Value.ToString(), out b_ReceivedQty);//入库量_实绩
  1210. double.TryParse(ugr.Cells["weightQty"].Value.ToString(), out b_weightQty);//库存数量
  1211. double.TryParse(ugr.Cells["ITEMUOMCONEFFICIENT"].Value.ToString(), out b_ITEMUOMCONEFFICIENT);//转换系数
  1212. double b_NumException = 0;//待入库量
  1213. if (ultraTabControl1.SelectedTab.Key != "3")
  1214. {
  1215. if (ugr.Cells["ITEMUOM"].Value.ToString() == "基吨")//库存数量可输
  1216. {
  1217. if (strTips == "2")
  1218. {
  1219. b_InNum = Math.Round(b_weightQty * b_ITEMUOMCONEFFICIENT, 3, System.MidpointRounding.AwayFromZero);
  1220. b_NumException = b_SHIPQTY - b_weightQty;
  1221. if (ugr.Cells["CheckStatu"].Value.ToString() == "0")//不合格
  1222. {
  1223. ugr.Cells["InNum"].Value = 0;
  1224. ugr.Cells["weightQty"].Value = 0;
  1225. //ugr.Cells["numException"].Value = Math.Round(b_SHIPQTY, 3, System.MidpointRounding.AwayFromZero);
  1226. }
  1227. else
  1228. {
  1229. ugr.Cells["InNum"].Value = b_InNum;
  1230. //ugr.Cells["numException"].Value = b_NumException;
  1231. }
  1232. }
  1233. else
  1234. {
  1235. b_weightQty = Math.Round(b_InNum / b_ITEMUOMCONEFFICIENT, 3, System.MidpointRounding.AwayFromZero);
  1236. //b_NumException = b_SHIPQTY - b_weightQty;
  1237. if (ugr.Cells["CheckStatu"].Value.ToString() == "0")//不合格
  1238. {
  1239. ugr.Cells["InNum"].Value = 0;
  1240. ugr.Cells["weightQty"].Value = 0;
  1241. // ugr.Cells["numException"].Value = Math.Round(b_SHIPQTY, 3, System.MidpointRounding.AwayFromZero);
  1242. }
  1243. else
  1244. {
  1245. ugr.Cells["weightQty"].Value = b_weightQty;
  1246. // ugr.Cells["numException"].Value = b_NumException;
  1247. }
  1248. }
  1249. }
  1250. else
  1251. {
  1252. if (strTips == "2")//改库存量
  1253. {
  1254. //乘转换系数
  1255. b_InNum = Math.Round(b_weightQty / b_ITEMUOMCONEFFICIENT, 3, System.MidpointRounding.AwayFromZero);
  1256. // b_NumException = b_SHIPQTY - b_InNum;
  1257. if (ugr.Cells["CheckStatu"].Value.ToString() == "0")//不合格
  1258. {
  1259. ugr.Cells["InNum"].Value = 0;
  1260. ugr.Cells["weightQty"].Value = 0;
  1261. // ugr.Cells["numException"].Value = b_SHIPQTY;
  1262. }
  1263. else
  1264. {
  1265. ugr.Cells["InNum"].Value = b_InNum;
  1266. // ugr.Cells["numException"].Value = b_NumException;
  1267. }
  1268. }
  1269. else//该采购量
  1270. {
  1271. //乘转换系数
  1272. b_weightQty = Math.Round(b_InNum * b_ITEMUOMCONEFFICIENT, 3, System.MidpointRounding.AwayFromZero);
  1273. // b_NumException = b_SHIPQTY - b_InNum;
  1274. if (ugr.Cells["CheckStatu"].Value.ToString() == "0")//不合格
  1275. {
  1276. ugr.Cells["InNum"].Value = 0;
  1277. ugr.Cells["weightQty"].Value = 0;
  1278. // ugr.Cells["numException"].Value = b_SHIPQTY;
  1279. }
  1280. else
  1281. {
  1282. ugr.Cells["weightQty"].Value = b_weightQty;
  1283. // ugr.Cells["numException"].Value = b_NumException;
  1284. }
  1285. }
  1286. }
  1287. double bUNITWEIGHT = 0;//每袋重量
  1288. double bPACKAGEQTY = 0;//包装数量
  1289. double.TryParse(ugr.Cells["PACKAGEQTY"].Value.ToString().Trim(), out bPACKAGEQTY);
  1290. if (bPACKAGEQTY != 0)
  1291. {
  1292. bUNITWEIGHT = Math.Round(b_weightQty / bPACKAGEQTY, 3);
  1293. }
  1294. ugr.Cells["UNITWEIGHT"].Value = bUNITWEIGHT;
  1295. }
  1296. else
  1297. {
  1298. if (ugr.Cells["ITEMUOM"].Value.ToString() == "基吨")//库存数量可输
  1299. {
  1300. b_InNum = Math.Round(b_ReceivedQty * b_ITEMUOMCONEFFICIENT, 3, System.MidpointRounding.AwayFromZero);
  1301. ugr.Cells["weightQty"].Value = b_ReceivedQty;
  1302. ugr.Cells["RECEIVEDQTY"].Value = b_InNum;
  1303. }
  1304. else
  1305. {
  1306. b_weightQty = Math.Round(b_ReceivedQty * b_ITEMUOMCONEFFICIENT, 3, System.MidpointRounding.AwayFromZero);
  1307. ugr.Cells["weightQty"].Value = b_weightQty;
  1308. }
  1309. }
  1310. }
  1311. /// <summary>
  1312. /// 计算计量之后的量
  1313. /// </summary>
  1314. /// <returns></returns>
  1315. private void getJlInNum(UltraGridRow ugr)
  1316. {
  1317. if (ugr == null)
  1318. { return; }
  1319. double b_JL_QTY = 0.00;
  1320. double b_KZ_QTY = 0.00;
  1321. double b_ITEMUOMCONEFFICIENT = 0;
  1322. double b_txt_deduction2 = 0.00;
  1323. double b_txt_deduction3 = 0.00;
  1324. double b_txt_deduction4 = 0.00;
  1325. double.TryParse(ugr.Cells["JLQTY"].Value.ToString(), out b_JL_QTY);//计量结果
  1326. double.TryParse(ugr.Cells["KZQTY"].Value.ToString(), out b_KZ_QTY);//扣杂量
  1327. double.TryParse(ugr.Cells["ITEMUOMCONEFFICIENT"].Value.ToString(), out b_ITEMUOMCONEFFICIENT);//转换系数
  1328. double.TryParse(ugr.Cells["deduction2"].Value.ToString(), out b_txt_deduction2);//扣杂量
  1329. double.TryParse(ugr.Cells["deduction3"].Value.ToString(), out b_txt_deduction3);//扣杂量
  1330. double.TryParse(ugr.Cells["deduction4"].Value.ToString(), out b_txt_deduction4);//扣杂量
  1331. double b_REC_QTY = 0.00;//可入库量..自动计算
  1332. double b_weightQty = 0;//库存数量
  1333. //b_REC_QTY = b_JL_QTY - b_KZ_QTY - b_txt_deduction2 - b_txt_deduction3 - b_txt_deduction4;//可入库量..自动计算
  1334. b_REC_QTY = b_JL_QTY - b_txt_deduction2 - b_txt_deduction3 - b_txt_deduction4;//可入库量..自动计算
  1335. //乘转换系数
  1336. if (ugr.Cells["CheckStatu"].Value.ToString() == "0")
  1337. {
  1338. ugr.Cells["InNum"].Value = 0;
  1339. ugr.Cells["weightQty"].Value = 0;
  1340. // ugr.Cells["numException"].Value = Math.Round(b_REC_QTY, 3, System.MidpointRounding.AwayFromZero);
  1341. }
  1342. else
  1343. {
  1344. if (ugr.Cells["ITEMUOM"].Value.ToString() == "基吨")//库存数量可输
  1345. {
  1346. ugr.Cells["InNum"].Value = Math.Round(b_REC_QTY * b_ITEMUOMCONEFFICIENT, 3, System.MidpointRounding.AwayFromZero);
  1347. ugr.Cells["weightQty"].Value = b_REC_QTY;
  1348. }
  1349. else
  1350. {
  1351. b_weightQty = Math.Round(b_REC_QTY * b_ITEMUOMCONEFFICIENT, 3);
  1352. ugr.Cells["InNum"].Value = Math.Round(b_REC_QTY, 3, System.MidpointRounding.AwayFromZero);
  1353. ugr.Cells["weightQty"].Value = b_weightQty;
  1354. }
  1355. }
  1356. double bUNITWEIGHT = 0;//每袋重量
  1357. double bPACKAGEQTY = 0;//包装数量
  1358. double.TryParse(ugr.Cells["PACKAGEQTY"].Value.ToString().Trim(), out bPACKAGEQTY);
  1359. if (bPACKAGEQTY != 0)
  1360. {
  1361. bUNITWEIGHT = Math.Round(b_weightQty / bPACKAGEQTY, 3);
  1362. }
  1363. ugr.Cells["UNITWEIGHT"].Value = bUNITWEIGHT;
  1364. }
  1365. /// <summary>
  1366. /// 获取CMB
  1367. /// </summary>
  1368. /// <returns></returns>
  1369. private UltraComboEditor getNewUltraComboEditor()
  1370. {
  1371. UltraComboEditor cmb = new UltraComboEditor();
  1372. cmb.DropDownStyle = DropDownStyle.DropDownList;
  1373. cmb.Visible = false;
  1374. this.Controls.Add(cmb);
  1375. return cmb;
  1376. }
  1377. /// <summary>
  1378. /// 入库操作
  1379. /// </summary>
  1380. /// <param name="strTips">1:待检入库 2:正式入库</param>
  1381. private void instock(String strTips)
  1382. {
  1383. try
  1384. {
  1385. Hashtable htAttr = new Hashtable();
  1386. if (strTips != "1" && strTips != "2")
  1387. {
  1388. MessageUtil.ShowTips("入库类型参数错误 1:待检入库,2:正式入库");
  1389. return;
  1390. }
  1391. int tips = Int32.Parse(strTips);
  1392. UltraGrid ug = null;
  1393. DataTable dt_forUsePlan = new DataTable();
  1394. if (ultraTabControl1.SelectedTab.Key == "2")//计量
  1395. {
  1396. if (cbxJGZC.SelectedIndex == -1)
  1397. {
  1398. MessageUtil.ShowTips("请选择价格政策");
  1399. return;
  1400. }
  1401. ug = GridSubDJL;
  1402. ug.UpdateData();
  1403. dt_forUsePlan = DTsubDJL;
  1404. }
  1405. else
  1406. {
  1407. MessageUtil.ShowTips("请选择待入库数据");
  1408. return;
  1409. }
  1410. ArrayList al_CkInBillEntity = new ArrayList();//入库单表
  1411. ArrayList al_PurCkInbillPositionEntity = new ArrayList();//入库单储位明细表
  1412. ArrayList al_CkStorageEntity = new ArrayList();//库存
  1413. ArrayList al_CkStoragePosEntity = new ArrayList();//库存储位
  1414. ArrayList al_ExcDeliverySubC = new ArrayList();//送货单行
  1415. ArrayList al_ExcDeliveryException = new ArrayList();//送货单行---正式入库记录
  1416. Hashtable htusePlan = null;//领用单表---正式入库记录
  1417. foreach (UltraGridRow ugr in ug.Rows)
  1418. {
  1419. if (ugr.Hidden || !(bool)ugr.Cells["Check"].Value)
  1420. { continue; }
  1421. String strSubSqe = ugr.Cells["DELIVERYSUBLINESQE"].Value.ToString().Trim();
  1422. if (String.IsNullOrEmpty(strSubSqe))
  1423. {
  1424. MessageUtil.ShowTips("送货单行号为空");
  1425. return;
  1426. }
  1427. ExcDeliverySubC subCOld = new ExcDeliverySubC();
  1428. ExcDeliverySubM subMOld = new ExcDeliverySubM();
  1429. if (String.IsNullOrEmpty(strCoustomInfo))
  1430. {
  1431. if (testDeliveryStatus(strSubSqe, tips, ref subCOld, ref subMOld) == false)
  1432. {
  1433. return;
  1434. }
  1435. }
  1436. else
  1437. {
  1438. if (testDeliveryStatus(strSubSqe, 4, ref subCOld, ref subMOld) == false)
  1439. {
  1440. return;
  1441. }
  1442. }
  1443. //入库数据
  1444. double b_QTY = 0; //编制量
  1445. double b_INNUM = 0; //入库量
  1446. double b_ReceivedQty = 0; //收货量
  1447. double b_ITEMUOMCONEFFICIENT = 0;//转化系数
  1448. double b_KZQTY = 0;//扣杂
  1449. if (ugr.Cells["ITEMUOM"].Value.ToString() == "基吨")//入库量
  1450. {
  1451. double.TryParse(ugr.Cells["weightqTY"].Value.ToString().Trim(), out b_INNUM);
  1452. }
  1453. else
  1454. {
  1455. double.TryParse(ugr.Cells["INNUM"].Value.ToString().Trim(), out b_INNUM);
  1456. }
  1457. double.TryParse(ugr.Cells["KZQTY"].Value.ToString().Trim(), out b_KZQTY);//扣杂量
  1458. double.TryParse(ugr.Cells["SHIPQTY"].Value.ToString().Trim(), out b_ReceivedQty);//接收量
  1459. subCOld.ShipQty = b_ReceivedQty;
  1460. double.TryParse(ugr.Cells["ITEMUOMCONEFFICIENT"].Value.ToString().Trim(), out b_ITEMUOMCONEFFICIENT);//转换系数
  1461. double.TryParse(ugr.Cells["QTY"].Value.ToString().Trim(), out b_QTY);//编制量
  1462. //入库储位
  1463. String strInvPhysic = ugr.Cells["DELETEUSERID"].Value.ToString().Trim();
  1464. string strINVPOS = ugr.Cells["INVPOS"].Value.ToString().Trim();//入库储位
  1465. //待处置数据
  1466. String strRemarkException = ugr.Cells["RemarkException"].Value.ToString().Trim();//处置意见
  1467. string strInvPosException = ugr.Cells["InvPosException"].Value.ToString().Trim();//待处置储位
  1468. double b_non_Standard = 0;//待处置量
  1469. double.TryParse(ugr.Cells["numException"].Value.ToString().Trim(), out b_non_Standard);
  1470. //包装数据
  1471. double bUNITWEIGHT = 0;//每袋重量
  1472. double bPACKAGEQTY = 0;//包装数量
  1473. double.TryParse(ugr.Cells["PACKAGEQTY"].Value.ToString().Trim(), out bPACKAGEQTY);
  1474. if (bPACKAGEQTY != 0)
  1475. {
  1476. bUNITWEIGHT = Math.Round(b_INNUM / bPACKAGEQTY, 3);
  1477. }
  1478. String strPackUnit = ugr.Cells["PACKAGEUNIT"].Value.ToString().Trim();
  1479. //计量数据
  1480. double dbJLQty = ugr.Cells["JLQTY"].Value.ToString().Trim() == "" ? 0 : double.Parse(ugr.Cells["JLQTY"].Value.ToString());//净重
  1481. double dbDeduction2 = ugr.Cells["Deduction2"].Value.ToString().Trim() == "" ? 0 : double.Parse(ugr.Cells["Deduction2"].Value.ToString());//扣机铁
  1482. double dbDeduction3 = ugr.Cells["Deduction3"].Value.ToString().Trim() == "" ? 0 : double.Parse(ugr.Cells["Deduction3"].Value.ToString());//扣超长
  1483. double dbDeduction4 = ugr.Cells["Deduction4"].Value.ToString().Trim() == "" ? 0 : double.Parse(ugr.Cells["Deduction4"].Value.ToString());//扣轻薄
  1484. double dbGROSS = ugr.Cells["GROSS"].Value.ToString().Trim() == "" ? 0 : double.Parse(ugr.Cells["GROSS"].Value.ToString());//毛重
  1485. double dbTARE = ugr.Cells["TARE"].Value.ToString().Trim() == "" ? 0 : double.Parse(ugr.Cells["TARE"].Value.ToString());//皮重
  1486. string strmatchid = "";
  1487. string strCheckResult = "";
  1488. if (ultraTabControl1.SelectedTab.Key == "2")
  1489. {
  1490. strmatchid=ugr.Cells["matchid"].Value.ToString().Trim();//绑单号
  1491. if (String.IsNullOrEmpty(strmatchid))
  1492. {
  1493. MessageUtil.ShowTips("送货单行:" + subCOld.DeliverySubLineSqe + "未绑定磅单,无法入库");
  1494. return;
  1495. }
  1496. strCheckResult = ugr.Cells["CheckResult"].Value.ToString().Trim();//料型
  1497. if (!String.IsNullOrEmpty(strCheckResult))
  1498. {
  1499. String keys=strCheckResult + subCOld.ItemCode;
  1500. if (htAttr.ContainsKey(keys))
  1501. {
  1502. strCheckResult = (String)htAttr[keys];
  1503. }
  1504. else
  1505. {
  1506. PurClassMatAttrEntity MatAttr = new PurClassMatAttrEntity();
  1507. MatAttr.AttrName = strCheckResult;
  1508. //MatAttr.ItemCode = subCOld.ItemCode;
  1509. List<PurClassMatAttrEntity> listMatAttr = this.GetJsonService().execute<List<PurClassMatAttrEntity>>("com.hnshituo.pur.configure.service.ClassMatAttrService", "find", new object[] { MatAttr,0,0});
  1510. if (listMatAttr != null && listMatAttr.Count >= 1)//此物料判定合格
  1511. {
  1512. htAttr.Add(keys, listMatAttr[0].AttrCode);
  1513. strCheckResult = listMatAttr[0].AttrCode;
  1514. }
  1515. else
  1516. {
  1517. MessageUtil.ShowTips("未发现物料:" + subCOld.ItemName + "存在料型:" + strCheckResult+",或请维护!");
  1518. return;
  1519. }
  1520. }
  1521. }
  1522. }
  1523. //质检数据
  1524. String strCheckStatu = ugr.Cells["CheckStatu"].Value.ToString().Trim();
  1525. String strCheckUser = String.IsNullOrEmpty(ugr.Cells["CHECKUSERNAME"].Value.ToString().Trim()) ? UserInfo.GetUserName() : ugr.Cells["CHECKUSERNAME"].Value.ToString().Trim();//判断人
  1526. DateTime DtCheck = DateTime.Now;
  1527. if (!String.IsNullOrEmpty(ugr.Cells["CHECKDATE"].Value.ToString().Trim()))
  1528. {
  1529. DtCheck=DateTime.Parse(ugr.Cells["CHECKDATE"].Value.ToString().Trim());
  1530. }
  1531. //校验数据--待检
  1532. if (tips == 1)
  1533. {
  1534. //入库量大于0
  1535. if (b_INNUM <= 0)
  1536. {
  1537. MessageUtil.ShowTips("请填写送货单行:" + strSubSqe + "的入库量");
  1538. return;
  1539. }
  1540. if (strINVPOS.Trim() == "")
  1541. {
  1542. MessageUtil.ShowTips("请填写送货单行:" + strSubSqe + "的入库储位");
  1543. return;
  1544. }
  1545. if (b_non_Standard > 0)
  1546. {
  1547. MessageUtil.ShowTips("送货单行:" + strSubSqe + "有待处置数量,不能做待检入库操作");
  1548. return;
  1549. }
  1550. }
  1551. //校验数据--正式
  1552. else
  1553. {
  1554. if (b_INNUM > 0 && strINVPOS.Trim() == "")
  1555. {
  1556. MessageUtil.ShowTips("请填写送货单行:" + strSubSqe + "的入库储位");
  1557. return;
  1558. }
  1559. if (strCheckStatu == "0")
  1560. {
  1561. if (b_non_Standard <= 0)
  1562. {
  1563. MessageUtil.ShowTips("送货单行:" + strSubSqe + "的综合判定结果为不合格,待处置量必须>0");
  1564. return;
  1565. }
  1566. }
  1567. else
  1568. {
  1569. if (b_INNUM <= 0)
  1570. {
  1571. MessageUtil.ShowTips("送货单行:" + strSubSqe + "的综合判定结果为合格,入库量必须>0");
  1572. return;
  1573. }
  1574. }
  1575. //交货量差控制
  1576. if (testDeliveryQtyCtrl(subMOld, subCOld,b_INNUM) == false)
  1577. {
  1578. return;
  1579. }
  1580. }
  1581. //包装单位校验
  1582. if (!String.IsNullOrEmpty(strPackUnit))
  1583. {
  1584. if (strPackUnit.Length >= 35)
  1585. {
  1586. MessageUtil.ShowTips("送货单行:" + strSubSqe + "的包装单位字符串多长,请控制在10个字以内");
  1587. return;
  1588. }
  1589. if (bPACKAGEQTY <= 0 || bUNITWEIGHT<=0)
  1590. {
  1591. MessageUtil.ShowTips("送货单行:" + strSubSqe + "的包装单位信息不全,包装数量和包装重量不能为空");
  1592. return;
  1593. }
  1594. }
  1595. if (bPACKAGEQTY>0)
  1596. {
  1597. if (String.IsNullOrEmpty(strPackUnit))
  1598. {
  1599. MessageUtil.ShowTips("送货单行:" + strSubSqe + "的包装单位信息不全,请填写包装单位");
  1600. return;
  1601. }
  1602. }
  1603. PurCkInBillEntity CkInBillEntity = new PurCkInBillEntity();//入库单表
  1604. CkStorage CkStorageEntity = new CkStorage();
  1605. PurCkStoragePosEntity CkStoragePosEntity = new PurCkStoragePosEntity();//库存收发存表
  1606. PurCkInbillPositionEntity CkInbillPositionEntity = new PurCkInbillPositionEntity();//入库单储位明细表
  1607. ExcDeliveryException edecp = new ExcDeliveryException();//异常处理信息
  1608. ExcDeliverySubC EdC = new ExcDeliverySubC();
  1609. EdC.Status = "5";//正式入库
  1610. if (tips == 1)
  1611. {
  1612. EdC.Status = "4";//待检入库
  1613. }
  1614. //正式入库---待处置入库
  1615. if (b_non_Standard > 0 && tips == 2)
  1616. {
  1617. //异常单
  1618. edecp.DeliverySubLineSqe = strSubSqe;
  1619. edecp.DeliverySubId = subMOld.DeliverySubId;
  1620. edecp.Qty = b_non_Standard;
  1621. if (String.IsNullOrEmpty(strRemarkException))
  1622. {
  1623. MessageUtil.ShowTips("送货单行:" + strSubSqe + "有待处置量,待处置原因或意见不能为空");
  1624. return;
  1625. }
  1626. if (String.IsNullOrEmpty(strInvPosException))
  1627. {
  1628. MessageUtil.ShowTips("送货单行:" + strSubSqe + "有待处置量,待检储位不能为空");
  1629. return;
  1630. }
  1631. edecp.Remark = strRemarkException;
  1632. edecp.InvPos = strInvPosException;
  1633. edecp.InvPhysic = strInvPhysic;
  1634. edecp.Ecptype = "3";
  1635. edecp.Validflag = "1";
  1636. edecp.Status = "1";
  1637. edecp.CreateName = UserInfo.GetUserName();
  1638. edecp.CreateUserid = UserInfo.GetUserID();
  1639. edecp.CreateTime = System.DateTime.Now;
  1640. al_ExcDeliveryException.Add(edecp);
  1641. }
  1642. if (strCheckStatu != "0")//合格入库
  1643. {
  1644. CkInBillEntity.RefeId = strSubSqe;//送货通知单行号
  1645. CkInBillEntity.RefType = "2";
  1646. CkInBillEntity.InvPhysic = strInvPhysic;
  1647. CkInBillEntity.ItemUomConefficient = b_ITEMUOMCONEFFICIENT;
  1648. CkInBillEntity.Status = tips == 2 ? "1" : "0";// 状态
  1649. CkInBillEntity.InNum = b_INNUM;//入库量
  1650. //读取计量结果
  1651. CkInBillEntity.JlQty = dbJLQty; //净重
  1652. CkInBillEntity.KzQty = b_KZQTY;//扣杂
  1653. CkInBillEntity.Deduction2 = dbDeduction2;//扣机铁
  1654. CkInBillEntity.Deduction3 = dbDeduction3;//扣超长
  1655. CkInBillEntity.Deduction4 = dbDeduction4;//扣轻薄
  1656. CkInBillEntity.Gross = dbGROSS;//毛重
  1657. CkInBillEntity.Tare = dbTARE;//皮重
  1658. CkInBillEntity.Matchid = strmatchid;
  1659. if (ugr.Cells["Suttletime"].Value.ToString().Trim() != "")
  1660. {
  1661. CkInBillEntity.Suttletime= DateTime.Parse(ugr.Cells["Suttletime"].Value.ToString().Trim());
  1662. }
  1663. CkInBillEntity.Result = strCheckResult;
  1664. //包装
  1665. if (!String.IsNullOrEmpty(strPackUnit))
  1666. {
  1667. CkInBillEntity.PackageQty = bPACKAGEQTY + "";//包装数
  1668. CkInBillEntity.UnitWeight = bUNITWEIGHT;//每包重量
  1669. CkInBillEntity.PackageUnit = strPackUnit + "";//包装单位
  1670. }
  1671. CkInBillEntity.CreateUserid = UserInfo.GetUserID();
  1672. CkInBillEntity.CreateName = UserInfo.GetUserName();
  1673. CkInBillEntity.CreateTime = DateTime.Now;
  1674. CkInBillEntity.InstockDate = DateTime.Now;
  1675. CkInBillEntity.OperateOrgId = UserInfo.GetDeptid();
  1676. CkInBillEntity.OperateOrgName = UserInfo.GetDepartment();
  1677. CkInBillEntity.UpdateName = null;
  1678. CkInBillEntity.UpdateUserid = null;
  1679. CkInBillEntity.UpdateTime = null;
  1680. //检化验数据
  1681. CkInBillEntity.Result = strCheckResult;//检验结果(料型或者等级)
  1682. CkInBillEntity.CheckResult = strCheckStatu;//判定是否合格
  1683. CkInBillEntity.CheckDate = DtCheck;//判定时间
  1684. CkInBillEntity.CheckUserName = strCheckUser;//判断人
  1685. CkInBillEntity.BasePriceId = cbxJGZC.Value.ToString();//获取价格政策id
  1686. CkInBillEntity.BasePriceName = cbxJGZC.SelectedItem.ToString();//获取价格政策名称
  1687. // CkInBillEntity.TxtLEN_DEDUCT_PRICE = dbDeduction3 > 0 ? double.Parse(txtLEN_DEDUCT_PRICE.Value.ToString()) : 0;//超长扣减
  1688. CkInBillEntity.TxtLEN_DEDUCT_PRICE = double.Parse(txtLEN_DEDUCT_PRICE.Value.ToString());
  1689. CkInBillEntity.Txt_check = double.Parse(txt_check.Value.ToString());//考核
  1690. CkInBillEntity.Txt_honour = double.Parse(txt_honour.Value.ToString());//承兑加价
  1691. CkInBillEntity.Txt_volume = double.Parse(txt_volume.Value.ToString());//保量加价
  1692. al_CkInBillEntity.Add(CkInBillEntity);
  1693. //-----------------------------------------------------------------------------库存单表
  1694. CkStorageEntity.RefeId = CkInBillEntity.RefeId;
  1695. CkStorageEntity.Status = tips == 2 ? "1" : "0";
  1696. CkStorageEntity.UseStatus = tips == 2 ? "1" : "0";
  1697. CkStorageEntity.Validflag = "1";
  1698. CkStorageEntity.InvPhysic = strInvPhysic;
  1699. CkStorageEntity.InvQty = b_INNUM;//库存数量
  1700. CkStorageEntity.InvOrigQty = b_INNUM;//期初库存数量
  1701. if (!String.IsNullOrEmpty(strPackUnit))
  1702. {
  1703. CkStorageEntity.PackageQty = bPACKAGEQTY + "";//包装数
  1704. CkStorageEntity.UnitWeight = bUNITWEIGHT + "";//每包重量
  1705. CkStorageEntity.PackageUnit = strPackUnit + "";//包装单位
  1706. }
  1707. CkStorageEntity.CreateUserid = UserInfo.GetUserID();
  1708. CkStorageEntity.CreateName = UserInfo.GetUserName();
  1709. CkStorageEntity.OperateOrgId = UserInfo.GetDeptid();
  1710. CkStorageEntity.OperateOrgName = UserInfo.GetDepartment();
  1711. CkStorageEntity.UpdateName = null;
  1712. CkStorageEntity.UpdateUserid = null;
  1713. CkStorageEntity.UpdateTime = null;
  1714. CkStorageEntity.ItemUomConefficient = b_ITEMUOMCONEFFICIENT;
  1715. //检化验数据
  1716. CkStorageEntity.Result = "";//检验结果(料型或者等级)
  1717. CkStorageEntity.CheckResult = strCheckStatu;//判定是否合格
  1718. CkStorageEntity.CheckDate = DtCheck;//判定时间
  1719. CkStorageEntity.CheckUsername = strCheckUser;//判断人
  1720. al_CkStorageEntity.Add(CkStorageEntity);
  1721. //-----------------------------------------------------------------------------------------------------------入库单储位明细表
  1722. CkInbillPositionEntity.InStockNo = CkInBillEntity.RefeId;// ultraGrid5.ActiveRow.Cells["DELIVERYSUBLINESQE"].Value.ToString();//入库单号记录送货通知单行号,方便在后台获取入库单号
  1723. CkInbillPositionEntity.Validflag = "1";
  1724. CkInbillPositionEntity.InNum = b_INNUM;//入库量
  1725. CkInbillPositionEntity.InvPhysic = CkInBillEntity.InvPhysic;//物理库区
  1726. CkInbillPositionEntity.InvPos = strINVPOS; ;//库位
  1727. CkInbillPositionEntity.CreateUserid = UserInfo.GetUserID();
  1728. if (!String.IsNullOrEmpty(strPackUnit))
  1729. {
  1730. CkInbillPositionEntity.PackageQty = bPACKAGEQTY + "";//包装数量
  1731. }
  1732. CkInbillPositionEntity.CreateUserid = UserInfo.GetUserID();
  1733. CkInbillPositionEntity.CreateName = UserInfo.GetUserName();
  1734. al_PurCkInbillPositionEntity.Add(CkInbillPositionEntity);//添加入库单储位明细表
  1735. //---------------------------------------------------------------------------------------------------------------------------------库存储位明细表
  1736. CkStoragePosEntity.InvId = CkInBillEntity.RefeId;//库存记录号记录发货通知单行号,方便在后台获取入库单号
  1737. CkStoragePosEntity.Validflag = "1";
  1738. CkStoragePosEntity.InvOrigQty = b_INNUM;//期初入库量
  1739. CkStoragePosEntity.InvQty = b_INNUM;//库存数量
  1740. CkStoragePosEntity.InvPhysic = CkInBillEntity.InvPhysic; //txt_INV_PHYSIC.Value == null ? null : txt_INV_PHYSIC.Value.ToString();//物理库区
  1741. CkStoragePosEntity.InvPos = strINVPOS;//ugr_5.Cells["INVPOS"].Value.ToString();//库位
  1742. if (!String.IsNullOrEmpty(strPackUnit))
  1743. {
  1744. CkStoragePosEntity.PackageQty = bPACKAGEQTY + "";//包装数量
  1745. CkStoragePosEntity.PackageUnit = strPackUnit + "";//包装单位
  1746. CkStoragePosEntity.UnitWeight = bUNITWEIGHT;//每袋重量
  1747. }
  1748. CkStoragePosEntity.InvQtyWeight = b_INNUM * b_ITEMUOMCONEFFICIENT;
  1749. CkStoragePosEntity.CreateUserid = UserInfo.GetUserID();
  1750. CkStoragePosEntity.CreateName = UserInfo.GetUserName();
  1751. al_CkStoragePosEntity.Add(CkStoragePosEntity);//添加库存单储位明细表
  1752. }
  1753. //送货单
  1754. EdC.DeliverySubLineSqe = strSubSqe;//送货通知单行号
  1755. //获取计量信息
  1756. EdC.JlQty = dbJLQty;//计量结果
  1757. EdC.ReceivedQty = b_INNUM;//实际入库量
  1758. EdC.KzQty = b_KZQTY;//扣杂量
  1759. EdC.ItemUomConefficient = b_ITEMUOMCONEFFICIENT;
  1760. EdC.Deduction2 = dbDeduction2;//扣机铁
  1761. EdC.Deduction3 = dbDeduction3;//扣超长
  1762. EdC.Deduction4 = dbDeduction4;//扣轻薄
  1763. EdC.Matchid = strmatchid;
  1764. EdC.PackageQty = bPACKAGEQTY + "";//包装数量
  1765. EdC.PackageUnit = strPackUnit + "";//包装单位
  1766. EdC.UnitWeight = bUNITWEIGHT;//每袋重量
  1767. EdC.RkName = UserInfo.GetUserName();
  1768. EdC.RkUserid = UserInfo.GetUserID();
  1769. EdC.RkTime = DateTime.Now;
  1770. al_ExcDeliverySubC.Add(EdC);
  1771. }
  1772. if (al_ExcDeliverySubC.Count < 1)
  1773. {
  1774. MessageUtil.ShowTips("请勾选送货单");
  1775. return;
  1776. }
  1777. CoreResult crt = new CoreResult();
  1778. if (tips == 1)
  1779. {
  1780. if (MessageUtil.ShowYesNoAndQuestion("确定待检入库?") != DialogResult.Yes)
  1781. {
  1782. return;
  1783. }
  1784. crt = this.GetJsonService().execute<CoreResult>("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "doWaitInstock", new object[] { al_ExcDeliverySubC, al_CkInBillEntity, al_PurCkInbillPositionEntity, al_CkStorageEntity, al_CkStoragePosEntity,strCoustomInfo });
  1785. }
  1786. else if (tips == 2)
  1787. {
  1788. frmPopSetCkInBillOutNum frm = new frmPopSetCkInBillOutNum(this.ob, dt_forUsePlan, al_ExcDeliverySubC);
  1789. frm.ShowDialog();
  1790. htusePlan = frm.ht;
  1791. if (frm.strTips == "0")
  1792. {
  1793. return;
  1794. }
  1795. else
  1796. {
  1797. if (frm.strTips == "1")
  1798. {
  1799. if (MessageUtil.ShowYesNoAndQuestion("确定正式入库? 若存在异常单数量,请及时输入异常单数量并及时通知业务员进行异常单处置。") != DialogResult.Yes)
  1800. {
  1801. return;
  1802. }
  1803. }
  1804. }
  1805. crt = this.GetJsonService().execute<CoreResult>("com.hnshituo.pur.ck.service.CkInBillService", "doInstock", new object[] { al_CkInBillEntity, al_PurCkInbillPositionEntity, al_CkStorageEntity, al_CkStoragePosEntity, al_ExcDeliverySubC, al_ExcDeliveryException, htusePlan, strCoustomInfo});
  1806. }
  1807. else
  1808. {
  1809. MessageUtil.ShowTips("入库类型参数错误 1:待检入库,2:正式入库");
  1810. return;
  1811. }
  1812. if (crt.Resultcode != 0)
  1813. {
  1814. MessageUtil.ShowTips("操作失败 " + crt.Resultmsg);
  1815. return;
  1816. }
  1817. MessageUtil.ShowTips("操作成功");
  1818. Get_PUR_EXC_DELIVERY_M("");
  1819. }
  1820. catch (System.Exception ex)
  1821. {
  1822. MessageUtil.ShowTips("操作失败:" + ex.Message);
  1823. }
  1824. }
  1825. #endregion
  1826. #region 交货量差控制
  1827. private bool testDeliveryQtyCtrl(ExcDeliverySubM subMOld, ExcDeliverySubC subCOld, double b_INNUM)
  1828. {
  1829. String strSupp = subMOld.SuppCode;
  1830. String strItemCode = subCOld.ItemCode;
  1831. Entity_SuppGrade grade = new Entity_SuppGrade();
  1832. grade.SuppCode = strSupp;
  1833. grade.ItemCode = strItemCode;
  1834. double qty = (double)subCOld.ShipQty;
  1835. List<Entity_SuppGrade> listGrade = this.execute<List<Entity_SuppGrade>>("com.hnshituo.pur.configure.service.SuppGradeService", "find", new object[] { grade,0,0 });//添加操作
  1836. if (listGrade != null && listGrade.Count >= 1)
  1837. {
  1838. grade = listGrade[0];
  1839. if (grade.DelvryRangeTpe == "0")
  1840. {
  1841. return true;
  1842. }
  1843. else if (grade.DelvryRangeTpe == "1")//绝对值
  1844. {
  1845. double maxQty = (double)grade.DelvryRangeMax + qty;
  1846. double minQty = qty - (double)grade.DelvryRangeMin;
  1847. if (b_INNUM > maxQty)
  1848. {
  1849. MessageUtil.ShowTips("供应商:" + subMOld.SuppName + "的物料:" + subCOld.ItemName + "的入库量已经超出交货量上限为:" + maxQty);
  1850. return false;
  1851. }
  1852. if (b_INNUM < minQty)
  1853. {
  1854. MessageUtil.ShowTips("供应商:" + subMOld.SuppName + "的物料:" + subCOld.ItemName + "的入库量已经超出交货量下限为:" + minQty);
  1855. return false;
  1856. }
  1857. }
  1858. else if (grade.DelvryRangeTpe == "2")//百分比
  1859. {
  1860. double maxQty = Math.Round(qty * (1 + (double)grade.DelvryRangeMax / 100), 3);
  1861. double minQty = Math.Round(qty * (1 - (double)grade.DelvryRangeMax / 100), 3);
  1862. if (b_INNUM > maxQty)
  1863. {
  1864. MessageUtil.ShowTips("供应商:" + subMOld.SuppName + "的物料:" + subCOld.ItemName + "的入库量已经超出交货量上限为:" + maxQty);
  1865. return false;
  1866. }
  1867. if (b_INNUM < minQty)
  1868. {
  1869. MessageUtil.ShowTips("供应商:" + subMOld.SuppName + "的物料:" + subCOld.ItemName + "的入库量已经超出交货量下限为:" + minQty);
  1870. return false;
  1871. }
  1872. }
  1873. else if (grade.DelvryRangeTpe == "2") //不允许
  1874. {
  1875. if (b_INNUM != qty)
  1876. {
  1877. MessageUtil.ShowTips("供应商:" + subMOld.SuppName + "的物料:" + subCOld.ItemName + "的入库量不允许有交货量差,入库量和和要求送货量必须一致");
  1878. return false;
  1879. }
  1880. }
  1881. else
  1882. {
  1883. MessageUtil.ShowTips("请维护供应商:" + subMOld.SuppName + "的物料:" + subCOld.ItemName + "的交货量差方式");
  1884. return false;
  1885. }
  1886. }
  1887. else
  1888. {
  1889. MessageUtil.ShowTips("请维护供应商:" + subMOld.SuppName + "的物料:" + subCOld.ItemName + "的交货量差");
  1890. return false;
  1891. }
  1892. return true;
  1893. }
  1894. #endregion
  1895. #region 公共函数
  1896. /// <summary>
  1897. /// 设置可编辑的单元格及其颜色
  1898. /// </summary>
  1899. /// <param name="ugr"></param>
  1900. /// <param name="columnName"></param>
  1901. private void setCellColor(UltraGridRow ugr, Color color, params string[] columnName)
  1902. {
  1903. for (int i = 0; i < columnName.Length; i++)
  1904. {
  1905. columnName[i] = columnName[i].ToUpper();
  1906. }
  1907. foreach (UltraGridCell ugc in ugr.Cells)
  1908. {
  1909. if (columnName.Contains(ugc.Column.Key.ToString().ToUpper()))
  1910. {
  1911. ugc.Appearance.BackColor = color;
  1912. ugc.Activation = Activation.AllowEdit;
  1913. }
  1914. else
  1915. {
  1916. ugc.Appearance.BackColor = ugr.Cells["status"].Appearance.BackColor;
  1917. ugc.Activation = Activation.ActivateOnly;
  1918. }
  1919. if (ugc.Column.Key.ToString().ToUpper() == "CHECK")
  1920. {
  1921. ugc.Appearance.BackColor = color;
  1922. ugc.Activation = Activation.AllowEdit;
  1923. }
  1924. }
  1925. }
  1926. /// <summary>
  1927. /// 设置单元格颜色,和在可编辑状态
  1928. /// </summary>
  1929. /// <param name="ugr"></param>
  1930. /// <param name="columnName"></param>
  1931. private void setColumnColor(UltraGrid ug, Color color, params string[] columnName)
  1932. {
  1933. return;
  1934. for (int i = 0; i < columnName.Length; i++)
  1935. {
  1936. columnName[i] = columnName[i].ToUpper();
  1937. }
  1938. foreach (UltraGridColumn ugc in ug.DisplayLayout.Bands[0].Columns)
  1939. {
  1940. if (columnName.Contains(ugc.Key.ToString().ToUpper()))
  1941. {
  1942. ugc.CellAppearance.BackColor = color;
  1943. ugc.CellActivation = Activation.AllowEdit;
  1944. }
  1945. else
  1946. {
  1947. ugc.CellAppearance.BackColor = ug.DisplayLayout.Bands[0].Columns["status"].CellAppearance.BackColor;
  1948. ugc.CellActivation = Activation.ActivateOnly;
  1949. }
  1950. }
  1951. }
  1952. #endregion
  1953. #region 计量-检化验-异常单 行信息
  1954. /// <summary>
  1955. /// 查询非计量入库单质检、异常单信息
  1956. /// </summary>
  1957. /// <param name="sender"></param>
  1958. /// <param name="e"></param>
  1959. private void GridSubDNoJL_ClickCell(object sender, ClickCellEventArgs e)
  1960. {
  1961. UltraGridRow row = e.Cell.Row;
  1962. String subSqe = row.GetCellValue("DELIVERYSUBLINESQE").ToString().Trim();
  1963. ArrayList list = new ArrayList();
  1964. list.Add(subSqe);
  1965. String sordSqe = row.GetCellValue("ORDERLINESQE").ToString().Trim();
  1966. ArrayList list1 = new ArrayList();
  1967. list1.Add(sordSqe);
  1968. getDetailForSubD((string[])list.ToArray(typeof(string)), "1", (string[])list1.ToArray(typeof(string)));
  1969. }
  1970. /// <summary>
  1971. /// 查询计量入库单质检、异常单信息
  1972. /// </summary>
  1973. /// <param name="sender"></param>
  1974. /// <param name="e"></param>
  1975. private void GridSubDJL_ClickCell(object sender, ClickCellEventArgs e)
  1976. {
  1977. }
  1978. /// <summary>
  1979. /// 查询实绩入库单质检、异常单信息
  1980. /// </summary>
  1981. /// <param name="sender"></param>
  1982. /// <param name="e"></param>
  1983. private void GridSubDSJ_ClickCell(object sender, ClickCellEventArgs e)
  1984. {
  1985. UltraGridRow row = e.Cell.Row;
  1986. String subSqe = row.GetCellValue("DELIVERYSUBLINESQE").ToString().Trim();
  1987. ArrayList list = new ArrayList();
  1988. list.Add(subSqe);
  1989. String sordSqe = row.GetCellValue("ORDERLINESQE").ToString().Trim();
  1990. ArrayList list1 = new ArrayList();
  1991. list1.Add(sordSqe);
  1992. getDetailForSubD((string[])list.ToArray(typeof(string)), "3", (string[])list1.ToArray(typeof(string)));
  1993. }
  1994. /// <summary>
  1995. /// 获取计量-检化验-异常单数据
  1996. /// </summary>
  1997. /// <param name="subSqe"></param>
  1998. /// <param name="p"></param>
  1999. private void getDetailForSubD(String[] list, string p, String[] orderList)
  2000. {
  2001. if ("2" == p)
  2002. {
  2003. publicPms.clearOldData(panel_JL, new string[] { });
  2004. }
  2005. else if ("3" == p)
  2006. {
  2007. publicPms.clearOldData(panel_sj, new string[] { });
  2008. }
  2009. JHY.Clear();
  2010. JLdata.Clear();
  2011. exception.Clear();
  2012. //DataTable data1 = new DataTable();
  2013. if (list.Length>0)
  2014. {
  2015. DataTable dtjl = null;
  2016. for (int i = 0; i < list.Length; i++) //根据选中的行数循环获取榜单记录
  2017. {
  2018. String subSqe = list[i].ToString();
  2019. ExcDeliverySubC subc = this.GetJsonService().execute<ExcDeliverySubC>("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "findById", new object[] { subSqe });
  2020. if (subc == null)
  2021. {
  2022. return;
  2023. }
  2024. String strCheckNo = subc.CheckNo;
  2025. //查询检化验
  2026. if (!String.IsNullOrEmpty(strCheckNo))
  2027. {
  2028. CheckconsignBaseinfo baseinfo = new CheckconsignBaseinfo();
  2029. baseinfo.CheckNo = strCheckNo;
  2030. List<CheckconsignBaseinfo> Listbaseinfo = this.GetJsonService().execute<List<CheckconsignBaseinfo>>("com.hnshituo.pur.jhy.service.CheckconsignBaseinfo_jhyService", "doQuery_Baseinfo", new object[] { baseinfo });
  2031. if (Listbaseinfo != null && Listbaseinfo.Count >= 1)
  2032. {
  2033. baseinfo = Listbaseinfo[0];
  2034. if ("2" == p)
  2035. {
  2036. JHY_check_no_JL.Text = baseinfo.CheckNo;
  2037. JHY_CHECK_COUNT_JL.Text = baseinfo.CheckCount;
  2038. JHY_CONSIGN_DEPT_JL.Text = baseinfo.ConsignDept;
  2039. JHY_CONSIGN_NAME_JL.Text = baseinfo.ConsignName;
  2040. JHY_CONSIGN_TIME_JL.Value = baseinfo.ConsignTime;
  2041. JHY_IS_JUDGE_JL.Text = baseinfo.IsJudge;
  2042. JHY_JUDGE_LEVEL_JL.Text = baseinfo.JudgeLevel;
  2043. JHY_PRODUCT_STD_JL.Text = baseinfo.ProductStd;
  2044. }
  2045. else if ("3" == p)
  2046. {
  2047. JHY_check_no_SJ.Text = baseinfo.CheckNo;
  2048. JHY_CHECK_COUNT_SJ.Text = baseinfo.CheckCount;
  2049. JHY_CONSIGN_DEPT_SJ.Text = baseinfo.ConsignDept;
  2050. JHY_CONSIGN_NAME_SJ.Text = baseinfo.ConsignName;
  2051. JHY_CONSIGN_TIME_SJ.Value = baseinfo.ConsignTime;
  2052. JHY_IS_JUDGE_SJ.Text = baseinfo.IsJudge;
  2053. JHY_JUDGE_LEVEL_SJ.Text = baseinfo.JudgeLevel;
  2054. JHY_PRODUCT_STD_SJ.Text = baseinfo.ProductStd;
  2055. }
  2056. //加载行表
  2057. CheckconsignDetail detail = new CheckconsignDetail();
  2058. detail.CheckNo = strCheckNo;
  2059. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.jhy.service.CheckconsignDetail_jhyService", "doQuery_Detail", new object[] { detail, 0, 0 });
  2060. GridHelper.CopyDataToDatatable(dt, DTJHY, true);
  2061. }
  2062. }
  2063. //加载异常单
  2064. ExcDeliveryException hand = new ExcDeliveryException();
  2065. hand.DeliverySubLineSqe = list[i].ToString();
  2066. hand.Validflag = "1";
  2067. DataTable dte = this.execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliveryExceptionService", "doQuery_Exceptions", new object[] { hand });
  2068. GridHelper.CopyDataToDatatable(dte, DTHandle, true);
  2069. //if ("2" == p)
  2070. //{
  2071. // //加载计量数据
  2072. // QSubSqe_JL.Text = list[i].ToString();
  2073. // // dtjl = getJLData("");
  2074. // // data1.Merge(dtjl); //合并datatable 循环查询选中的送货单行号
  2075. // // GridHelper.CopyDataToDatatable(data1, DTJL, true);//下表查询到的榜单 赋值给DTJL
  2076. dtjl = getJLData(orderList);
  2077. // GridHelper.CopyDataToDatatable(dtjl, DTJL, true);//下表查询到的榜单 赋值给DTJL
  2078. // GridHelper.RefreshAndAutoSize(GridJHY_JL);
  2079. // GridHelper.RefreshAndAutoSize(GridHandleJL);
  2080. // GridHelper.RefreshAndAutoSize(GridJL_JL);
  2081. //}
  2082. //else if ("3" == p)
  2083. if("3"==p)
  2084. {
  2085. if (!String.IsNullOrEmpty(subc.Matchid))
  2086. {
  2087. //加载计量数据
  2088. //dtjl = getJLData(subc.Matchid);
  2089. if (dtjl != null && dtjl.Rows.Count > 0)
  2090. {
  2091. GridHelper.CopyDataToDatatable(dtjl, DTJL, true);//下标查询到的榜单 赋值给DTJL
  2092. // GridHelper.CopyDataToDatatable(dtjl, DTJL, true);
  2093. }
  2094. }
  2095. //加载入库数据
  2096. PurCkInBillEntity pcibEntity = new PurCkInBillEntity();
  2097. pcibEntity.RefeId = subSqe;
  2098. DataTable dtinbill = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkInBillService", "GetCkInBill", new object[] { pcibEntity });
  2099. GridHelper.CopyDataToDatatable(dtinbill, DTinbill, true);
  2100. GridHelper.RefreshAndAutoSize(GridJHY_SJ);
  2101. GridHelper.RefreshAndAutoSize(GridHandleSJ);
  2102. GridHelper.RefreshAndAutoSize(GridJL_SJ);
  2103. GridHelper.RefreshAndAutoSize(GridInbill);
  2104. }
  2105. }
  2106. if ("2" == p)
  2107. {
  2108. //加载计量数据
  2109. //QSubSqe_JL.Text = list[i].ToString();
  2110. // dtjl = getJLData("");
  2111. // data1.Merge(dtjl); //合并datatable 循环查询选中的送货单行号
  2112. // GridHelper.CopyDataToDatatable(data1, DTJL, true);//下表查询到的榜单 赋值给DTJL
  2113. //dtjl = getJLData(list);
  2114. GridHelper.CopyDataToDatatable(dtjl, DTJL, true);//下表查询到的榜单 赋值给DTJL
  2115. GridHelper.RefreshAndAutoSize(GridJHY_JL);
  2116. GridHelper.RefreshAndAutoSize(GridHandleJL);
  2117. GridHelper.RefreshAndAutoSize(GridJL_JL);
  2118. }
  2119. }
  2120. }
  2121. /// <summary>
  2122. /// 查询
  2123. /// </summary>
  2124. private DataTable getJLData(String[] ordernos)
  2125. {
  2126. try
  2127. {
  2128. this.Cursor = Cursors.WaitCursor;//等待
  2129. Hashtable ht = new Hashtable();
  2130. // if(String.IsNullOrEmpty(strMatchId))
  2131. if (ordernos.Length>0)
  2132. {
  2133. ht.Add("materialcode", QitemCode_JL.Text.Trim());
  2134. ht.Add("materialname", QitemName_JL.Text.Trim());
  2135. ht.Add("sourcecode", QsuppCode_JL.Text.Trim());
  2136. ht.Add("sourcename", QSuppName_JL.Text);
  2137. if (ck_shutt_JL.Checked)
  2138. {
  2139. if (txt_shuttTimeStart_JL.Value != null)
  2140. {
  2141. ht.Add("suttletime", ((DateTime)txt_shuttTimeStart_JL.Value).ToString("yyyy-MM-dd") + " 00:00:00");//净重时间开始
  2142. }
  2143. if (txt_shuttTimeEnd_JL.Value != null)
  2144. {
  2145. ht.Add("taretime", ((DateTime)txt_shuttTimeEnd_JL.Value).ToString("yyyy-MM-dd") + " 23:59:59");//净重时间结束
  2146. }
  2147. }
  2148. ht.Add("matchid", Qmatchid_JL.Text.Trim());
  2149. ht.Add("carno", QCarNo_JL.Text.Trim());
  2150. // ht.Add("orderno", QSubSqe_JL.Text.Trim());
  2151. ht.Add("ordernos", ordernos);
  2152. ht.Add("updateUserid", "5");
  2153. DataTable subc = this.execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "Query_C", new object[] { ht });
  2154. ArrayList matchids = new ArrayList();
  2155. for (int i = 0; i < subc.Rows.Count; i++)
  2156. {
  2157. matchids.Add(subc.Rows[i]["MATCHID"].ToString2());
  2158. }
  2159. if (matchids.Count > 0)
  2160. {
  2161. ht.Add("matchidsnNotIn", (string[])matchids.ToArray(typeof(string)));
  2162. }
  2163. }
  2164. else
  2165. {
  2166. ht.Add("materialcode", QitemCode_JL.Text.Trim());
  2167. ht.Add("materialname", QitemName_JL.Text.Trim());
  2168. ht.Add("sourcecode", QsuppCode_JL.Text.Trim());
  2169. ht.Add("sourcename", QSuppName_JL.Text);
  2170. if (ck_shutt_JL.Checked)
  2171. {
  2172. if (txt_shuttTimeStart_JL.Value != null)
  2173. {
  2174. ht.Add("suttletime", ((DateTime)txt_shuttTimeStart_JL.Value));//净重时间开始
  2175. }
  2176. if (txt_shuttTimeEnd_JL.Value != null)
  2177. {
  2178. ht.Add("taretime", ((DateTime)txt_shuttTimeEnd_JL.Value));//净重时间结束
  2179. }
  2180. }
  2181. ht.Add("matchid", Qmatchid_JL.Text.Trim());
  2182. ht.Add("carno", QCarNo_JL.Text.Trim());
  2183. // ht.Add("orderno", QSubSqe_JL.Text.Trim());
  2184. ht.Add("ordernos", ordernos);
  2185. }
  2186. DataTable dt = this.GetJsonService().execute<DataTable>("com.hnshituo.pur.utils.service.UtilsService", "readData", new object[] { ht });
  2187. return dt;
  2188. }
  2189. catch (System.Exception e)
  2190. {
  2191. MessageUtil.ShowTips("加载计量数据异常:" + e.Message);
  2192. return null;
  2193. }
  2194. finally
  2195. {
  2196. this.Cursor = Cursors.Default;//鼠标状态恢复正常
  2197. }
  2198. }
  2199. #endregion
  2200. //选中送货行单(右上表) 触发事件
  2201. private void GridSubDJL_AfterRowActivate(object sender, System.EventArgs e)
  2202. {
  2203. //获取选中的行数的 送货单行
  2204. IQueryable<UltraGridRow> uGridss = GridSubDJL.Rows.AsQueryable().Where(" Check = 'True'");
  2205. ArrayList list = new ArrayList();
  2206. ArrayList list1 = new ArrayList();
  2207. foreach (UltraGridRow ugrs in uGridss)
  2208. {
  2209. String shdhid = ugrs.Cells["DELIVERYSUBLINESQE"].Value.ToString();
  2210. list.Add(shdhid);
  2211. String sordSqe = ugrs.GetCellValue("ORDERLINESQE").ToString().Trim();
  2212. list1.Add(sordSqe);
  2213. }
  2214. if (GridSubDJL.ActiveRow == null)
  2215. return;
  2216. //DTJL.Clear();
  2217. getDetailForSubD((string[])list.ToArray(typeof(string)), "2", (string[])list1.ToArray(typeof(string)));
  2218. }
  2219. //计算加减价后价格政策明细单价
  2220. private void setJGZCPrice(DataTable re)
  2221. {
  2222. if (!StringUtil.Is_Below_zero(txt_honour.Text.Trim()))
  2223. {
  2224. txt_honour.Text = "0";
  2225. }
  2226. if (!StringUtil.Is_Below_zero(txt_volume.Text.Trim()))
  2227. {
  2228. txt_volume.Text = "0";
  2229. }
  2230. if (!StringUtil.Is_Below_zero(txt_check.Text.Trim()))
  2231. {
  2232. txt_check.Text = "0";
  2233. }
  2234. if (!StringUtil.Is_Below_zero(txtLEN_DEDUCT_PRICE.Text.Trim()))
  2235. {
  2236. txtLEN_DEDUCT_PRICE.Text = "0";
  2237. }
  2238. //double addNum = Convert.ToDouble(txtADD_PRICE.Text.Trim());
  2239. //double addNum = Convert.ToDouble(txt_honour.Text.Trim()) + Convert.ToDouble(txt_volume.Text.Trim()) - Convert.ToDouble(txt_check.Text.Trim()) - Convert.ToDouble(txtLEN_DEDUCT_PRICE.Text.Trim());
  2240. double addNum = Convert.ToDouble(txt_honour.Text.Trim()) + Convert.ToDouble(txt_volume.Text.Trim()) - Convert.ToDouble(txt_check.Text.Trim());
  2241. foreach (DataRow dr in re.Rows)
  2242. {
  2243. dr["priceVal"] = Convert.ToDouble(dr["priceVal"].ToString()) + addNum;
  2244. }
  2245. }
  2246. private void bindPrice() {
  2247. if (cbxJGZC.SelectedIndex == -1)
  2248. {
  2249. MessageUtil.ShowTips("请选择价格政策计算废钢价格!");
  2250. return;
  2251. }
  2252. BalanceBasepriceC pc = new BalanceBasepriceC();
  2253. pc.StandId = cbxJGZC.Value.ToString();
  2254. pc.Validflag = "1";
  2255. //调用服务器查询API进行查询
  2256. DataTable re = this.execute<DataTable>("com.hnshituo.pur.balance.service.BalanceBasepriceCService", "doQureyBasePriceC", new object[] { pc });
  2257. setJGZCPrice(re);
  2258. Double priceVal = 0;
  2259. Double jlqty = 0;
  2260. Double sl = 1.13;//税率
  2261. foreach (UltraGridRow row in GridSubDJL.Rows)
  2262. {
  2263. String checkResult = row.GetCellValue("CheckResult").ToString().Trim();
  2264. if (row.Cells["JLQTY"].Value.ToString().Trim() != "0.00" && !String.IsNullOrEmpty(checkResult))
  2265. {
  2266. foreach (DataRow dr in re.Rows)
  2267. {
  2268. if (checkResult == dr["gradeLevel"].ToString())
  2269. {
  2270. Double.TryParse(dr["priceVal"].ToString().Trim(), out priceVal);//计价值
  2271. Double.TryParse(row.Cells["JLQTY"].Value.ToString().Trim(), out jlqty);//净重
  2272. row.Cells["regularPrice"].Value = Math.Round(priceVal, 4).ToString();//含税单价
  2273. row.Cells["regularPriceVal"].Value = Math.Round(priceVal * jlqty, 4).ToString();//含税价格
  2274. row.Cells["price"].Value = Math.Round(priceVal / sl, 4).ToString();//不含税单价
  2275. row.Cells["priceVal"].Value = Math.Round(priceVal / sl * jlqty, 4).ToString();//含税价格
  2276. }
  2277. }
  2278. }
  2279. }
  2280. }
  2281. }
  2282. }