| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:HR_CMN_001.cs
- * 2.功能描述:人力资源模块的通用查询页面
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 张国印 2014/09/09 1.00 新建
- *******************************************************************************/
- using System;
- using System.Data;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Client.DataModels;
- namespace Dongke.IBOSS.PRD.Basics.BaseControls
- {
- /// <summary>
- /// 人力资源模块的通用查询页面
- /// </summary>
- public partial class HR_CMN_001 : FormBase
- {
- # region 成员变量
- //员工档案实体
- private HR_CMN_StaffEntity _staffEntity = new HR_CMN_StaffEntity();
- #endregion
- #region 属性
- /// <summary>
- /// 当前员工实体
- /// </summary>
- public HR_CMN_StaffEntity StaffEntity
- {
- get { return _staffEntity; }
- set { _staffEntity = value; }
- }
- #endregion
- #region 构造函数
- public HR_CMN_001()
- {
- InitializeComponent();
- SetFromTitleInfo();
- try
- {
- #region 绑定数据源
- DataTable dtT_SYS_Gender = LogInUserInfo.CurrentUser.GetSystemParameterByName(BaseResources.Constant.SysCacheTable.TP_SYS_Gender, "displayno ASC");
- this.dropGender.DisplayMember = "GenderName";
- this.dropGender.ValueMember = "GenderCode";
- this.dropGender.DataSource = dtT_SYS_Gender;
- DataTable dtT_SYS_MaritalStatus = LogInUserInfo.CurrentUser.GetSystemParameterByName(BaseResources.Constant.SysCacheTable.TP_SYS_MaritalStatus, "displayno ASC");
- this.dropMaritalStatus.DisplayMember = "maritalstatusname";
- this.dropMaritalStatus.ValueMember = "maritalstatusid";
- this.dropMaritalStatus.DataSource = dtT_SYS_MaritalStatus;
- DataTable dtT_SYS_National = LogInUserInfo.CurrentUser.GetSystemParameterByName(BaseResources.Constant.SysCacheTable.TP_SYS_National, "displayno ASC");
- this.dropNational.DisplayMember = "nationalname";
- this.dropNational.ValueMember = "nationalid";
- this.dropNational.DataSource = dtT_SYS_National;
- DataTable dtT_SYS_Educational = LogInUserInfo.CurrentUser.GetSystemParameterByName(BaseResources.Constant.SysCacheTable.TP_SYS_Educational, "displayno ASC");
- this.dropEducational.DisplayMember = "educationalname";
- this.dropEducational.ValueMember = "educationalid";
- this.dropEducational.DataSource = dtT_SYS_Educational;
- #endregion
- this.dtPBirthdayBegin.Value = Convert.ToDateTime(DateTime.Now.Date.ToString("yyyy-MM-dd"));
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- #region 事件处理
- /// <summary>
- /// 确定按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnOK_Click(object sender, EventArgs e)
- {
- try
- {
- if (!IsInputValid())
- {
- return;
- }
- this.StaffEntity.ClearEntityValue();
- #region 为条件实体赋值
- this.StaffEntity.IDCardNo = string.IsNullOrEmpty(this.txtIDCardNo.Text.Trim()) ? string.Empty : this.txtIDCardNo.Text.Trim();
- this.StaffEntity.IsCheckBirthday = this.cBoxBirthday.Checked;
- if (this.cBoxBirthday.Checked)
- {
- string strBegin = this.dtPBirthdayBegin.Value.ToString("yyyy-MM-dd") + " 0:0:0";
- string strEnd = this.dtPBirthdayEnd.Value.AddDays(1).ToString("yyyy-MM-dd") + " 0:0:0";
- this.StaffEntity.StartBirthday = Convert.ToDateTime(strBegin);
- this.StaffEntity.EndBirthday = Convert.ToDateTime(strEnd);
- }
- if (this.dropGender.SelectedValue != null)
- {
- string strGenderName = this.dropGender.Text.Trim();
- string strGenderValue = this.dropGender.SelectedValue.ToString().Trim();
- if (!string.IsNullOrEmpty(strGenderValue))
- {
- this.StaffEntity.Gender = strGenderValue;
- this.StaffEntity.GenderName = strGenderName;
- }
- }
- if (this.dropMaritalStatus.SelectedValue != null)
- {
- string strMaritalStatusName = this.dropMaritalStatus.Text.Trim();
- string strMaritalStatusValue = this.dropMaritalStatus.SelectedValue.ToString().Trim();
- if (!string.IsNullOrEmpty(strMaritalStatusValue))
- {
- this.StaffEntity.MaritalStatus = Convert.ToInt32(strMaritalStatusValue);
- this.StaffEntity.MaritalStatusName = strMaritalStatusName;
- }
- }
- string strHomeTown = this.txtHomeTown.Text.Trim();
- if (!string.IsNullOrEmpty(strHomeTown))
- {
- this.StaffEntity.HomeTown = strHomeTown;
- }
- string strPolicitalStatus = this.txtPolicitalStatus.Text.Trim();
- if (!string.IsNullOrEmpty(strPolicitalStatus))
- {
- this.StaffEntity.PolicitalStatus = strPolicitalStatus;
- }
- if (this.dropNational.SelectedValue != null)
- {
- string strNationalName = this.dropNational.Text.Trim();
- string strNationalValue = this.dropNational.SelectedValue.ToString().Trim();
- if (!string.IsNullOrEmpty(strNationalValue))
- {
- this.StaffEntity.National = Convert.ToInt32(strNationalValue);
- this.StaffEntity.NationalName = strNationalName;
- }
- }
- if (this.dropEducational.SelectedValue != null)
- {
- string strEducationalName = this.dropEducational.Text.Trim();
- string strEducationalValue = this.dropEducational.SelectedValue.ToString().Trim();
- if (!string.IsNullOrEmpty(strEducationalValue))
- {
- this.StaffEntity.Educational = Convert.ToInt32(strEducationalValue);
- this.StaffEntity.EducationalName = strEducationalName;
- }
- }
- string strGraduated = this.txtGraduated.Text.Trim();
- if (!string.IsNullOrEmpty(strGraduated))
- {
- this.StaffEntity.Graduated = strGraduated;
- }
- string strSpecialField = this.txtSpecialField.Text.Trim();
- if (!string.IsNullOrEmpty(strSpecialField))
- {
- this.StaffEntity.SpecialField = strSpecialField;
- }
- string strTelephone = this.txtTelephone.Text.Trim();
- if (!string.IsNullOrEmpty(strTelephone))
- {
- this.StaffEntity.Telephone = strTelephone;
- }
- #endregion
- this.DialogResult = System.Windows.Forms.DialogResult.OK;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 关闭按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 生日 选中框变更事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void cBoxBirthday_CheckedChanged(object sender, EventArgs e)
- {
- if (this.cBoxBirthday.Checked)
- {
- this.dtPBirthdayBegin.Enabled = true;
- this.dtPBirthdayEnd.Enabled = true;
- }
- else
- {
- this.dtPBirthdayBegin.Enabled = false;
- this.dtPBirthdayEnd.Enabled = false;
- }
- }
- /// <summary>
- /// 页面加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void HR_CMN_001_Load(object sender, EventArgs e)
- {
- #region 设置条件的值
- if (StaffEntity != null)
- {
- this.txtIDCardNo.Text = string.IsNullOrEmpty(this.StaffEntity.IDCardNo) ? string.Empty : this.StaffEntity.IDCardNo;
- if (this.StaffEntity.IsCheckBirthday)
- {
- this.cBoxBirthday.Checked = true;
- this.dtPBirthdayBegin.Value = this.StaffEntity.StartBirthday.Value;
- this.dtPBirthdayEnd.Value = this.StaffEntity.EndBirthday.Value.AddDays(-1);
- }
- if (!string.IsNullOrEmpty(this.StaffEntity.Gender))
- {
- this.dropGender.SelectedValue = this.StaffEntity.Gender;
- }
- if (this.StaffEntity.MaritalStatus != null)
- {
- this.dropMaritalStatus.SelectedValue = this.StaffEntity.MaritalStatus.Value;
- }
- this.txtHomeTown.Text = string.IsNullOrEmpty(this.StaffEntity.HomeTown) ? string.Empty : this.StaffEntity.HomeTown;
- this.txtPolicitalStatus.Text = string.IsNullOrEmpty(this.StaffEntity.PolicitalStatus) ? string.Empty : this.StaffEntity.PolicitalStatus;
- if (this.StaffEntity.National != null)
- {
- this.dropNational.SelectedValue = this.StaffEntity.National.Value;
- }
- if (this.StaffEntity.Educational != null)
- {
- this.dropEducational.SelectedValue = this.StaffEntity.Educational.Value;
- }
- this.txtGraduated.Text = string.IsNullOrEmpty(this.StaffEntity.Graduated) ? string.Empty : this.StaffEntity.Graduated;
- this.txtSpecialField.Text = string.IsNullOrEmpty(this.StaffEntity.SpecialField) ? string.Empty : this.StaffEntity.SpecialField;
- this.txtTelephone.Text = string.IsNullOrEmpty(this.StaffEntity.Telephone) ? string.Empty : this.StaffEntity.Telephone;
- }
- #endregion
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 数据检查处理验证
- /// </summary>
- /// <returns>True 验证通过 False 验证不通过</returns>
- private bool IsInputValid()
- {
- if (cBoxBirthday.Checked)
- {
- DateTime dtBegin = this.dtPBirthdayBegin.Value;
- DateTime dtEnd = this.dtPBirthdayEnd.Value;
- if (dtBegin == null)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "开始时间"),
- this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1);
- this.dtPBirthdayBegin.Focus();
- return false;
- }
- if (dtEnd == null)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "结束时间"),
- this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1);
- this.dtPBirthdayEnd.Focus();
- return false;
- }
- if (dtBegin > dtEnd)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W014, "开始时间", "结束时间"),
- this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1);
- this.dtPBirthdayEnd.Focus();
- return false;
- }
- }
- return true;
- }
- /// <summary>
- /// 设置窗体按钮的文本信息
- /// </summary>
- private void SetFromTitleInfo()
- {
- this.Text = FormTitles.F_HR_CMN_001;
- this.btnOK.Text = ButtonText.BTN_OK;
- this.btnClose.Text = ButtonText.BTN_CANCEL;
- }
- #endregion
- }
- }
|