frmPipeStow.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  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 System.Collections;
  11. using Core.Mes.Client.Comm.Server;
  12. using Core.Mes.Client.Comm.Control;
  13. using Infragistics.Win.UltraWinGrid;
  14. using Core.StlMes.Client.YdmPipeManage.Controls;
  15. using Core.Mes.Client.Comm.Tool;
  16. using Infragistics.Win;
  17. using Core.StlMes.Client.YdmPipeManage.Tool;
  18. using Core.StlMes.Client.YdmBase;
  19. namespace Core.StlMes.Client.YdmPipeManage
  20. {
  21. public partial class frmPipeStow : FrmBase
  22. {
  23. ArrayList pram = new ArrayList();
  24. private int isSelect = 0;//新增
  25. public frmPipeStow()
  26. {
  27. InitializeComponent();
  28. }
  29. private void frmPipeStow_Load(object sender, EventArgs e)
  30. {
  31. //StorInfo();
  32. Init();
  33. ultraGrid3.Enabled = false;
  34. //doQuery();
  35. this.chkMaterial.Visible = false;
  36. BaseMethod.InitStorage(cmbWarehous, CustomInfo, this.ValidDataPurviewIds, this.ob);
  37. }
  38. /// <summary>
  39. /// 重写基类方法
  40. /// </summary>
  41. /// <param name="sender"></param>
  42. /// <param name="ToolbarKey"></param>
  43. public override void ToolBar_Click(object sender, string ToolbarKey)
  44. {
  45. switch (ToolbarKey)
  46. {
  47. case "Query":
  48. if(!CheckQuery())return;
  49. doQuery();
  50. break;
  51. case "Add":
  52. doSave();
  53. break;
  54. case"Refresh":
  55. doRefresh();
  56. break;
  57. case "Export":
  58. GridHelper.ulGridToExcel(ultraGrid4, "倒垛历史实绩");
  59. break;
  60. case "Close":
  61. this.Close();
  62. break;
  63. }
  64. }
  65. /// <summary>
  66. /// 绑定仓库号
  67. /// </summary>
  68. private void StorInfo()
  69. {
  70. ArrayList arList = new ArrayList();
  71. //获取用户对应科室ID
  72. string User = this.UserInfo.GetDeptid();
  73. string StorageType = "";//根据传递的参数获取仓库类别
  74. string StorageAttr = "";////根据传递的参数获取仓库类型
  75. if (CustomInfo != "")
  76. {
  77. string[] strflg = CustomInfo.ToString().Split(new char[] { ',' });
  78. StorageType = strflg[0];
  79. StorageAttr = strflg[1];
  80. }
  81. pram.Clear();
  82. pram.Add(StorageType);
  83. pram.Add(StorageAttr);
  84. pram.Add(User);
  85. PipeManageClass.BindComBaseInfo(pram, cmbWarehous, ob);
  86. }
  87. /// <summary>
  88. /// 绑定原料位号下拉框
  89. /// </summary>
  90. private void Init()
  91. {
  92. //绑定料位号
  93. string strStorage = "";
  94. if (cmbWarehous.SelectedIndex != -1)
  95. {
  96. strStorage = cmbWarehous.Value.ToString();
  97. }
  98. pram.Clear();
  99. pram.Add(strStorage);
  100. PipeManageClass.BindLocationInfo(pram, cmbMaterialEid, ob);
  101. }
  102. private void doQuery()
  103. {
  104. string strWare = "";//仓库号
  105. string strMat = "";//料位号
  106. string strFurnace = "";
  107. string strBatch = "";
  108. if (chkWarehous.Checked)
  109. {
  110. strWare = cmbWarehous.Value.ToString();
  111. }
  112. if (chkMaterial.Checked)
  113. {
  114. strMat = cmbMaterialEid.Value.ToString();
  115. }
  116. if (chkFurnace.Checked)
  117. {
  118. strFurnace = txtFurnace.Text.Trim();
  119. }
  120. if (chkBatch.Checked)
  121. {
  122. strBatch = txtBatch.Text.Trim();
  123. }
  124. pram.Clear();
  125. pram.Add(strWare);
  126. pram.Add(strMat);
  127. pram.Add(strFurnace);
  128. //pram.Add(strBatch);
  129. //pram.Add(txtGroup.Text.Trim());
  130. //pram.Add(this.UserInfo.GetUserName());
  131. string[] arr = BaseMethod.WarehousePermissions(CustomInfo,this.ValidDataPurviewIds,this.ob);
  132. if (ultraTabControl1.SelectedTab.Key.Equals("0"))
  133. {
  134. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeStow.queryStorage", new object[] { pram, arr }, ob);
  135. GridHelper.CopyDataToDatatable(dt, this.dataStorage, true);
  136. GridHelper.RefreshAndAutoSize(ultraGrid1);
  137. }
  138. else
  139. {
  140. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeStow.queryStowList", new object[] { pram, arr }, ob);
  141. GridHelper.CopyDataToDatatable(dt, this.dataStowList, true);
  142. GridHelper.RefreshAndAutoSize(ultraGrid4);
  143. }
  144. }
  145. /// <summary>
  146. /// 保存,新增
  147. /// </summary>
  148. private void doSave()
  149. {
  150. //需对倒垛历史表进行插入、对位置表进行删除
  151. ultraGrid3.UpdateData();
  152. int count = 0;
  153. UltraGridRow ugr1 = this.ultraGrid1.ActiveRow;
  154. UltraGridRow ugr3 = this.ultraGrid3.ActiveRow;
  155. UltraGridRow ugr2 = this.ultraGrid2.ActiveRow;
  156. string loactionNo = "";
  157. if (ugr3 == null||isSelect==0)
  158. {
  159. MessageUtil.ShowTips("请输入您要操作的记录!");
  160. return;
  161. }
  162. if (MessageUtil.ShowYesNoAndQuestion("是否确认倒垛?") == DialogResult.No)
  163. {
  164. return;
  165. }
  166. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow uRow in ultraGrid3.Rows)
  167. {
  168. if (Convert.ToBoolean(uRow.Cells["CHOOSE"].Text) == true)
  169. {
  170. string strLocat=uRow.Cells["LOCATION_NO"].Text.Trim();
  171. if (strLocat == "")
  172. {
  173. MessageUtil.ShowTips("目标料位不能为空!");
  174. return;
  175. }
  176. if (ugr2.Cells["LOCATION_NO"].Text.Trim() == strLocat)
  177. {
  178. MessageUtil.ShowTips("目标料位与当前料位一致,请重新输入!");
  179. return;
  180. }
  181. if (uRow.Cells["ACT_COUNT"].Value.ToString() == "0" || uRow.Cells["ACT_COUNT"].Value.ToString() == "")
  182. {
  183. MessageUtil.ShowTips("目标支数不能为空或零!");
  184. return;
  185. }
  186. pram.Clear();
  187. pram.Add(ugr1.Cells["storage_no"].Text.Trim());
  188. pram.Add(ugr1.Cells["JUDGE_STOVE_NO"].Text.Trim());
  189. pram.Add(ugr1.Cells["BATCH_NO"].Text.Trim());
  190. pram.Add(ugr1.Cells["BATCH_GROUD_NO"].Text.Trim());
  191. pram.Add(ugr2.Cells["LOCATION_NO"].Text.Trim());
  192. pram.Add(uRow.Cells["ACT_COUNT"].Text.Trim());
  193. pram.Add(uRow.Cells["LOCATION_NO"].Text.Trim());
  194. pram.Add(this.UserInfo.GetUserOrder());
  195. pram.Add(this.UserInfo.GetUserGroup());
  196. pram.Add(this.UserInfo.GetUserName());
  197. pram.Add(UserInfo.GetDeptid());
  198. pram.Add(UserInfo.GetDepartment());
  199. loactionNo = this.ultraGrid3.ActiveRow.Cells["LOCATION_NO"].Text.ToString();
  200. string departMentNo = ClsBaseInfo.GetDepartIdBySectionId(UserInfo.GetDeptid(), this.ob);
  201. string departMent = ClsBaseInfo.GetDepartBySectionId(UserInfo.GetDeptid(), this.ob);
  202. pram.Add(departMentNo);
  203. pram.Add(departMent);
  204. CoreClientParam ccp = new CoreClientParam();
  205. ccp.ServerName = "com.steering.pss.ydm.pipemanage.FrmPipeStow";
  206. ccp.MethodName = "addPipeSwtow";
  207. ccp.ServerParams = new object[] { pram };
  208. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  209. if (ccp.ReturnCode == -1)
  210. {
  211. return;
  212. }
  213. count += 1;
  214. //count = ServerHelper.SetData("com.steering.pss.ydm.pipemanage.FrmPipeStow.addPipeSwtow", new object[] { pram }, ob);
  215. }
  216. }
  217. if (count > 0)
  218. {
  219. MessageUtil.ShowTips("倒垛成功!");
  220. }
  221. QueryOutList();
  222. doQuery();
  223. YdmBaseClass.Postioning(this.ultraGrid1, "LOCATION_NO", loactionNo);
  224. }
  225. private void doRefresh()
  226. {
  227. StorInfo();
  228. Init();
  229. ultraGrid2.UpdateData();
  230. UltraGridRow ugr = this.ultraGrid2.ActiveRow;
  231. if (this.ultraGrid2.Rows.Count <= 0) return;
  232. if (ugr == null) return;
  233. if (ugr.IsFilterRow) return;
  234. if (ugr.HasParent() == true) return;
  235. pram.Clear();
  236. pram.Add(ugr.Cells["storage_no"].Text.ToString());
  237. PipeManageClass.BindLocationInfo(pram, cmbMaterialEid, ob);
  238. }
  239. private void QueryOutList()
  240. {
  241. ultraGrid1.UpdateData();
  242. UltraGridRow ugr = this.ultraGrid1.ActiveRow;
  243. if (this.ultraGrid1.Rows.Count <= 0) return;
  244. if (ugr == null) return;
  245. if (ugr.IsFilterRow) return;
  246. if (ugr.HasParent() == true) return;
  247. string strMat = "";
  248. if (cmbWarehous.SelectedIndex != -1)
  249. {
  250. strMat = cmbWarehous.Value.ToString();
  251. }
  252. pram.Clear();
  253. pram.Add(ugr.Cells["STORAGE_NO"].Value.ToString());
  254. pram.Add(ugr.Cells["judge_stove_no"].Text.ToString());
  255. pram.Add(ugr.Cells["batch_no"].Text.ToString());
  256. //pram.Add(ugr.Cells["batch_groud_no"].Text.ToString());
  257. pram.Add(ugr.Cells["LOCATION_NO"].Text.ToString());
  258. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeStow.queryStow", new object[] { pram }, ob);
  259. GridHelper.CopyDataToDatatable(dt, this.dataStow, true);
  260. GridHelper.RefreshAndAutoSize(ultraGrid2);
  261. }
  262. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  263. {
  264. QueryOutList();
  265. }
  266. private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
  267. {
  268. ultraGrid2.UpdateData();
  269. UltraGridRow ugr = this.ultraGrid2.ActiveRow;
  270. if (this.ultraGrid2.Rows.Count <= 0) return;
  271. if (ugr == null)
  272. {
  273. ultraGrid3.Enabled = false;
  274. return;
  275. }
  276. else
  277. {
  278. ultraGrid3.Enabled = true;
  279. }
  280. if (ugr.IsFilterRow) return;
  281. if (ugr.HasParent() == true) return;
  282. DataTable dt = new DataTable();
  283. pram.Clear();
  284. pram.Add(ugr.Cells["storage_no"].Text.ToString());
  285. //pram.Add(ugr.Cells["LOCATION_NO"].Text.ToString());
  286. //DataTable dtLond = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeStow.queryLocaTarget", new object[] { pram }, ob);
  287. //cmbMaterialEid.DataSource = dtLond;
  288. //cmbMaterialEid.ValueMember = "LOCATION_NO";
  289. PipeManageClass.BindLocationInfo(pram, cmbMaterialEid, ob);
  290. GridHelper.CopyDataToDatatable(dt, this.dataTable1, true);
  291. }
  292. /// <summary>
  293. /// 验证Checked是否勾选,显示控件可编辑 打勾表示可编辑,不打勾表示不可编辑
  294. /// </summary>
  295. /// <param name="sender"></param>
  296. /// <param name="e"></param>
  297. private void chk_CheckedChanged(object sender, EventArgs e)
  298. {
  299. if (chkWarehous.Checked) { cmbWarehous.Enabled = true; } else { cmbWarehous.Enabled = false; }
  300. if (chkMaterial.Checked) { cmbMaterialEid.Enabled = true; } else { cmbMaterialEid.Enabled = false; }
  301. if (chkFurnace.Checked) { txtFurnace.Enabled = true; } else { txtFurnace.Enabled = false; }
  302. if (chkBatch.Checked) { txtBatch.Enabled = true; } else { txtBatch.Enabled = false; }
  303. if (chkGroup.Checked) { txtGroup.Enabled = true; } else { txtGroup.Enabled = false; }
  304. }
  305. private void cmbWarehous_TextChanged(object sender, EventArgs e)
  306. {
  307. Init();
  308. }
  309. ///查询时验证必填项
  310. private bool CheckQuery()
  311. {
  312. if (chkWarehous.Checked && string.IsNullOrEmpty(cmbWarehous.Text.Trim()))
  313. {
  314. MessageBox.Show("请选择仓库号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  315. return false;
  316. }
  317. if (chkMaterial.Checked && string.IsNullOrEmpty(cmbMaterialEid.Text.Trim()))
  318. {
  319. MessageBox.Show("请选择料位号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  320. return false;
  321. }
  322. if (chkFurnace.Checked && string.IsNullOrEmpty(txtFurnace.Text.Trim()))
  323. {
  324. MessageBox.Show("请输入炉号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  325. return false;
  326. }
  327. if (chkBatch.Checked && string.IsNullOrEmpty(txtBatch.Text.Trim()))
  328. {
  329. MessageBox.Show("请输入批号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  330. return false;
  331. }
  332. if (chkGroup.Checked && string.IsNullOrEmpty(txtGroup.Text.Trim()))
  333. {
  334. MessageBox.Show("请输入组号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  335. return false;
  336. }
  337. return true;
  338. }
  339. /// <summary>
  340. /// 对录入支数进行判断
  341. /// </summary>
  342. /// <param name="sender"></param>
  343. /// <param name="e"></param>
  344. private void ultraGrid3_CellChange(object sender, CellEventArgs e)
  345. {
  346. ultraGrid2.UpdateData();
  347. ultraGrid3.UpdateData();
  348. UltraGridRow ugr = this.ultraGrid2.ActiveRow;
  349. UltraGridRow ugr1 = this.ultraGrid3.ActiveRow;
  350. string plannum = ugr.Cells["ACT_COUNT"].Value.ToString();//当前料位支数
  351. if (e.Cell.Column.Key.Equals("ACT_COUNT"))
  352. {
  353. double strCount = 0;
  354. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow uRow in ultraGrid3.Rows)
  355. {
  356. if (uRow.Cells["ACT_COUNT"].Value.ToString()=="")
  357. {
  358. uRow.Cells["ACT_COUNT"].Value = "0";
  359. }
  360. if (Convert.ToBoolean(uRow.Cells["CHOOSE"].Text) == true)
  361. {
  362. strCount += double.Parse(uRow.Cells["ACT_COUNT"].Value.ToString());//目标料位支数
  363. }
  364. }
  365. if (strCount.ToString() != "" && strCount.ToString() != "0")
  366. {
  367. if (Convert.ToInt32(strCount.ToString()) > Convert.ToInt32(plannum))
  368. {
  369. MessageUtil.ShowWarning("目标料位支数不能大于当前料位支数!");
  370. ugr1.Cells["ACT_COUNT"].Value = "";
  371. return;
  372. }
  373. }
  374. }
  375. if (e.Cell.Column.Key.Equals("CHOOSE"))
  376. {
  377. if (Convert.ToBoolean(e.Cell.Value))
  378. {
  379. isSelect += 1;
  380. }
  381. else
  382. isSelect -= 1;
  383. }
  384. if (e.Cell.Column.Key.Equals("AREA_NO"))
  385. {
  386. this.ultraGrid3.ActiveRow.Cells["LOCATION_NO"].Value = this.ultraGrid1.ActiveRow.Cells["STORAGE_NO"].Text.Trim() + this.ultraGrid3.ActiveRow.Cells["AREA_NO"].Text.Trim() + this.ultraGrid3.ActiveRow.Cells["ROW_NO"].Text.Trim() + this.ultraGrid3.ActiveRow.Cells["COL_NO"].Text.Trim();
  387. }
  388. if (e.Cell.Column.Key.Equals("ROW_NO"))
  389. {
  390. this.ultraGrid3.ActiveRow.Cells["LOCATION_NO"].Value = this.ultraGrid1.ActiveRow.Cells["STORAGE_NO"].Text.Trim() + this.ultraGrid3.ActiveRow.Cells["AREA_NO"].Text.Trim() + this.ultraGrid3.ActiveRow.Cells["ROW_NO"].Text.Trim() + this.ultraGrid3.ActiveRow.Cells["COL_NO"].Text.Trim();
  391. }
  392. if (e.Cell.Column.Key.Equals("COL_NO"))
  393. {
  394. this.ultraGrid3.ActiveRow.Cells["LOCATION_NO"].Value = this.ultraGrid1.ActiveRow.Cells["STORAGE_NO"].Text.Trim() + this.ultraGrid3.ActiveRow.Cells["AREA_NO"].Text.Trim() + this.ultraGrid3.ActiveRow.Cells["ROW_NO"].Text.Trim() + this.ultraGrid3.ActiveRow.Cells["COL_NO"].Text.Trim();
  395. }
  396. }
  397. private void frmPipeStow_Shown(object sender, EventArgs e)
  398. {
  399. toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.False;
  400. }
  401. private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
  402. {
  403. if (toolMenu == null) return;
  404. if (e.Tab.TabControl.SelectedTab.Key.Equals("0"))
  405. {
  406. toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.False;
  407. toolMenu.Toolbars[0].Tools["Add"].InstanceProps.Visible = DefaultableBoolean.True;
  408. }
  409. else
  410. {
  411. toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.True;
  412. toolMenu.Toolbars[0].Tools["Add"].InstanceProps.Visible = DefaultableBoolean.False;
  413. }
  414. }
  415. private void ultraGrid3_InitializeRow(object sender, InitializeRowEventArgs e)
  416. {
  417. if (!Convert.ToBoolean(e.Row.Cells["CHOOSE"].Value))
  418. {
  419. for (int i = 0; i < e.Row.Cells.Count; i++)
  420. {
  421. if (!e.Row.Cells[i].Column.Key.Equals("CHOOSE"))
  422. e.Row.Cells[i].Activation = Activation.ActivateOnly;
  423. }
  424. }
  425. else
  426. {
  427. for (int i = 0; i < e.Row.Cells.Count; i++)
  428. {
  429. e.Row.Cells[i].Activation = Activation.AllowEdit;
  430. }
  431. }
  432. }
  433. private void txtFurnace_KeyDown(object sender, KeyEventArgs e)
  434. {
  435. if (e.KeyValue == 13)
  436. {
  437. doQuery();
  438. }
  439. }
  440. }
  441. }