F_PM_1105.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_1105.cs
  5. * 2.功能描述:进度考核奖惩新建/编辑
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 张国印 2014/10/9 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.PMModuleService;
  21. namespace Dongke.IBOSS.PRD.Client.PMModule
  22. {
  23. /// <summary>
  24. /// 进度考核奖惩新建/编辑
  25. /// </summary>
  26. public partial class F_PM_1105 : 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_PM_1105(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_PM_1105_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. #endregion
  85. FormPermissionManager.FormPermissionControl(this.Name, this,
  86. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  87. if (this._editStatus == Constant.FormMode.Edit)
  88. {
  89. // 获取用户信息数据集
  90. DataSet staffInfoData = (DataSet)DoAsync(new BaseAsyncMethod(this.GetDataGridViewInfo));
  91. if (staffInfoData != null && staffInfoData.Tables.Count > Constant.INT_IS_ZERO && staffInfoData.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  92. {
  93. #region 为控件赋值
  94. this.dkUserName.UserID = Convert.ToInt32(staffInfoData.Tables[0].Rows[0]["StaffID"]);
  95. this.dkUserName.UserCode = staffInfoData.Tables[0].Rows[0]["StaffCode"].ToString().Trim();
  96. this.dkUserName.UserName = staffInfoData.Tables[0].Rows[0]["StaffName"].ToString().Trim();
  97. string strRAPType = staffInfoData.Tables[0].Rows[0]["RAPType"].ToString().Trim();
  98. if (!string.IsNullOrEmpty(strRAPType))
  99. {
  100. this.comRAPType.SelectedValue = strRAPType;
  101. }
  102. string strRapDate = staffInfoData.Tables[0].Rows[0]["RAPDate"].ToString().Trim();
  103. if (!string.IsNullOrEmpty(strRapDate))
  104. {
  105. this.dtpRAPDate.Value = Convert.ToDateTime(strRapDate);
  106. }
  107. this.txtRAPAmount.Text = staffInfoData.Tables[0].Rows[0]["RAPAmount"].ToString().Trim();
  108. this.txtReason.Text = staffInfoData.Tables[0].Rows[0]["Reason"].ToString().Trim();
  109. this.txtRemarks.Text = staffInfoData.Tables[0].Rows[0]["Remarks"].ToString().Trim();
  110. this._oPTimeStamp = Convert.ToDateTime(staffInfoData.Tables[0].Rows[0]["OPTIMESTAMP"]);
  111. string strAuditStatus = staffInfoData.Tables[0].Rows[0]["AUDITSTATUS"].ToString();
  112. if (!Constant.ApprovalStatus.Pending.GetHashCode().ToString().Equals(strAuditStatus))//非待审批
  113. {
  114. //设置非待审核的履历控件禁用
  115. this.SetControlEnable();
  116. }
  117. #endregion
  118. }
  119. else
  120. {
  121. //设置非待审核的履历控件禁用
  122. this.SetControlEnable();
  123. }
  124. }
  125. }
  126. catch (Exception ex)
  127. {
  128. // 对异常进行共通处理
  129. ExceptionManager.HandleEventException(this.ToString(),
  130. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  131. }
  132. }
  133. /// <summary>
  134. /// 保存按钮
  135. /// </summary>
  136. /// <param name="sender"></param>
  137. /// <param name="e"></param>
  138. private void btnSave_Click(object sender, EventArgs e)
  139. {
  140. try
  141. {
  142. if (IsInputValid())
  143. {
  144. PMProgressRAPEntity tempRecord = SetStaffRecordEntity();
  145. PMResultEntity resultStaff = (PMResultEntity)DoAsync(new BaseAsyncMethod(() =>
  146. {
  147. if (_editStatus == Constant.FormMode.Add)
  148. {
  149. return WCF.Proxys.PMModuleProxy.Service.SaveStaffProgressRAPInfo(tempRecord, WCFConstant.FormMode.Add);
  150. }
  151. else if (_editStatus == Constant.FormMode.Edit)
  152. {
  153. return WCF.Proxys.PMModuleProxy.Service.SaveStaffProgressRAPInfo(tempRecord, WCFConstant.FormMode.Edit);
  154. }
  155. return 0;
  156. }));
  157. if (resultStaff.OperateStatus > Constant.INT_IS_ZERO)
  158. {
  159. // 提示信息
  160. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "进度考核奖惩", "保存"),
  161. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  162. this._staffIDList.Add(resultStaff.OperateKey);
  163. if (_editStatus == Constant.FormMode.Add)
  164. {
  165. this.InitializationForm();//清空输入项
  166. }
  167. else
  168. {
  169. this.btnCancel_Click(sender, e); //关闭窗体
  170. }
  171. }
  172. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_ONE)
  173. {
  174. // 提示信息
  175. MessageBox.Show(string.Format(Messages.MSG_HR_W003, "进度考核奖惩"),
  176. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  177. }
  178. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_TWO)
  179. {
  180. // 提示信息
  181. MessageBox.Show(Messages.MSG_CMN_W012,
  182. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  183. }
  184. else
  185. {
  186. // 提示信息
  187. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "进度考核奖惩", "保存"),
  188. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  189. }
  190. }
  191. }
  192. catch (Exception ex)
  193. {
  194. // 对异常进行共通处理
  195. ExceptionManager.HandleEventException(this.ToString(),
  196. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  197. }
  198. }
  199. /// <summary>
  200. /// 取消按钮
  201. /// </summary>
  202. /// <param name="sender"></param>
  203. /// <param name="e"></param>
  204. private void btnCancel_Click(object sender, EventArgs e)
  205. {
  206. if (this._staffIDList != null && this._staffIDList.Count > Constant.INT_IS_ZERO)
  207. {
  208. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  209. }
  210. else
  211. {
  212. this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  213. }
  214. }
  215. #endregion
  216. #region 私有方法
  217. /// <summary>
  218. /// 设置窗体按钮的文本信息
  219. /// </summary>
  220. private void SetFromTitleInfo()
  221. {
  222. if (this._editStatus == Constant.FormMode.Add)
  223. {
  224. this.Text = FormTitles.F_PM_1105_ADD;
  225. this.dkUserName.Enabled = true;
  226. this._oPTimeStamp = null;
  227. this.dtpRAPDate.Value = DateTime.Now;
  228. }
  229. else if (this._editStatus == Constant.FormMode.Edit)
  230. {
  231. this.Text = FormTitles.F_PM_1105_EDIT;
  232. this.dkUserName.Enabled = false;
  233. }
  234. this.btnSave.Text = ButtonText.BTN_SAVE;
  235. this.btnCancel.Text = ButtonText.BTN_CANCEL;
  236. }
  237. /// <summary>
  238. /// 获取奖惩类型数据源
  239. /// </summary>
  240. /// <returns></returns>
  241. private DataTable GetRAPTypeInfo()
  242. {
  243. //1:奖励;-1:惩罚
  244. DataTable dtRAPType = new DataTable();
  245. dtRAPType.Columns.Add("TypeID");
  246. dtRAPType.Columns.Add("TypeName");
  247. DataRow newRowType = dtRAPType.NewRow();
  248. newRowType["TypeID"] = "1";
  249. newRowType["TypeName"] = "奖励";
  250. dtRAPType.Rows.Add(newRowType);
  251. newRowType = dtRAPType.NewRow();
  252. newRowType["TypeID"] = "-1";
  253. newRowType["TypeName"] = "惩罚";
  254. dtRAPType.Rows.Add(newRowType);
  255. return dtRAPType;
  256. }
  257. /// <summary>
  258. /// 根据查询条件获取要显示的数据
  259. /// </summary>
  260. /// <returns>返回查询的结果集</returns>
  261. private DataSet GetDataGridViewInfo()
  262. {
  263. SearchProgressRAPEntity searchProgressRAPEntity = new SearchProgressRAPEntity();
  264. searchProgressRAPEntity.IDList = new int[] { _staffRAPID };
  265. searchProgressRAPEntity.ValueFlag = Constant.ValueFlag.Effective.GetHashCode().ToString();
  266. return PMModuleProxy.Service.SearcStaffAdminRAPInfo(searchProgressRAPEntity);
  267. }
  268. /// <summary>
  269. /// 设置非待审核的履历控件禁用
  270. /// </summary>
  271. private void SetControlEnable()
  272. {
  273. this.dkUserName.Enabled = false;
  274. this.comRAPType.Enabled = false;
  275. this.dtpRAPDate.Enabled = false;
  276. this.txtRAPAmount.Enabled = false;
  277. this.txtReason.Enabled = false;
  278. this.txtRemarks.Enabled = false;
  279. this.btnSave.Enabled = false;
  280. }
  281. /// <summary>
  282. /// 检查页面的输入项目
  283. /// </summary>
  284. /// <remarks>
  285. /// </remarks>
  286. /// <returns></returns>
  287. private bool IsInputValid()
  288. {
  289. if (this.dkUserName.UserID == null)
  290. {
  291. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "员工姓名"),
  292. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  293. this.dkUserName.Focus();
  294. return false;
  295. }
  296. else if (string.IsNullOrEmpty(this.txtRAPAmount.Text))
  297. {
  298. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "奖惩金额"),
  299. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  300. this.txtRAPAmount.Focus();
  301. return false;
  302. }
  303. else if (string.IsNullOrEmpty(this.txtReason.Text))
  304. {
  305. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "奖惩原因"),
  306. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  307. this.txtReason.Focus();
  308. return false;
  309. }
  310. else
  311. {
  312. return true;
  313. }
  314. }
  315. /// <summary>
  316. /// 根据页面输入值,对实体赋值
  317. /// </summary>
  318. /// <returns></returns>
  319. private PMProgressRAPEntity SetStaffRecordEntity()
  320. {
  321. PMProgressRAPEntity staffRecordEntity = new PMProgressRAPEntity();
  322. staffRecordEntity.RAPID = this._staffRAPID;
  323. staffRecordEntity.StaffID = this.dkUserName.UserID.Value;
  324. staffRecordEntity.RAPType = Convert.ToDouble(this.comRAPType.SelectedValue);
  325. staffRecordEntity.Reason = this.txtReason.Text;
  326. staffRecordEntity.RAPDate = this.dtpRAPDate.Value;
  327. staffRecordEntity.RAPAmount = Convert.ToDouble(this.txtRAPAmount.Text);
  328. staffRecordEntity.Remarks = this.txtRemarks.Text;
  329. staffRecordEntity.AuditStatus = Constant.ApprovalStatus.Pending.GetHashCode();
  330. staffRecordEntity.ValueFlag = Constant.ValueFlag.Effective.GetHashCode();
  331. if (this._oPTimeStamp != null)
  332. {
  333. staffRecordEntity.OPTimeStamp = this._oPTimeStamp.Value;
  334. }
  335. return staffRecordEntity;
  336. }
  337. /// <summary>
  338. /// 清空输入项
  339. /// </summary>
  340. private void InitializationForm()
  341. {
  342. this.dkUserName.UserID = null;
  343. this.dkUserName.UserCode = string.Empty;
  344. this.dkUserName.UserName = string.Empty;
  345. this.dkUserName.StaffEntity = null;
  346. this.comRAPType.SelectedIndex = 0;
  347. this.dtpRAPDate.Value = DateTime.Now;
  348. this.txtRAPAmount.Text = "0";
  349. this.txtReason.Text = string.Empty;
  350. this.txtRemarks.Text = string.Empty;
  351. }
  352. #endregion
  353. }
  354. }