/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_PM_1105.cs * 2.功能描述:进度考核奖惩新建/编辑 * 编辑履历: * 作者 日期 版本 修改内容 * 张国印 2014/10/9 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.PMModuleService; namespace Dongke.IBOSS.PRD.Client.PMModule { /// /// 进度考核奖惩新建/编辑 /// public partial class F_PM_1105 : FormBase { #region 成员变量 // 窗体状态的枚举 新建/编辑 private Constant.FormMode _editStatus; //行政奖惩编号 private int _staffRAPID; // 新建的ID集合 private List _staffIDList = new List(); //时间戳 private DateTime? _oPTimeStamp; #endregion #region 构造函数 /// /// 构造函数 /// /// /// public F_PM_1105(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_PM_1105_Load(object sender, EventArgs e) { try { #region 绑定数据源 this.comRAPType.DataSource = GetRAPTypeInfo(); this.comRAPType.DisplayMember = "TypeName"; this.comRAPType.ValueMember = "TypeID"; #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 > Constant.INT_IS_ZERO && staffInfoData.Tables[0].Rows.Count > Constant.INT_IS_ZERO) { #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(); 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()) { PMProgressRAPEntity tempRecord = SetStaffRecordEntity(); PMResultEntity resultStaff = (PMResultEntity)DoAsync(new BaseAsyncMethod(() => { if (_editStatus == Constant.FormMode.Add) { return WCF.Proxys.PMModuleProxy.Service.SaveStaffProgressRAPInfo(tempRecord, WCFConstant.FormMode.Add); } else if (_editStatus == Constant.FormMode.Edit) { return WCF.Proxys.PMModuleProxy.Service.SaveStaffProgressRAPInfo(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.OperateKey); 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 > Constant.INT_IS_ZERO) { 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_PM_1105_ADD; this.dkUserName.Enabled = true; this._oPTimeStamp = null; this.dtpRAPDate.Value = DateTime.Now; } else if (this._editStatus == Constant.FormMode.Edit) { this.Text = FormTitles.F_PM_1105_EDIT; this.dkUserName.Enabled = false; } this.btnSave.Text = ButtonText.BTN_SAVE; this.btnCancel.Text = ButtonText.BTN_CANCEL; } /// /// 获取奖惩类型数据源 /// /// 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; } /// /// 根据查询条件获取要显示的数据 /// /// 返回查询的结果集 private DataSet GetDataGridViewInfo() { SearchProgressRAPEntity searchProgressRAPEntity = new SearchProgressRAPEntity(); searchProgressRAPEntity.IDList = new int[] { _staffRAPID }; searchProgressRAPEntity.ValueFlag = Constant.ValueFlag.Effective.GetHashCode().ToString(); return PMModuleProxy.Service.SearcStaffAdminRAPInfo(searchProgressRAPEntity); } /// /// 设置非待审核的履历控件禁用 /// private void SetControlEnable() { this.dkUserName.Enabled = false; this.comRAPType.Enabled = false; this.dtpRAPDate.Enabled = false; this.txtRAPAmount.Enabled = false; this.txtReason.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 PMProgressRAPEntity SetStaffRecordEntity() { PMProgressRAPEntity staffRecordEntity = new PMProgressRAPEntity(); 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); 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; this.txtRemarks.Text = string.Empty; } #endregion } }