F_HR_0301.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_HR_0301.cs
  5. * 2.功能描述:员工转正
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2014/09/19 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_0301 : DockPanelBase
  28. {
  29. #region 成员变量
  30. // 单例模式
  31. private static F_HR_0301 _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. public F_HR_0301()
  43. {
  44. InitializeComponent();
  45. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  46. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  47. this.tsbtnDisable.Text = ButtonText.TSBTN_DISABLE;
  48. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  49. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  50. this.tsbtnMoreCondition.Text = ButtonText.TSBTN_MORECONDITION;
  51. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  52. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  53. this.Text = FormTitles.F_HR_0301;
  54. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  55. }
  56. /// <summary>
  57. /// 单例模式,防止重复创建窗体
  58. /// </summary>
  59. public static F_HR_0301 Instance
  60. {
  61. get
  62. {
  63. if (_instance == null)
  64. {
  65. _instance = new F_HR_0301();
  66. }
  67. return _instance;
  68. }
  69. }
  70. #endregion
  71. #region 事件
  72. /// <summary>
  73. /// 单元格双击事件
  74. /// </summary>
  75. /// <param name="sender"></param>
  76. /// <param name="e"></param>
  77. private void dgvStaff_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
  78. {
  79. if (-Constant.INT_IS_ONE < e.RowIndex && -Constant.INT_IS_ONE < e.ColumnIndex && this.tsbtnEdit.Enabled && this.tsbtnEdit.Visible)
  80. {
  81. this.tsbtnEdit_Click(sender, e);
  82. }
  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 tsbtnMoreCondition_Click(object sender, EventArgs e)
  108. {
  109. Dongke.IBOSS.PRD.Basics.BaseControls.HR_CMN_001 hrcmn = new Basics.BaseControls.HR_CMN_001();
  110. hrcmn.StaffEntity = _staffEntity;
  111. if (hrcmn.ShowDialog() == DialogResult.OK)
  112. {
  113. this.txtOther.Text = hrcmn.StaffEntity.GetSqlDispText();
  114. this._staffEntity = hrcmn.StaffEntity;
  115. }
  116. }
  117. /// <summary>
  118. /// 清空条件按钮事件
  119. /// </summary>
  120. /// <param name="sender"></param>
  121. /// <param name="e"></param>
  122. private void btnClearCondition_Click(object sender, EventArgs e)
  123. {
  124. this.txtStaffCode.Clear();
  125. this.txtStaffName.Clear();
  126. this.txtOther.Clear();
  127. this._staffEntity.ClearEntityValue();
  128. }
  129. /// <summary>
  130. /// 搜索按钮事件
  131. /// </summary>
  132. /// <param name="sender"></param>
  133. /// <param name="e"></param>
  134. private void btnSearch_Click(object sender, EventArgs e)
  135. {
  136. try
  137. {
  138. this._staffIDList = null;
  139. // 记录当前选中行
  140. int selectRowIndex = this._selecedRow;
  141. // 异步处理
  142. this.btnSearch.Enabled = false;
  143. this.btnClearCondition.Enabled = false;
  144. DataSet userDataSet
  145. = (DataSet)DoAsync(new AsyncMethod(this.SearchHrStaffAndRecordList));
  146. this.btnSearch.Enabled = true;
  147. this.btnClearCondition.Enabled = true;
  148. if (userDataSet != null)
  149. {
  150. base.DataSource = (DataSet)userDataSet;
  151. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  152. {
  153. this.dgvStaff.DataSource = this.DataSource.Tables[0];
  154. if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  155. {
  156. // 提示未查找到数据
  157. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  158. MessageBoxButtons.OK, MessageBoxIcon.Information);
  159. }
  160. else
  161. {
  162. if (selectRowIndex >= Constant.INT_IS_ZERO)
  163. {
  164. if (selectRowIndex >= userDataSet.Tables[0].Rows.Count)
  165. {
  166. this.dgvStaff.Rows[this.dgvStaff.Rows.Count - 1].Selected = true;
  167. this.dgvStaff.CurrentCell
  168. = this.dgvStaff.Rows[this.dgvStaff.Rows.Count - 1].Cells["StaffCode"];
  169. }
  170. else
  171. {
  172. this.dgvStaff.Rows[selectRowIndex].Selected = true;
  173. this.dgvStaff.CurrentCell
  174. = this.dgvStaff.Rows[selectRowIndex].Cells["StaffCode"];
  175. }
  176. }
  177. }
  178. }
  179. }
  180. this.SetToolStripButtonEnable();
  181. }
  182. catch (Exception ex)
  183. {
  184. this.btnSearch.Enabled = true;
  185. this.btnClearCondition.Enabled = true;
  186. // 对异常进行共通处理
  187. ExceptionManager.HandleEventException(this.ToString(),
  188. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  189. }
  190. }
  191. /// <summary>
  192. /// 窗体加载事件
  193. /// </summary>
  194. /// <param name="sender"></param>
  195. /// <param name="e"></param>
  196. private void F_HR_0301_Load(object sender, EventArgs e)
  197. {
  198. try
  199. {
  200. // 加载权限
  201. FormPermissionManager.FormPermissionControl(this.Name, this,
  202. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  203. // 设置表格不自动创建列
  204. this.dgvStaff.AutoGenerateColumns = false;
  205. // 设置ToolStripButton状态
  206. this.SetToolStripButtonEnable();
  207. this.tsbtnDisable.Visible = false;
  208. }
  209. catch (Exception ex)
  210. {
  211. // 对异常进行共通处理
  212. ExceptionManager.HandleEventException(this.ToString(),
  213. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  214. }
  215. }
  216. /// <summary>
  217. /// 新建按钮事件
  218. /// </summary>
  219. /// <param name="sender"></param>
  220. /// <param name="e"></param>
  221. private void tsbtnAdd_Click(object sender, EventArgs e)
  222. {
  223. try
  224. {
  225. F_HR_0302 frmHR0302 = new F_HR_0302(Constant.FormMode.Add, Constant.INT_IS_NEGATIE_ONE, Constant.INT_IS_NEGATIE_ONE);
  226. DialogResult dialogResult = frmHR0302.ShowDialog();
  227. // 重新加载GridView
  228. if (dialogResult == DialogResult.OK)
  229. {
  230. this._staffIDList = frmHR0302.StaffIDList.ToArray();
  231. DataSet userDataSet = (DataSet)DoAsync(new AsyncMethod(this.SearchHrStaffAndRecordList));
  232. if (userDataSet != null && userDataSet.Tables.Count > Constant.INT_IS_ZERO
  233. && userDataSet.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  234. {
  235. this.dgvStaff.DataSource = null;
  236. this.dgvStaff.DataSource = userDataSet.Tables[0];
  237. // 设置ToolStripButton按钮状态
  238. this.SetToolStripButtonEnable();
  239. this.dgvStaff.ReadOnly = true;
  240. }
  241. }
  242. }
  243. catch (Exception ex)
  244. {
  245. // 对异常进行共通处理
  246. ExceptionManager.HandleEventException(this.ToString(),
  247. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  248. }
  249. }
  250. /// <summary>
  251. /// 编辑按钮事件
  252. /// </summary>
  253. /// <param name="sender"></param>
  254. /// <param name="e"></param>
  255. private void tsbtnEdit_Click(object sender, EventArgs e)
  256. {
  257. try
  258. {
  259. if (this.dgvStaff.CurrentRow != null)
  260. {
  261. int intStaffID = Convert.ToInt32(this.dgvStaff.CurrentRow.Cells["StaffID"].Value);
  262. int intStaffRecordID = Convert.ToInt32(this.dgvStaff.CurrentRow.Cells["StaffRecordID"].Value);
  263. F_HR_0302 frmHR0302 = new F_HR_0302(Constant.FormMode.Edit, intStaffID, intStaffRecordID);
  264. if (frmHR0302.ShowDialog() == DialogResult.OK)
  265. {
  266. this._staffIDList = frmHR0302.StaffIDList.ToArray();
  267. DataSet userDataSet = (DataSet)DoAsync(new AsyncMethod(this.SearchHrStaffAndRecordList));
  268. if (userDataSet != null && userDataSet.Tables.Count > Constant.INT_IS_ZERO
  269. && userDataSet.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  270. {
  271. this.dgvStaff.DataSource = null;
  272. this.dgvStaff.DataSource = userDataSet.Tables[0];
  273. // 设置ToolStripButton按钮状态
  274. this.SetToolStripButtonEnable();
  275. this.dgvStaff.ReadOnly = true;
  276. }
  277. }
  278. }
  279. }
  280. catch (Exception ex)
  281. {
  282. // 对异常进行共通处理
  283. ExceptionManager.HandleEventException(this.ToString(),
  284. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  285. }
  286. }
  287. /// <summary>
  288. /// 停用按钮事件
  289. /// </summary>
  290. /// <param name="sender"></param>
  291. /// <param name="e"></param>
  292. private void tsbtnDisable_Click(object sender, EventArgs e)
  293. {
  294. try
  295. {
  296. DialogResult msgBoxResult = MessageBox.Show(
  297. string.Format(Messages.MSG_CMN_Q002, "该员工", "停用"), this.Text,
  298. MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  299. if (msgBoxResult == DialogResult.Yes)
  300. {
  301. int staffid = Convert.ToInt32(this.dgvStaff.CurrentRow.Cells["STAFFRECORDID"].Value);
  302. this._staffID = staffid;
  303. HRResultEntity resultStaff = (HRResultEntity)DoAsync(() =>
  304. {
  305. return HRModuleProxy.Service.SetStaffRecordValueFlag(_staffID);
  306. }
  307. );
  308. this.dgvStaff.ReadOnly = true;
  309. // 修改成功
  310. if (resultStaff.OperateStatus > Constant.INT_IS_ZERO)
  311. {
  312. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "员工转正", "停用"),
  313. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  314. this.btnSearch_Click(sender, e);
  315. }
  316. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_FIVE)
  317. {
  318. MessageBox.Show(Messages.MSG_HR_W002,
  319. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  320. }
  321. else
  322. {
  323. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "员工转正", "停用"),
  324. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  325. }
  326. }
  327. }
  328. catch (Exception ex)
  329. {
  330. // 对异常进行共通处理
  331. ExceptionManager.HandleEventException(this.ToString(),
  332. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  333. }
  334. }
  335. /// <summary>
  336. /// 窗体关闭事件
  337. /// </summary>
  338. /// <param name="sender"></param>
  339. /// <param name="e"></param>
  340. private void F_HR_0301_FormClosed(object sender, FormClosedEventArgs e)
  341. {
  342. _instance = null;
  343. }
  344. #endregion
  345. #region 私有方法
  346. /// <summary>
  347. /// 搜索数据集
  348. /// </summary>
  349. /// <returns></returns>
  350. private DataSet SearchHrStaffAndRecordList()
  351. {
  352. SearchStaffEntity searchStaffEntity = new SearchStaffEntity();
  353. DataConvert.Convert(this._staffEntity, searchStaffEntity);
  354. searchStaffEntity.StaffCode = this.txtStaffCode.Text.Trim();
  355. searchStaffEntity.StaffName = this.txtStaffName.Text.Trim();
  356. searchStaffEntity.Recordtype = Constant.StaffRecordType.Positive.GetHashCode(); //2:转正
  357. searchStaffEntity.RValueflag = Constant.ValueFlag.Effective.GetHashCode(); //1:正常
  358. if (this._staffIDList != null && this._staffIDList.Length > Constant.INT_IS_ZERO)
  359. {
  360. searchStaffEntity.RStaffRecordIDList = this._staffIDList;
  361. }
  362. return HRModuleProxy.Service.SearchHrStaffAndRecord(searchStaffEntity);
  363. }
  364. /// <summary>
  365. /// 设置工具按钮的可用状态
  366. /// </summary>
  367. private void SetToolStripButtonEnable()
  368. {
  369. if (this.dgvStaff.CurrentCell != null)
  370. {
  371. this.tsbtnEdit.Enabled = true;
  372. this.tsbtnDisable.Enabled = true;
  373. }
  374. else
  375. {
  376. this.tsbtnEdit.Enabled = false;
  377. this.tsbtnDisable.Enabled = false;
  378. }
  379. }
  380. #endregion
  381. }
  382. }