FrmJGRBLCode.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 FrmJGRBLCode : FrmBase
  12. {
  13. public FrmJGRBLCode()
  14. {
  15. InitializeComponent();
  16. this.IsLoadUserView = true;
  17. }
  18. private void FrmJGRBLCode_Load(object sender, EventArgs e)
  19. {
  20. InitJGCode();
  21. }
  22. private void InitJGCode()
  23. {
  24. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.JGRBLCode.GetGrid1", null, this.ob);
  25. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
  26. UltraGridColumn[] col = new UltraGridColumn[] { this.ultraGrid1.DisplayLayout.Bands[0].Columns["MEMO"] };
  27. GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid1, col);
  28. if (dt != null && dt.Rows.Count > 0)
  29. {
  30. ultraGrid1.Rows[0].Activate();
  31. }
  32. }
  33. private void doQuery()
  34. {
  35. UltraGridRow ugr1 = this.ultraGrid1.ActiveRow;
  36. string jgcode = ugr1.Cells["CODE_JG"].Value.ToString();
  37. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.JGRBLCode.doQuery", new Object[] { jgcode }, this.ob);
  38. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable2, true);
  39. UltraGridColumn[] col = new UltraGridColumn[] { this.ultraGrid2.DisplayLayout.Bands[0].Columns["MEMO"] };
  40. GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid2, col);
  41. }
  42. public override void ToolBar_Click(object sender, string ToolbarKey)
  43. {
  44. switch (ToolbarKey)
  45. {
  46. case "Query":
  47. this.InitJGCode();
  48. break;
  49. case "Save":
  50. this.doSave();
  51. break;
  52. case "Close":
  53. this.Close();
  54. break;
  55. }
  56. }
  57. private void doSave()
  58. {
  59. if (MessageBox.Show("是否确认保存修改?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  60. {
  61. return;
  62. }
  63. ultraGrid2.UpdateData();
  64. string jgcode = "";
  65. UltraGridRow ugr1 = this.ultraGrid1.ActiveRow;
  66. jgcode = ugr1.Cells["CODE_JG"].Value.ToString();
  67. ArrayList list = new ArrayList();
  68. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in ultraGrid2.Rows)
  69. {
  70. ArrayList parm = new ArrayList();
  71. if (Convert.ToBoolean(row.Cells["CHK"].Value))
  72. {
  73. parm.Add(ugr1.Cells["CODE_JG"].Value.ToString());
  74. parm.Add(row.Cells["PSC_BL"].Value.ToString());
  75. parm.Add(this.UserInfo.GetUserName());
  76. parm.Add(row.Cells["MEMO"].Value.ToString());
  77. list.Add(parm);
  78. }
  79. }
  80. CoreClientParam ccp = new CoreClientParam(); //CoreClientParam是平台用来向服务端传递存放所有相关参数信息的。
  81. ccp.ServerName = "com.steering.pss.qcm.JGRBLCode"; //服务名指的是服务端的包名+类名
  82. ccp.MethodName = "doAdd"; //方法名指的是服务名指定类里的方法
  83. ccp.ServerParams = new object[] { list, jgcode };//服务端方法的参数\
  84. //ExecuteNonQuery主要用来执行添加、修改、删除、存储过程的操作。
  85. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  86. if (ccp.ReturnCode == -1)
  87. return;
  88. MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  89. InitJGCode();
  90. UltraGridRow rw = null;
  91. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  92. {
  93. rw = ultraGrid1.Rows[i];
  94. if (rw.Cells["CODE_JG"].Value.ToString().Trim() == jgcode)
  95. {
  96. rw.Activate();
  97. }
  98. }
  99. }
  100. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  101. {
  102. doQuery();
  103. }
  104. }
  105. }