frmPipeInventoryOut.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using CoreFS.CA06;
  10. using Core.StlMes.Client.YdmPipeManage.Controls;
  11. using System.Collections;
  12. using Core.Mes.Client.Comm.Control;
  13. using Core.Mes.Client.Comm.Server;
  14. using Core.Mes.Client.Comm.Tool;
  15. using Infragistics.Win.UltraWinGrid;
  16. using Infragistics.Win;
  17. using Core.StlMes.Client.YdmPipeManage.Tool;
  18. using com.steering.pss.ydm.entity;
  19. namespace Core.StlMes.Client.YdmPipeManage
  20. {
  21. public partial class frmPipeInventoryOut : FrmBase
  22. {
  23. private string errMessage = "";
  24. public frmPipeInventoryOut()
  25. {
  26. InitializeComponent();
  27. }
  28. private void frmPipeInventoryOut_Load(object sender, EventArgs e)
  29. {
  30. RegStartTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")).AddMonths(-1);
  31. RegEndTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")).AddDays(1).AddSeconds(-1);
  32. BaseMethod.InitStorage(cmbStorage, CustomInfo, this.ValidDataPurviewIds, this.ob);
  33. EntityHelper.ShowGridCaption<YdmZcStocktakinglistEntity>(ultraGridOut.DisplayLayout.Bands[0]);
  34. EntityHelper.ShowGridCaption<MatZcMEntity>(ultraGridManagement.DisplayLayout.Bands[0]);
  35. BaseMethod.InitReason(cmbRsn, this.ob);
  36. //BaseMethod.setOtherColumnReadOnly(ultraGridOut, new string[] { "Chc" });
  37. BaseMethod.setOtherColumnReadOnly(ultraGridManagement, new string[] { "" });
  38. BaseMethod.InitCellPosition(ultraGridOut, new string[] { "ActWeight", "ActCount", "ActLenMax", "ActLenMin", "ActTheoryWeight", "ActHeight", "ActDimater" });
  39. ultraGridOut.DisplayLayout.Bands[0].Columns["StocktakingRsnName"].Header.Caption = "盘亏原因";
  40. InitStaus();
  41. }
  42. private void InitStaus()
  43. {
  44. //材料状态
  45. this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150101", "材料产出等待");
  46. this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150102", "材料管理封锁");
  47. this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150103", "材料质量封锁");
  48. this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150104", "材料可编计划");
  49. this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150105", "材料已编计划");
  50. this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150106", "材料为余材");
  51. this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150201", "材料产出等待(未综合判定)");
  52. this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150202", "材料产出(已综合判定");
  53. this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150203", "材料为余材(已综合判定)");
  54. this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150204", "材料脱单余材(销售组织脱单)");
  55. this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150301", "材料可编提单");
  56. this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150302", "材料已编提单");
  57. this.ultraGridManagement.DisplayLayout.ValueLists[0].ValueListItems.Add("80150303", "销售出厂");
  58. //材料类别
  59. this.ultraGridManagement.DisplayLayout.ValueLists[1].ValueListItems.Add("801401", "在制品");
  60. this.ultraGridManagement.DisplayLayout.ValueLists[1].ValueListItems.Add("801402", "成品");
  61. this.ultraGridManagement.DisplayLayout.ValueLists[1].ValueListItems.Add("801403", "商品");
  62. //封锁标识
  63. this.ultraGridManagement.DisplayLayout.ValueLists[2].ValueListItems.Add("0", "未封锁");
  64. this.ultraGridManagement.DisplayLayout.ValueLists[2].ValueListItems.Add("1", "管理封锁");
  65. this.ultraGridManagement.DisplayLayout.ValueLists[2].ValueListItems.Add("2", "质量封锁");
  66. this.ultraGridManagement.DisplayLayout.ValueLists[2].ValueListItems.Add("3", "管理质量双封锁");
  67. //DataTable ds = ClsLoad.GetValueListDataTable("8014", this.ob);
  68. //this.ultraGridManagement.DisplayLayout.Bands[0].Columns["ProductFlag"].ValueList = ClsLoad.GeneralValuelist(ref ds, "BASECODE", "BASENAME");
  69. //string[] arr = new string[3] { "801501", "801502", "801503" };
  70. //DataTable dt = ClsLoad.GetValueListDataTable(arr, this.ob);
  71. //this.ultraGridManagement.DisplayLayout.Bands[0].Columns["MatStatus"].ValueList = ClsLoad.GeneralValuelist(ref dt, "BASECODE", "BASENAME");
  72. //DataTable dd = ClsLoad.GetValueListDataTable(this.ob);
  73. //this.ultraGridManagement.DisplayLayout.Bands[0].Columns["lockFlag"].ValueList = ClsLoad.GeneralValuelist(ref dd, "LOCK_FLAG", "FLAG");
  74. }
  75. /// <summary>
  76. /// 重写基类方法
  77. /// </summary>
  78. /// <param name="sender"></param>
  79. /// <param name="ToolbarKey"></param>
  80. public override void ToolBar_Click(object sender, string ToolbarKey)
  81. {
  82. switch (ToolbarKey)
  83. {
  84. case "Query":
  85. DoQueryMangement();
  86. break;
  87. case"Query1":
  88. DoQueryOut();
  89. break;
  90. case "Delete":
  91. DoDelete();
  92. break;
  93. case "updateYear":
  94. updateYear();
  95. break;
  96. case"Read":
  97. readCard();
  98. break;
  99. case "Export":
  100. GridHelper.ulGridToExcel(ultraGridOut, "盘亏实绩");
  101. break;
  102. case "Close":
  103. this.Close();
  104. break;
  105. }
  106. }
  107. /// <summary>
  108. /// 读卡
  109. /// </summary>
  110. private void readCard()
  111. {
  112. }
  113. /// <summary>
  114. /// 修改结转年月
  115. /// </summary>
  116. private void updateYear()
  117. {
  118. this.ultraGridOut.UpdateData();
  119. ArrayList list = new ArrayList();
  120. ArrayList parm = new ArrayList();
  121. UltraGridRow uRow = this.ultraGridOut.ActiveRow;
  122. string yearMoth = uRow.Cells["balYearMonth"].Text.Substring(0, 4) + uRow.Cells["balYearMonth"].Text.Substring(5, 2);
  123. string adjustDoc = uRow.Cells["stocktakingDoc"].Value.ToString();
  124. string heatNo = uRow.Cells["judgeStoveNo"].Value.ToString();
  125. string bacthNo = uRow.Cells["batchNo"].Value.ToString();
  126. string bacthGroupNo = uRow.Cells["batchGroudNo"].Value.ToString();
  127. //string moth = DateTime.Now.AddMonths(1).ToString("yyyyMM");
  128. string moth = DateTime.Parse(uRow.Cells["balYearMonth"].Text).AddMonths(1).ToString("yyyyMM");
  129. string[] arr = BaseMethod.InitPermissions(this.ValidDataPurviewIds,ob);
  130. //parm.Add(heatNo);
  131. //parm.Add(bacthNo);
  132. //parm.Add(bacthGroupNo);
  133. parm.Add(moth);
  134. DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeAdjust.selectYearMoth", new object[] { parm,arr }, ob);
  135. if (int.Parse(ds.Rows[0]["ACOUNT"].ToString()) > 0)
  136. {
  137. MessageUtil.ShowTips("此炉【" + heatNo + "】已进行结转,不允许调整结转年月!");
  138. return;
  139. }
  140. string nowYearMoth = DateTime.Now.ToString("yyyyMM");
  141. //if (int.Parse(yearMoth) < int.Parse(nowYearMoth))
  142. //{
  143. // MessageUtil.ShowTips("修改的结转年月不能小于当月!");
  144. // return;
  145. //}
  146. list.Add(yearMoth);
  147. list.Add(yearMoth + "02 12:00:00");
  148. list.Add(adjustDoc);
  149. int count = ServerHelper.SetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryOut.updateYear", new object[] { list }, ob);
  150. if (count > 0)
  151. {
  152. DoQueryOut();
  153. MessageUtil.ShowTips("修改成功");
  154. }
  155. }
  156. private void chk_CheckedChanged(object sender, EventArgs e)
  157. {
  158. if (chkRegTime.Checked)
  159. {
  160. RegStartTime.Enabled = true;
  161. RegEndTime.Enabled = true;
  162. }
  163. else
  164. {
  165. RegStartTime.Enabled = false;
  166. RegEndTime.Enabled = false;
  167. }
  168. if (chkFurnace.Checked)
  169. {
  170. txtFurnace.Enabled = true;
  171. }
  172. else
  173. {
  174. txtFurnace.Enabled = false;
  175. }
  176. if (chkMaterial.Checked)
  177. {
  178. cmbLocation.Enabled = true;
  179. }
  180. else
  181. {
  182. cmbLocation.Enabled = false;
  183. }
  184. }
  185. private void cmbStorage_SelectionChanged(object sender, EventArgs e)
  186. {
  187. if (cmbStorage.Value == null)
  188. {
  189. cmbLocation.DataSource = null;
  190. return;
  191. }
  192. string storageNo = cmbStorage.Value.ToString();
  193. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getLocationNo", new object[] { storageNo }, this.ob);
  194. cmbLocation.DataSource = dt;
  195. cmbLocation.DisplayMember = "LOCATION_NO";
  196. cmbLocation.ValueMember = "LOCATION_NO";
  197. }
  198. private void chkWarehous_CheckedChanged(object sender, EventArgs e)
  199. {
  200. if (chkWarehous.Checked)
  201. {
  202. cmbStorage.Enabled = true;
  203. chkMaterial.Enabled = true;
  204. if (chkMaterial.Checked)
  205. {
  206. cmbLocation.Enabled = true;
  207. }
  208. else
  209. {
  210. cmbLocation.Enabled = false;
  211. }
  212. }
  213. else
  214. {
  215. chkMaterial.Checked = false;
  216. cmbStorage.Enabled = false;
  217. chkMaterial.Enabled = false;
  218. cmbLocation.Enabled = false;
  219. }
  220. }
  221. /// <summary>
  222. /// 查询条件
  223. /// </summary>
  224. /// <returns></returns>
  225. private ArrayList getQueryCondition()
  226. {
  227. ArrayList param = new ArrayList();
  228. string strBegin = "1900-01-01 00:00:00";
  229. string strEnd = "9900-01-01 00:00:00";
  230. string justStoveNo = "";
  231. string stoveNo = "";//仓库号;
  232. string locationNo = "";//料位号
  233. if (chkRegTime.Checked)
  234. {
  235. if (RegStartTime.Value == null || RegEndTime.Value == null)
  236. {
  237. errMessage = "请选择正确的时间";
  238. return null;
  239. }
  240. strBegin = RegStartTime.Value.ToString();
  241. strEnd = RegEndTime.Value.ToString();
  242. }
  243. if (chkFurnace.Checked)
  244. {
  245. justStoveNo = txtFurnace.Text.Trim();
  246. }
  247. if (chkWarehous.Checked && cmbStorage.Value != null)
  248. {
  249. stoveNo = cmbStorage.Value.ToString();
  250. }
  251. if (chkMaterial.Checked && cmbLocation.Value != null)
  252. {
  253. locationNo = cmbLocation.Value.ToString();
  254. }
  255. param.Add(strBegin);
  256. param.Add(strEnd);
  257. param.Add(justStoveNo);
  258. param.Add(stoveNo);
  259. param.Add(locationNo);
  260. return param;
  261. }
  262. /// <summary>
  263. /// 查询库存信息
  264. /// </summary>
  265. private void DoQueryMangement()
  266. {
  267. ArrayList param = getQueryCondition();
  268. if (param == null)
  269. {
  270. MessageUtil.ShowWarning(errMessage);
  271. return;
  272. }
  273. //string[] stoveages = BaseMethod.WarehousePermissions(CustomInfo, this.ValidDataPurviewIds, this.ob);
  274. string[] stoveages = BaseMethod.InitPermissions(this.ValidDataPurviewIds, ob);
  275. string supplyUnit = this.CustomInfo;
  276. List<MatZcMEntity> listSource = EntityHelper.GetData<MatZcMEntity>(
  277. "com.steering.pss.ydm.pipemanage.FrmPipeInventoryOut.getMangement", new object[] { param, stoveages, supplyUnit }, this.ob);
  278. matZcMEntityBindingSource.DataSource = listSource;
  279. BaseMethod.MergedCell(ultraGridManagement,new string[]{"BelongName"});
  280. }
  281. /// <summary>
  282. /// 查询盘亏信息
  283. /// </summary>
  284. private void DoQueryOut()
  285. {
  286. ArrayList param = getQueryCondition();
  287. if (param == null)
  288. {
  289. MessageUtil.ShowWarning(errMessage);
  290. return;
  291. }
  292. //string[] stoveages = BaseMethod.WarehousePermissions(CustomInfo, this.ValidDataPurviewIds, this.ob);
  293. string[] stoveages = BaseMethod.InitPermissions(this.ValidDataPurviewIds, ob);
  294. string supplyUnit = this.CustomInfo;
  295. List<YdmZcStocktakinglistEntity> listSource = EntityHelper.GetData<YdmZcStocktakinglistEntity>(
  296. "com.steering.pss.ydm.pipemanage.FrmPipeInventoryOut.getOut", new object[] { param, stoveages, supplyUnit }, this.ob);
  297. ydmZcStocktakinglistEntityBindingSource.DataSource = listSource;
  298. }
  299. /// <summary>
  300. /// 盘亏操作
  301. /// </summary>
  302. private void DoDelete()
  303. {
  304. UltraGridRow ugr = ultraGridManagement.ActiveRow;
  305. if (ugr == null)
  306. {
  307. MessageUtil.ShowWarning("请选择要盘亏的记录!");
  308. return;
  309. }
  310. MatZcMEntity matzcMEntity = (MatZcMEntity)ugr.ListObject;
  311. int count = TxtNum.Value == null ? 0 : Convert.ToInt32(TxtNum.Value.ToString());
  312. if (count <= 0)
  313. {
  314. MessageUtil.ShowWarning("盘亏支数必须大于0!");
  315. return;
  316. }
  317. if (count > Convert.ToInt32(matzcMEntity.ActCount.ToString()))
  318. {
  319. MessageUtil.ShowWarning("盘亏支数不能大于库存实际支数!");
  320. return;
  321. }
  322. string reasonCode = cmbRsn.Value == null ? "" : cmbRsn.Value.ToString();
  323. if (reasonCode.Equals(""))
  324. {
  325. MessageUtil.ShowWarning("请选择盘亏原因!");
  326. return;
  327. }
  328. //if (ugr.Cells["matStatus"].Value != "材料可编计划(发运控制)")
  329. //{
  330. // MessageUtil.ShowWarning("材料已被做计划,不能盘亏!");
  331. // return;
  332. //}
  333. string reasonName = cmbRsn.Text;
  334. string memo = txtMemo.Text.Trim();
  335. ArrayList param = new ArrayList();
  336. param.Add(count);
  337. param.Add(reasonCode);
  338. param.Add(reasonName);
  339. param.Add(memo);
  340. param.Add(UserInfo.GetUserName());
  341. param.Add(ugr.Cells["OrdLnDlyPk"].Value.ToString());
  342. param.Add(DateTime.Now.ToString("yyyyMM"));
  343. DataTable dd = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.CorePipeInTemp.getLockFlag", new object[] { matzcMEntity.JudgeStoveNo, matzcMEntity.BatchNo, matzcMEntity.BatchGroudNo }, ob);
  344. if (int.Parse(dd.Rows[0]["ACOUNT"].ToString()) > 0)
  345. {
  346. MessageUtil.ShowTips("炉号:" + matzcMEntity.JudgeStoveNo + "、批号:" + matzcMEntity.BatchNo + "的数据有被封锁的,不能进行盘亏!");
  347. return;
  348. }
  349. if (MessageUtil.ShowYesNoAndQuestion("是否对炉号:" + matzcMEntity.JudgeStoveNo + " 批号:" + matzcMEntity.BatchNo + " 组号:" + matzcMEntity.BatchGroudNo + "进行盘亏操作?") == DialogResult.No)
  350. {
  351. return;
  352. }
  353. CoreClientParam ccp = new CoreClientParam();
  354. ccp.ServerName = "com.steering.pss.ydm.pipemanage.FrmPipeInventoryOut";
  355. ccp.MethodName = "InventoryOut";
  356. ccp.ServerParams = new object[] { matzcMEntity, param,this.CustomInfo };
  357. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  358. if (ccp.ReturnCode != -1)
  359. {
  360. MessageUtil.ShowTips(ccp.ReturnInfo);
  361. DoQueryMangement();
  362. //DoQueryOut();
  363. BaseMethod.UltraGridLocation(ultraGridManagement, new string[] { "BatchNo", "JudgeStoveNo", "BatchGroudNo" },
  364. new string[] { matzcMEntity.BatchNo, matzcMEntity.JudgeStoveNo, matzcMEntity.BatchGroudNo });
  365. }
  366. }
  367. private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
  368. {
  369. if (toolMenu == null) return;
  370. if(ultraTabControl1.SelectedTab.Key == "0")
  371. {
  372. if (toolMenu.Toolbars[0].Tools.Exists("Query"))
  373. {
  374. toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = DefaultableBoolean.True;
  375. }
  376. if (toolMenu.Toolbars[0].Tools.Exists("Query1"))
  377. {
  378. toolMenu.Toolbars[0].Tools["Query1"].InstanceProps.Visible = DefaultableBoolean.False;
  379. }
  380. if (toolMenu.Toolbars[0].Tools.Exists("Delete"))
  381. {
  382. toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = DefaultableBoolean.True;
  383. }
  384. if (toolMenu.Toolbars[0].Tools.Exists("Export"))
  385. {
  386. toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.False;
  387. }
  388. if (toolMenu.Toolbars[0].Tools.Exists("updateYear"))
  389. {
  390. toolMenu.Toolbars[0].Tools["updateYear"].InstanceProps.Visible = DefaultableBoolean.False;
  391. }
  392. this.chkRegTime.Text = "入库时间";
  393. }
  394. else if (ultraTabControl1.SelectedTab.Key == "1")
  395. {
  396. if (toolMenu.Toolbars[0].Tools.Exists("Query"))
  397. {
  398. toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = DefaultableBoolean.False;
  399. }
  400. if (toolMenu.Toolbars[0].Tools.Exists("Query1"))
  401. {
  402. toolMenu.Toolbars[0].Tools["Query1"].InstanceProps.Visible = DefaultableBoolean.True;
  403. }
  404. if (toolMenu.Toolbars[0].Tools.Exists("Delete"))
  405. {
  406. toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = DefaultableBoolean.False;
  407. }
  408. if (toolMenu.Toolbars[0].Tools.Exists("Export"))
  409. {
  410. toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.True;
  411. }
  412. if (toolMenu.Toolbars[0].Tools.Exists("updateYear"))
  413. {
  414. toolMenu.Toolbars[0].Tools["updateYear"].InstanceProps.Visible = DefaultableBoolean.True;
  415. }
  416. this.chkRegTime.Text = "盘亏时间";
  417. }
  418. }
  419. private void frmPipeInventoryOut_Shown(object sender, EventArgs e)
  420. {
  421. if (toolMenu == null) return;
  422. if (toolMenu.Toolbars[0].Tools.Exists("Query"))
  423. {
  424. toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = DefaultableBoolean.True;
  425. }
  426. if (toolMenu.Toolbars[0].Tools.Exists("Query1"))
  427. {
  428. toolMenu.Toolbars[0].Tools["Query1"].InstanceProps.Visible = DefaultableBoolean.False;
  429. }
  430. if (toolMenu.Toolbars[0].Tools.Exists("Delete"))
  431. {
  432. toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = DefaultableBoolean.True;
  433. }
  434. if (toolMenu.Toolbars[0].Tools.Exists("Export"))
  435. {
  436. toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.False;
  437. }
  438. if (toolMenu.Toolbars[0].Tools.Exists("updateYear"))
  439. {
  440. toolMenu.Toolbars[0].Tools["updateYear"].InstanceProps.Visible = DefaultableBoolean.False;
  441. }
  442. }
  443. }
  444. }