FrmJGAndMSC.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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.Data;
  7. using System.Drawing;
  8. using System.Windows.Forms;
  9. namespace Core.StlMes.Client.Qcm
  10. {
  11. public partial class FrmJGAndMSC : FrmBase
  12. {
  13. public FrmJGAndMSC()
  14. {
  15. InitializeComponent();
  16. this.IsLoadUserView = true;
  17. }
  18. private void FrmJGAndMSC_Load(object sender, EventArgs e)
  19. {
  20. InitMSC();
  21. GridHelper.RefreshAndAutoSize(ultraGrid1);
  22. }
  23. public override void ToolBar_Click(object sender, string ToolbarKey)
  24. {
  25. switch (ToolbarKey)
  26. {
  27. case "Query":
  28. this.InitMSC();
  29. break;
  30. case "Delete":
  31. this.doDelete(true);
  32. break;
  33. case "Resume":
  34. this.doDelete(false);
  35. break;
  36. case "Close":
  37. this.Close();
  38. break;
  39. }
  40. }
  41. private void InitMSC()
  42. {
  43. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.JGAndMSC.GetMSC", null, this.ob);
  44. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
  45. if (dt != null && dt.Rows.Count > 0)
  46. {
  47. ultraGrid1.Rows[0].Activate();
  48. }
  49. }
  50. public void doQuery()
  51. {
  52. UltraGridRow ugr = this.ultraGrid1.ActiveRow;
  53. string msc = ugr.Cells["MSC"].Value.ToString();
  54. bool flag = this.ultraCheckEditor1.Checked;
  55. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.JGAndMSC.doQuery", new Object[] { flag, msc }, this.ob);
  56. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable2, true);
  57. UltraGridColumn[] col = new UltraGridColumn[] { this.ultraGrid2.DisplayLayout.Bands[0].Columns["MEMO"] };
  58. GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid2, col);
  59. Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
  60. for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  61. {
  62. row = ultraGrid2.Rows[i];
  63. if (!row.Cells["VALIDFLAG"].Value.ToString().Equals("有效"))
  64. {
  65. row.Appearance.ForeColor = Color.Red;
  66. }
  67. else
  68. {
  69. row.Appearance.ForeColor = Color.Black;
  70. }
  71. }
  72. }
  73. /// <summary>
  74. /// 删除或恢复
  75. /// </summary>
  76. /// <param name="flag">TRUE删除 FALSE恢复</param>
  77. private void doDelete(bool flag)
  78. {
  79. UltraGridRow ugr = this.ultraGrid2.ActiveRow;
  80. if (ugr == null)
  81. {
  82. MessageBox.Show("请选择需要操作的记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  83. return;
  84. }
  85. if (ugr.Cells["VALIDFLAG"].Value.ToString() == "无效" && flag == true)
  86. {
  87. MessageBox.Show("您选择的数据已经无效,无法作废", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  88. return;
  89. }
  90. if (ugr.Cells["VALIDFLAG"].Value.ToString() == "有效" && flag == false)
  91. {
  92. MessageBox.Show("您选择的数据有效,无法恢复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  93. return;
  94. }
  95. if (MessageBox.Show("是否确认" + (flag ? "作废" : "恢复") + "选中的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  96. {
  97. return;
  98. }
  99. string msc = ugr.Cells["MSC"].Value.ToString();
  100. string code = ugr.Cells["CODE_JG"].Value.ToString();
  101. string deletename = this.UserInfo.GetUserName();
  102. int count = ServerHelper.SetData("com.steering.pss.qcm.JGAndMSC.doDeleteOrResume", new Object[] { flag, msc, code, deletename }, this.ob);
  103. if (count > 0)
  104. {
  105. doQuery();
  106. if (flag == false)
  107. {
  108. Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
  109. for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  110. {
  111. row = ultraGrid2.Rows[i];
  112. if (row.Cells["MSC"].Value.ToString().Equals(msc) && row.Cells["CODE_JG"].Value.ToString().Equals(code))
  113. {
  114. row.Activate();
  115. break;
  116. }
  117. }
  118. }
  119. }
  120. }
  121. private void ultraButton1_Click(object sender, EventArgs e) //JG选择
  122. {
  123. UltraGridRow ugr1 = this.ultraGrid1.ActiveRow;
  124. string msc = ugr1.Cells["MSC"].Value.ToString();
  125. string msc_desc = ugr1.Cells["MSC_DESC"].Value.ToString();
  126. JGCodeManage jgcm = new JGCodeManage(ob, msc, msc_desc, "", "", "", "", "", "", "", "", "", "", "");
  127. jgcm.ShowDialog();
  128. this.ultraGrid1.ActiveRow = ugr1;
  129. doQuery();
  130. }
  131. private void ultraButton2_Click(object sender, EventArgs e) //BL选择
  132. {
  133. UltraGridRow ugr1 = this.ultraGrid1.ActiveRow;
  134. string msc = ugr1.Cells["MSC"].Value.ToString();
  135. string msc_desc = ugr1.Cells["MSC_DESC"].Value.ToString();
  136. BLCodeManageParms blCodeParms = new BLCodeManageParms();
  137. blCodeParms.Ob = ob;
  138. blCodeParms.Msc = msc;
  139. blCodeParms.Msc_desc = msc_desc;
  140. BLCodeManage blcm = new BLCodeManage(blCodeParms);
  141. blcm.ShowDialog();
  142. this.ultraGrid1.ActiveRow = ugr1;
  143. doQuery();
  144. }
  145. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  146. {
  147. doQuery();
  148. }
  149. }
  150. }