FrmGPInRule.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 FrmGPInRule : FrmBase
  22. {
  23. public FrmGPInRule()
  24. {
  25. InitializeComponent();
  26. }
  27. private void Frm_Load(object sender, EventArgs e)
  28. {
  29. GridHelper.SetColumnsActivateAndColor(ultraGrid1.Rows.Band, "CHK","InActCount");
  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. public static List<UltraGridRow> UltraGridGetChooseRows(UltraGrid grid, string columnName = "CHK")
  49. {
  50. grid.UpdateData();
  51. List<UltraGridRow> list = new List<UltraGridRow>();
  52. RowsCollection rows = grid.Rows;
  53. foreach (var item in rows)
  54. {
  55. try
  56. {
  57. if (Convert.ToBoolean(item.Cells[columnName].Value) == true && item.Hidden == false && item.IsFilteredOut == false)
  58. {
  59. list.Add(item);
  60. }
  61. }
  62. catch { }
  63. }
  64. return list;
  65. }
  66. private string[] arr = null;//仓库权限
  67. private void doQuery()
  68. {
  69. var dic = new Dictionary<string, object>();
  70. if (chkStoveNo.Checked)
  71. dic.Add("txtStoveNo", txtStoveNo.Text);
  72. if (chkFurnace.Checked)
  73. dic.Add("txtFurnace", txtFurnace.Text);
  74. ultraGrid1.DataSource = EntityHelper.GetData<FrmGPRuleEntity>("Core.LgMes.Server.Stuffmanage.FrmGPRule.queryInList", new object[] { arr,dic },this.ob);
  75. }
  76. private void doUpdate()
  77. {
  78. try
  79. {
  80. this.ultraGrid1.UpdateData();
  81. List<UltraGridRow> rows = UltraGridGetChooseRows(this.ultraGrid1);
  82. if (rows.Count == 0)
  83. {
  84. MessageUtil.ShowTips("请选择需要红冲的数据!");
  85. return;
  86. }
  87. ArrayList strEntity = new ArrayList();
  88. foreach (UltraGridRow row in rows)
  89. {
  90. if (row.Cells["inActCount"].Value.ToString().Equals(""))
  91. {
  92. MessageUtil.ShowTips("请输入红冲支数!");
  93. return;
  94. }
  95. if (Int32.Parse(row.Cells["ActCount"].Value.ToString()) < Int32.Parse(row.Cells["inActCount"].Value.ToString())) {
  96. MessageUtil.ShowTips("红冲支数不能大于总支数!");
  97. return;
  98. }
  99. strEntity.Add(JSONFormat.Format(row.ListObject as FrmGPRuleEntity));
  100. }
  101. CoreClientParam ccp = new CoreClientParam();
  102. ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmGPRule";
  103. ccp.MethodName = "insertYdmGpInList";
  104. ccp.ServerParams = new object[] { strEntity,UserInfo.GetUserName() };
  105. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  106. if (ccp != null)
  107. {
  108. if (ccp.ReturnCode == -1)
  109. {
  110. MessageUtil.ShowWarning(ccp.ReturnInfo);
  111. return;
  112. }
  113. MessageUtil.ShowTips("入库成功!");
  114. }
  115. }
  116. catch (System.Exception ex)
  117. {
  118. MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  119. }
  120. }
  121. private void chkStoveNo_CheckedChanged(object sender, EventArgs e)
  122. {
  123. if (chkStoveNo.Checked)
  124. {
  125. this.txtStoveNo.Enabled = true;
  126. }
  127. else {
  128. this.txtStoveNo.Enabled = false;
  129. }
  130. }
  131. private void chkFurnace_CheckedChanged(object sender, EventArgs e)
  132. {
  133. if (chkFurnace.Checked)
  134. {
  135. this.txtFurnace.Enabled = true;
  136. }
  137. else
  138. {
  139. this.txtFurnace.Enabled = false;
  140. }
  141. }
  142. }
  143. }