FrmHttCoupling.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. using Core.Mes.Client.Comm.Format;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using Core.StlMes.Client.Mcp.Treatment.Entity;
  5. using CoreFS.CA06;
  6. using Infragistics.Win.UltraWinEditors;
  7. using Infragistics.Win.UltraWinGrid;
  8. using System;
  9. using System.Collections;
  10. using System.Collections.Generic;
  11. using System.ComponentModel;
  12. using System.Data;
  13. using System.Drawing;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Windows.Forms;
  17. namespace Core.StlMes.Client.Mcp.Treatment.HeatTreatment
  18. {
  19. public partial class FrmHttCoupling : FrmBase
  20. {
  21. public FrmHttCoupling()
  22. {
  23. InitializeComponent();
  24. }
  25. private void FrmHttCoupling_Load(object sender, EventArgs e)
  26. {
  27. EntityHelper.ShowGridCaption<HttCouplingEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  28. getDropdown(MachineComboEditor, ob, false, "com.steering.mes.mcp.heatTreatment.FcaHttCoupling.getMachine", "MACHINE_NAME", "MACHINE_NAME");// 查询机床
  29. getDropdown(SpecComboEditor, ob, false, "com.steering.ydm.bc.BaseOperations.getSpc", "SPEC_NAME", "SPEC_NAME");// 查询规格
  30. getDropdown(ModelComboEditor, ob, false, "com.steering.ydm.bc.BaseOperations.getModel", "MODEL_DESC", "MODEL_DESC");// 查询扣型
  31. }
  32. /// <summary>
  33. /// 下拉赋值
  34. /// </summary>
  35. public bool getDropdown(UltraComboEditor cmb, OpeBase ob, bool hasBlankLine, String m, String v, String d)
  36. {
  37. DataTable dt = ServerHelper.GetData(m, new object[] { }, ob);
  38. if (hasBlankLine && dt != null && dt.Rows.Count > 0)
  39. {
  40. DataRow dr = dt.NewRow();
  41. dt.Rows.InsertAt(dr, 0);
  42. }
  43. cmb.DataSource = dt;
  44. cmb.DisplayMember = d;
  45. cmb.ValueMember = v;
  46. return true;
  47. }
  48. /// <summary>
  49. /// 重写基类方法
  50. /// </summary>
  51. /// <param name="sender"></param>
  52. /// <param name="ToolbarKey"></param>
  53. public override void ToolBar_Click(object sender, string ToolbarKey)
  54. {
  55. switch (ToolbarKey)
  56. {
  57. case "DoQuery":
  58. doQuery();
  59. break;
  60. case "DoSave":
  61. doAdd();
  62. break;
  63. case "DoUpdate":
  64. doUpdate();
  65. break;
  66. case "DoRecover":
  67. doNullifyOrRecover("1");
  68. break;
  69. case "DoNullify":
  70. doNullifyOrRecover("0");
  71. break;
  72. case "Close":
  73. this.Close();
  74. break;
  75. }
  76. }
  77. private void doQuery()
  78. {
  79. String nullifyFlag = "1"; // 作废状态(1:有效)
  80. if (nullifyFlagSearch.Checked)
  81. {
  82. nullifyFlag = "";
  83. }
  84. List<HttCouplingEntity> listSource = EntityHelper.GetData<HttCouplingEntity>(
  85. "com.steering.mes.mcp.heatTreatment.FcaHttCoupling.doQuery", new object[] { nullifyFlag }, this.ob);
  86. httCouplingEntityBindingSource.DataSource = listSource;
  87. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  88. {
  89. UltraGridRow row = ultraGrid1.Rows[i];
  90. if (row.Cells["validflag"].Value.ToString().Equals("0"))
  91. {
  92. row.Appearance.ForeColor = Color.Red;
  93. }
  94. }
  95. }
  96. private void doAdd()
  97. {
  98. this.ultraGrid1.UpdateData();
  99. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  100. if (checkMagRows.Count() == 0)
  101. {
  102. MessageUtil.ShowTips("请选择需要新增的信息!");
  103. return;
  104. }
  105. ArrayList parmList = new ArrayList();
  106. foreach (UltraGridRow row in checkMagRows)
  107. {
  108. HttCouplingEntity entity = row.ListObject as HttCouplingEntity;
  109. if (!String.IsNullOrEmpty(entity.Id))
  110. continue;
  111. entity.CreateName = UserInfo.GetUserName();
  112. string baseEntity = JSONFormat.Format(entity);
  113. parmList.Add(baseEntity);
  114. }
  115. if (parmList.Count > 0)
  116. {
  117. CoreClientParam ccp = new CoreClientParam();
  118. ccp.ServerName = "com.steering.mes.mcp.heatTreatment.FcaHttCoupling";
  119. ccp.MethodName = "doAdd";
  120. ccp.ServerParams = new object[] { parmList };
  121. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  122. if (ccp.ReturnCode != -1)
  123. {
  124. doQuery();
  125. MessageUtil.ShowTips("新增成功!");
  126. }
  127. }
  128. }
  129. private void doUpdate()
  130. {
  131. this.ultraGrid1.UpdateData();
  132. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  133. if (checkMagRows.Count() == 0)
  134. {
  135. MessageUtil.ShowTips("请选择需要修改的信息!");
  136. return;
  137. }
  138. ArrayList parmList = new ArrayList();
  139. foreach (UltraGridRow row in checkMagRows)
  140. {
  141. HttCouplingEntity entity = row.ListObject as HttCouplingEntity;
  142. if (String.IsNullOrEmpty(entity.Id))
  143. continue;
  144. entity.UpdateName = UserInfo.GetUserName();
  145. string baseEntity = JSONFormat.Format(entity);
  146. parmList.Add(baseEntity);
  147. }
  148. if (parmList.Count > 0)
  149. {
  150. CoreClientParam ccp = new CoreClientParam();
  151. ccp.ServerName = "com.steering.mes.mcp.heatTreatment.FcaHttCoupling";
  152. ccp.MethodName = "doUpdate";
  153. ccp.ServerParams = new object[] { parmList };
  154. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  155. if (ccp.ReturnCode != -1)
  156. {
  157. doQuery();
  158. MessageUtil.ShowTips("修改成功!");
  159. }
  160. }
  161. }
  162. private void doNullifyOrRecover(string flag)
  163. {
  164. this.ultraGrid1.UpdateData();
  165. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  166. String info = "1".Equals(flag) ? "恢复" : "作废";
  167. if (checkMagRows.Count() == 0)
  168. {
  169. MessageUtil.ShowTips("请选择需要" + info + "的信息!");
  170. return;
  171. }
  172. ArrayList parmList = new ArrayList();
  173. foreach (UltraGridRow row in checkMagRows)
  174. {
  175. HttCouplingEntity entity = row.ListObject as HttCouplingEntity;
  176. if (String.IsNullOrEmpty(entity.Id))
  177. continue;
  178. entity.DeleteName = UserInfo.GetUserName();
  179. entity.Validflag = flag;
  180. string baseEntity = JSONFormat.Format(entity);
  181. parmList.Add(baseEntity);
  182. }
  183. if (parmList.Count > 0)
  184. {
  185. CoreClientParam ccp = new CoreClientParam();
  186. ccp.ServerName = "com.steering.mes.mcp.heatTreatment.FcaHttCoupling";
  187. ccp.MethodName = "doNullifyOrRecover";
  188. ccp.ServerParams = new object[] { parmList };
  189. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  190. if (ccp.ReturnCode != -1)
  191. {
  192. doQuery();
  193. MessageUtil.ShowTips(info + "成功");
  194. }
  195. }
  196. }
  197. }
  198. }