HR_CMN_001.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:HR_CMN_001.cs
  5. * 2.功能描述:人力资源模块的通用查询页面
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 张国印 2014/09/09 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.Client.DataModels;
  15. namespace Dongke.IBOSS.PRD.Basics.BaseControls
  16. {
  17. /// <summary>
  18. /// 人力资源模块的通用查询页面
  19. /// </summary>
  20. public partial class HR_CMN_001 : FormBase
  21. {
  22. # region 成员变量
  23. //员工档案实体
  24. private HR_CMN_StaffEntity _staffEntity = new HR_CMN_StaffEntity();
  25. #endregion
  26. #region 属性
  27. /// <summary>
  28. /// 当前员工实体
  29. /// </summary>
  30. public HR_CMN_StaffEntity StaffEntity
  31. {
  32. get { return _staffEntity; }
  33. set { _staffEntity = value; }
  34. }
  35. #endregion
  36. #region 构造函数
  37. public HR_CMN_001()
  38. {
  39. InitializeComponent();
  40. SetFromTitleInfo();
  41. try
  42. {
  43. #region 绑定数据源
  44. DataTable dtT_SYS_Gender = LogInUserInfo.CurrentUser.GetSystemParameterByName(BaseResources.Constant.SysCacheTable.TP_SYS_Gender, "displayno ASC");
  45. this.dropGender.DisplayMember = "GenderName";
  46. this.dropGender.ValueMember = "GenderCode";
  47. this.dropGender.DataSource = dtT_SYS_Gender;
  48. DataTable dtT_SYS_MaritalStatus = LogInUserInfo.CurrentUser.GetSystemParameterByName(BaseResources.Constant.SysCacheTable.TP_SYS_MaritalStatus, "displayno ASC");
  49. this.dropMaritalStatus.DisplayMember = "maritalstatusname";
  50. this.dropMaritalStatus.ValueMember = "maritalstatusid";
  51. this.dropMaritalStatus.DataSource = dtT_SYS_MaritalStatus;
  52. DataTable dtT_SYS_National = LogInUserInfo.CurrentUser.GetSystemParameterByName(BaseResources.Constant.SysCacheTable.TP_SYS_National, "displayno ASC");
  53. this.dropNational.DisplayMember = "nationalname";
  54. this.dropNational.ValueMember = "nationalid";
  55. this.dropNational.DataSource = dtT_SYS_National;
  56. DataTable dtT_SYS_Educational = LogInUserInfo.CurrentUser.GetSystemParameterByName(BaseResources.Constant.SysCacheTable.TP_SYS_Educational, "displayno ASC");
  57. this.dropEducational.DisplayMember = "educationalname";
  58. this.dropEducational.ValueMember = "educationalid";
  59. this.dropEducational.DataSource = dtT_SYS_Educational;
  60. #endregion
  61. this.dtPBirthdayBegin.Value = Convert.ToDateTime(DateTime.Now.Date.ToString("yyyy-MM-dd"));
  62. }
  63. catch (Exception ex)
  64. {
  65. throw ex;
  66. }
  67. }
  68. #endregion
  69. #region 事件处理
  70. /// <summary>
  71. /// 确定按钮
  72. /// </summary>
  73. /// <param name="sender"></param>
  74. /// <param name="e"></param>
  75. private void btnOK_Click(object sender, EventArgs e)
  76. {
  77. try
  78. {
  79. if (!IsInputValid())
  80. {
  81. return;
  82. }
  83. this.StaffEntity.ClearEntityValue();
  84. #region 为条件实体赋值
  85. this.StaffEntity.IDCardNo = string.IsNullOrEmpty(this.txtIDCardNo.Text.Trim()) ? string.Empty : this.txtIDCardNo.Text.Trim();
  86. this.StaffEntity.IsCheckBirthday = this.cBoxBirthday.Checked;
  87. if (this.cBoxBirthday.Checked)
  88. {
  89. string strBegin = this.dtPBirthdayBegin.Value.ToString("yyyy-MM-dd") + " 0:0:0";
  90. string strEnd = this.dtPBirthdayEnd.Value.AddDays(1).ToString("yyyy-MM-dd") + " 0:0:0";
  91. this.StaffEntity.StartBirthday = Convert.ToDateTime(strBegin);
  92. this.StaffEntity.EndBirthday = Convert.ToDateTime(strEnd);
  93. }
  94. if (this.dropGender.SelectedValue != null)
  95. {
  96. string strGenderName = this.dropGender.Text.Trim();
  97. string strGenderValue = this.dropGender.SelectedValue.ToString().Trim();
  98. if (!string.IsNullOrEmpty(strGenderValue))
  99. {
  100. this.StaffEntity.Gender = strGenderValue;
  101. this.StaffEntity.GenderName = strGenderName;
  102. }
  103. }
  104. if (this.dropMaritalStatus.SelectedValue != null)
  105. {
  106. string strMaritalStatusName = this.dropMaritalStatus.Text.Trim();
  107. string strMaritalStatusValue = this.dropMaritalStatus.SelectedValue.ToString().Trim();
  108. if (!string.IsNullOrEmpty(strMaritalStatusValue))
  109. {
  110. this.StaffEntity.MaritalStatus = Convert.ToInt32(strMaritalStatusValue);
  111. this.StaffEntity.MaritalStatusName = strMaritalStatusName;
  112. }
  113. }
  114. string strHomeTown = this.txtHomeTown.Text.Trim();
  115. if (!string.IsNullOrEmpty(strHomeTown))
  116. {
  117. this.StaffEntity.HomeTown = strHomeTown;
  118. }
  119. string strPolicitalStatus = this.txtPolicitalStatus.Text.Trim();
  120. if (!string.IsNullOrEmpty(strPolicitalStatus))
  121. {
  122. this.StaffEntity.PolicitalStatus = strPolicitalStatus;
  123. }
  124. if (this.dropNational.SelectedValue != null)
  125. {
  126. string strNationalName = this.dropNational.Text.Trim();
  127. string strNationalValue = this.dropNational.SelectedValue.ToString().Trim();
  128. if (!string.IsNullOrEmpty(strNationalValue))
  129. {
  130. this.StaffEntity.National = Convert.ToInt32(strNationalValue);
  131. this.StaffEntity.NationalName = strNationalName;
  132. }
  133. }
  134. if (this.dropEducational.SelectedValue != null)
  135. {
  136. string strEducationalName = this.dropEducational.Text.Trim();
  137. string strEducationalValue = this.dropEducational.SelectedValue.ToString().Trim();
  138. if (!string.IsNullOrEmpty(strEducationalValue))
  139. {
  140. this.StaffEntity.Educational = Convert.ToInt32(strEducationalValue);
  141. this.StaffEntity.EducationalName = strEducationalName;
  142. }
  143. }
  144. string strGraduated = this.txtGraduated.Text.Trim();
  145. if (!string.IsNullOrEmpty(strGraduated))
  146. {
  147. this.StaffEntity.Graduated = strGraduated;
  148. }
  149. string strSpecialField = this.txtSpecialField.Text.Trim();
  150. if (!string.IsNullOrEmpty(strSpecialField))
  151. {
  152. this.StaffEntity.SpecialField = strSpecialField;
  153. }
  154. string strTelephone = this.txtTelephone.Text.Trim();
  155. if (!string.IsNullOrEmpty(strTelephone))
  156. {
  157. this.StaffEntity.Telephone = strTelephone;
  158. }
  159. #endregion
  160. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  161. }
  162. catch (Exception ex)
  163. {
  164. throw ex;
  165. }
  166. }
  167. /// <summary>
  168. /// 关闭按钮
  169. /// </summary>
  170. /// <param name="sender"></param>
  171. /// <param name="e"></param>
  172. private void btnClose_Click(object sender, EventArgs e)
  173. {
  174. this.Close();
  175. }
  176. /// <summary>
  177. /// 生日 选中框变更事件
  178. /// </summary>
  179. /// <param name="sender"></param>
  180. /// <param name="e"></param>
  181. private void cBoxBirthday_CheckedChanged(object sender, EventArgs e)
  182. {
  183. if (this.cBoxBirthday.Checked)
  184. {
  185. this.dtPBirthdayBegin.Enabled = true;
  186. this.dtPBirthdayEnd.Enabled = true;
  187. }
  188. else
  189. {
  190. this.dtPBirthdayBegin.Enabled = false;
  191. this.dtPBirthdayEnd.Enabled = false;
  192. }
  193. }
  194. /// <summary>
  195. /// 页面加载事件
  196. /// </summary>
  197. /// <param name="sender"></param>
  198. /// <param name="e"></param>
  199. private void HR_CMN_001_Load(object sender, EventArgs e)
  200. {
  201. #region 设置条件的值
  202. if (StaffEntity != null)
  203. {
  204. this.txtIDCardNo.Text = string.IsNullOrEmpty(this.StaffEntity.IDCardNo) ? string.Empty : this.StaffEntity.IDCardNo;
  205. if (this.StaffEntity.IsCheckBirthday)
  206. {
  207. this.cBoxBirthday.Checked = true;
  208. this.dtPBirthdayBegin.Value = this.StaffEntity.StartBirthday.Value;
  209. this.dtPBirthdayEnd.Value = this.StaffEntity.EndBirthday.Value.AddDays(-1);
  210. }
  211. if (!string.IsNullOrEmpty(this.StaffEntity.Gender))
  212. {
  213. this.dropGender.SelectedValue = this.StaffEntity.Gender;
  214. }
  215. if (this.StaffEntity.MaritalStatus != null)
  216. {
  217. this.dropMaritalStatus.SelectedValue = this.StaffEntity.MaritalStatus.Value;
  218. }
  219. this.txtHomeTown.Text = string.IsNullOrEmpty(this.StaffEntity.HomeTown) ? string.Empty : this.StaffEntity.HomeTown;
  220. this.txtPolicitalStatus.Text = string.IsNullOrEmpty(this.StaffEntity.PolicitalStatus) ? string.Empty : this.StaffEntity.PolicitalStatus;
  221. if (this.StaffEntity.National != null)
  222. {
  223. this.dropNational.SelectedValue = this.StaffEntity.National.Value;
  224. }
  225. if (this.StaffEntity.Educational != null)
  226. {
  227. this.dropEducational.SelectedValue = this.StaffEntity.Educational.Value;
  228. }
  229. this.txtGraduated.Text = string.IsNullOrEmpty(this.StaffEntity.Graduated) ? string.Empty : this.StaffEntity.Graduated;
  230. this.txtSpecialField.Text = string.IsNullOrEmpty(this.StaffEntity.SpecialField) ? string.Empty : this.StaffEntity.SpecialField;
  231. this.txtTelephone.Text = string.IsNullOrEmpty(this.StaffEntity.Telephone) ? string.Empty : this.StaffEntity.Telephone;
  232. }
  233. #endregion
  234. }
  235. #endregion
  236. #region 私有方法
  237. /// <summary>
  238. /// 数据检查处理验证
  239. /// </summary>
  240. /// <returns>True 验证通过 False 验证不通过</returns>
  241. private bool IsInputValid()
  242. {
  243. if (cBoxBirthday.Checked)
  244. {
  245. DateTime dtBegin = this.dtPBirthdayBegin.Value;
  246. DateTime dtEnd = this.dtPBirthdayEnd.Value;
  247. if (dtBegin == null)
  248. {
  249. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "开始时间"),
  250. this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1);
  251. this.dtPBirthdayBegin.Focus();
  252. return false;
  253. }
  254. if (dtEnd == null)
  255. {
  256. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "结束时间"),
  257. this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1);
  258. this.dtPBirthdayEnd.Focus();
  259. return false;
  260. }
  261. if (dtBegin > dtEnd)
  262. {
  263. MessageBox.Show(string.Format(Messages.MSG_CMN_W014, "开始时间", "结束时间"),
  264. this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1);
  265. this.dtPBirthdayEnd.Focus();
  266. return false;
  267. }
  268. }
  269. return true;
  270. }
  271. /// <summary>
  272. /// 设置窗体按钮的文本信息
  273. /// </summary>
  274. private void SetFromTitleInfo()
  275. {
  276. this.Text = FormTitles.F_HR_CMN_001;
  277. this.btnOK.Text = ButtonText.BTN_OK;
  278. this.btnClose.Text = ButtonText.BTN_CANCEL;
  279. }
  280. #endregion
  281. }
  282. }