FrmGPRule.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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.Mes.Client.Comm.Tool;
  11. using Core.Mes.Client.Comm.Server;
  12. using Core.StlMes.Client.YdmStuffManage.Entity;
  13. using System.Collections;
  14. using Infragistics.Win.UltraWinGrid;
  15. using Core.Mes.Client.Comm.Format;
  16. using Infragistics.Win;
  17. using Core.Mes.Client.Comm.Control;
  18. using System.Threading;
  19. namespace Core.StlMes.Client.YdmStuffManage
  20. {
  21. public partial class FrmGPRule : FrmBase
  22. {
  23. public FrmGPRule()
  24. {
  25. InitializeComponent();
  26. }
  27. private void Frm_Load(object sender, EventArgs e)
  28. {
  29. GridHelper.SetColumnsActivateAndColor(ultraGrid1.Rows.Band, "CHK");
  30. EntityHelper.ShowGridCaption<FrmGPRuleEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  31. arr = BaseMethod.WarehousePermissionsStore(this.ValidDataPurviewIds, ob);
  32. }
  33. public override void ToolBar_Click(object sender, string ToolbarKey)
  34. {
  35. switch (ToolbarKey)
  36. {
  37. case "doQuery":
  38. doQuery();
  39. break;
  40. case "doUpdate":
  41. doUpdate();
  42. break;
  43. case "Close":
  44. this.Close();
  45. break;
  46. }
  47. }
  48. private void doUpdate()
  49. {
  50. //List<UltraGridRow> rows = UltraGridGetChooseRows(this.ultraGrid1);
  51. //if (rows.Count==0)
  52. //{
  53. // MessageUtil.ShowTips("请选择需要返库的数据!");
  54. // return;
  55. //}
  56. //List<FrmGPRuleEntity> list = new List<FrmGPRuleEntity>();
  57. //foreach (UltraGridRow row in rows) {
  58. // FrmGPRuleEntity entity = row.ListObject as FrmGPRuleEntity;
  59. // list.Add(entity);
  60. //}
  61. //FrmGPLocationDlog frm = new FrmGPLocationDlog(list);
  62. //frm.ob = this.ob;
  63. //frm.ShowDialog();
  64. //if (frm.CloseEvent.Equals("update"))
  65. // this.doQuery();
  66. try
  67. {
  68. this.ultraGrid1.UpdateData();
  69. List<UltraGridRow> rows = UltraGridGetChooseRows(this.ultraGrid1);
  70. if (rows.Count == 0)
  71. {
  72. MessageUtil.ShowTips("请选择需要入库的数据!");
  73. return;
  74. }
  75. ArrayList strEntity = new ArrayList();
  76. foreach (UltraGridRow row in rows) {
  77. strEntity.Add(JSONFormat.Format(row.ListObject as FrmGPRuleEntity));
  78. }
  79. CoreClientParam ccp = new CoreClientParam();
  80. ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmGPRule";
  81. ccp.MethodName = "insertYdmGpOutList";
  82. ccp.ServerParams = new object[] { strEntity,this.UserInfo.GetUserName() };
  83. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  84. if (ccp != null)
  85. {
  86. if (ccp.ReturnCode != -1)
  87. {
  88. MessageUtil.ShowWarning(ccp.ReturnInfo);
  89. return;
  90. }
  91. if (ccp.ReturnInfo.Equals("返库成功!"))
  92. {
  93. MessageUtil.ShowWarning("返库成功!");
  94. doQuery();
  95. }
  96. }
  97. }
  98. catch (System.Exception ex)
  99. {
  100. MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  101. }
  102. }
  103. public static List<UltraGridRow> UltraGridGetChooseRows(UltraGrid grid, string columnName = "CHK")
  104. {
  105. grid.UpdateData();
  106. List<UltraGridRow> list = new List<UltraGridRow>();
  107. RowsCollection rows = grid.Rows;
  108. foreach (var item in rows)
  109. {
  110. try
  111. {
  112. if (Convert.ToBoolean(item.Cells[columnName].Value) == true && item.Hidden == false && item.IsFilteredOut == false)
  113. {
  114. list.Add(item);
  115. }
  116. }
  117. catch { }
  118. }
  119. return list;
  120. }
  121. private string[] arr = null;//仓库权限
  122. private void doQuery()
  123. {
  124. var dic = new Dictionary<string, object>();
  125. if (chkStoveNo.Checked)
  126. dic.Add("txtStoveNo", txtStoveNo.Text);
  127. if (chkFurnace.Checked)
  128. dic.Add("txtFurnace", txtFurnace.Text);
  129. ultraGrid1.DataSource = EntityHelper.GetData<FrmGPRuleEntity>("Core.LgMes.Server.Stuffmanage.FrmGPRule.query", new object[] { arr,dic },this.ob);
  130. }
  131. private void chkStoveNo_CheckedChanged(object sender, EventArgs e)
  132. {
  133. if (chkStoveNo.Checked)
  134. {
  135. this.txtStoveNo.Enabled = true;
  136. }
  137. else {
  138. this.txtStoveNo.Enabled = false;
  139. }
  140. }
  141. private void chkFurnace_CheckedChanged(object sender, EventArgs e)
  142. {
  143. if (chkFurnace.Checked)
  144. {
  145. this.txtFurnace.Enabled = true;
  146. }
  147. else
  148. {
  149. this.txtFurnace.Enabled = false;
  150. }
  151. }
  152. }
  153. }