| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378 |
- /*******************************************************************************
- * 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
- {
- /// <summary>
- /// 进度考核奖惩新建/编辑
- /// </summary>
- public partial class F_PM_1105 : FormBase
- {
- #region 成员变量
- // 窗体状态的枚举 新建/编辑
- private Constant.FormMode _editStatus;
- //行政奖惩编号
- private int _staffRAPID;
- // 新建的ID集合
- private List<int> _staffIDList = new List<int>();
- //时间戳
- private DateTime? _oPTimeStamp;
- #endregion
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="editStatus"></param>
- /// <param name="pRapID"></param>
- 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 属性
- /// <summary>
- /// ID集合
- /// </summary>
- public List<int> StaffIDList
- {
- get
- {
- return _staffIDList;
- }
- set
- {
- _staffIDList = value;
- }
- }
- #endregion
- #region 事件
- /// <summary>
- /// 页面加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- }
- /// <summary>
- /// 保存按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- }
- /// <summary>
- /// 取消按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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 私有方法
- /// <summary>
- /// 设置窗体按钮的文本信息
- /// </summary>
- 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;
- }
- /// <summary>
- /// 获取奖惩类型数据源
- /// </summary>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 根据查询条件获取要显示的数据
- /// </summary>
- /// <returns>返回查询的结果集</returns>
- private DataSet GetDataGridViewInfo()
- {
- SearchProgressRAPEntity searchProgressRAPEntity = new SearchProgressRAPEntity();
- searchProgressRAPEntity.IDList = new int[] { _staffRAPID };
- searchProgressRAPEntity.ValueFlag = Constant.ValueFlag.Effective.GetHashCode().ToString();
- return PMModuleProxy.Service.SearcStaffAdminRAPInfo(searchProgressRAPEntity);
- }
- /// <summary>
- /// 设置非待审核的履历控件禁用
- /// </summary>
- 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;
- }
- /// <summary>
- /// 检查页面的输入项目
- /// </summary>
- /// <remarks>
- /// </remarks>
- /// <returns></returns>
- 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;
- }
- }
- /// <summary>
- /// 根据页面输入值,对实体赋值
- /// </summary>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 清空输入项
- /// </summary>
- 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
- }
- }
|