F_PAM_0101.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PAM_0101.cs
  5. * 2.功能描述:工资方案参数设定
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2015/08/17 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Reflection;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseControls;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Basics.DockPanel;
  17. using Dongke.IBOSS.PRD.Client.CommonModule;
  18. using Dongke.IBOSS.PRD.Client.Controls;
  19. using Dongke.IBOSS.PRD.Client.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.DataModels;
  21. using Dongke.IBOSS.PRD.WCF.Proxys;
  22. namespace Dongke.IBOSS.PRD.Client.PAMModule
  23. {
  24. /// <summary>
  25. /// 工资方案参数设定
  26. /// </summary>
  27. public partial class F_PAM_0101 : DKDockPanelBase
  28. {
  29. #region 成员变量
  30. // 单例模式
  31. private static F_PAM_0101 _instance;
  32. // 数据源
  33. private DataTable _dtSourse;
  34. // 选定行
  35. private int _selectedRow = 0;
  36. #endregion
  37. #region 单例模式
  38. /// <summary>
  39. /// 单例模式,防止重复创建窗体
  40. /// </summary>
  41. public static F_PAM_0101 Instance
  42. {
  43. get
  44. {
  45. if (_instance == null)
  46. {
  47. _instance = new F_PAM_0101();
  48. }
  49. return _instance;
  50. }
  51. }
  52. #endregion
  53. #region 构造函数
  54. public F_PAM_0101()
  55. {
  56. InitializeComponent();
  57. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  58. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  59. this.tsbtnSave.Text = ButtonText.BTN_SAVE;
  60. this.Text = FormTitles.F_PAM_0101;
  61. }
  62. #endregion
  63. #region 事件
  64. /// <summary>
  65. /// 关闭按钮事件
  66. /// </summary>
  67. /// <param name="sender"></param>
  68. /// <param name="e"></param>
  69. private void tsbtnClose_Click(object sender, EventArgs e)
  70. {
  71. this.Close();
  72. }
  73. /// <summary>
  74. /// 自动适应列宽
  75. /// </summary>
  76. /// <param name="sender"></param>
  77. /// <param name="e"></param>
  78. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  79. {
  80. this.dgvPayPlanSetting.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  81. }
  82. /// <summary>
  83. /// 窗体加载事件
  84. /// </summary>
  85. /// <param name="sender"></param>
  86. /// <param name="e"></param>
  87. private void F_PAM_0101_Load(object sender, EventArgs e)
  88. {
  89. try
  90. {
  91. // 设置datagridview不自动创建列
  92. this.dgvPayPlanSetting.AutoGenerateColumns = false;
  93. //this.dgvPayPlanSetting.IsSetInputColumnsColor = true;
  94. this.dgvPayPlanSetting.AllowUserToDeleteRows = false;
  95. // 加载数据源
  96. this.GetPayPlanSetting();
  97. //权限控制
  98. FormPermissionManager.FormPermissionControl(this.Name, this,
  99. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  100. this.dgvPayPlanSetting.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect;
  101. tsbtnSave.Size = new System.Drawing.Size(60,25);
  102. }
  103. catch (Exception ex)
  104. {
  105. // 对异常进行共通处理
  106. ExceptionManager.HandleEventException(this.ToString(),
  107. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  108. }
  109. }
  110. /// <summary>
  111. /// 窗体关闭事件
  112. /// </summary>
  113. /// <param name="sender"></param>
  114. /// <param name="e"></param>
  115. private void F_PAM_0101_FormClosed(object sender, FormClosedEventArgs e)
  116. {
  117. _instance = null;
  118. }
  119. /// <summary>
  120. /// 保存按钮事件
  121. /// </summary>
  122. /// <param name="sender"></param>
  123. /// <param name="e"></param>
  124. private void tsbtnSave_Click(object sender, EventArgs e)
  125. {
  126. try
  127. {
  128. //this.dgvPayPlanSetting.CommitEdit(DataGridViewDataErrorContexts.Commit);
  129. this.dgvPayPlanSetting.EndEdit();
  130. DataTable dt = this.dgvPayPlanSetting.DataSource as DataTable;
  131. if (dt == null)
  132. {
  133. return;
  134. }
  135. int returnValue = (int)DoAsync(new AsyncMethod(() =>
  136. {
  137. return PAMModuleProxy.Service.SavePayPlanSetting(dt);
  138. }));
  139. if (returnValue > 0)
  140. {
  141. // 提示信息
  142. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, this.Text, "保存"),
  143. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  144. GetPayPlanSetting();
  145. }
  146. //else if (returnValue == 0)
  147. //{
  148. // // 提示信息
  149. // MessageBox.Show("保存失败",
  150. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  151. //}
  152. }
  153. catch (Exception ex)
  154. {
  155. // 对异常进行共通处理
  156. ExceptionManager.HandleEventException(this.ToString(),
  157. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  158. }
  159. }
  160. #endregion
  161. #region 私有方法
  162. /// <summary>
  163. /// 获取数据
  164. /// </summary>
  165. /// <returns></returns>
  166. /// <remarks>
  167. ///
  168. /// </remarks>
  169. private void GetPayPlanSetting()
  170. {
  171. try
  172. {
  173. DataSet dsResultAccount = (DataSet)DoAsync(new AsyncMethod(() =>
  174. {
  175. return PAMModuleProxy.Service.GetPayPlanSetting();
  176. }));
  177. this._dtSourse = dsResultAccount.Tables[0];
  178. this.dgvPayPlanSetting.DataSource = this._dtSourse;
  179. }
  180. catch (Exception ex)
  181. {
  182. throw ex;
  183. }
  184. }
  185. #endregion
  186. private void dgvPayPlanSetting_CurrentCellDirtyStateChanged(object sender, EventArgs e)
  187. {
  188. //try
  189. //{
  190. // if (this.dgvPayPlanSetting.CurrentRow != null && this.dgvPayPlanSetting.IsCurrentCellDirty)
  191. // {
  192. // if ("SettingValue".Equals(this.dgvPayPlanSetting.Columns
  193. // [this.dgvPayPlanSetting.CurrentCell.ColumnIndex].Name))
  194. // {
  195. // this.dgvPayPlanSetting.CommitEdit(DataGridViewDataErrorContexts.Commit);
  196. // }
  197. // }
  198. //}
  199. //catch (Exception ex)
  200. //{
  201. // // 对异常进行共通处理
  202. // ExceptionManager.HandleEventException(this.ToString(),
  203. // System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  204. //}
  205. }
  206. private void F_PAM_0101_Shown(object sender, EventArgs e)
  207. {
  208. this.dgvPayPlanSetting.IsSetInputColumnsColor = true;
  209. }
  210. }
  211. }