| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PAM_0502.cs
- * 2.功能描述:行政奖惩新建/编辑
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 张国印 2014/09/25 1.00 新建
- *******************************************************************************/
- using System;
- 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.Controls;
- using Dongke.IBOSS.PRD.Client.DataModels;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- namespace Dongke.IBOSS.PRD.Client.HRModule
- {
- /// <summary>
- /// 行政奖惩新建/编辑
- /// </summary>
- public partial class F_PAM_0502 : DKFormBase
- {
- #region 成员变量
- // 窗体状态的枚举 新建/编辑
- private Constant.FormMode _editStatus;
- //行政奖惩编号
- private int _adminEXAID;
- // 编辑数据
- private DataTable _data;
- #endregion
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="editStatus"></param>
- /// <param name="pRapID"></param>
- public F_PAM_0502()
- : this(Constant.FormMode.Add, 0)
- {
- }
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="editStatus"></param>
- /// <param name="pRapID"></param>
- public F_PAM_0502(Constant.FormMode editStatus, int adminEXAID)
- {
- InitializeComponent();
- this._editStatus = editStatus;
- this._adminEXAID = adminEXAID;
- this.dkUserName.WhereCondition = "(StaffStatus = 1 Or StaffStatus = 2) AND ValueFlag = 1";
- //this.txtRAPAmount.Text = "0";
- this.SetFromTitleInfo();
- }
- #endregion
- #region 属性
- #endregion
- #region 事件
- /// <summary>
- /// 页面加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_HR_1102_Load(object sender, EventArgs e)
- {
- try
- {
- #region 绑定数据源
- 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)
- {
- // 获取用户信息数据集
- ServiceResultEntity srData = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(this.GetDataInfo));
- if (srData.Status == Constant.ServiceResultStatus.Success)
- {
- _data = srData.Data.Tables[0];
- DataRow info = _data.Rows[0];
- this.dkUserName.UserID = Convert.ToInt32(info["StaffID"]);
- this.dkUserName.UserCode = info["StaffCode"].ToString().Trim();
- this.dkUserName.UserName = info["StaffName"].ToString().Trim();
- this.dtpRAPDate.Value = Convert.ToDateTime(info["CreateTime"]);
- this.txtRAPAmount.DataValue = Convert.ToDecimal(info["Amount"]);
- this.comAdministrationType.SelectedValue = Convert.ToInt32(info["AdminEXATypeID"]);
- this.txtRemarks.Text = info["Remarks"].ToString();
- }
- }
- }
- 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())
- {
- return ;
- }
- if (_editStatus == Constant.FormMode.Add)
- {
- AdminEXAEntity se = SetStaffRecordEntity();
- ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PAMModuleProxy.Service.AddAdminEXA(se);
- }
- );
- if (sre.Status == Constant.ServiceResultStatus.Success)
- {
- DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
- }
- }
- else
- {
- DataRow info = _data.Rows[0];
- info["StaffID"] = this.dkUserName.UserID;
- info["Amount"] = this.txtRAPAmount.DataValue;
- info["AdminEXATypeID"] = this.comAdministrationType.SelectedValue;
- info["Remarks"] = this.txtRemarks.Text;
- ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PAMModuleProxy.Service.EditAdminEXA(_data);
- }
- );
- if (sre.Status == Constant.ServiceResultStatus.Success)
- {
- DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
- }
- else
- {
- DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, "数据已被修改");
- }
- }
- this.Close();
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 设置窗体按钮的文本信息
- /// </summary>
- private void SetFromTitleInfo()
- {
- if (this._editStatus == Constant.FormMode.Add)
- {
- this.Text = FormTitles.F_PAM_0502_ADD;
- this.dkUserName.Enabled = true;
- }
- else if (this._editStatus == Constant.FormMode.Edit)
- {
- this.Text = FormTitles.F_PAM_0502_EDIT;
- this.dkUserName.Enabled = false;
- }
- this.dtpRAPDate.Value = DateTime.Now;
- this.btnSave.Text = ButtonText.BTN_SAVE;
- this.btnCancel.Text = ButtonText.BTN_CLOSE;
- }
- /// <summary>
- /// 获取行政考核类别数据源
- /// </summary>
- /// <returns></returns>
- public DataTable DataDictionaryInfo()
- {
- DataTable dtDicInfo = (DataTable)DoAsync(new BaseAsyncMethod(() =>
- {
- return CommonModuleProxy.Service.GetDataDictionaryByType(Constant.ASE_ASE001);
- }));
- return dtDicInfo;
- }
- /// <summary>
- /// 根据查询条件获取要显示的数据
- /// </summary>
- /// <returns>返回查询的结果集</returns>
- private ServiceResultEntity GetDataInfo()
- {
- return PAMModuleProxy.Service.GetAdminEXAByID(_adminEXAID);
- }
- /// <summary>
- /// 设置非待审核的履历控件禁用
- /// </summary>
- private void SetControlEnable()
- {
- this.dkUserName.Enabled = false;
- this.dtpRAPDate.Enabled = false;
- this.txtRAPAmount.Enabled = false;
- this.comAdministrationType.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 (this.comAdministrationType.SelectedValue == null)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "考核类别"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- this.comAdministrationType.Focus();
- return false;
- }
- else
- {
- return true;
- }
- }
- /// <summary>
- /// 根据页面输入值,对实体赋值
- /// </summary>
- /// <returns></returns>
- private AdminEXAEntity SetStaffRecordEntity()
- {
- AdminEXAEntity staffRecordEntity = new AdminEXAEntity();
- staffRecordEntity.StaffID = this.dkUserName.UserID.Value;
- staffRecordEntity.Amount = this.txtRAPAmount.DataValue.Value;
- if (this.comAdministrationType.SelectedValue != null)
- {
- staffRecordEntity.AdminEXATypeID = Convert.ToInt32(this.comAdministrationType.SelectedValue);
- }
- staffRecordEntity.Remarks = this.txtRemarks.Text;
- 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.dtpRAPDate.Value = DateTime.Now;
- this.txtRAPAmount.Text = "0";
- if (this.comAdministrationType.SelectedValue != null)
- {
- this.comAdministrationType.SelectedIndex = 0;
- }
- this.txtRemarks.Text = string.Empty;
- }
- #endregion
- }
- }
|