F_PM_1106.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_1106.cs
  5. * 2.功能描述:进度考核奖惩审核
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 张国印 2014/10/9 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Windows.Forms;
  13. using Dongke.IBOSS.PRD.Basics.BaseResources;
  14. using Dongke.IBOSS.PRD.Basics.DockPanel;
  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. 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_1106 : DockPanelBase
  27. {
  28. #region 成员变量
  29. // 窗体的单例模式
  30. private static F_PM_1106 _instance;
  31. //Grid当前选中的行
  32. private int _selectedRowIndex;
  33. #endregion
  34. #region 构造函数
  35. /// <summary>
  36. /// 构造函数
  37. /// </summary>
  38. public F_PM_1106()
  39. {
  40. InitializeComponent();
  41. this.SetFromTitleInfo();
  42. }
  43. #endregion
  44. #region 单例模式
  45. /// <summary>
  46. /// 单例模式,防止重复创建窗体
  47. /// </summary>
  48. public static F_PM_1106 Instance
  49. {
  50. get
  51. {
  52. if (_instance == null)
  53. {
  54. _instance = new F_PM_1106();
  55. }
  56. return _instance;
  57. }
  58. }
  59. #endregion
  60. #region 事件
  61. /// <summary>
  62. /// 窗体加载事件
  63. /// </summary>
  64. /// <param name="sender"></param>
  65. /// <param name="e"></param>
  66. private void F_PM_1106_Load(object sender, EventArgs e)
  67. {
  68. try
  69. {
  70. #region 绑定数据源
  71. this.dkStaffName.WhereCondition = "(StaffStatus = 1 Or StaffStatus = 2) AND ValueFlag = 1";
  72. this.comRAPType.DataSource = GetRAPTypeInfo();
  73. this.comRAPType.DisplayMember = "TypeName";
  74. this.comRAPType.ValueMember = "TypeID";
  75. this.comSettlementFlag.DataSource = GetSettlementFlagInfo();
  76. this.comSettlementFlag.DisplayMember = "SettlementFlagName";
  77. this.comSettlementFlag.ValueMember = "SettlementFlagID";
  78. #endregion
  79. FormPermissionManager.FormPermissionControl(this.Name, this,
  80. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  81. }
  82. catch (Exception ex)
  83. {
  84. // 对异常进行共通处理
  85. ExceptionManager.HandleEventException(this.ToString(),
  86. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  87. }
  88. }
  89. /// <summary>
  90. /// 窗体关闭事件
  91. /// </summary>
  92. /// <param name="sender"></param>
  93. /// <param name="e"></param>
  94. private void F_PM_1106_FormClosed(object sender, FormClosedEventArgs e)
  95. {
  96. _instance = null;
  97. }
  98. /// <summary>
  99. /// 行获取焦点后查看明细
  100. /// </summary>
  101. /// <param name="sender"></param>
  102. /// <param name="e"></param>
  103. private void dgvStaff_CellEnter(object sender, DataGridViewCellEventArgs e)
  104. {
  105. try
  106. {
  107. if (this.dgvStaff.CurrentCell != null)
  108. {
  109. // 记录最后选择行
  110. this._selectedRowIndex = this.dgvStaff.CurrentCell.RowIndex;
  111. }
  112. }
  113. catch (Exception ex)
  114. {
  115. // 对异常进行共通处理
  116. ExceptionManager.HandleEventException(this.ToString(),
  117. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  118. }
  119. }
  120. /// <summary>
  121. /// 单元格鼠标双击事件
  122. /// </summary>
  123. /// <param name="sender"></param>
  124. /// <param name="e"></param>
  125. private void dgvStaff_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
  126. {
  127. if (Constant.INT_IS_NEGATIE_ONE < e.RowIndex && Constant.INT_IS_NEGATIE_ONE < e.ColumnIndex
  128. && this.tsbtnApprover.Enabled && this.tsbtnApprover.Visible)
  129. {
  130. this.tsbtnApprover_Click(sender, e);
  131. }
  132. }
  133. /// <summary>
  134. /// 审批按钮
  135. /// </summary>
  136. /// <param name="sender"></param>
  137. /// <param name="e"></param>
  138. private void tsbtnApprover_Click(object sender, EventArgs e)
  139. {
  140. try
  141. {
  142. if (this.dgvStaff.CurrentRow != null)
  143. {
  144. int intRAPID = Convert.ToInt32(this.dgvStaff.CurrentRow.Cells["RAPID"].Value);
  145. DateTime sopTimeStamp = Convert.ToDateTime(this.dgvStaff.CurrentRow.Cells["OPTIMESTAMP"].Value);
  146. PMProgressRAPEntity progressRAPEntity = new PMProgressRAPEntity();
  147. progressRAPEntity.RAPID = intRAPID;
  148. progressRAPEntity.OPTimeStamp = sopTimeStamp;
  149. S_CMN_012 frmCMN012 = new S_CMN_012();
  150. if (frmCMN012.ShowDialog() == DialogResult.OK)
  151. {
  152. bool bolState = frmCMN012.HRApprovalState;
  153. PMResultEntity resultStaff = (PMResultEntity)DoAsync(new AsyncMethod(() =>
  154. {
  155. return PMModuleProxy.Service.SaveStaffProgressRAPApprovalInfo(progressRAPEntity, bolState);
  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.btnSearch_Click(sender, e);
  163. }
  164. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_ONE)
  165. {
  166. // 提示信息
  167. MessageBox.Show(string.Format(Messages.MSG_HR_W003, "进度考核奖惩"),
  168. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  169. }
  170. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_TWO)
  171. {
  172. // 提示信息
  173. MessageBox.Show(Messages.MSG_CMN_W012,
  174. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  175. }
  176. else
  177. {
  178. // 提示信息
  179. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "进度考核奖惩", "保存"),
  180. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  181. }
  182. }
  183. }
  184. }
  185. catch (Exception ex)
  186. {
  187. // 对异常进行共通处理
  188. ExceptionManager.HandleEventException(this.ToString(),
  189. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  190. }
  191. }
  192. /// <summary>
  193. /// 自动适应列宽
  194. /// </summary>
  195. /// <param name="sender"></param>
  196. /// <param name="e"></param>
  197. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  198. {
  199. this.dgvStaff.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  200. }
  201. /// <summary>
  202. /// 关闭按钮事件
  203. /// </summary>
  204. /// <param name="sender"></param>
  205. /// <param name="e"></param>
  206. private void tsbtnClose_Click(object sender, EventArgs e)
  207. {
  208. this.Close();
  209. }
  210. /// <summary>
  211. /// 查询按钮
  212. /// </summary>
  213. /// <param name="sender"></param>
  214. /// <param name="e"></param>
  215. private void btnSearch_Click(object sender, EventArgs e)
  216. {
  217. try
  218. {
  219. // 记录当前选中行
  220. int selectRowIndex = this._selectedRowIndex;
  221. SearchProgressRAPEntity searchProgressRAPEntity = SetSearchProgressRAPEntity();
  222. DataSet dsResultStaff = (DataSet)DoAsync(new AsyncMethod(() =>
  223. {
  224. return PMModuleProxy.Service.SearcStaffAdminRAPInfo(searchProgressRAPEntity);
  225. }));
  226. if (dsResultStaff != null)
  227. {
  228. base.DataSource = dsResultStaff;
  229. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  230. {
  231. this.dgvStaff.DataSource = this.DataSource.Tables[0];
  232. if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  233. {
  234. // 提示未查找到数据
  235. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  236. MessageBoxButtons.OK, MessageBoxIcon.Information);
  237. }
  238. else
  239. {
  240. #region 选择原有行
  241. if (selectRowIndex >= Constant.INT_IS_ZERO)
  242. {
  243. if (selectRowIndex >= dsResultStaff.Tables[0].Rows.Count)
  244. {
  245. this.dgvStaff.Rows[this.dgvStaff.Rows.Count - 1].Selected = true;
  246. this.dgvStaff.CurrentCell = this.dgvStaff.Rows[this.dgvStaff.Rows.Count - 1].Cells["StaffName"];
  247. }
  248. else
  249. {
  250. this.dgvStaff.Rows[selectRowIndex].Selected = true;
  251. this.dgvStaff.CurrentCell = this.dgvStaff.Rows[selectRowIndex].Cells["StaffName"];
  252. }
  253. }
  254. #endregion
  255. }
  256. }
  257. }
  258. }
  259. catch (Exception ex)
  260. {
  261. // 对异常进行共通处理
  262. ExceptionManager.HandleEventException(this.ToString(),
  263. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  264. }
  265. }
  266. /// <summary>
  267. /// 清空条件
  268. /// </summary>
  269. /// <param name="sender"></param>
  270. /// <param name="e"></param>
  271. private void btnClearCondition_Click(object sender, EventArgs e)
  272. {
  273. this.dkStaffName.UserID = null;
  274. this.dkStaffName.UserName = string.Empty;
  275. this.dkStaffName.UserCode = string.Empty;
  276. this.dkStaffName.StaffEntity = null;
  277. this.comRAPType.SelectedIndex = 0;
  278. this.comSettlementFlag.SelectedIndex = 0;
  279. }
  280. #endregion
  281. #region 私有方法
  282. /// <summary>
  283. /// 设置窗体按钮的文本信息
  284. /// </summary>
  285. private void SetFromTitleInfo()
  286. {
  287. this.tsbtnApprover.Text = ButtonText.TSBTN_APPROVER;
  288. this.Text = FormTitles.F_PM_1106;
  289. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  290. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  291. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  292. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  293. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  294. }
  295. /// <summary>
  296. /// 获取奖惩类型数据源
  297. /// </summary>
  298. /// <returns></returns>
  299. private DataTable GetRAPTypeInfo()
  300. {
  301. //1:奖励;-1:惩罚
  302. DataTable dtRAPType = new DataTable();
  303. dtRAPType.Columns.Add("TypeID");
  304. dtRAPType.Columns.Add("TypeName");
  305. DataRow newRowType = dtRAPType.NewRow();
  306. newRowType["TypeID"] = Constant.CBO_SELECT_ALL_VALUE;
  307. newRowType["TypeName"] = Constant.CBO_SELECT_ALL_NAME;
  308. dtRAPType.Rows.Add(newRowType);
  309. newRowType = dtRAPType.NewRow();
  310. newRowType["TypeID"] = "1";
  311. newRowType["TypeName"] = "奖励";
  312. dtRAPType.Rows.Add(newRowType);
  313. newRowType = dtRAPType.NewRow();
  314. newRowType["TypeID"] = "-1";
  315. newRowType["TypeName"] = "惩罚";
  316. dtRAPType.Rows.Add(newRowType);
  317. return dtRAPType;
  318. }
  319. /// <summary>
  320. /// 工资结算标识数据源
  321. /// </summary>
  322. /// <returns></returns>
  323. private DataTable GetSettlementFlagInfo()
  324. {
  325. //1:已经结算 0:未结算
  326. DataTable dtRAPType = new DataTable();
  327. dtRAPType.Columns.Add("SettlementFlagID");
  328. dtRAPType.Columns.Add("SettlementFlagName");
  329. DataRow newRowType = dtRAPType.NewRow();
  330. newRowType["SettlementFlagID"] = Constant.CBO_SELECT_ALL_VALUE;
  331. newRowType["SettlementFlagName"] = Constant.CBO_SELECT_ALL_NAME;
  332. dtRAPType.Rows.Add(newRowType);
  333. newRowType = dtRAPType.NewRow();
  334. newRowType["SettlementFlagID"] = "0";
  335. newRowType["SettlementFlagName"] = "未结算";
  336. dtRAPType.Rows.Add(newRowType);
  337. newRowType = dtRAPType.NewRow();
  338. newRowType["SettlementFlagID"] = "1";
  339. newRowType["SettlementFlagName"] = "已经结算";
  340. dtRAPType.Rows.Add(newRowType);
  341. return dtRAPType;
  342. }
  343. /// <summary>
  344. /// 根据查询条件 形成查询实体
  345. /// </summary>
  346. /// <returns></returns>
  347. public SearchProgressRAPEntity SetSearchProgressRAPEntity()
  348. {
  349. SearchProgressRAPEntity searchProgressRAPEntity = new SearchProgressRAPEntity();
  350. searchProgressRAPEntity.ValueFlag = Constant.ValueFlag.Effective.GetHashCode().ToString();
  351. searchProgressRAPEntity.AuditStatus = Constant.ApprovalStatus.Pending.GetHashCode();
  352. if (this.dkStaffName.UserID != null)
  353. {
  354. searchProgressRAPEntity.StaffID = this.dkStaffName.UserID;
  355. }
  356. if (this.comRAPType.SelectedValue != null
  357. && !Constant.CBO_SELECT_ALL_VALUE.Equals(this.comRAPType.SelectedValue.ToString()))
  358. {
  359. searchProgressRAPEntity.RAPType = Convert.ToDouble(this.comRAPType.SelectedValue);
  360. }
  361. if (this.comSettlementFlag.SelectedValue != null
  362. && !Constant.CBO_SELECT_ALL_VALUE.Equals(this.comSettlementFlag.SelectedValue.ToString()))
  363. {
  364. searchProgressRAPEntity.SettlementFlag = this.comSettlementFlag.SelectedValue.ToString();
  365. }
  366. return searchProgressRAPEntity;
  367. }
  368. #endregion
  369. }
  370. }