FrmCkStorage.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using CoreFS.CA06;using Pur.Entity;
  10. using Pur.Entity.ck;
  11. using Pur.require_plan;
  12. using Pur.Entity.configureEntity;
  13. using Core.Mes.Client.Comm.Control;
  14. using com.hnshituo.pur.vo;
  15. using Pur.configure;
  16. using Infragistics.Win;
  17. using Pur.PublicTools;
  18. using Infragistics.Win.UltraWinGrid;
  19. using Pur.Pop_upWindow;
  20. using Core.Mes.Client.Comm.Tool;
  21. using System.Collections;
  22. using Core.Mes.Client.Comm.Server;
  23. using Core.Mes.Client.Comm;
  24. namespace Pur.ck
  25. {
  26. public partial class FrmCkStorage : FrmPmsBase
  27. {
  28. public FrmCkStorage()
  29. {
  30. InitializeComponent();
  31. txt_createTimeE.Value = System.DateTime.Now;
  32. txt_createTimeS.Value = ((DateTime)txt_createTimeE.Value).AddMonths(-1);
  33. //ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
  34. }
  35. //菜单按钮事件
  36. public override void ToolBar_Click(object sender, string ToolbarKey)
  37. {
  38. switch (ToolbarKey)
  39. {
  40. case "Query":
  41. if (ultraTabControl2.SelectedTab.Key == "0")
  42. {
  43. GetPUR_CK_STORAGE();
  44. }
  45. else
  46. {
  47. getPur_Ck_StorageSuorce();
  48. }
  49. break;
  50. case "Add":
  51. addCkInBill();
  52. break;
  53. case "cockInv":
  54. cockInv();
  55. break;
  56. case "unCockInv":
  57. unCockInv();
  58. break;
  59. case "MovingInvPhy":
  60. MovingInvPhy();
  61. break;
  62. case "CanCelMovingInvPhy":
  63. CanCelMovingInvPhy();
  64. break;
  65. case "Print":
  66. doPrint("0");
  67. break;
  68. case "overPrint":
  69. doPrint("1");
  70. break;
  71. case "CanCelPrint":
  72. CanCelPrint();
  73. break;
  74. case "doexport":
  75. doexport();
  76. break;
  77. case "doSaveMemo":
  78. doSaveMemo();
  79. break;
  80. }
  81. }
  82. public void doexport()
  83. {
  84. if (ultraTabControl2.ActiveTab.Key == "0")
  85. GridHelper.ulGridToExcel(ultraGrid1, ultraGrid1.Text);
  86. else
  87. GridHelper.ulGridToExcel(ultraGrid5, ultraGrid5.Text);
  88. }
  89. /// <summary>
  90. /// 查询
  91. /// </summary>
  92. private void GetPUR_CK_STORAGE()
  93. {
  94. dataTable2.Rows.Clear();
  95. dataTable3.Rows.Clear();
  96. CkStorage CkSto = new CkStorage();
  97. CkSto.InvId = txt_InvId.Text;
  98. CkSto.ItemCode = txt_itemCode.Text;
  99. CkSto.ItemName = txt_itemName.Text;
  100. if (txt_invBin.Value != null)
  101. {
  102. CkSto.DeleteName = txt_invBin.Text;
  103. }
  104. //CkSto.InvLogic = txt_invLogic.Text;
  105. if (txt_invPhysic.Value != null)
  106. {
  107. CkSto.DeleteUserid = txt_invPhysic.Text;
  108. }
  109. CkSto.SuppName = txt_suppName.Text;
  110. CkSto.OrderId = txt_orderId.Text;
  111. CkSto.InStockNo = txt_inStockNo.Text;
  112. CkSto.InvQty = Convert.ToDouble(txt_invOrigQty.Value);
  113. CkSto.CreateName = txtItemClass.Text;
  114. if (!string.IsNullOrEmpty(txt_createTimeS.Text) && !string.IsNullOrEmpty(txt_createTimeE.Text))
  115. {
  116. CkSto.CreateTime = Convert.ToDateTime(txt_createTimeS.Text);
  117. CkSto.UpdateTime = Convert.ToDateTime(txt_createTimeE.Text).AddDays(1);
  118. }
  119. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkStorageService", "find_Storage", new object[] { CkSto });
  120. GridHelper.CopyDataToDatatable(dt, dataTable1, true);
  121. GridHelper.RefreshAndAutoSize(ultraGrid1);
  122. //publicPms.autoGridColumnWSize(ultraGrid1.DisplayLayout.Bands[0]);
  123. getBindInvPhySic();
  124. getBindInvPhySicPos();
  125. txt_invPhysic.Text = CkSto.DeleteUserid;
  126. txt_invBin.Text = CkSto.DeleteName;
  127. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  128. {
  129. //标记待检状态入库单
  130. if (ugr.Cells["USESTATUS"].Value.ToString() == "不可用")
  131. {
  132. ugr.Cells["USESTATUS"].Appearance.ForeColor = Color.Red;// System.Drawing.Color.FromArgb(255, 128, 0);
  133. ugr.Cells["STATUS"].Appearance.ForeColor = Color.Red;// System.Drawing.Color.FromArgb(255, 128, 0);
  134. }
  135. else
  136. {
  137. ugr.Cells["USESTATUS"].Appearance.ForeColor = Color.Black;
  138. ugr.Cells["STATUS"].Appearance.ForeColor = Color.Black;// System.Drawing.Color.FromArgb(255, 128, 0);
  139. }
  140. }
  141. }
  142. /// <summary>
  143. /// 获取移库记录
  144. /// </summary>
  145. private void getPur_Ck_StorageSuorce()
  146. {
  147. //dataTable7.Rows.Clear();
  148. //CkStorage CkSto = new CkStorage();
  149. //CkSto.InvId = txt_InvId.Text;
  150. //CkSto.ItemCode = txt_itemCode.Text;
  151. //CkSto.ItemName = txt_itemName.Text;
  152. //if (txt_invBin.Value != null)
  153. //{
  154. // CkSto.DeleteName = txt_invBin.Text;
  155. //}
  156. ////CkSto.InvLogic = txt_invLogic.Text;
  157. //if (txt_invPhysic.Value != null)
  158. //{
  159. // CkSto.DeleteUserid = txt_invPhysic.Text;
  160. //}
  161. //CkSto.SuppName = txt_suppName.Text;
  162. //CkSto.OrderId = txt_orderId.Text;
  163. //CkSto.InStockNo = txt_inStockNo.Text;
  164. //CkSto.InvQty = Convert.ToDouble(txt_invOrigQty.Value);
  165. //if (!string.IsNullOrEmpty(txt_createTimeS.Text) && !string.IsNullOrEmpty(txt_createTimeE.Text))
  166. //{
  167. // CkSto.CreateTime = Convert.ToDateTime(txt_createTimeS.Text);
  168. // CkSto.UpdateTime = Convert.ToDateTime(txt_createTimeE.Text).AddDays(1);
  169. //}
  170. ////查询源移库记录
  171. //CkSto.Status = "11";
  172. //DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkStorageService", "find_Storage", new object[] { CkSto });
  173. //GridHelper.CopyDataToDatatable(dt, dataTable4, true);
  174. //GridHelper.RefreshAndAutoSize(ultraGrid2);
  175. dataTable6.Rows.Clear();
  176. CkStorage CkSto = new CkStorage();
  177. CkSto.InvId = txt_InvId.Text;
  178. CkSto.ItemCode = txt_itemCode.Text;
  179. CkSto.ItemName = txt_itemName.Text;
  180. if (txt_invBin.Value != null)
  181. {
  182. CkSto.DeleteName = txt_invBin.Text;
  183. }
  184. //CkSto.InvLogic = txt_invLogic.Text;
  185. if (txt_invPhysic.Value != null)
  186. {
  187. CkSto.DeleteUserid = txt_invPhysic.Text;
  188. }
  189. CkSto.SuppName = txt_suppName.Text;
  190. CkSto.OrderId = txt_orderId.Text;
  191. CkSto.InStockNo = txt_inStockNo.Text;
  192. CkSto.InvQty = Convert.ToDouble(txt_invOrigQty.Value);
  193. if (!string.IsNullOrEmpty(txt_createTimeS.Text) && !string.IsNullOrEmpty(txt_createTimeE.Text))
  194. {
  195. CkSto.CreateTime = Convert.ToDateTime(txt_createTimeS.Text);
  196. CkSto.UpdateTime = Convert.ToDateTime(txt_createTimeE.Text).AddDays(1);
  197. }
  198. CkSto.CreateName = txtItemClass.Text;
  199. CkSto.PrintNo = utPrintNo.Text.Trim();
  200. //查询源移库记录
  201. //CkSto.Status = "11";
  202. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkStorageUseService", "getCk_YK", new object[] { CkSto });
  203. GridHelper.CopyDataToDatatable(dt, dataTable6, true);
  204. GridHelper.RefreshAndAutoSize(ultraGrid5);
  205. }
  206. /// <summary>
  207. /// 解冻库存
  208. /// </summary>
  209. private void unCockInv()
  210. {
  211. UltraGridRow ugr = ultraGrid1.ActiveRow;
  212. CkStorage ck = new CkStorage();
  213. ck.InvId = ugr.Cells["InvId"].Value.ToString();
  214. ck.UseStatus = "1";
  215. if (MessageUtil.ShowYesNoAndQuestion("确定解冻库存【" + ck.InvId + "】?").Equals(DialogResult.No))
  216. {
  217. return;
  218. }
  219. CoreResult re1 = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkStorageService", "doUpdate", new object[] { ck });
  220. if (re1.Resultcode == -1)
  221. {
  222. MessageBox.Show("解冻失败:" + re1.Resultmsg, "");
  223. return;
  224. }
  225. MessageBox.Show("解冻成功!");
  226. GetPUR_CK_STORAGE();
  227. getPur_Ck_StorageSuorce();
  228. }
  229. /// <summary>
  230. /// 冻结库存
  231. /// </summary>
  232. private void cockInv()
  233. {
  234. UltraGridRow ugr = ultraGrid1.ActiveRow;
  235. CkStorage ck = new CkStorage();
  236. ck.InvId = ugr.Cells["InvId"].Value.ToString();
  237. ck.UseStatus = "0";
  238. if (MessageUtil.ShowYesNoAndQuestion("确定冻结库存【" + ck.InvId + "】?").Equals(DialogResult.No))
  239. {
  240. return;
  241. }
  242. CoreResult re1 = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkStorageService", "doUpdate", new object[] { ck });
  243. if (re1.Resultcode == -1)
  244. {
  245. MessageBox.Show("冻结失败:" + re1.Resultmsg, "");
  246. return;
  247. }
  248. MessageBox.Show("冻结成功!");
  249. GetPUR_CK_STORAGE();
  250. getPur_Ck_StorageSuorce();
  251. }
  252. /// <summary>
  253. /// 新增入库操作
  254. /// </summary>
  255. private void addCkInBill()
  256. {
  257. PopFrmCkInBill frm = new PopFrmCkInBill(this.ob);
  258. frm.ShowDialog();
  259. }
  260. /// <summary>
  261. /// 物料弹窗
  262. /// </summary>
  263. /// <param name="sender"></param>
  264. /// <param name="e"></param>
  265. private void txt_itemCode_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  266. {
  267. FrmPurPlanMat mat = new FrmPurPlanMat(this.ob);
  268. mat.ShowDialog();
  269. if (mat.getItemCode() != null)
  270. {
  271. txt_itemCode.Text = mat.getItemCode().ToString();
  272. txt_itemName.Text = mat.getItemName().ToString();
  273. }
  274. }
  275. /// <summary>
  276. /// 界面加载,库区下拉框加载
  277. /// </summary>
  278. /// <param name="sender"></param>
  279. /// <param name="e"></param>
  280. private void PurCkStorage_Load(object sender, EventArgs e)
  281. {
  282. //加载成本中心
  283. DataTable dt1 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1230" }, this.ob);
  284. if (dt1.Rows.Count > 0)
  285. {
  286. dt1.DefaultView.Sort = "BASENAME";
  287. dt1 = dt1.DefaultView.ToTable();
  288. }
  289. publicPms.FilComboboxAdd(txt_Dept1, dt1, "baseCode", "baseName", "validflag NOT in ('0')", false, "/", "");
  290. txt_createTimeS.Text = DateTime.Now.AddMonths(-1).ToString();
  291. txt_invOrigQty.Value = 2;
  292. //获取
  293. PurCkInBillEntity CkInBillEntity = new PurCkInBillEntity();
  294. DataTable dt_GropByItem = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkInBillService", "GetCkInBill_GropByItem", new object[] { CkInBillEntity });
  295. comm.FilComboboxAdd(txtItemClass, dt_GropByItem, "basecode", "basename", "", true, "", "");
  296. //LogicWareHouseEntity lhouse = new LogicWareHouseEntity();
  297. //lhouse.Validflag = "1";
  298. //DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.LogicSeatService", "getLogicSeat", new object[] { lhouse, 0, 0 });
  299. //if (dt.Rows.Count > 0)
  300. //{
  301. // txt_invLogic.DataSource = dt;
  302. // this.txt_invLogic.DisplayMember = "invLogicName";
  303. // this.txt_invLogic.ValueMember = "invLogic";
  304. //}
  305. //PhysicSeatEntity Phouse = new PhysicSeatEntity();
  306. //Phouse.Validflag = "1";
  307. //DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.configure.service.ActualSeatService", "getActualSeat", new object[] { Phouse, 0, 0 });
  308. //if (dt1.Rows.Count > 0)
  309. //{
  310. // txt_invPhysic.DataSource = dt1;
  311. // this.txt_invPhysic.DisplayMember = "invPhysicName";
  312. // this.txt_invPhysic.ValueMember = "invPhysic";
  313. //}
  314. //ActualSeatPosEntity PosEntity = new ActualSeatPosEntity();
  315. //PosEntity.Validflag = "1";
  316. //DataTable dt3 = this.execute<DataTable>("com.hnshituo.pur.configure.service.ActualSeatPosService", "find", new object[] { PosEntity, 0, 0 });
  317. //if (dt3.Rows.Count > 0)
  318. //{
  319. // txt_invBin.DataSource = dt3;
  320. // this.txt_invBin.DisplayMember = "invPosName";
  321. // this.txt_invBin.ValueMember = "invPos";
  322. //}
  323. ValueListItem[] item1 = new ValueListItem[] {
  324. new ValueListItem("0", "待确认"),
  325. new ValueListItem("1", "已确认"),
  326. };
  327. ValueList valueList1 = new ValueList();
  328. valueList1.ValueListItems.AddRange(item1);
  329. ultraGrid5.DisplayLayout.Bands[0].Columns["confirmStatus"].ValueList = valueList1;
  330. ValueListItem[] item2 = new ValueListItem[] {
  331. new ValueListItem("0", "未打印"),
  332. new ValueListItem("1", "已打印"),};
  333. ValueList valueList2 = new ValueList();
  334. valueList2.ValueListItems.AddRange(item2);
  335. ultraGrid5.DisplayLayout.Bands[0].Columns["printType"].ValueList = valueList2;
  336. GridHelper.SetExcludeColumnsActive(ultraGrid5.DisplayLayout.Bands[0], "Check","MEMO");
  337. GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0], "Check", "MoveQtyKC", "MoveQty");
  338. ultraExpandableGroupBox2.Expanded = true;
  339. //GetPUR_CK_STORAGE();
  340. }
  341. /// <summary>
  342. /// 供应商弹窗
  343. /// </summary>
  344. /// <param name="sender"></param>
  345. /// <param name="e"></param>
  346. private void txt_suppName_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  347. {
  348. Supp Sp = new Supp();
  349. Sp.Validflag = "1";
  350. //DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.SuppService", "find", new object[] {Sp,0,0 });
  351. frmSuppSel Sky = new frmSuppSel(this.ob);
  352. Sky.ShowDialog();
  353. if (Sky.strSUPP_CODE == null)
  354. return;
  355. txt_suppName.Text = Sky.strSUPP_NAME.ToString();
  356. //Supp_Code = Sky.strSUPP_CODE.ToString();
  357. }
  358. /// <summary>
  359. /// 激活库存表
  360. /// </summary>
  361. /// <param name="sender"></param>
  362. /// <param name="e"></param>
  363. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  364. {
  365. //GetPUR_CK_STORAGE_USE();
  366. //GetPUR_CK_STORAGE_POS();
  367. }
  368. /// <summary>
  369. /// 保存备注
  370. /// </summary>
  371. private void doSaveMemo()
  372. {
  373. List<UltraGridRow> rows = ComHelper.UltraGridGetOtherRows(ultraGrid5, "Check");
  374. if (rows.Count <= 0)
  375. {
  376. MessageUtil.ShowTips("请勾选需要填写的记录");
  377. return;
  378. }
  379. if (!MessageUtil.ShowYesNoQuestion("确定保存当前记录?"))
  380. return;
  381. List<PurCkStorageUseEntity> list = new List<PurCkStorageUseEntity>();
  382. foreach (UltraGridRow row in rows)
  383. {
  384. PurCkStorageUseEntity ckuse = new PurCkStorageUseEntity();
  385. ckuse.Id = row.Cells["Id"].Value.ToString();
  386. ckuse.Memo = row.Cells["MEMO"].Value.ToString();
  387. list.Add(ckuse);
  388. }
  389. CoreResult re1 = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkStorageUseService", "doSaveMemo", new object[] { list });
  390. if (re1.Resultcode == -1)
  391. {
  392. MessageBox.Show("保存失败:" + re1.Resultmsg, "");
  393. return;
  394. }
  395. MessageBox.Show("保存成功!");
  396. GetPUR_CK_STORAGE_USE();
  397. }
  398. /// <summary>
  399. /// 查询库存使用表
  400. /// </summary>
  401. private void GetPUR_CK_STORAGE_USE()
  402. {
  403. if (ultraGrid1.ActiveRow != null)
  404. {
  405. PurCkStorageUseEntity CkStorageUseEntity = new PurCkStorageUseEntity();
  406. CkStorageUseEntity.InvId = ultraGrid1.ActiveRow.Cells["INVID"].Value.ToString();
  407. CkStorageUseEntity.Validflag = "1";
  408. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkStorageUseService", "find", new object[] { CkStorageUseEntity, 0, 0 });
  409. //按创建时间降序
  410. if (dt.Rows.Count > 1)
  411. {
  412. dt.DefaultView.Sort = "CREATETIME DESC";
  413. dt = dt.DefaultView.ToTable();
  414. }
  415. GridHelper.CopyDataToDatatable(dt, dataTable3, true);
  416. }
  417. }
  418. /// <summary>
  419. /// 查询库存库位
  420. /// </summary>
  421. private void GetPUR_CK_STORAGE_POS()
  422. {
  423. if (ultraGrid1.ActiveRow != null)
  424. {
  425. PurCkStoragePosEntity CkStoragePosEntity = new PurCkStoragePosEntity();
  426. CkStoragePosEntity.InvId = ultraGrid1.ActiveRow.Cells["INVID"].Value.ToString();
  427. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkStoragePosService", "getCkStoragePos_ByInvId", new object[] { CkStoragePosEntity });
  428. //按创建时间降序
  429. if (dt.Rows.Count > 1)
  430. {
  431. dt.DefaultView.Sort = "CREATETIME DESC";
  432. dt = dt.DefaultView.ToTable();
  433. }
  434. GridHelper.CopyDataToDatatable(dt, dataTable2, true);
  435. }
  436. //publicPms.autoGridColumnWSize(ultraGrid2.DisplayLayout.Bands[0]);
  437. }
  438. /// <summary>
  439. /// 查询库存中的库区分组
  440. /// </summary>
  441. private void getBindInvPhySic()
  442. {
  443. CkStorage CkSto = new CkStorage();
  444. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkStorageService", "GetCkStorage_GropByInvPhisc", new object[] { CkSto });
  445. comm.setUltraComboEditorBind(txt_invPhysic, dt, "itemName", "itemCode");
  446. }
  447. /// <summary>
  448. /// 查询库存中的库位分组
  449. /// </summary>
  450. private void getBindInvPhySicPos()
  451. {
  452. CkStorage CkSto = new CkStorage();
  453. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkStorageService", "GetCkStorage_GropByInvPos", new object[] { CkSto });
  454. dt = comm.getDtGroupBy_reDt(dt, "itemName");
  455. comm.setUltraComboEditorBind(txt_invBin, dt, "itemName", "itemCode");
  456. }
  457. /// <summary>
  458. /// 勾选库存记录
  459. /// </summary>
  460. /// <param name="sender"></param>
  461. /// <param name="e"></param>
  462. private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  463. {
  464. object o = e.Cell.Value;
  465. ultraGrid1.UpdateData();
  466. //UltraGridRow[] ugrs = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "Check" }, new string[] { e.Cell.Value.ToString()});
  467. //判断库区是否全相同
  468. //UltraGridRow[] ugrsPhysic = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "Check","invPhysic" }, new string[] { e.Cell.Value.ToString(),e.Cell.Row.Cells["invPhysic"].Value.ToString() });
  469. //判断库位是否全相同
  470. //UltraGridRow[] ugrsPhysicPos = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "Check", "invPos" }, new string[] { e.Cell.Value.ToString(), e.Cell.Row.Cells["invPos"].Value.ToString() });
  471. if (e.Cell.Column.Key == "MoveQtyKC")
  472. {
  473. double bMoveQtyKC = 0;
  474. double.TryParse(e.Cell.Row.Cells["MoveQtyKC"].Value.ToString(), out bMoveQtyKC);
  475. double bINVQTYWEIGHT = 0;
  476. double.TryParse(e.Cell.Row.Cells["INVQTYWEIGHT"].Value.ToString(), out bINVQTYWEIGHT);
  477. double bITEMUOMCONEFFICIENT = 0;
  478. double.TryParse(e.Cell.Row.Cells["ITEMUOMCONEFFICIENT"].Value.ToString(), out bITEMUOMCONEFFICIENT);
  479. if (bMoveQtyKC > bINVQTYWEIGHT)
  480. {
  481. MessageUtil.ShowTips("移库数量不能>库存数量");
  482. e.Cell.Value = o;
  483. return;
  484. }
  485. else
  486. {
  487. if (e.Cell.Row.Cells["itemUom"].Value.ToString() == "基吨")
  488. {
  489. e.Cell.Row.Cells["MoveQty"].Value = Math.Round(bMoveQtyKC * bITEMUOMCONEFFICIENT, 3);
  490. }
  491. else
  492. {
  493. e.Cell.Row.Cells["MoveQty"].Value = Math.Round(bMoveQtyKC / bITEMUOMCONEFFICIENT, 3);
  494. }
  495. }
  496. }
  497. if (e.Cell.Column.Key == "MoveQty")
  498. {
  499. double bMoveQty = 0;
  500. double.TryParse(e.Cell.Row.Cells["MoveQty"].Value.ToString(), out bMoveQty);
  501. double bINVQTY = 0;
  502. double.TryParse(e.Cell.Row.Cells["INVQTY"].Value.ToString(), out bINVQTY);
  503. double bITEMUOMCONEFFICIENT = 0;
  504. double.TryParse(e.Cell.Row.Cells["ITEMUOMCONEFFICIENT"].Value.ToString(), out bITEMUOMCONEFFICIENT);
  505. if (bMoveQty > bINVQTY)
  506. {
  507. MessageUtil.ShowTips("移库数量不能>采购数量");
  508. e.Cell.Value = o;
  509. return;
  510. }
  511. else
  512. {
  513. if (e.Cell.Row.Cells["itemUom"].Value.ToString() == "基吨")
  514. {
  515. e.Cell.Row.Cells["MoveQtyKC"].Value = Math.Round(bMoveQty / bITEMUOMCONEFFICIENT, 3);
  516. }
  517. else
  518. {
  519. e.Cell.Row.Cells["MoveQtyKC"].Value = Math.Round(bMoveQty * bITEMUOMCONEFFICIENT, 3);
  520. }
  521. }
  522. }
  523. }
  524. /// <summary>
  525. /// 选择库区
  526. /// </summary>
  527. /// <param name="sender"></param>
  528. /// <param name="e"></param>
  529. private void txt_PhysicNew_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  530. {
  531. try
  532. {
  533. frmPopActualSeat pas = new frmPopActualSeat(this.ob, "0");
  534. pas.ShowDialog();
  535. txt_PhysicNew.Text = pas.DeliveryLocation;
  536. txt_PhysicNewCode.Text = pas.DeliveryLocationCode;
  537. //获取储位
  538. ActualSeatPosEntity aspe = new ActualSeatPosEntity();
  539. aspe.InvPhysic = pas.DeliveryLocationCode;
  540. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.ActualSeatPosService", "find", new object[] { aspe, 0, 0 });
  541. comm.setUltraComboEditorBind(txtPhysicPosNew, dt, "INVPOSNAME", "invpos");
  542. }
  543. catch (Exception ee)
  544. {
  545. MessageUtil.ShowTips(ee.Message);
  546. }
  547. }
  548. /// <summary>
  549. /// 移库操作
  550. /// </summary>
  551. /// <param name="sender"></param>
  552. /// <param name="e"></param>
  553. private void btn_MovePhysic_Click(object sender, EventArgs e)
  554. {
  555. MovingInvPhy();
  556. }
  557. /// <summary>
  558. /// 移库
  559. /// </summary>
  560. private void MovingInvPhy()
  561. {
  562. ultraGrid1.UpdateData();
  563. if (ultraTabControl2.SelectedTab.Key != "0")
  564. {
  565. MessageUtil.ShowTips("请切换tab页面到“库存记录”,再进行移库");
  566. return;
  567. }
  568. if (txt_PhysicNew.Text.Trim() == "")
  569. {
  570. MessageUtil.ShowTips("请选择新库区");
  571. return;
  572. }
  573. if (txtPhysicPosNew.Text.Trim() == "")
  574. {
  575. MessageUtil.ShowTips("请选择新库位");
  576. return;
  577. }
  578. if (txt_PhysicNewCode.Text.Trim() == "")
  579. {
  580. MessageUtil.ShowTips("未获取到新库区编码,请重试或联系管理员");
  581. return;
  582. }
  583. if (txtPhysicPosNew.Value == null || txtPhysicPosNew.Value.ToString().Trim() == "")
  584. {
  585. MessageUtil.ShowTips("未获取到新库位编码,请重试或联系管理员");
  586. return;
  587. }
  588. ArrayList al = new ArrayList();
  589. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  590. {
  591. if ((bool)ugr.Cells["Check"].Value)
  592. {
  593. double bMoveQty = 0;
  594. //if (ugr.Cells["itemUom"].Value.ToString() == "基吨")
  595. //{
  596. // double.TryParse(ugr.Cells["MoveQtyKC"].Value.ToString(), out bMoveQty);
  597. //}
  598. //else
  599. //{
  600. // double.TryParse(ugr.Cells["MoveQty"].Value.ToString(), out bMoveQty);
  601. //}
  602. double.TryParse(ugr.Cells["MoveQtyKC"].Value.ToString(), out bMoveQty);
  603. CkStorage ck = new CkStorage();
  604. ck.InvId = ugr.Cells["InvId"].Value.ToString();
  605. ck.InvQty = bMoveQty;//移库数量
  606. if (bMoveQty <= 0)
  607. {
  608. MessageUtil.ShowTips("库存记录【" + ck.InvId + "】移库数量必须>0");
  609. return;
  610. }
  611. //标记待检状态入库单
  612. if (ugr.Cells["USESTATUS"].Value.ToString() == "不可用")
  613. {
  614. MessageUtil.ShowTips("库存记录【" + ck.InvId + "】使用状态为“不可用”,不能做移库操作");
  615. return;
  616. }
  617. al.Add(ck);
  618. }
  619. }
  620. if (al.Count < 1)
  621. {
  622. MessageUtil.ShowTips("请勾选需要移库的库存记录");
  623. return;
  624. }
  625. PurCkStoragePosEntity csp = new PurCkStoragePosEntity();
  626. csp.InvPhysic = txt_PhysicNewCode.Text;
  627. csp.InvPos = txtPhysicPosNew.Value.ToString().Trim();
  628. csp.CreateName = UserInfo.GetUserName();
  629. csp.CreateUserid = UserInfo.GetUserID();
  630. if (MessageUtil.ShowYesNoAndQuestion("确定移库?").Equals(DialogResult.No))
  631. {
  632. return;
  633. }
  634. CoreResult re1 = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkStorageService", "MoveInvPhysic", new object[] { al, csp });
  635. if (re1.Resultcode == -1)
  636. {
  637. MessageBox.Show("操作失败:" + re1.Resultmsg, "");
  638. return;
  639. }
  640. MessageBox.Show("移库成功!");
  641. GetPUR_CK_STORAGE();
  642. getPur_Ck_StorageSuorce();
  643. }
  644. /// <summary>
  645. /// 撤销移库
  646. /// </summary>
  647. private void CanCelMovingInvPhy()
  648. {
  649. if (ultraTabControl2.SelectedTab.Key != "1")
  650. {
  651. MessageUtil.ShowTips("请切换tab页面到“移库记录”,再撤销移库");
  652. return;
  653. }
  654. List<UltraGridRow> rows = ComHelper.UltraGridGetOtherRows(ultraGrid5, "Check");
  655. if (rows.Count<=0)
  656. {
  657. MessageUtil.ShowTips("请勾选需要撤销的记录");
  658. return;
  659. }
  660. if (!MessageUtil.ShowYesNoQuestion("确定进行撤销移库操作"))
  661. return;
  662. List<CkStorage> list = new List<CkStorage>();
  663. foreach (UltraGridRow row in rows)
  664. {
  665. CkStorage ck = new CkStorage();
  666. ck.InvId = row.Cells["INVIDNEW"].Value.ToString();
  667. ck.InvIdSource = row.Cells["invid"].Value.ToString();
  668. ck.UpdateName = UserInfo.GetUserName();
  669. ck.UpdateUserid = UserInfo.GetUserID();
  670. list.Add(ck);
  671. }
  672. CoreResult re1 = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkStorageService", "CanCelMovingInvPhy", new object[] { list });
  673. if (re1.Resultcode == -1)
  674. {
  675. MessageBox.Show("撤销失败:" + re1.Resultmsg, "");
  676. return;
  677. }
  678. MessageBox.Show("撤销成功!");
  679. GetPUR_CK_STORAGE();
  680. getPur_Ck_StorageSuorce();
  681. }
  682. /// <summary>
  683. /// 选择新库位
  684. /// </summary>
  685. /// <param name="sender"></param>
  686. /// <param name="e"></param>
  687. private void txtPhysicPosNew_ValueChanged(object sender, EventArgs e)
  688. {
  689. //获取库位编码
  690. }
  691. private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
  692. {
  693. CkStorage CkSto = new CkStorage();
  694. CkSto.InvIdSource = ultraGrid2.ActiveRow.Cells["InvId"].Value.ToString();
  695. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkStorageService", "find_Storage", new object[] { CkSto });
  696. GridHelper.CopyDataToDatatable(dt, dataTable7, true);
  697. GridHelper.RefreshAndAutoSize(ultraGrid4);
  698. }
  699. private void doPrint(String strTips)
  700. {
  701. if (ultraTabControl2.SelectedTab.Key != "1")
  702. {
  703. MessageUtil.ShowTips("请切换tab页面到“移库记录”,再进行打印操作");
  704. return;
  705. }
  706. List<UltraGridRow> rows = ComHelper.UltraGridGetOtherRows(ultraGrid5, "Check");
  707. if (rows.Count <= 0)
  708. {
  709. MessageUtil.ShowTips("请勾选需要打印的记录");
  710. return;
  711. }
  712. List<CkStorage> al = new List<CkStorage>();//打印出库单清单
  713. String strUrlPort = "http://172.54.10.42:8080";//报表系统IP
  714. String[] str = strUrlPort.Split(':');
  715. String strUrl = str[0] + ":" + str[1];
  716. String isAll_print = "0";//是否汇总打印
  717. //汇总打印
  718. if (!ck_single_m.Checked)
  719. {
  720. String strDeptUse = "";
  721. String strDept = txt_Dept1.Value == null ? "" : txt_Dept1.Value.ToString();
  722. if (is_JIT.Checked)
  723. {
  724. if (String.IsNullOrEmpty(strDept))
  725. {
  726. MessageUtil.ShowTips("若选择按照成本中心打印,请先指定成本中心");
  727. return;
  728. }
  729. strDeptUse = strDept;
  730. }
  731. //string strPrintNo = getPrintCode();
  732. string stroutStockno = "";
  733. ultraGrid1.UpdateData();
  734. foreach (UltraGridRow row in rows)
  735. {
  736. String invId = row.Cells["INVIDNEW"].Value.ToString();
  737. stroutStockno += "'" + invId + "',";
  738. CkStorage ck = new CkStorage();
  739. ck.InvId = invId;
  740. if (String.IsNullOrEmpty(invId))
  741. {
  742. MessageUtil.ShowTips("若单张打印的出库单号不能为空");
  743. return;
  744. }
  745. CkStorage ckInfo = this.execute<CkStorage>("com.hnshituo.pur.ck.service.CkStorageService", "findById", new object[] { invId });
  746. if (ckInfo == null)
  747. {
  748. MessageUtil.ShowTips("未发现库存号:" + invId + "信息记录");
  749. row.Activate();
  750. return;
  751. }
  752. if (!String.IsNullOrEmpty(ckInfo.PrintNo) && strTips == "0")
  753. {
  754. MessageUtil.ShowTips("库存号:" + invId + " 已打印,或请取消打印");
  755. row.Activate();
  756. return;
  757. }
  758. if (String.IsNullOrEmpty(ckInfo.PrintNo) && strTips == "1")
  759. {
  760. MessageUtil.ShowTips("库存号:" + invId + " 还未打印,或请先打印");
  761. row.Activate();
  762. return;
  763. }
  764. ck.CreateName = UserInfo.GetUserName();
  765. ck.CreateUserid = UserInfo.GetUserID();
  766. ck.CreateTime = DateTime.Now;
  767. //pcibEntity.PrintCode = strPrintNo;
  768. al.Add(ck);
  769. }
  770. stroutStockno = stroutStockno.Remove(0, 1);
  771. stroutStockno = stroutStockno.Remove(stroutStockno.Length - 2);
  772. strUrl = strUrlPort + "/webroot/decision/view/report?viewlet=rpt_InBill.cpt&op=view" + "&dept=" + strDeptUse + "&outStockNo=" + stroutStockno + "&ID=" + 1232025;
  773. isAll_print = "1";
  774. }
  775. //单张连打
  776. else
  777. {
  778. string stroutStockno = "";
  779. ultraGrid1.UpdateData();
  780. foreach (UltraGridRow row in rows)
  781. {
  782. String invId = row.Cells["INVIDNEW"].Value.ToString();
  783. stroutStockno += "'" + invId + "',";
  784. CkStorage ck = new CkStorage();
  785. ck.InvId = invId;
  786. ck.CreateName = UserInfo.GetUserName();
  787. ck.CreateUserid = UserInfo.GetUserID();
  788. ck.CreateTime = DateTime.Now;
  789. if (String.IsNullOrEmpty(invId))
  790. {
  791. MessageUtil.ShowTips("若单张打印的出库单号不能为空");
  792. return;
  793. }
  794. CkStorage ckInfo = this.execute<CkStorage>("com.hnshituo.pur.ck.service.CkStorageService", "findById", new object[] { invId });
  795. if (ckInfo == null)
  796. {
  797. MessageUtil.ShowTips("未发现库存号:" + invId + "信息记录");
  798. row.Activate();
  799. return;
  800. }
  801. if (!String.IsNullOrEmpty(ckInfo.PrintNo) && strTips == "0")
  802. {
  803. MessageUtil.ShowTips("库存号:" + invId + " 已打印,或请取消打印");
  804. row.Activate();
  805. return;
  806. }
  807. if (String.IsNullOrEmpty(ckInfo.PrintNo) && strTips == "1")
  808. {
  809. MessageUtil.ShowTips("库存号:" + invId + " 还未打印,或请先打印");
  810. row.Activate();
  811. return;
  812. }
  813. al.Add(ck);
  814. }
  815. stroutStockno = stroutStockno.Remove(0, 1);
  816. stroutStockno = stroutStockno.Remove(stroutStockno.Length - 2);
  817. strUrl = strUrlPort + "/webroot/decision/view/report?viewlet=rpt_InBill_single_ly_m.cpt&op=view" + "&outStockNo=" + stroutStockno + "&ID=" + 1232025;
  818. }
  819. if (strTips == "0")
  820. {
  821. CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkStorageService", "doPrint", new object[] { al, isAll_print });
  822. if (rt.Resultcode != 0)
  823. {
  824. MessageUtil.ShowTips("生成打印编号失败:" + rt.Resultmsg);
  825. return;
  826. }
  827. }
  828. comm.printReport(this.ob, strUrl, "移库单打印");
  829. if (strTips == "0")
  830. {
  831. if (!MessageUtil.ShowYesNoAndQuestion("是否已打印移库单?").Equals(DialogResult.Yes))
  832. {
  833. CoreResult rt1 = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkStorageService", "cancelPrint", new object[] { al });
  834. if (rt1.Resultcode != 0)
  835. {
  836. MessageUtil.ShowTips("取消标记打印失败:" + rt1.Resultmsg);
  837. }
  838. }
  839. }
  840. }
  841. private void CanCelPrint()
  842. {
  843. if (ultraTabControl2.SelectedTab.Key != "1")
  844. {
  845. MessageUtil.ShowTips("请切换tab页面到“移库记录”,再进行取消打印操作");
  846. return;
  847. }
  848. List<UltraGridRow> rows = ComHelper.UltraGridGetOtherRows(ultraGrid5, "Check");
  849. if (rows.Count <= 0)
  850. {
  851. MessageUtil.ShowTips("请勾选需要取消打印的记录");
  852. return;
  853. }
  854. List<CkStorage> list = new List<CkStorage>();
  855. foreach (UltraGridRow row in rows)
  856. {
  857. String invId = row.Cells["INVIDNEW"].Value.ToString();
  858. CkStorage ck = new CkStorage();
  859. ck.InvId = invId;
  860. ck.CreateName = UserInfo.GetUserName();
  861. ck.CreateUserid = UserInfo.GetUserID();
  862. ck.CreateTime = DateTime.Now;
  863. CkStorage ckInfo = this.execute<CkStorage>("com.hnshituo.pur.ck.service.CkStorageService", "findById", new object[] { invId });
  864. if (ckInfo == null)
  865. {
  866. MessageUtil.ShowTips("未发现库存号:" + invId + "信息记录");
  867. row.Activate();
  868. return;
  869. }
  870. if (String.IsNullOrEmpty(ckInfo.PrintNo))
  871. {
  872. MessageUtil.ShowTips("库存号:" + invId + " 还未打印,不能取消");
  873. row.Activate();
  874. return;
  875. }
  876. list.Add(ck);
  877. }
  878. CoreResult rt1 = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkStorageService", "cancelPrint", new object[] { list });
  879. if (rt1.Resultcode != 0)
  880. {
  881. MessageUtil.ShowTips("取消打印失败:" + rt1.Resultmsg);
  882. }
  883. }
  884. private void ultraTabControl2_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
  885. {
  886. if ("0".Equals(ultraTabControl2.SelectedTab.Key))
  887. {
  888. utPrintNo.Visible = false;
  889. ultraLabel18.Visible = false;
  890. ultraPanel3.Visible = false;
  891. }
  892. else
  893. {
  894. utPrintNo.Visible = true;
  895. ultraLabel18.Visible = true;
  896. ultraPanel3.Visible = true;
  897. }
  898. }
  899. }
  900. }