F_PAM_0201.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PAM_0201.cs
  5. * 2.功能描述:工价分类
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2015/08/18 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Windows.Forms;
  13. using Dongke.IBOSS.PRD.Client.CommonModule;
  14. using Dongke.IBOSS.PRD.Basics.BaseResources;
  15. using Dongke.IBOSS.PRD.Basics.DockPanel;
  16. using Dongke.IBOSS.PRD.WCF.DataModels;
  17. using Dongke.IBOSS.PRD.WCF.Proxys;
  18. using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
  19. namespace Dongke.IBOSS.PRD.Client.PAMModule
  20. {
  21. /// <summary>
  22. /// 工价分类
  23. /// </summary>
  24. public partial class F_PAM_0201 : DockPanelBase
  25. {
  26. #region 成员变量
  27. //单例模式
  28. private static F_PAM_0201 _instance;
  29. // 最后选择行
  30. private int _selecedRow;
  31. #endregion
  32. #region 构造函数
  33. public F_PAM_0201()
  34. {
  35. InitializeComponent();
  36. this.Text = FormTitles.F_PAM_0201;
  37. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  38. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  39. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  40. // this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  41. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  42. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  43. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  44. }
  45. #endregion
  46. #region 单例模式
  47. /// <summary>
  48. /// 单例模式,防止重复创建窗体
  49. /// </summary>
  50. public static F_PAM_0201 Instance
  51. {
  52. get
  53. {
  54. if (_instance == null)
  55. {
  56. _instance = new F_PAM_0201();
  57. }
  58. return _instance;
  59. }
  60. }
  61. #endregion
  62. #region 事件
  63. /// <summary>
  64. /// 窗体加载
  65. /// </summary>
  66. private void F_PAM_0201_Load(object sender, EventArgs e)
  67. {
  68. this.dgvJobsPayPlan.AutoGenerateColumns = false;
  69. }
  70. /// <summary>
  71. /// 查询事件
  72. /// </summary>
  73. private void btnSearch_Click(object sender, EventArgs e)
  74. {
  75. try
  76. {
  77. // 记录当前选中行
  78. int selectRowIndex = this._selecedRow;
  79. // 异步处理
  80. this.btnSearch.Enabled = false;
  81. this.btnClearCondition.Enabled = false;
  82. DataSet dsProductionData = (DataSet)DoAsync(new AsyncMethod(() =>
  83. {
  84. return PAMModuleProxy.Service.GetGoodsWagesType(this.txtWagesTypeName.Text.Trim(),this.txtGoodsCode.Text.Trim());
  85. }));
  86. this.btnSearch.Enabled = true;
  87. this.btnClearCondition.Enabled = true;
  88. if (dsProductionData != null)
  89. {
  90. base.DataSource = dsProductionData;
  91. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  92. {
  93. this.dgvJobsPayPlan.DataSource = this.DataSource.Tables[0];
  94. if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  95. {
  96. // 提示未查找到数据
  97. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  98. MessageBoxButtons.OK, MessageBoxIcon.Information);
  99. }
  100. else
  101. {
  102. if (selectRowIndex >= Constant.INT_IS_ZERO)
  103. {
  104. if (selectRowIndex >= dsProductionData.Tables[0].Rows.Count)
  105. {
  106. this.dgvJobsPayPlan.Rows[this.dgvJobsPayPlan.Rows.Count - 1].Selected = true;
  107. this.dgvJobsPayPlan.CurrentCell = this.dgvJobsPayPlan.Rows[this.dgvJobsPayPlan.Rows.Count - 1].Cells["WagesTypeName"];
  108. }
  109. else
  110. {
  111. this.dgvJobsPayPlan.Rows[selectRowIndex].Selected = true;
  112. this.dgvJobsPayPlan.CurrentCell = this.dgvJobsPayPlan.Rows[selectRowIndex].Cells["WagesTypeName"];
  113. }
  114. }
  115. }
  116. }
  117. }
  118. }
  119. catch (Exception ex)
  120. {
  121. this.btnSearch.Enabled = true;
  122. this.btnClearCondition.Enabled = true;
  123. // 对异常进行共通处理
  124. ExceptionManager.HandleEventException(this.ToString(),
  125. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  126. }
  127. }
  128. /// <summary>
  129. /// 清空事件
  130. /// </summary>
  131. private void btnClearCondition_Click(object sender, EventArgs e)
  132. {
  133. this.txtWagesTypeName.Text = string.Empty;
  134. this.txtGoodsCode.Text = string.Empty;
  135. }
  136. /// <summary>
  137. /// 关闭窗体事件
  138. /// </summary>
  139. private void tsbtnClose_Click(object sender, EventArgs e)
  140. {
  141. this.Close();
  142. }
  143. /// <summary>
  144. /// 自适应事件
  145. /// </summary>
  146. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  147. {
  148. this.dgvJobsPayPlan.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); ;
  149. }
  150. /// <summary>
  151. /// 窗体关闭事件
  152. /// </summary>
  153. private void F_PAM_0201_FormClosed(object sender, FormClosedEventArgs e)
  154. {
  155. _instance = null;
  156. }
  157. /// <summary>
  158. /// 添加事件
  159. /// </summary>
  160. private void tsbtnAdd_Click(object sender, EventArgs e)
  161. {
  162. try
  163. {
  164. //以新建模式打开信息窗体
  165. F_PAM_0203 frmPAM0203 = new F_PAM_0203(Constant.FormMode.Add, Constant.INT_IS_ZERO);
  166. DialogResult dialogResult = frmPAM0203.ShowDialog();
  167. if (dialogResult == DialogResult.OK)
  168. {
  169. btnSearch_Click(sender, e);
  170. }
  171. }
  172. catch (Exception ex)
  173. {
  174. // 对异常进行共通处理
  175. ExceptionManager.HandleEventException(this.ToString(),
  176. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  177. }
  178. }
  179. /// <summary>
  180. ///编辑事件
  181. /// </summary>
  182. private void tsbtnEdit_Click(object sender, EventArgs e)
  183. {
  184. try
  185. {
  186. DataGridViewRow currentRow = this.dgvJobsPayPlan.CurrentRow;
  187. if (currentRow != null)
  188. {
  189. //获取需要的信息ID
  190. int entityId = Convert.ToInt32(currentRow.Cells["PayPlanID"].Value);
  191. //以复制模式打开信息窗体
  192. F_PAM_0103 frmPAM0103 = new F_PAM_0103(Constant.FormMode.Edit, entityId);
  193. DialogResult dialogResult = frmPAM0103.ShowDialog();
  194. //操作成功后刷新数据源
  195. if (dialogResult == DialogResult.OK)
  196. {
  197. btnSearch_Click(sender, e);
  198. }
  199. }
  200. }
  201. catch (Exception ex)
  202. {
  203. // 对异常进行共通处理
  204. ExceptionManager.HandleEventException(this.ToString(),
  205. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  206. }
  207. }
  208. #endregion
  209. }
  210. }