F_HR_1102.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_HR_1102.cs
  5. * 2.功能描述:行政奖惩新建/编辑
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 张国印 2014/09/25 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseControls;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.Client.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.Proxys;
  20. using Dongke.IBOSS.PRD.WCF.Proxys.HRModuleService;
  21. namespace Dongke.IBOSS.PRD.Client.HRModule
  22. {
  23. /// <summary>
  24. /// 行政奖惩新建/编辑
  25. /// </summary>
  26. public partial class F_HR_1102 : FormBase
  27. {
  28. #region 成员变量
  29. // 窗体状态的枚举 新建/编辑
  30. private Constant.FormMode _editStatus;
  31. //行政奖惩编号
  32. private int _staffRAPID;
  33. // 新建的ID集合
  34. private List<int> _staffIDList = new List<int>();
  35. //时间戳
  36. private DateTime? _oPTimeStamp;
  37. #endregion
  38. #region 构造函数
  39. /// <summary>
  40. /// 构造函数
  41. /// </summary>
  42. /// <param name="editStatus"></param>
  43. /// <param name="pRapID"></param>
  44. public F_HR_1102(Constant.FormMode editStatus, int pRapID)
  45. {
  46. InitializeComponent();
  47. this._editStatus = editStatus;
  48. this._staffRAPID = pRapID;
  49. this.dkUserName.WhereCondition = "(StaffStatus = 1 Or StaffStatus = 2) AND ValueFlag = 1";
  50. this.txtRAPAmount.Text = "0";
  51. this.SetFromTitleInfo();
  52. }
  53. #endregion
  54. #region 属性
  55. /// <summary>
  56. /// ID集合
  57. /// </summary>
  58. public List<int> StaffIDList
  59. {
  60. get
  61. {
  62. return _staffIDList;
  63. }
  64. set
  65. {
  66. _staffIDList = value;
  67. }
  68. }
  69. #endregion
  70. #region 事件
  71. /// <summary>
  72. /// 页面加载事件
  73. /// </summary>
  74. /// <param name="sender"></param>
  75. /// <param name="e"></param>
  76. private void F_HR_1102_Load(object sender, EventArgs e)
  77. {
  78. try
  79. {
  80. #region 绑定数据源
  81. this.comRAPType.DataSource = GetRAPTypeInfo();
  82. this.comRAPType.DisplayMember = "TypeName";
  83. this.comRAPType.ValueMember = "TypeID";
  84. this.comAdministrationType.DataSource = DataDictionaryInfo();
  85. this.comAdministrationType.DisplayMember = "DictionaryValue";
  86. this.comAdministrationType.ValueMember = "DictionaryID";
  87. #endregion
  88. FormPermissionManager.FormPermissionControl(this.Name, this,
  89. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  90. if (this._editStatus == Constant.FormMode.Edit)
  91. {
  92. // 获取用户信息数据集
  93. DataSet staffInfoData = (DataSet)DoAsync(new BaseAsyncMethod(this.GetDataGridViewInfo));
  94. if (staffInfoData != null && staffInfoData.Tables.Count > 0 && staffInfoData.Tables[0].Rows.Count > 0)
  95. {
  96. #region 为控件赋值
  97. this.dkUserName.UserID = Convert.ToInt32(staffInfoData.Tables[0].Rows[0]["StaffID"]);
  98. this.dkUserName.UserCode = staffInfoData.Tables[0].Rows[0]["StaffCode"].ToString().Trim();
  99. this.dkUserName.UserName = staffInfoData.Tables[0].Rows[0]["StaffName"].ToString().Trim();
  100. string strRAPType = staffInfoData.Tables[0].Rows[0]["RAPType"].ToString().Trim();
  101. if (!string.IsNullOrEmpty(strRAPType))
  102. {
  103. this.comRAPType.SelectedValue = strRAPType;
  104. }
  105. string strRapDate = staffInfoData.Tables[0].Rows[0]["RAPDate"].ToString().Trim();
  106. if (!string.IsNullOrEmpty(strRapDate))
  107. {
  108. this.dtpRAPDate.Value = Convert.ToDateTime(strRapDate);
  109. }
  110. this.txtRAPAmount.Text = staffInfoData.Tables[0].Rows[0]["RAPAmount"].ToString().Trim();
  111. this.txtReason.Text = staffInfoData.Tables[0].Rows[0]["Reason"].ToString().Trim();
  112. string strAdministrationType = staffInfoData.Tables[0].Rows[0]["AdministrationType"].ToString().Trim();
  113. if (!string.IsNullOrEmpty(strAdministrationType))
  114. {
  115. this.comAdministrationType.SelectedValue = strAdministrationType;
  116. }
  117. this.txtRemarks.Text = staffInfoData.Tables[0].Rows[0]["Remarks"].ToString().Trim();
  118. this._oPTimeStamp = Convert.ToDateTime(staffInfoData.Tables[0].Rows[0]["OPTIMESTAMP"]);
  119. string strAuditStatus = staffInfoData.Tables[0].Rows[0]["AUDITSTATUS"].ToString();
  120. if (!Constant.ApprovalStatus.Pending.GetHashCode().ToString().Equals(strAuditStatus))//非待审批
  121. {
  122. //设置非待审核的履历控件禁用
  123. this.SetControlEnable();
  124. }
  125. #endregion
  126. }
  127. else
  128. {
  129. //设置非待审核的履历控件禁用
  130. this.SetControlEnable();
  131. }
  132. }
  133. }
  134. catch (Exception ex)
  135. {
  136. // 对异常进行共通处理
  137. ExceptionManager.HandleEventException(this.ToString(),
  138. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  139. }
  140. }
  141. /// <summary>
  142. /// 保存按钮
  143. /// </summary>
  144. /// <param name="sender"></param>
  145. /// <param name="e"></param>
  146. private void btnSave_Click(object sender, EventArgs e)
  147. {
  148. try
  149. {
  150. if (IsInputValid())
  151. {
  152. HRAdminRAPEntity tempRecord = SetStaffRecordEntity();
  153. HRResultEntity resultStaff = (HRResultEntity)DoAsync(new BaseAsyncMethod(() =>
  154. {
  155. if (_editStatus == Constant.FormMode.Add)
  156. {
  157. return WCF.Proxys.HRModuleProxy.Service.SaveStaffAdminRAPInfo(tempRecord, WCFConstant.FormMode.Add);
  158. }
  159. else if (_editStatus == Constant.FormMode.Edit)
  160. {
  161. return WCF.Proxys.HRModuleProxy.Service.SaveStaffAdminRAPInfo(tempRecord, WCFConstant.FormMode.Edit);
  162. }
  163. return 0;
  164. }));
  165. if (resultStaff.OperateStatus > Constant.INT_IS_ZERO)
  166. {
  167. // 提示信息
  168. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "行政奖惩", "保存"),
  169. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  170. this._staffIDList.Add(resultStaff.HRStaffID);
  171. if (_editStatus == Constant.FormMode.Add)
  172. {
  173. this.InitializationForm();//清空输入项
  174. }
  175. else
  176. {
  177. this.btnCancel_Click(sender, e); //关闭窗体
  178. }
  179. }
  180. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_ONE)
  181. {
  182. // 提示信息
  183. MessageBox.Show(string.Format(Messages.MSG_HR_W003, "行政奖惩"),
  184. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  185. }
  186. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_TWO)
  187. {
  188. // 提示信息
  189. MessageBox.Show(Messages.MSG_CMN_W012,
  190. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  191. }
  192. else
  193. {
  194. // 提示信息
  195. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "行政奖惩", "保存"),
  196. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  197. }
  198. }
  199. }
  200. catch (Exception ex)
  201. {
  202. // 对异常进行共通处理
  203. ExceptionManager.HandleEventException(this.ToString(),
  204. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  205. }
  206. }
  207. /// <summary>
  208. /// 取消按钮
  209. /// </summary>
  210. /// <param name="sender"></param>
  211. /// <param name="e"></param>
  212. private void btnCancel_Click(object sender, EventArgs e)
  213. {
  214. if (this._staffIDList != null && this._staffIDList.Count > 0)
  215. {
  216. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  217. }
  218. else
  219. {
  220. this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  221. }
  222. }
  223. #endregion
  224. #region 私有方法
  225. /// <summary>
  226. /// 设置窗体按钮的文本信息
  227. /// </summary>
  228. private void SetFromTitleInfo()
  229. {
  230. if (this._editStatus == Constant.FormMode.Add)
  231. {
  232. this.Text = FormTitles.F_HR_1102_ADD;
  233. this.dkUserName.Enabled = true;
  234. this._oPTimeStamp = null;
  235. this.dtpRAPDate.Value = DateTime.Now;
  236. }
  237. else if (this._editStatus == Constant.FormMode.Edit)
  238. {
  239. this.Text = FormTitles.F_HR_1102_EDIT;
  240. this.dkUserName.Enabled = false;
  241. }
  242. this.btnSave.Text = ButtonText.BTN_SAVE;
  243. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  244. }
  245. /// <summary>
  246. /// 获取奖惩类型数据源
  247. /// </summary>
  248. /// <returns></returns>
  249. private DataTable GetRAPTypeInfo()
  250. {
  251. //1:奖励;-1:惩罚
  252. DataTable dtRAPType = new DataTable();
  253. dtRAPType.Columns.Add("TypeID");
  254. dtRAPType.Columns.Add("TypeName");
  255. DataRow newRowType = dtRAPType.NewRow();
  256. newRowType["TypeID"] = "1";
  257. newRowType["TypeName"] = "奖励";
  258. dtRAPType.Rows.Add(newRowType);
  259. newRowType = dtRAPType.NewRow();
  260. newRowType["TypeID"] = "-1";
  261. newRowType["TypeName"] = "惩罚";
  262. dtRAPType.Rows.Add(newRowType);
  263. return dtRAPType;
  264. }
  265. /// <summary>
  266. /// 获取行政考核类别数据源
  267. /// </summary>
  268. /// <returns></returns>
  269. public DataTable DataDictionaryInfo()
  270. {
  271. DataTable dtDicInfo = (DataTable)DoAsync(new BaseAsyncMethod(() =>
  272. {
  273. return CommonModuleProxy.Service.GetDataDictionaryByType(Constant.ASE_ASE001);
  274. }));
  275. return dtDicInfo;
  276. }
  277. /// <summary>
  278. /// 根据查询条件获取要显示的数据
  279. /// </summary>
  280. /// <returns>返回查询的结果集</returns>
  281. private DataSet GetDataGridViewInfo()
  282. {
  283. SearchAdminRAPEntity searchAdminRAPEntity = new SearchAdminRAPEntity();
  284. searchAdminRAPEntity.ValueFlag = Constant.ValueFlag.Effective.GetHashCode().ToString();
  285. searchAdminRAPEntity.IDList = new int[] { _staffRAPID };
  286. return HRModuleProxy.Service.SearcStaffAdminRAPInfo(searchAdminRAPEntity);
  287. }
  288. /// <summary>
  289. /// 设置非待审核的履历控件禁用
  290. /// </summary>
  291. private void SetControlEnable()
  292. {
  293. this.dkUserName.Enabled = false;
  294. this.comRAPType.Enabled = false;
  295. this.dtpRAPDate.Enabled = false;
  296. this.txtRAPAmount.Enabled = false;
  297. this.txtReason.Enabled = false;
  298. this.comAdministrationType.Enabled = false;
  299. this.txtRemarks.Enabled = false;
  300. this.btnSave.Enabled = false;
  301. }
  302. /// <summary>
  303. /// 检查页面的输入项目
  304. /// </summary>
  305. /// <remarks>
  306. /// </remarks>
  307. /// <returns></returns>
  308. private bool IsInputValid()
  309. {
  310. if (this.dkUserName.UserID == null)
  311. {
  312. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "员工姓名"),
  313. this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1);
  314. this.dkUserName.Focus();
  315. return false;
  316. }
  317. else if (string.IsNullOrEmpty(this.txtRAPAmount.Text))
  318. {
  319. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "奖惩金额"),
  320. this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1);
  321. this.txtRAPAmount.Focus();
  322. return false;
  323. }
  324. else if (string.IsNullOrEmpty(this.txtReason.Text))
  325. {
  326. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "奖惩原因"),
  327. this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1);
  328. this.txtReason.Focus();
  329. return false;
  330. }
  331. else
  332. {
  333. return true;
  334. }
  335. }
  336. /// <summary>
  337. /// 根据页面输入值,对实体赋值
  338. /// </summary>
  339. /// <returns></returns>
  340. private HRAdminRAPEntity SetStaffRecordEntity()
  341. {
  342. HRAdminRAPEntity staffRecordEntity = new HRAdminRAPEntity();
  343. staffRecordEntity.RAPID = this._staffRAPID;
  344. staffRecordEntity.StaffID = this.dkUserName.UserID.Value;
  345. staffRecordEntity.RAPType = Convert.ToDouble(this.comRAPType.SelectedValue);
  346. staffRecordEntity.Reason = this.txtReason.Text;
  347. staffRecordEntity.RAPDate = this.dtpRAPDate.Value;
  348. staffRecordEntity.RAPAmount = Convert.ToDouble(this.txtRAPAmount.Text);
  349. if (this.comAdministrationType.SelectedValue != null)
  350. {
  351. staffRecordEntity.AdministrationType = Convert.ToInt32(this.comAdministrationType.SelectedValue);
  352. }
  353. staffRecordEntity.Remarks = this.txtRemarks.Text;
  354. staffRecordEntity.AuditStatus = Constant.ApprovalStatus.Pending.GetHashCode();
  355. staffRecordEntity.ValueFlag = Constant.ValueFlag.Effective.GetHashCode();
  356. if (this._oPTimeStamp != null)
  357. {
  358. staffRecordEntity.OPTimeStamp = this._oPTimeStamp.Value;
  359. }
  360. return staffRecordEntity;
  361. }
  362. /// <summary>
  363. /// 清空输入项
  364. /// </summary>
  365. private void InitializationForm()
  366. {
  367. this.dkUserName.UserID = null;
  368. this.dkUserName.UserCode = string.Empty;
  369. this.dkUserName.UserName = string.Empty;
  370. this.dkUserName.StaffEntity = null;
  371. this.comRAPType.SelectedIndex = 0;
  372. this.dtpRAPDate.Value = DateTime.Now;
  373. this.txtRAPAmount.Text = "0";
  374. this.txtReason.Text = string.Empty;
  375. if (this.comAdministrationType.SelectedValue != null)
  376. {
  377. this.comAdministrationType.SelectedIndex = 0;
  378. }
  379. this.txtRemarks.Text = string.Empty;
  380. }
  381. #endregion
  382. }
  383. }