/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_HR_1102.cs * 2.功能描述:行政奖惩新建/编辑 * 编辑履历: * 作者 日期 版本 修改内容 * 张国印 2014/09/25 1.00 新建 *******************************************************************************/ using System; using System.Collections.Generic; using System.Data; using System.Windows.Forms; using Dongke.IBOSS.PRD.Basics.BaseControls; using Dongke.IBOSS.PRD.Basics.BaseResources; using Dongke.IBOSS.PRD.Client.CommonModule; using Dongke.IBOSS.PRD.Client.DataModels; using Dongke.IBOSS.PRD.WCF.DataModels; using Dongke.IBOSS.PRD.WCF.Proxys; using Dongke.IBOSS.PRD.WCF.Proxys.HRModuleService; namespace Dongke.IBOSS.PRD.Client.HRModule { /// /// 行政奖惩新建/编辑 /// public partial class F_HR_1102 : FormBase { #region 成员变量 // 窗体状态的枚举 新建/编辑 private Constant.FormMode _editStatus; //行政奖惩编号 private int _staffRAPID; // 新建的ID集合 private List _staffIDList = new List(); //时间戳 private DateTime? _oPTimeStamp; #endregion #region 构造函数 /// /// 构造函数 /// /// /// public F_HR_1102(Constant.FormMode editStatus, int pRapID) { InitializeComponent(); this._editStatus = editStatus; this._staffRAPID = pRapID; this.dkUserName.WhereCondition = "(StaffStatus = 1 Or StaffStatus = 2) AND ValueFlag = 1"; this.txtRAPAmount.Text = "0"; this.SetFromTitleInfo(); } #endregion #region 属性 /// /// ID集合 /// public List StaffIDList { get { return _staffIDList; } set { _staffIDList = value; } } #endregion #region 事件 /// /// 页面加载事件 /// /// /// private void F_HR_1102_Load(object sender, EventArgs e) { try { #region 绑定数据源 this.comRAPType.DataSource = GetRAPTypeInfo(); this.comRAPType.DisplayMember = "TypeName"; this.comRAPType.ValueMember = "TypeID"; this.comAdministrationType.DataSource = DataDictionaryInfo(); this.comAdministrationType.DisplayMember = "DictionaryValue"; this.comAdministrationType.ValueMember = "DictionaryID"; #endregion FormPermissionManager.FormPermissionControl(this.Name, this, LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData); if (this._editStatus == Constant.FormMode.Edit) { // 获取用户信息数据集 DataSet staffInfoData = (DataSet)DoAsync(new BaseAsyncMethod(this.GetDataGridViewInfo)); if (staffInfoData != null && staffInfoData.Tables.Count > 0 && staffInfoData.Tables[0].Rows.Count > 0) { #region 为控件赋值 this.dkUserName.UserID = Convert.ToInt32(staffInfoData.Tables[0].Rows[0]["StaffID"]); this.dkUserName.UserCode = staffInfoData.Tables[0].Rows[0]["StaffCode"].ToString().Trim(); this.dkUserName.UserName = staffInfoData.Tables[0].Rows[0]["StaffName"].ToString().Trim(); string strRAPType = staffInfoData.Tables[0].Rows[0]["RAPType"].ToString().Trim(); if (!string.IsNullOrEmpty(strRAPType)) { this.comRAPType.SelectedValue = strRAPType; } string strRapDate = staffInfoData.Tables[0].Rows[0]["RAPDate"].ToString().Trim(); if (!string.IsNullOrEmpty(strRapDate)) { this.dtpRAPDate.Value = Convert.ToDateTime(strRapDate); } this.txtRAPAmount.Text = staffInfoData.Tables[0].Rows[0]["RAPAmount"].ToString().Trim(); this.txtReason.Text = staffInfoData.Tables[0].Rows[0]["Reason"].ToString().Trim(); string strAdministrationType = staffInfoData.Tables[0].Rows[0]["AdministrationType"].ToString().Trim(); if (!string.IsNullOrEmpty(strAdministrationType)) { this.comAdministrationType.SelectedValue = strAdministrationType; } this.txtRemarks.Text = staffInfoData.Tables[0].Rows[0]["Remarks"].ToString().Trim(); this._oPTimeStamp = Convert.ToDateTime(staffInfoData.Tables[0].Rows[0]["OPTIMESTAMP"]); string strAuditStatus = staffInfoData.Tables[0].Rows[0]["AUDITSTATUS"].ToString(); if (!Constant.ApprovalStatus.Pending.GetHashCode().ToString().Equals(strAuditStatus))//非待审批 { //设置非待审核的履历控件禁用 this.SetControlEnable(); } #endregion } else { //设置非待审核的履历控件禁用 this.SetControlEnable(); } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 保存按钮 /// /// /// private void btnSave_Click(object sender, EventArgs e) { try { if (IsInputValid()) { HRAdminRAPEntity tempRecord = SetStaffRecordEntity(); HRResultEntity resultStaff = (HRResultEntity)DoAsync(new BaseAsyncMethod(() => { if (_editStatus == Constant.FormMode.Add) { return WCF.Proxys.HRModuleProxy.Service.SaveStaffAdminRAPInfo(tempRecord, WCFConstant.FormMode.Add); } else if (_editStatus == Constant.FormMode.Edit) { return WCF.Proxys.HRModuleProxy.Service.SaveStaffAdminRAPInfo(tempRecord, WCFConstant.FormMode.Edit); } return 0; })); if (resultStaff.OperateStatus > Constant.INT_IS_ZERO) { // 提示信息 MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "行政奖惩", "保存"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); this._staffIDList.Add(resultStaff.HRStaffID); if (_editStatus == Constant.FormMode.Add) { this.InitializationForm();//清空输入项 } else { this.btnCancel_Click(sender, e); //关闭窗体 } } else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_ONE) { // 提示信息 MessageBox.Show(string.Format(Messages.MSG_HR_W003, "行政奖惩"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_TWO) { // 提示信息 MessageBox.Show(Messages.MSG_CMN_W012, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { // 提示信息 MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "行政奖惩", "保存"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 取消按钮 /// /// /// private void btnCancel_Click(object sender, EventArgs e) { if (this._staffIDList != null && this._staffIDList.Count > 0) { this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { this.DialogResult = System.Windows.Forms.DialogResult.Cancel; } } #endregion #region 私有方法 /// /// 设置窗体按钮的文本信息 /// private void SetFromTitleInfo() { if (this._editStatus == Constant.FormMode.Add) { this.Text = FormTitles.F_HR_1102_ADD; this.dkUserName.Enabled = true; this._oPTimeStamp = null; this.dtpRAPDate.Value = DateTime.Now; } else if (this._editStatus == Constant.FormMode.Edit) { this.Text = FormTitles.F_HR_1102_EDIT; this.dkUserName.Enabled = false; } this.btnSave.Text = ButtonText.BTN_SAVE; this.btnCancel.Text = ButtonText.BTN_CLOSE; } /// /// 获取奖惩类型数据源 /// /// private DataTable GetRAPTypeInfo() { //1:奖励;-1:惩罚 DataTable dtRAPType = new DataTable(); dtRAPType.Columns.Add("TypeID"); dtRAPType.Columns.Add("TypeName"); DataRow newRowType = dtRAPType.NewRow(); newRowType["TypeID"] = "1"; newRowType["TypeName"] = "奖励"; dtRAPType.Rows.Add(newRowType); newRowType = dtRAPType.NewRow(); newRowType["TypeID"] = "-1"; newRowType["TypeName"] = "惩罚"; dtRAPType.Rows.Add(newRowType); return dtRAPType; } /// /// 获取行政考核类别数据源 /// /// public DataTable DataDictionaryInfo() { DataTable dtDicInfo = (DataTable)DoAsync(new BaseAsyncMethod(() => { return CommonModuleProxy.Service.GetDataDictionaryByType(Constant.ASE_ASE001); })); return dtDicInfo; } /// /// 根据查询条件获取要显示的数据 /// /// 返回查询的结果集 private DataSet GetDataGridViewInfo() { SearchAdminRAPEntity searchAdminRAPEntity = new SearchAdminRAPEntity(); searchAdminRAPEntity.ValueFlag = Constant.ValueFlag.Effective.GetHashCode().ToString(); searchAdminRAPEntity.IDList = new int[] { _staffRAPID }; return HRModuleProxy.Service.SearcStaffAdminRAPInfo(searchAdminRAPEntity); } /// /// 设置非待审核的履历控件禁用 /// private void SetControlEnable() { this.dkUserName.Enabled = false; this.comRAPType.Enabled = false; this.dtpRAPDate.Enabled = false; this.txtRAPAmount.Enabled = false; this.txtReason.Enabled = false; this.comAdministrationType.Enabled = false; this.txtRemarks.Enabled = false; this.btnSave.Enabled = false; } /// /// 检查页面的输入项目 /// /// /// /// private bool IsInputValid() { if (this.dkUserName.UserID == null) { MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "员工姓名"), this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1); this.dkUserName.Focus(); return false; } else if (string.IsNullOrEmpty(this.txtRAPAmount.Text)) { MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "奖惩金额"), this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1); this.txtRAPAmount.Focus(); return false; } else if (string.IsNullOrEmpty(this.txtReason.Text)) { MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "奖惩原因"), this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1); this.txtReason.Focus(); return false; } else { return true; } } /// /// 根据页面输入值,对实体赋值 /// /// private HRAdminRAPEntity SetStaffRecordEntity() { HRAdminRAPEntity staffRecordEntity = new HRAdminRAPEntity(); staffRecordEntity.RAPID = this._staffRAPID; staffRecordEntity.StaffID = this.dkUserName.UserID.Value; staffRecordEntity.RAPType = Convert.ToDouble(this.comRAPType.SelectedValue); staffRecordEntity.Reason = this.txtReason.Text; staffRecordEntity.RAPDate = this.dtpRAPDate.Value; staffRecordEntity.RAPAmount = Convert.ToDouble(this.txtRAPAmount.Text); if (this.comAdministrationType.SelectedValue != null) { staffRecordEntity.AdministrationType = Convert.ToInt32(this.comAdministrationType.SelectedValue); } staffRecordEntity.Remarks = this.txtRemarks.Text; staffRecordEntity.AuditStatus = Constant.ApprovalStatus.Pending.GetHashCode(); staffRecordEntity.ValueFlag = Constant.ValueFlag.Effective.GetHashCode(); if (this._oPTimeStamp != null) { staffRecordEntity.OPTimeStamp = this._oPTimeStamp.Value; } return staffRecordEntity; } /// /// 清空输入项 /// private void InitializationForm() { this.dkUserName.UserID = null; this.dkUserName.UserCode = string.Empty; this.dkUserName.UserName = string.Empty; this.dkUserName.StaffEntity = null; this.comRAPType.SelectedIndex = 0; this.dtpRAPDate.Value = DateTime.Now; this.txtRAPAmount.Text = "0"; this.txtReason.Text = string.Empty; if (this.comAdministrationType.SelectedValue != null) { this.comAdministrationType.SelectedIndex = 0; } this.txtRemarks.Text = string.Empty; } #endregion } }