F_HR_0201.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_HR_0201.cs
  5. * 2.功能描述:员工入职
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2014/09/12 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.Basics.Library;
  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.DataModels.HRModule;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. using Dongke.IBOSS.PRD.WCF.Proxys.HRModuleService;
  22. namespace Dongke.IBOSS.PRD.Client.HRModule
  23. {
  24. /// <summary>
  25. /// 员工入职
  26. /// </summary>
  27. public partial class F_HR_0201 : DockPanelBase
  28. {
  29. #region 成员变量
  30. // 单例模式
  31. private static F_HR_0201 _instance;
  32. // 最后选择行
  33. private int _selecedRow;
  34. // 员工ID
  35. private int _staffID;
  36. // 查询条件实体
  37. private HR_CMN_StaffEntity _staffEntity = new HR_CMN_StaffEntity();
  38. //用户编辑的ID集合
  39. int[] _staffIDList;
  40. #endregion
  41. #region 单例模式
  42. /// <summary>
  43. /// 单例模式,防止重复创建窗体
  44. /// </summary>
  45. public static F_HR_0201 Instance
  46. {
  47. get
  48. {
  49. if (_instance == null)
  50. {
  51. _instance = new F_HR_0201();
  52. }
  53. return _instance;
  54. }
  55. }
  56. #endregion
  57. #region 构造函数
  58. public F_HR_0201()
  59. {
  60. InitializeComponent();
  61. // 设置窗体控件文字显示
  62. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  63. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  64. this.tsbtnDisable.Text = ButtonText.TSBTN_DISABLE;
  65. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  66. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  67. this.tsbtnMoreCondition.Text = ButtonText.TSBTN_MORECONDITION;
  68. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  69. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  70. this.Text = FormTitles.F_HR_0201;
  71. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  72. }
  73. #endregion
  74. #region 事件
  75. /// <summary>
  76. /// 窗体关闭事件
  77. /// </summary>
  78. /// <param name="sender"></param>
  79. /// <param name="e"></param>
  80. private void F_HR_0103_FormClosed(object sender, FormClosedEventArgs e)
  81. {
  82. _instance = null;
  83. }
  84. /// <summary>
  85. /// 关闭按钮事件
  86. /// </summary>
  87. /// <param name="sender"></param>
  88. /// <param name="e"></param>
  89. private void tsbtnClose_Click(object sender, EventArgs e)
  90. {
  91. this.Close();
  92. }
  93. /// <summary>
  94. /// 自动适应列宽
  95. /// </summary>
  96. /// <param name="sender"></param>
  97. /// <param name="e"></param>
  98. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  99. {
  100. this.dgvStaff.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  101. }
  102. /// <summary>
  103. /// 添加按钮事件
  104. /// </summary>
  105. /// <param name="sender"></param>
  106. /// <param name="e"></param>
  107. private void tsbtnAdd_Click(object sender, EventArgs e)
  108. {
  109. try
  110. {
  111. F_HR_0202 frmHR0104 = new F_HR_0202(Constant.FormMode.Add);
  112. DialogResult dialogResult = frmHR0104.ShowDialog();
  113. // 重新加载GridView
  114. if (dialogResult == DialogResult.OK)
  115. {
  116. this._staffIDList = frmHR0104.StaffIDList.ToArray();
  117. DataSet userDataSet = (DataSet)DoAsync(new AsyncMethod(this.SearchHrStaffAndRecordList));
  118. if (userDataSet != null && userDataSet.Tables.Count > Constant.INT_IS_ZERO
  119. && userDataSet.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  120. {
  121. this.dgvStaff.DataSource = null;
  122. this.dgvStaff.DataSource = userDataSet.Tables[0];
  123. // 设置ToolStripButton按钮状态
  124. this.SetToolStripButtonEnable();
  125. this.dgvStaff.ReadOnly = true;
  126. }
  127. }
  128. }
  129. catch (Exception ex)
  130. {
  131. // 对异常进行共通处理
  132. ExceptionManager.HandleEventException(this.ToString(),
  133. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  134. }
  135. }
  136. /// <summary>
  137. /// 窗体加载事件
  138. /// </summary>
  139. /// <param name="sender"></param>
  140. /// <param name="e"></param>
  141. private void F_HR_0103_Load(object sender, EventArgs e)
  142. {
  143. try
  144. {
  145. // 加载权限
  146. FormPermissionManager.FormPermissionControl(this.Name, this,
  147. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  148. // 设置表格不自动创建列
  149. this.dgvStaff.AutoGenerateColumns = false;
  150. // 设置ToolStripButton状态
  151. this.SetToolStripButtonEnable();
  152. this.tsbtnDisable.Visible = false;
  153. }
  154. catch (Exception ex)
  155. {
  156. // 对异常进行共通处理
  157. ExceptionManager.HandleEventException(this.ToString(),
  158. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  159. }
  160. }
  161. /// <summary>
  162. /// 设置工具按钮的可用状态
  163. /// </summary>
  164. private void SetToolStripButtonEnable()
  165. {
  166. if (this.dgvStaff.CurrentCell != null)
  167. {
  168. this.tsbtnEdit.Enabled = true;
  169. this.tsbtnDisable.Enabled = true;
  170. // 单据状态
  171. int approvalStatus = int.Parse(this.dgvStaff.Rows[this.dgvStaff.CurrentCell.RowIndex].Cells["ApprovalStatus"].Value.ToString());
  172. if (approvalStatus == Constant.ApprovalStatus.Agree.GetHashCode()
  173. || approvalStatus == Constant.ApprovalStatus.Disagree.GetHashCode()
  174. || approvalStatus == Constant.ApprovalStatus.Doing.GetHashCode())
  175. {
  176. this.tsbtnEdit.Enabled = false;
  177. this.tsbtnDisable.Enabled = false;
  178. }
  179. }
  180. else
  181. {
  182. this.tsbtnEdit.Enabled = false;
  183. this.tsbtnDisable.Enabled = false;
  184. }
  185. }
  186. /// <summary>
  187. /// 清空条件按钮事件
  188. /// </summary>
  189. /// <param name="sender"></param>
  190. /// <param name="e"></param>
  191. private void btnClearCondition_Click(object sender, EventArgs e)
  192. {
  193. this.txtStaffCode.Clear();
  194. this.txtStaffName.Clear();
  195. this.txtOther.Clear();
  196. this._staffEntity.ClearEntityValue();
  197. }
  198. /// <summary>
  199. /// 搜索按钮事件
  200. /// </summary>
  201. /// <param name="sender"></param>
  202. /// <param name="e"></param>
  203. private void btnSearch_Click(object sender, EventArgs e)
  204. {
  205. try
  206. {
  207. this._staffIDList = null;
  208. // 记录当前选中行
  209. int selectRowIndex = this._selecedRow;
  210. // 异步处理
  211. this.btnSearch.Enabled = false;
  212. this.btnClearCondition.Enabled = false;
  213. DataSet userDataSet
  214. = (DataSet)DoAsync(new AsyncMethod(this.SearchHrStaffAndRecordList));
  215. this.btnSearch.Enabled = true;
  216. this.btnClearCondition.Enabled = true;
  217. //this.sbxOrganization.ReadOnly = true;
  218. if (userDataSet != null)
  219. {
  220. base.DataSource = (DataSet)userDataSet;
  221. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  222. {
  223. this.dgvStaff.DataSource = this.DataSource.Tables[0];
  224. if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  225. {
  226. // 提示未查找到数据
  227. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  228. MessageBoxButtons.OK, MessageBoxIcon.Information);
  229. }
  230. else
  231. {
  232. if (selectRowIndex >= Constant.INT_IS_ZERO)
  233. {
  234. if (selectRowIndex >= userDataSet.Tables[0].Rows.Count)
  235. {
  236. this.dgvStaff.Rows[this.dgvStaff.Rows.Count - 1].Selected = true;
  237. this.dgvStaff.CurrentCell
  238. = this.dgvStaff.Rows[this.dgvStaff.Rows.Count - 1].Cells["StaffCode"];
  239. }
  240. else
  241. {
  242. this.dgvStaff.Rows[selectRowIndex].Selected = true;
  243. this.dgvStaff.CurrentCell
  244. = this.dgvStaff.Rows[selectRowIndex].Cells["StaffCode"];
  245. }
  246. }
  247. }
  248. }
  249. }
  250. this.SetToolStripButtonEnable();
  251. }
  252. catch (Exception ex)
  253. {
  254. this.btnSearch.Enabled = true;
  255. this.btnClearCondition.Enabled = true;
  256. // 对异常进行共通处理
  257. ExceptionManager.HandleEventException(this.ToString(),
  258. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  259. }
  260. }
  261. /// <summary>
  262. /// 关闭按钮事件
  263. /// </summary>
  264. /// <param name="sender"></param>
  265. /// <param name="e"></param>
  266. private void tsbtnClose_Click_1(object sender, EventArgs e)
  267. {
  268. this.Close();
  269. }
  270. /// <summary>
  271. /// 自动适应列宽
  272. /// </summary>
  273. /// <param name="sender"></param>
  274. /// <param name="e"></param>
  275. private void tsbtnAdaptive_Click_1(object sender, EventArgs e)
  276. {
  277. this.dgvStaff.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  278. }
  279. /// <summary>
  280. /// 更多条件按钮事件
  281. /// </summary>
  282. /// <param name="sender"></param>
  283. /// <param name="e"></param>
  284. private void tsbtnMoreCondition_Click(object sender, EventArgs e)
  285. {
  286. Dongke.IBOSS.PRD.Basics.BaseControls.HR_CMN_001 frmHRCMN001 = new Basics.BaseControls.HR_CMN_001();
  287. frmHRCMN001.StaffEntity = this._staffEntity;
  288. if (frmHRCMN001.ShowDialog() == DialogResult.OK)
  289. {
  290. this.txtOther.Text = frmHRCMN001.StaffEntity.GetSqlDispText();
  291. this._staffEntity = frmHRCMN001.StaffEntity;
  292. }
  293. }
  294. /// <summary>
  295. /// 停用按钮事件
  296. /// </summary>
  297. /// <param name="sender"></param>
  298. /// <param name="e"></param>
  299. private void tsbtnDisable_Click(object sender, EventArgs e)
  300. {
  301. try
  302. {
  303. DialogResult msgBoxResult = MessageBox.Show(
  304. string.Format(Messages.MSG_CMN_Q002, "该员工", "停用"), this.Text,
  305. MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  306. if (msgBoxResult == DialogResult.Yes)
  307. {
  308. int staffid = Convert.ToInt32(this.dgvStaff.CurrentRow.Cells["STAFFRECORDID"].Value);
  309. this._staffID = staffid;
  310. HRResultEntity resultStaff = (HRResultEntity)DoAsync(() =>
  311. {
  312. return HRModuleProxy.Service.SetStaffRecordValueFlag(_staffID);
  313. }
  314. );
  315. this.dgvStaff.ReadOnly = true;
  316. // 修改成功
  317. if (resultStaff.OperateStatus > Constant.INT_IS_ZERO)
  318. {
  319. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "员工入职", "停用"),
  320. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  321. this.btnSearch_Click(sender, e);
  322. }
  323. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_FIVE)
  324. {
  325. MessageBox.Show(Messages.MSG_HR_W002,
  326. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  327. }
  328. else
  329. {
  330. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "员工入职", "停用"),
  331. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  332. }
  333. }
  334. }
  335. catch (Exception ex)
  336. {
  337. // 对异常进行共通处理
  338. ExceptionManager.HandleEventException(this.ToString(),
  339. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  340. }
  341. }
  342. /// <summary>
  343. /// 编辑按钮事件
  344. /// </summary>
  345. /// <param name="sender"></param>
  346. /// <param name="e"></param>
  347. private void tsbtnEdit_Click(object sender, EventArgs e)
  348. {
  349. try
  350. {
  351. if (this.dgvStaff.CurrentRow != null)
  352. {
  353. F_HR_0202 frmHR0104 = new F_HR_0202(Constant.FormMode.Edit);
  354. frmHR0104.StaffID = Convert.ToInt32(this.dgvStaff.CurrentRow.Cells["StaffID"].Value);
  355. frmHR0104.Gender = this.dgvStaff.CurrentRow.Cells["SGendername"].Value.ToString();
  356. frmHR0104.MaritalStatus = this.dgvStaff.CurrentRow.Cells["SMaritalstatusname"].Value.ToString();
  357. frmHR0104.NationalName = this.dgvStaff.CurrentRow.Cells["SNationalname"].Value.ToString();
  358. frmHR0104.Educational = this.dgvStaff.CurrentRow.Cells["SEducationalname"].Value.ToString();
  359. if (this.dgvStaff.CurrentRow.Cells["STAFFRECORDID"].Value != DBNull.Value)
  360. frmHR0104.StaffRecordID = Convert.ToInt32(this.dgvStaff.CurrentRow.Cells["STAFFRECORDID"].Value);
  361. DialogResult dialogResult = frmHR0104.ShowDialog();
  362. if (dialogResult.Equals(DialogResult.OK))
  363. {
  364. this._staffIDList = frmHR0104.StaffIDList.ToArray();
  365. DataSet userDataSet = (DataSet)DoAsync(new AsyncMethod(this.SearchHrStaffAndRecordList));
  366. if (userDataSet != null && userDataSet.Tables.Count > Constant.INT_IS_ZERO
  367. && userDataSet.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  368. {
  369. this.dgvStaff.DataSource = null;
  370. this.dgvStaff.DataSource = userDataSet.Tables[0];
  371. // 设置ToolStripButton按钮状态
  372. this.SetToolStripButtonEnable();
  373. this.dgvStaff.ReadOnly = true;
  374. }
  375. }
  376. }
  377. }
  378. catch (Exception ex)
  379. {
  380. // 对异常进行共通处理
  381. ExceptionManager.HandleEventException(this.ToString(),
  382. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  383. }
  384. }
  385. /// <summary>
  386. /// 单元格进入事件
  387. /// </summary>
  388. /// <param name="sender"></param>
  389. /// <param name="e"></param>
  390. private void dgvStaff_CellEnter(object sender, DataGridViewCellEventArgs e)
  391. {
  392. this.SetToolStripButtonEnable();
  393. if (dgvStaff.Rows.Count > Constant.INT_IS_ZERO)
  394. {
  395. this._selecedRow = this.dgvStaff.CurrentCell.RowIndex;
  396. }
  397. }
  398. /// <summary>
  399. /// 单元格双击事件
  400. /// </summary>
  401. /// <param name="sender"></param>
  402. /// <param name="e"></param>
  403. private void dgvStaff_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
  404. {
  405. if (-Constant.INT_IS_ONE < e.RowIndex && -Constant.INT_IS_ONE < e.ColumnIndex && this.tsbtnEdit.Enabled && this.tsbtnEdit.Visible)
  406. {
  407. // 单据状态
  408. int approvalStatus = int.Parse(this.dgvStaff.Rows[this.dgvStaff.CurrentCell.RowIndex].Cells["ApprovalStatus"].Value.ToString());
  409. if (approvalStatus == Constant.ApprovalStatus.Pending.GetHashCode())
  410. {
  411. this.tsbtnEdit_Click(sender, e);
  412. }
  413. }
  414. }
  415. #endregion
  416. #region 私有方法
  417. /// <summary>
  418. /// 搜索数据集
  419. /// </summary>
  420. /// <returns></returns>
  421. private DataSet SearchHrStaffAndRecordList()
  422. {
  423. SearchStaffEntity searchStaffEntity = new SearchStaffEntity();
  424. DataConvert.Convert(this._staffEntity, searchStaffEntity);
  425. searchStaffEntity.StaffCode = this.txtStaffCode.Text.Trim();
  426. searchStaffEntity.StaffName = this.txtStaffName.Text.Trim();
  427. searchStaffEntity.Recordtype = 1;
  428. searchStaffEntity.RValueflag = 1;
  429. if (this._staffIDList != null && this._staffIDList.Length > Constant.INT_IS_ZERO)
  430. {
  431. searchStaffEntity.RStaffRecordIDList = this._staffIDList;
  432. }
  433. //searchStaffEntity.StaffStatusArray = SelStaffStatus.SelectedArray;
  434. return HRModuleProxy.Service.SearchHrStaffAndRecord(searchStaffEntity);
  435. }
  436. #endregion
  437. }
  438. }