F_PAM_0502.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PAM_0502.cs
  5. * 2.功能描述:行政奖惩新建/编辑
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 张国印 2014/09/25 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Windows.Forms;
  13. using Dongke.IBOSS.PRD.Basics.BaseControls;
  14. using Dongke.IBOSS.PRD.Basics.BaseResources;
  15. using Dongke.IBOSS.PRD.Client.CommonModule;
  16. using Dongke.IBOSS.PRD.Client.Controls;
  17. using Dongke.IBOSS.PRD.Client.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.Proxys;
  20. namespace Dongke.IBOSS.PRD.Client.HRModule
  21. {
  22. /// <summary>
  23. /// 行政奖惩新建/编辑
  24. /// </summary>
  25. public partial class F_PAM_0502 : DKFormBase
  26. {
  27. #region 成员变量
  28. // 窗体状态的枚举 新建/编辑
  29. private Constant.FormMode _editStatus;
  30. //行政奖惩编号
  31. private int _adminEXAID;
  32. // 编辑数据
  33. private DataTable _data;
  34. #endregion
  35. #region 构造函数
  36. /// <summary>
  37. /// 构造函数
  38. /// </summary>
  39. /// <param name="editStatus"></param>
  40. /// <param name="pRapID"></param>
  41. public F_PAM_0502()
  42. : this(Constant.FormMode.Add, 0)
  43. {
  44. }
  45. /// <summary>
  46. /// 构造函数
  47. /// </summary>
  48. /// <param name="editStatus"></param>
  49. /// <param name="pRapID"></param>
  50. public F_PAM_0502(Constant.FormMode editStatus, int adminEXAID)
  51. {
  52. InitializeComponent();
  53. this._editStatus = editStatus;
  54. this._adminEXAID = adminEXAID;
  55. this.dkUserName.WhereCondition = "(StaffStatus = 1 Or StaffStatus = 2) AND ValueFlag = 1";
  56. //this.txtRAPAmount.Text = "0";
  57. this.SetFromTitleInfo();
  58. }
  59. #endregion
  60. #region 属性
  61. #endregion
  62. #region 事件
  63. /// <summary>
  64. /// 页面加载事件
  65. /// </summary>
  66. /// <param name="sender"></param>
  67. /// <param name="e"></param>
  68. private void F_HR_1102_Load(object sender, EventArgs e)
  69. {
  70. try
  71. {
  72. #region 绑定数据源
  73. this.comAdministrationType.DataSource = DataDictionaryInfo();
  74. this.comAdministrationType.DisplayMember = "DictionaryValue";
  75. this.comAdministrationType.ValueMember = "DictionaryID";
  76. #endregion
  77. FormPermissionManager.FormPermissionControl(this.Name, this,
  78. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  79. if (this._editStatus == Constant.FormMode.Edit)
  80. {
  81. // 获取用户信息数据集
  82. ServiceResultEntity srData = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(this.GetDataInfo));
  83. if (srData.Status == Constant.ServiceResultStatus.Success)
  84. {
  85. _data = srData.Data.Tables[0];
  86. DataRow info = _data.Rows[0];
  87. this.dkUserName.UserID = Convert.ToInt32(info["StaffID"]);
  88. this.dkUserName.UserCode = info["StaffCode"].ToString().Trim();
  89. this.dkUserName.UserName = info["StaffName"].ToString().Trim();
  90. this.dtpRAPDate.Value = Convert.ToDateTime(info["CreateTime"]);
  91. this.txtRAPAmount.DataValue = Convert.ToDecimal(info["Amount"]);
  92. this.comAdministrationType.SelectedValue = Convert.ToInt32(info["AdminEXATypeID"]);
  93. this.txtRemarks.Text = info["Remarks"].ToString();
  94. }
  95. }
  96. }
  97. catch (Exception ex)
  98. {
  99. // 对异常进行共通处理
  100. ExceptionManager.HandleEventException(this.ToString(),
  101. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  102. }
  103. }
  104. /// <summary>
  105. /// 保存按钮
  106. /// </summary>
  107. /// <param name="sender"></param>
  108. /// <param name="e"></param>
  109. private void btnSave_Click(object sender, EventArgs e)
  110. {
  111. try
  112. {
  113. if (!IsInputValid())
  114. {
  115. return ;
  116. }
  117. if (_editStatus == Constant.FormMode.Add)
  118. {
  119. AdminEXAEntity se = SetStaffRecordEntity();
  120. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  121. {
  122. return PAMModuleProxy.Service.AddAdminEXA(se);
  123. }
  124. );
  125. if (sre.Status == Constant.ServiceResultStatus.Success)
  126. {
  127. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  128. }
  129. }
  130. else
  131. {
  132. DataRow info = _data.Rows[0];
  133. info["StaffID"] = this.dkUserName.UserID;
  134. info["Amount"] = this.txtRAPAmount.DataValue;
  135. info["AdminEXATypeID"] = this.comAdministrationType.SelectedValue;
  136. info["Remarks"] = this.txtRemarks.Text;
  137. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  138. {
  139. return PAMModuleProxy.Service.EditAdminEXA(_data);
  140. }
  141. );
  142. if (sre.Status == Constant.ServiceResultStatus.Success)
  143. {
  144. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  145. }
  146. else
  147. {
  148. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, "数据已被修改");
  149. }
  150. }
  151. this.Close();
  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. private void SetFromTitleInfo()
  166. {
  167. if (this._editStatus == Constant.FormMode.Add)
  168. {
  169. this.Text = FormTitles.F_PAM_0502_ADD;
  170. this.dkUserName.Enabled = true;
  171. }
  172. else if (this._editStatus == Constant.FormMode.Edit)
  173. {
  174. this.Text = FormTitles.F_PAM_0502_EDIT;
  175. this.dkUserName.Enabled = false;
  176. }
  177. this.dtpRAPDate.Value = DateTime.Now;
  178. this.btnSave.Text = ButtonText.BTN_SAVE;
  179. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  180. }
  181. /// <summary>
  182. /// 获取行政考核类别数据源
  183. /// </summary>
  184. /// <returns></returns>
  185. public DataTable DataDictionaryInfo()
  186. {
  187. DataTable dtDicInfo = (DataTable)DoAsync(new BaseAsyncMethod(() =>
  188. {
  189. return CommonModuleProxy.Service.GetDataDictionaryByType(Constant.ASE_ASE001);
  190. }));
  191. return dtDicInfo;
  192. }
  193. /// <summary>
  194. /// 根据查询条件获取要显示的数据
  195. /// </summary>
  196. /// <returns>返回查询的结果集</returns>
  197. private ServiceResultEntity GetDataInfo()
  198. {
  199. return PAMModuleProxy.Service.GetAdminEXAByID(_adminEXAID);
  200. }
  201. /// <summary>
  202. /// 设置非待审核的履历控件禁用
  203. /// </summary>
  204. private void SetControlEnable()
  205. {
  206. this.dkUserName.Enabled = false;
  207. this.dtpRAPDate.Enabled = false;
  208. this.txtRAPAmount.Enabled = false;
  209. this.comAdministrationType.Enabled = false;
  210. this.txtRemarks.Enabled = false;
  211. this.btnSave.Enabled = false;
  212. }
  213. /// <summary>
  214. /// 检查页面的输入项目
  215. /// </summary>
  216. /// <remarks>
  217. /// </remarks>
  218. /// <returns></returns>
  219. private bool IsInputValid()
  220. {
  221. if (this.dkUserName.UserID == null)
  222. {
  223. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "员工姓名"),
  224. this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1);
  225. this.dkUserName.Focus();
  226. return false;
  227. }
  228. else if (string.IsNullOrEmpty(this.txtRAPAmount.Text))
  229. {
  230. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "考核金额"),
  231. this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1);
  232. this.txtRAPAmount.Focus();
  233. return false;
  234. }
  235. else if (this.comAdministrationType.SelectedValue == null)
  236. {
  237. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "考核类别"),
  238. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  239. this.comAdministrationType.Focus();
  240. return false;
  241. }
  242. else
  243. {
  244. return true;
  245. }
  246. }
  247. /// <summary>
  248. /// 根据页面输入值,对实体赋值
  249. /// </summary>
  250. /// <returns></returns>
  251. private AdminEXAEntity SetStaffRecordEntity()
  252. {
  253. AdminEXAEntity staffRecordEntity = new AdminEXAEntity();
  254. staffRecordEntity.StaffID = this.dkUserName.UserID.Value;
  255. staffRecordEntity.Amount = this.txtRAPAmount.DataValue.Value;
  256. if (this.comAdministrationType.SelectedValue != null)
  257. {
  258. staffRecordEntity.AdminEXATypeID = Convert.ToInt32(this.comAdministrationType.SelectedValue);
  259. }
  260. staffRecordEntity.Remarks = this.txtRemarks.Text;
  261. return staffRecordEntity;
  262. }
  263. /// <summary>
  264. /// 清空输入项
  265. /// </summary>
  266. private void InitializationForm()
  267. {
  268. this.dkUserName.UserID = null;
  269. this.dkUserName.UserCode = string.Empty;
  270. this.dkUserName.UserName = string.Empty;
  271. this.dkUserName.StaffEntity = null;
  272. this.dtpRAPDate.Value = DateTime.Now;
  273. this.txtRAPAmount.Text = "0";
  274. if (this.comAdministrationType.SelectedValue != null)
  275. {
  276. this.comAdministrationType.SelectedIndex = 0;
  277. }
  278. this.txtRemarks.Text = string.Empty;
  279. }
  280. #endregion
  281. }
  282. }