| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_TAT_0301.cs
- * 2.功能描述:基本工资策略明细
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 任海 2014/12/12 1.00 新建
- *******************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- 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.Basics.Library;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
- using Dongke.IBOSS.PRD.WCF.Proxys.TATModuleService;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- namespace Dongke.IBOSS.PRD.Client.TATModule
- {
- /// <summary>
- /// 基本工资策略明细
- /// </summary>
- public partial class F_TAT_0302 : FormBase
- {
- #region 成员变量
- // 窗体模式ID
- private Constant.FormMode _formType;
- // 操作实体ID
- private int? _entityId;
- // 操作实体名称
- private string _entityname;
- // 操作实体
- private BasicSalaryEntity _basicSalaryEntity = new BasicSalaryEntity();
- // 选择窗体弹出标识
- private bool _showFlag = true;
- // 数据源
- private DataSet _dsSourse;
- // 窗体加载完毕标识
- private bool _pageLoadOK = false;
- #endregion
- #region 构造函数
- /// <summary>
- /// 窗体构造
- /// </summary>
- /// <param name="formType">窗体开启模式</param>
- /// <param name="entityId">操作实体ID</param>
- public F_TAT_0302(Constant.FormMode formType, int entityId, string entityname)
- {
- InitializeComponent();
- this._formType = formType;
- this._entityId = entityId;
- this._entityname = entityname;
- }
- #endregion
- #region 事件处理
- /// <summary>
- /// 窗体加载
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_TAT_0302_Load(object sender, EventArgs e)
- {
- try
- {
- this.lblBasicSalaryDetail.Text = "当前选择的策略名称:" + _entityname;
- this.dgvBasicSalaryDetail.AutoGenerateColumns = false;
- //绑定工种信息
- this.BindJobs();
- this.dgvBasicSalaryDetail.IsSetInputColumnsColor = true;
- //页面加载完毕
- this._pageLoadOK = true;
- //如果是审核及观看模式
- if (this._formType == Constant.FormMode.Display)
- {
- //列表设置为只读
- this.dgvBasicSalaryDetail.ReadOnly = true;
- this.dgvBasicSalaryDetail.IsSetInputColumnsColor = false;
- this.dgvBasicSalaryDetail.AllowUserToDeleteRows = false;
- //控件除关闭外全部不可用
- this.btnSave.Enabled = false;
- }
- }
- 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
- {
- int results = Conservation();
- if (results == Constant.INT_IS_ONE)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "工种编码"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.btnSave.Enabled = false;
- return;
- }
- if (results == Constant.INT_IS_TWO)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "基本工资"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.btnSave.Enabled = false;
- return;
- }
- if (results == Constant.INT_IS_THREE)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "补贴"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.btnSave.Enabled = false;
- return;
- }
- if (results == Constant.INT_IS_FOUR)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "保底工资"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.btnSave.Enabled = false;
- return;
- }
- //提交操作
- ServiceResultEntity srEntity =
- (ServiceResultEntity)DoAsync(() =>
- {
- return TATModuleProxy.Service.EditBasicSalaryDetail(Convert.ToInt32(this._entityId), _dsSourse);
- });
- ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
- if (srEntity.Status == Constant.ServiceResultStatus.Success)
- {
- this.DialogResult = DialogResult.OK;
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- private void dgvBasicSalaryDetail_CellValueChanged(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- //变更后重新加载
- this._pageLoadOK = false;
- if (this.dgvBasicSalaryDetail.Rows.Count <= 1 || !this._showFlag)
- {
- return;
- }
- DataGridViewRow rowItem = this.dgvBasicSalaryDetail.Rows[e.RowIndex];
- DataGridViewColumn columnItem = this.dgvBasicSalaryDetail.Columns[e.ColumnIndex];
- if (columnItem.Name == "JobsCode")
- {
- //打开多选页面进行值绑定
- this._showFlag = false;
- FormUtility.BindJobsRowDataSource(this.dgvBasicSalaryDetail,
- e.RowIndex, columnItem.Name, string.Empty);
- this._showFlag = true;
- }
- //加载OK
- this._pageLoadOK = true;
- // 设置可输入单元格的颜色
- this.dgvBasicSalaryDetail.IsSetInputColumnsColor = true;
- }
- 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 dgvBasicSalaryDetail_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
- {
- try
- {
- // 按Esc键时不校验
- if (!dgvBasicSalaryDetail.IsCurrentRowDirty)
- {
- this.dgvBasicSalaryDetail.IsSetInputColumnsColor = true;
- return;
- }
- if (this.ActiveControl != null && "btnClose".Equals(this.ActiveControl.Name))
- {
- // 清除单元格的错误消息
- this.dgvBasicSalaryDetail.CurrentRow.ErrorText = string.Empty;
- return;
- }
- DataGridViewRow row = dgvBasicSalaryDetail.CurrentRow;
- if (!row.IsNewRow)
- {
- // 判断工种编码能为空
- if (row.Cells["JobsCode"].Value == null
- || string.IsNullOrEmpty(row.Cells["JobsCode"].Value + string.Empty))
- {
- // 单元格的错误消息
- this.dgvBasicSalaryDetail.CurrentRow.ErrorText = string.Format(Messages.MSG_CMN_W005, "工种编码");
- e.Cancel = true;
- this.btnSave.Enabled = false;
- return;
- }
- // 判断基本工资不能为空
- if (row.Cells["BasicSalary"].Value == null
- || string.IsNullOrEmpty(row.Cells["BasicSalary"].Value + string.Empty))
- {
- // 单元格的错误消息
- this.dgvBasicSalaryDetail.CurrentRow.ErrorText = string.Format(Messages.MSG_CMN_W005, "基本工资");
- e.Cancel = true;
- this.btnSave.Enabled = false;
- return;
- }
- // 判断补贴不能为空
- if (row.Cells["Subsidy"].Value == null
- || string.IsNullOrEmpty(row.Cells["Subsidy"].Value + string.Empty))
- {
- // 单元格的错误消息
- this.dgvBasicSalaryDetail.CurrentRow.ErrorText = string.Format(Messages.MSG_CMN_W005, "补贴");
- e.Cancel = true;
- this.btnSave.Enabled = false;
- return;
- }
- // 判断保底工资不能为空
- if (row.Cells["MinimumSalary"].Value == null
- || string.IsNullOrEmpty(row.Cells["MinimumSalary"].Value + string.Empty))
- {
- // 单元格的错误消息
- this.dgvBasicSalaryDetail.CurrentRow.ErrorText = string.Format(Messages.MSG_CMN_W005, "保底工资");
- e.Cancel = true;
- this.btnSave.Enabled = false;
- return;
- }
- // 清除单元格的错误消息
- this.dgvBasicSalaryDetail.CurrentRow.ErrorText = string.Empty;
- }
- }
- 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 dgvBasicSalaryDetail_RowValidated(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- this.SetSaveBtnStatus();
- }
- 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 btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- #endregion
- #region 私有方法/函数
- /// <summary>
- /// 绑定对应工种明细
- /// </summary>
- private void BindJobs()
- {
- try
- {
- //获取对应工种明细
- ServiceResultEntity srEntityDetail
- = TATModuleProxy.Service.GetBasicSalaryDetailById(Convert.ToInt32(this._entityId));
- if (srEntityDetail.Data != null && srEntityDetail.Data.Tables.Count != 0)
- {
- this._dsSourse = srEntityDetail.Data;
- this.dgvBasicSalaryDetail.DataSource = srEntityDetail.Data.Tables[0];
- this.dgvBasicSalaryDetail.IsSetInputColumnsColor = true;
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 保存时单元格必输项不能为空
- /// </summary>
- private int Conservation()
- {
- int isConservation = Constant.INT_IS_ZERO;
- DataTable datatBasicSalaryDetail = (DataTable)this.dgvBasicSalaryDetail.DataSource;
- foreach (DataRow drproductionData in datatBasicSalaryDetail.Rows)
- {
- if (drproductionData.RowState == DataRowState.Added || drproductionData.RowState == DataRowState.Modified)
- {
- if (drproductionData["JobsCode"].ToString() == "")
- {
- isConservation = Constant.INT_IS_ONE;
- break;
- }
- if (drproductionData["BasicSalary"].ToString() == "")
- {
- isConservation = Constant.INT_IS_TWO;
- break;
- }
- if (drproductionData["Subsidy"].ToString() == "")
- {
- isConservation = Constant.INT_IS_THREE;
- break;
- }
- if (drproductionData["MinimumSalary"].ToString() == "")
- {
- isConservation = Constant.INT_IS_FOUR;
- break;
- }
- }
- }
- return isConservation;
- }
- /// <summary>
- /// 设置保存按钮的可用状态
- /// </summary>
- private void SetSaveBtnStatus()
- {
- if (DataJudge.IsChange((DataTable)this.dgvBasicSalaryDetail.DataSource))
- {
- this.btnSave.Enabled = true;
- }
- else
- {
- this.btnSave.Enabled = false;
- }
- }
- #endregion
- }
- }
|