/*******************************************************************************
* 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
{
///
/// 人力资源模块的通用查询页面
///
public partial class HR_CMN_001 : FormBase
{
# region 成员变量
//员工档案实体
private HR_CMN_StaffEntity _staffEntity = new HR_CMN_StaffEntity();
#endregion
#region 属性
///
/// 当前员工实体
///
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 事件处理
///
/// 确定按钮
///
///
///
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;
}
}
///
/// 关闭按钮
///
///
///
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 生日 选中框变更事件
///
///
///
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;
}
}
///
/// 页面加载事件
///
///
///
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 私有方法
///
/// 数据检查处理验证
///
/// True 验证通过 False 验证不通过
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;
}
///
/// 设置窗体按钮的文本信息
///
private void SetFromTitleInfo()
{
this.Text = FormTitles.F_HR_CMN_001;
this.btnOK.Text = ButtonText.BTN_OK;
this.btnClose.Text = ButtonText.BTN_CANCEL;
}
#endregion
}
}