FrmProductPlane.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using CoreFS.CA06;
  4. using Infragistics.Win.UltraWinGrid;
  5. using System;
  6. using System.Collections;
  7. using System.Data;
  8. using System.Windows.Forms;
  9. namespace Core.StlMes.Client.Qcm
  10. {
  11. public partial class FrmProductPlane : FrmBase
  12. {
  13. public FrmProductPlane()
  14. {
  15. InitializeComponent();
  16. }
  17. int isselect = 0;
  18. public override void ToolBar_Click(object sender, string ToolbarKey)
  19. {
  20. switch (ToolbarKey)
  21. {
  22. case "doQuery":
  23. DoQuery();
  24. break;
  25. case "Save":
  26. DoSave();
  27. break;
  28. case "doClose":
  29. this.Close();
  30. break;
  31. }
  32. }
  33. private void SetGridNoEdit(UltraGrid ug)
  34. {
  35. ug.UpdateData();
  36. foreach (UltraGridRow row in ug.Rows)
  37. {
  38. for (int i = 0; i < row.Cells.Count; i++)
  39. {
  40. if (!row.Cells[i].Column.Key.Equals("CHK") && !row.Cells[i].Column.Key.Equals("MEMO"))
  41. row.Cells[i].Activation = Activation.ActivateOnly;
  42. else
  43. row.Cells[i].Activation = Activation.AllowEdit;
  44. }
  45. }
  46. }
  47. private void FrmProductPlane_Load_1(object sender, EventArgs e)
  48. {
  49. DoQuery();
  50. }
  51. private void DoQuery()
  52. {
  53. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProductionPlane.doQuery", null, this.ob);
  54. GridHelper.CopyDataToDatatable(ref dt, ref dataTable2, true);
  55. isselect = 0;
  56. }
  57. private void GetPlineStation(string plinecode)
  58. {
  59. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProductionPlane.getPlineStation", new Object[] { plinecode }, this.ob);
  60. GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);
  61. //SetGridNoEdit(ultraGrid1);
  62. }
  63. private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
  64. {
  65. UltraGridRow ugr = ultraGrid2.ActiveRow;
  66. if (ugr == null)
  67. return;
  68. string plinecode = ugr.Cells["PLINE_CODE"].Value.ToString();
  69. GetPlineStation(plinecode);
  70. }
  71. private void DoSave()
  72. {
  73. ultraGrid1.UpdateData();
  74. ultraGrid2.UpdateData();
  75. if (isselect == 0)
  76. {
  77. MessageBox.Show("您没有做任何的修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  78. return;
  79. }
  80. if (MessageBox.Show("是否确认保存修改?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  81. {
  82. return;
  83. }
  84. UltraGridRow ugr1 = this.ultraGrid2.ActiveRow;
  85. if (ugr1 == null) return;
  86. ArrayList list = new ArrayList();
  87. string plinecode = ugr1.Cells["PLINE_CODE"].Value.ToString();
  88. foreach (UltraGridRow row in ultraGrid1.Rows)
  89. {
  90. if (row.Cells["CHK"].Value.ToString().ToUpper() == "TRUE")
  91. {
  92. ArrayList parm = new ArrayList();
  93. parm.Add(plinecode);
  94. parm.Add(ugr1.Cells["PLINE_NAME"].Value.ToString());
  95. parm.Add(row.Cells["STATION_CODE"].Value.ToString());
  96. parm.Add(row.Cells["STATION_DESC"].Value.ToString());
  97. parm.Add(row.Cells["STATION_ID"].Value.ToString());
  98. parm.Add(this.UserInfo.GetUserName());
  99. parm.Add(row.Cells["MEMO"].Value.ToString());
  100. list.Add(parm);
  101. }
  102. }
  103. int count = ServerHelper.SetData("com.steering.pss.qcm.CoreProductionPlane.doSave", new Object[] { list, plinecode }, this.ob);
  104. if (count > 0)
  105. {
  106. MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  107. DoQuery();
  108. foreach (UltraGridRow ugr in ultraGrid2.Rows)
  109. {
  110. if (ugr.Cells["PLINE_CODE"].Value.ToString().Equals(plinecode))
  111. {
  112. ugr.Activate();
  113. break;
  114. }
  115. }
  116. }
  117. }
  118. private void ultraGrid1_CellChange(object sender, CellEventArgs e)
  119. {
  120. if (e.Cell.Column.Key.Equals("CHK"))
  121. isselect += 1;
  122. ultraGrid1.UpdateData();
  123. }
  124. }
  125. }