CoreTest.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using CoreFS.CA06;
  10. namespace CoreDemo
  11. {
  12. public partial class CoreTest : FrmBase
  13. {
  14. public CoreTest()
  15. {
  16. InitializeComponent();
  17. }
  18. private void CoreTest_Load(object sender, EventArgs e)
  19. {
  20. this.ucEditTemplateButton1.ButtonClick += new Core.Dev.ComponentLibrary.Common.UcEditTemplateButton.Button_Click(ucEditTemplateButton1_ButtonClick);
  21. this.ucEditTemplateButton1.CurrentGrid = this.ugEmp;
  22. this.ucEditTemplateButton1.CurrTemplate = this.ultraGridRowEditTemplate1;
  23. }
  24. public override void ToolBar_Click(object sender, string ToolbarKey)
  25. {
  26. switch (ToolbarKey)
  27. {
  28. case "Query":
  29. this.DoQuery();
  30. break;
  31. case "Close":
  32. this.Close();
  33. break;
  34. }
  35. }
  36. private void ucEditTemplateButton1_ButtonClick(Core.Dev.ComponentLibrary.Common.EditTemplateButtonType type)
  37. {
  38. switch (type)
  39. {
  40. case Core.Dev.ComponentLibrary.Common.EditTemplateButtonType.Add:
  41. DoAdd();
  42. break;
  43. case Core.Dev.ComponentLibrary.Common.EditTemplateButtonType.Delete:
  44. DoDelete();
  45. break;
  46. case Core.Dev.ComponentLibrary.Common.EditTemplateButtonType.Edit:
  47. DoUpdate();
  48. break;
  49. }
  50. }
  51. //sqlid:C0601010301
  52. //调用ID C06010103
  53. private void DoQuery()
  54. {
  55. this.dataSet1.Tables[0].Clear();
  56. string sqlid = "C0601010301";
  57. CoreClientParam ccp = new CoreClientParam();
  58. ccp.InvokeID = "C06010103";
  59. ccp.ServerParams = new object[] { sqlid};
  60. ccp.SourceDataTable = this.dataSet1.Tables[0];
  61. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.External);
  62. }
  63. //C0601010101
  64. //调用ID --C06010101
  65. private void DoAdd()
  66. {
  67. string sqlid = "C0601010101";
  68. string id = this.ultraGridRowEditTemplate1.Row.Cells["EID"].Text;
  69. string name = this.ultraGridRowEditTemplate1.Row.Cells["ENAME"].Text;
  70. string job = this.ultraGridRowEditTemplate1.Row.Cells["EJOB"].Text;
  71. string dept = this.ultraGridRowEditTemplate1.Row.Cells["EDEPT"].Text;
  72. CoreClientParam ccp = new CoreClientParam();
  73. ccp.InvokeID = "C06010101";
  74. // ccp.ServerName = "CoreFs.Test.EmpManger";
  75. //ccp.MethodName = "AddEmp";
  76. ccp.ServerParams = new object[] { sqlid, id,name,job,dept };
  77. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.External);
  78. if (ccp.ReturnCode != 0) return;
  79. this.ultraGridRowEditTemplate1.Row.Update();
  80. MessageBox.Show("添加数据成功!");
  81. }
  82. // C0601010401
  83. //调用ID C06010104
  84. private void DoDelete()
  85. {
  86. if (MessageBox.Show("是否确认删除该数据!", "提示", MessageBoxButtons.YesNo) == DialogResult.No) return;
  87. string sqlid = "C0601010401";
  88. string id = this.ultraGridRowEditTemplate1.Row.Cells["EID"].Text;
  89. CoreClientParam ccp = new CoreClientParam();
  90. ccp.InvokeID = "C06010104";
  91. //ccp.ServerName = "CoreFs.Test.EmpManger";
  92. // ccp.MethodName = "DelEmp";
  93. ccp.ServerParams = new object[] { sqlid, id };
  94. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.External);
  95. if (ccp.ReturnCode != 0) return;
  96. this.ultraGridRowEditTemplate1.Row.Delete(false);
  97. MessageBox.Show("删除数据成功!");
  98. }
  99. //C0601010201
  100. //调用ID C06010102
  101. private void DoUpdate()
  102. {
  103. if (MessageBox.Show("是否确认修改该数据!", "提示", MessageBoxButtons.YesNo) == DialogResult.No) return;
  104. string sqlid = "C0601010201";
  105. string id = this.ultraGridRowEditTemplate1.Row.Cells["EID"].Text;
  106. string name = this.ultraGridRowEditTemplate1.Row.Cells["ENAME"].Text;
  107. string job = this.ultraGridRowEditTemplate1.Row.Cells["EJOB"].Text;
  108. string dept = this.ultraGridRowEditTemplate1.Row.Cells["EDEPT"].Text;
  109. CoreClientParam ccp = new CoreClientParam();
  110. ccp.InvokeID = "C06010102";
  111. // ccp.ServerName = "CoreFs.Test.EmpManger";
  112. //ccp.MethodName = "UpdateEmp";
  113. ccp.ServerParams = new object[] { sqlid, name,job,dept,id };
  114. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.External);
  115. if (ccp.ReturnCode != 0) return;
  116. this.ultraGridRowEditTemplate1.Row.Update();
  117. MessageBox.Show("修改数据成功!");
  118. }
  119. private void ugEmp_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
  120. {
  121. }
  122. }
  123. }