FrmBaseMaterialAPl.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using Core.Mes.Client.Comm.Format;
  11. using Core.Mes.Client.Comm.Server;
  12. using Core.Mes.Client.Comm.Tool;
  13. using Core.StlMes.Client.PlnSaleOrd.BaseMethod;
  14. using CoreFS.CA06;
  15. using Infragistics.Win.UltraWinGrid;
  16. using Core.StlMes.Client.PlnSaleOrd.炼钢计划;
  17. using Core.StlMes.Client.PlnSaleOrd.炼钢计划.entity;
  18. using Core.Mes.Client.Comm.Control;
  19. namespace Core.StlMes.Client.PlnSaleOrd
  20. {
  21. public partial class FrmBaseMaterialAPl : FrmBase
  22. {
  23. private string _inMaterialNo = "";
  24. private string _outMaterialNo = "";
  25. private string _inMaterialDesc = "";
  26. private string _outMaterialDesc = "";
  27. private string _plineCode = "";
  28. //public FrmBaseMaterialAPl()
  29. //{
  30. // InitializeComponent();
  31. //}
  32. public FrmBaseMaterialAPl()
  33. {
  34. this.ob = ob;
  35. InitializeComponent();
  36. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  37. }
  38. private void FrmBaseMaterialBPl_Load(object sender, EventArgs e)
  39. {
  40. EntityHelper.ShowGridCaption<SlmBaseMaterialAPlEntity>(ultraGridZz.DisplayLayout.Bands[0]);
  41. BaseHelper.setColumnBackColor(ultraGridZz, new string[] { "HrCapcty", "PrdRate", "DisableFl", "PlineCode", "PlineLevel" });
  42. BaseHelper.InitCellPosition(ultraGridZz, new string[] { "HrCapcty", "PrdRate", "DisableFl", "PlineLevel" });
  43. //InitMaterial();
  44. SteelHelper.InitPline(comEfPlin, "A", this.ob);
  45. SteelHelper.InitGrade(comGrade, this.ob);
  46. Query();
  47. }
  48. private void InitMaterial()
  49. {
  50. DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmBasematerialAPl.getBaseMaterialB", new object[] { _inMaterialNo, _outMaterialNo }, this.ob);
  51. if (dt != null && dt.Rows.Count > 0)
  52. {
  53. _inMaterialDesc = dt.Rows[0]["IN_MATERIAL_DESC"].ToString();
  54. _outMaterialDesc = dt.Rows[0]["OUT_MATERIAL_DESC"].ToString();
  55. }
  56. }
  57. public void Query()
  58. {
  59. string grade = "";
  60. string plineCode = "";
  61. if (chkEfPlin.Checked && comEfPlin.Value != null) { plineCode = comEfPlin.Value.ToString(); }
  62. if (plineCode == null) { MessageUtil.ShowWarning("请选择电炉产线!"); return; }
  63. if (chcGrade.Checked && comGrade.Value != null) { grade = comGrade.Value.ToString(); }
  64. if (grade == null) { MessageUtil.ShowWarning("请选择产出物料!"); return; }
  65. List<SlmBaseMaterialAPlEntity> materialAPlEntityList = EntityHelper.GetData<SlmBaseMaterialAPlEntity>(
  66. "com.steering.pss.plnsaleord.steelMarkingPlan.FrmBasematerialAPl.getBaseMaterialAPl", new object[] { plineCode, grade }, ob);
  67. slmBaseMaterialAPlEntityBindingSource.DataSource = materialAPlEntityList;
  68. GridHelper.RefreshAndAutoSize(ultraGridZz);
  69. if (!_plineCode.Equals(""))
  70. {
  71. IQueryable<UltraGridRow> chcRows = ultraGridZz.Rows.AsQueryable().Where(a => a.GetValue("PlineCode") == _plineCode);
  72. if (chcRows != null && chcRows.Count() != 0)
  73. {
  74. chcRows.First().Activate();
  75. chcRows.First().Cells["CHC"].Value = true;
  76. }
  77. }
  78. }
  79. private void update()
  80. {
  81. try
  82. {
  83. ultraGridZz.UpdateData();
  84. IQueryable<UltraGridRow> chcRows = ultraGridZz.Rows.AsQueryable().Where(a => a.GetValue("CHC") == "True");
  85. if (chcRows == null || chcRows.Count() == 0)
  86. {
  87. MessageUtil.ShowTips("请选择记录!");
  88. return;
  89. }
  90. ArrayList param = new ArrayList();
  91. foreach (UltraGridRow ugr in chcRows)
  92. {
  93. SlmBaseMaterialAPlEntity entity = (SlmBaseMaterialAPlEntity)ugr.ListObject;
  94. entity.UpdateName = UserInfo.GetUserName();
  95. string jsonStr = JSONFormat.Format(entity);
  96. param.Add(jsonStr);
  97. }
  98. if (MessageUtil.ShowYesNoAndQuestion("是否修改记录?") == DialogResult.No)
  99. {
  100. return;
  101. }
  102. ServerHelper.SetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmBasematerialAPl.updateBaseMaterialAPl", new object[] { param }, this.ob);
  103. Query();
  104. MessageUtil.ShowTips("修改成功!");
  105. }
  106. catch (Exception e)
  107. {
  108. MessageUtil.ShowTips(e.Message + " 数据异常,请重新操作!");
  109. }
  110. }
  111. private void ultraGridZg_InitializeRow(object sender, InitializeRowEventArgs e)
  112. {
  113. BaseHelper.ControlCellEdit(e.Row);
  114. }
  115. private void chc_CheckedChanged(object sender, EventArgs e)
  116. {
  117. if (chcGrade.Checked) { comGrade.Enabled = true; } else { comGrade.Enabled = false; }
  118. if (chkEfPlin.Checked) { comEfPlin.Enabled = true; } else { comEfPlin.Enabled = false; }
  119. }
  120. public override void ToolBar_Click(object sender, string ToolbarKey)
  121. {
  122. switch (ToolbarKey)
  123. {
  124. case "Query":
  125. Query();
  126. break;
  127. case "Update":
  128. update();
  129. break;
  130. case "Close":
  131. this.Close();
  132. break;
  133. default:
  134. break;
  135. }
  136. }
  137. private void ultraGridZz_CellChange(object sender, CellEventArgs e)
  138. {
  139. }
  140. }
  141. }