FrmStandards.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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;using Pur.Entity;
  10. using Pur.Entity.configureEntity;
  11. using Core.Mes.Client.Comm.Control;
  12. using com.hnshituo.pur.vo;
  13. using Core.Mes.Client.Comm.Tool;
  14. using Pur.Entity;
  15. namespace Pur.configure
  16. {
  17. public partial class FrmStandards : FrmPmsBase
  18. {
  19. public FrmStandards()
  20. {
  21. InitializeComponent();
  22. }
  23. public override void ToolBar_Click(object sender, string ToolbarKey)
  24. {
  25. switch (ToolbarKey)
  26. {
  27. case "doQuery":
  28. try
  29. {
  30. this.Cursor = Cursors.WaitCursor;
  31. get_PurStandards();
  32. }
  33. finally
  34. {
  35. this.Cursor = Cursors.Default;
  36. }
  37. break;
  38. case "doAdd":
  39. add_PurStandards();
  40. break;
  41. case "doModify":
  42. upd_PurStandards();
  43. break;
  44. case "doDelete":
  45. del_PurStandards();
  46. break;
  47. case "Close":
  48. this.Close();
  49. break;
  50. }
  51. }
  52. /// <summary>
  53. /// 查询标准编号
  54. /// </summary>
  55. /// <param name="configureMEntity"></param>
  56. public void get_PurStandards()
  57. {
  58. PurStandardsEntity StandardsEntity = new PurStandardsEntity();
  59. StandardsEntity.StandardsId = txt_STANDARDS_ID_QUERY.Text.Trim();
  60. StandardsEntity.StandardsCode = txt_STANDARDS_CODE_query.Text.Trim();
  61. StandardsEntity.Validflag = "1";
  62. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.StandardsService", "get_PurStandards", new object[] { StandardsEntity });
  63. GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);//绑定物料分类表
  64. }
  65. /// <summary>
  66. /// 增加标准编号
  67. /// </summary>
  68. /// <param name="configureMEntity"></param>
  69. public void add_PurStandards()
  70. {
  71. if (MessageUtil.ShowYesNoAndQuestion("是否确定添加?") == DialogResult.No && ValidInput())
  72. {
  73. return;
  74. }
  75. PurStandardsEntity StandardsEntity = new PurStandardsEntity();
  76. StandardsEntity.StandardsId = (this.execute<int>("com.hnshituo.pur.configure.service.StandardsService", "get_Id", new object[] { StandardsEntity })+1).ToString();
  77. StandardsEntity.StandardsCode = txt_STANDARDS_CODE.Text.Trim();
  78. StandardsEntity.StandardsDesc = txt_STANDARDS_DESC.Text.Trim();
  79. StandardsEntity.CreateName = UserInfo.GetUserName();
  80. StandardsEntity.CreateUserid = UserInfo.GetUserID();
  81. StandardsEntity.Validflag = "1";
  82. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.StandardsService", "doInsert", new object[] { StandardsEntity});
  83. if (crt.Resultcode != 0)
  84. {
  85. MessageUtil.ShowTips("添加失败 " + crt.Resultmsg);
  86. return;
  87. }
  88. MessageUtil.ShowTips("添加成功!");
  89. get_PurStandards();//查询标准编号
  90. ConfigureClassCommon.doActiveSelRow(ultraGrid1, "STANDARDSID", StandardsEntity.StandardsId);//激活当前行
  91. }
  92. /// <summary>
  93. /// 修改标准编号
  94. /// </summary>
  95. /// <param name="configureMEntity"></param>
  96. public void upd_PurStandards()
  97. {
  98. if (MessageUtil.ShowYesNoAndQuestion("是否确定修改?") == DialogResult.No && ValidInput())
  99. {
  100. return;
  101. }
  102. if (ultraGrid1.ActiveRow != null)
  103. {
  104. PurStandardsEntity StandardsEntity = new PurStandardsEntity();
  105. StandardsEntity.StandardsId = ultraGrid1.ActiveRow.Cells["STANDARDSID"].Value.ToString();
  106. StandardsEntity.StandardsCode = txt_STANDARDS_CODE.Text.Trim();
  107. StandardsEntity.StandardsDesc = txt_STANDARDS_DESC.Text.Trim();
  108. StandardsEntity.UpdateName = UserInfo.GetUserName();
  109. StandardsEntity.UpdateUserid = UserInfo.GetUserID();
  110. StandardsEntity.Validflag = "1";
  111. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.StandardsService", "doUpdate", new object[] { StandardsEntity, 0, 0 });
  112. if (crt.Resultcode != 0)
  113. {
  114. MessageUtil.ShowTips("修改失败 " + crt.Resultmsg);
  115. return;
  116. }
  117. MessageUtil.ShowTips("修改成功!");
  118. get_PurStandards();//查询标准编号
  119. ConfigureClassCommon.doActiveSelRow(ultraGrid1, "STANDARDSID", StandardsEntity.StandardsId);//激活当前行
  120. }
  121. else
  122. {
  123. MessageUtil.ShowTips("请选择一条标准编号");
  124. return;
  125. }
  126. }
  127. /// <summary>
  128. /// 删除标准编号
  129. /// </summary>
  130. /// <param name="configureMEntity"></param>
  131. public void del_PurStandards()
  132. {
  133. if (MessageUtil.ShowYesNoAndQuestion("是否确定删除?") == DialogResult.No)
  134. {
  135. return;
  136. }
  137. if (ultraGrid1.ActiveRow != null)
  138. {
  139. PurStandardsEntity StandardsEntity = new PurStandardsEntity();
  140. StandardsEntity.StandardsId = ultraGrid1.ActiveRow.Cells["STANDARDSID"].Value.ToString();
  141. StandardsEntity.StandardsCode = txt_STANDARDS_CODE.Text.Trim();
  142. StandardsEntity.StandardsDesc = txt_STANDARDS_DESC.Text.Trim();
  143. StandardsEntity.DeleteTime = System.DateTime.Now;
  144. StandardsEntity.DeleteName = UserInfo.GetUserName();
  145. StandardsEntity.DeleteUserid = UserInfo.GetUserID();
  146. StandardsEntity.Validflag = "0";
  147. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.StandardsService", "doUpdate", new object[] { StandardsEntity, 0, 0 });
  148. if (crt.Resultcode != 0)
  149. {
  150. MessageUtil.ShowTips("删除失败 " + crt.Resultmsg);
  151. return;
  152. }
  153. MessageUtil.ShowTips("删除成功!");
  154. get_PurStandards();//查询标准编号
  155. }
  156. else
  157. {
  158. MessageUtil.ShowTips("请选择一条标准编号");
  159. return;
  160. }
  161. }
  162. /// <summary>
  163. /// 验证必填项
  164. /// </summary>
  165. /// <returns></returns>
  166. private bool ValidInput()
  167. {
  168. if (string.IsNullOrEmpty(txt_STANDARDS_ID.Text.Trim()))
  169. {
  170. MessageBox.Show("请输入标准编号ID!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  171. return false;
  172. }
  173. if (string.IsNullOrEmpty(txt_STANDARDS_CODE.Text.Trim()))
  174. {
  175. MessageBox.Show("请输入标准编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  176. return false;
  177. }
  178. return true;
  179. }
  180. /// <summary>
  181. /// 激活grid列表
  182. /// </summary>
  183. /// <param name="sender"></param>
  184. /// <param name="e"></param>
  185. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  186. {
  187. txt_STANDARDS_CODE.Text = ultraGrid1.ActiveRow.Cells["STANDARDSCODE"].Value.ToString();
  188. txt_STANDARDS_DESC.Text = ultraGrid1.ActiveRow.Cells["STANDARDSDESC"].Value.ToString();
  189. txt_STANDARDS_ID.Text = ultraGrid1.ActiveRow.Cells["STANDARDSID"].Value.ToString();
  190. }
  191. }
  192. }