| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_TAT_0702.cs
- * 2.功能描述:管理岗位工资策略明细
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 庄天威 2014/11/18 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.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
- using Dongke.IBOSS.PRD.WCF.Proxys.TATModuleService;
- namespace Dongke.IBOSS.PRD.Client.TATModule
- {
- /// <summary>
- /// 管理岗位工资策略明细
- /// </summary>
- public partial class F_TAT_0702 : FormBase
- {
- #region 成员变量
- // 窗体模式ID
- private Constant.FormMode _formType;
- // 操作实体ID
- private int? _entityId;
- // 操作实体
- private ManagerSalaryEntity _msEntity = new ManagerSalaryEntity();
- // 选择窗体弹出标识
- private bool _showFromFlag = true;
- // 数据源
- private DataSet _dsSourse;
- // 窗体加载完毕标识
- private bool _pageLoadOK = false;
- #endregion
- #region 构造函数
- /// <summary>
- /// 窗体构造
- /// </summary>
- /// <param name="formType">窗体开启模式</param>
- /// <param name="entityId">操作实体ID</param>
- public F_TAT_0702(Constant.FormMode formType, int managerSalaryID)
- {
- InitializeComponent();
- this._formType = formType;
- this._entityId = managerSalaryID;
- // 窗口标题
- this.Text = FormTitles.F_TAT_0702;
- // 按钮
- this.btnSubmit.Text = ButtonText.BTN_SAVE;
- this.btnClose.Text = ButtonText.BTN_CANCEL;
- }
- #endregion
- #region 事件处理
- /// <summary>
- /// 窗体加载
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_TAT_0702_Load(object sender, EventArgs e)
- {
- try
- {
- BindManagerSalaryType();
- //无论如何先绑定工种,即使没有信息,也需要Table的结构
- this.dgvManagers.AutoGenerateColumns = false;
- this.BindManagers();
- //如果是编辑或审核模式,还要绑定主体信息
- if (this._formType == Constant.FormMode.Edit || this._formType == Constant.FormMode.Display)
- {
- this.BindPage();
- this.tsbtnOther.Visible = true;
- }
- else
- {
- //新建模式下是不可以进入明细的
- if (this._formType == Constant.FormMode.Add)
- {
- this.tsbtnOther.Visible = false;
- }
- else //复制模式不可编辑明细
- {
- this.dgvManagers.ReadOnly = true;
- this.dgvManagers.IsSetInputColumnsColor = false;
- this.dgvManagers.AllowUserToAddRows = false;
- }
- }
- //页面加载完毕
- this._pageLoadOK = true;
- //如果是审核及观看模式
- if (this._formType == Constant.FormMode.Display)
- {
- this.btnPass.Visible = true;
- this.btnReturn.Visible = true;
- //列表设置为只读
- this.dgvManagers.ReadOnly = true;
- this.dgvManagers.IsSetInputColumnsColor = false;
- this.dgvManagers.AllowUserToAddRows = false;
- this.dgvManagers.AllowUserToDeleteRows = false;
- //控件除关闭外全部不可用
- this.txtManagerSalaryName.Enabled = false;
- this.txtRemarks.Enabled = false;
- this.dtpStartTime.Enabled = false;
- this.btnSubmit.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 btnSubmit_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);
- return;
- }
- if (results == Constant.INT_IS_TWO)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "工资百分比"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (!ValidationInput())
- {
- return;
- }
- //获取页面值绑定属性
- this.BindEntity();
- //提交操作
- ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(() =>
- {
- return this.EntityToServer();
- });
- 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);
- }
- }
- /// <summary>
- /// 关闭窗体
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 进入明细
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnOther_Click(object sender, EventArgs e)
- {
- try
- {
- //获取当前行,如果不为空以及非新建行的话,就可以进入明细页面
- DataGridViewRow gvrNow = this.dgvManagers.CurrentRow;
- if (gvrNow != null && !gvrNow.IsNewRow)
- {
- //判断该行是否是新建行
- if (gvrNow.Cells["ManagersID"].Value != DBNull.Value)
- {
- //获取需要添加明细的信息ID
- int ManagersId = Convert.ToInt32(gvrNow.Cells["ManagersID"].Value);
- string StaffName = gvrNow.Cells["StaffName"].Value.ToString();
- string OrganizationName = gvrNow.Cells["OrganizationName"].Value.ToString();
- string PostName = gvrNow.Cells["PostName"].Value.ToString();
- //以编辑模式打开信息窗体
- F_TAT_0703 frmTAT0703
- = new F_TAT_0703(this._formType, Convert.ToInt32(this._msEntity.ManagerSalaryID), ManagersId, StaffName, OrganizationName, PostName);
- DialogResult dialogResult = frmTAT0703.ShowDialog();
- }
- else
- {
- //提示用户,该管理员信息暂未保存,不可创建组内成员
- MessageBox.Show(Messages.MSG_TAT_W002, this.Text,
- MessageBoxButtons.OK,
- MessageBoxIcon.Warning);
- }
- }
- else
- {
- //不可为空或选择新建行
- }
- }
- 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 tsbtnAdaptive_Click(object sender, EventArgs e)
- {
- this.dgvManagers.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- }
- /// <summary>
- /// 单元格值改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvManagers_CellValueChanged(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- if (this.dgvManagers.Rows.Count <= Constant.INT_IS_ONE || !_showFromFlag)
- {
- return;
- }
- DataGridViewRow rowItem = this.dgvManagers.Rows[e.RowIndex];
- DataGridViewColumn columnItem = this.dgvManagers.Columns[e.ColumnIndex];
- if (columnItem.Name == "StaffCode")
- {
- int managerSalaryID = this._entityId == null ? 0 : Convert.ToInt32(this._entityId);
- _showFromFlag = false;
- FormUtility.BindManagerRowDataSource(this.dgvManagers,
- e.RowIndex, columnItem.Name, null, managerSalaryID, false);
- _showFromFlag = true;
- foreach (DataGridViewRow gvrFor in this.dgvManagers.Rows)
- {
- if (!gvrFor.IsNewRow && gvrFor.Cells["Manager"].Value != DBNull.Value)
- {
- gvrFor.Cells["StaffCode"].ReadOnly = true;
- gvrFor.Cells["SalaryType"].ReadOnly = false;
- gvrFor.Cells["SalaryPercent"].ReadOnly = false;
- }
- //如果是新行,不可录入工种以外的项
- if (gvrFor.IsNewRow)
- {
- gvrFor.Cells["SalaryType"].ReadOnly = true;
- gvrFor.Cells["SalaryPercent"].ReadOnly = true;
- gvrFor.Cells["StaffCode"].ReadOnly = false;
- }
- }
- this.dgvManagers.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 btnPass_Click(object sender, EventArgs e)
- {
- //进行审核操作
- this._msEntity.AuditStatus = Convert.ToInt32(Constant.AuditStatus.Agree);
- ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(() =>
- {
- return EntityToServer();
- });
- //服务实体共通处理
- ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
- if (srEntity.Status == Constant.ServiceResultStatus.Success)
- {
- this.DialogResult = DialogResult.OK;
- }
- }
- /// <summary>
- /// 驳回审核
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnReturn_Click(object sender, EventArgs e)
- {
- //进行审核操作
- this._msEntity.AuditStatus = Convert.ToInt32(Constant.AuditStatus.Disagree);
- ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(() =>
- {
- return EntityToServer();
- });
- //服务实体共通处理
- ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
- if (srEntity.Status == Constant.ServiceResultStatus.Success)
- {
- this.DialogResult = DialogResult.OK;
- }
- }
- #endregion
- #region 私有方法/函数
- /// <summary>
- /// 绑定需要操作的实体信息
- /// </summary>
- private void BindPage()
- {
- try
- {
- if (this._entityId != 0 && this._entityId != null)
- {
- this._msEntity.ManagerSalaryID = this._entityId;
- //获取工价策略
- ServiceResultEntity srEntity
- = TATModuleProxy.Service.GetManagerSalary(_msEntity);
- //如果取出了对应的数据
- if (srEntity.Data != null && srEntity.Data.Tables.Count != 0
- && srEntity.Data.Tables[0].Rows.Count != 0)
- {
- //为实体及页面相关赋值
- DataSet dsEntityData = (DataSet)srEntity.Data;
- DataRow drEntityRow = dsEntityData.Tables[0].Rows[0];
- this.txtManagerSalaryName.Text = drEntityRow["ManagerSalaryName"].ToString();
- this.txtRemarks.Text = drEntityRow["Remarks"].ToString();
- this.dtpStartTime.Text = drEntityRow["BeginAccountMonth"].ToString();
- this._msEntity.BeginAccountMonth = Convert.ToDateTime(drEntityRow["BeginAccountMonth"].ToString());
- this._msEntity.OPTimeStamp = Convert.ToDateTime(drEntityRow["OPTimeStamp"]);
- }
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 绑定策略类型
- /// </summary>
- private void BindManagerSalaryType()
- {
- try
- {
- //绑定策略类型
- DataTable dtSalaryType = new DataTable();
- dtSalaryType.Columns.Add("SalaryType");
- dtSalaryType.Columns.Add("SalaryTypeName");
- Type ManagerSalaryTypeEnum = typeof(Constant.ManagerSalaryType);
- Array ManagerSalaryTypeArray = Enum.GetValues(ManagerSalaryTypeEnum);
- for (int i = 0; i < Constant.ManagerSalaryTypeName.Length; i++)
- {
- dtSalaryType.Rows.Add(Convert.ToInt32(ManagerSalaryTypeArray.GetValue(i)), Constant.ManagerSalaryTypeName[i]);
- }
- this.SalaryType.DisplayMember = "SalaryTypeName";
- this.SalaryType.ValueMember = "SalaryType";
- this.SalaryType.DataSource = dtSalaryType;
- }
- catch(Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 绑定对应管理者信息
- /// </summary>
- private void BindManagers()
- {
- try
- {
- //获取对应管理者信息
- ServiceResultEntity srEntityDetail
- = TATModuleProxy.Service.GetManagersById(Convert.ToInt32(this._entityId));
- if (srEntityDetail.Data != null && srEntityDetail.Data.Tables.Count != 0)
- {
- this._dsSourse = srEntityDetail.Data;
- this.dgvManagers.DataSource = srEntityDetail.Data.Tables[0];
- //新行单元格可用性编辑
- DataGridViewRow gvrNew = this.dgvManagers.Rows[this.dgvManagers.NewRowIndex];
- gvrNew.Cells["StaffCode"].ReadOnly = false;
- gvrNew.Cells["SalaryType"].ReadOnly = true;
- gvrNew.Cells["SalaryPercent"].ReadOnly = true;
- this.dgvManagers.IsSetInputColumnsColor = true;
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 与服务交互操作
- /// </summary>
- /// <returns></returns>
- private ServiceResultEntity EntityToServer()
- {
- if (this._formType == Constant.FormMode.Add)
- {
- return TATModuleProxy.Service.AddManagerSalary(this._msEntity, _dsSourse);
- }
- else if (this._formType == Constant.FormMode.Edit)
- {
- return TATModuleProxy.Service.EditManagerSalary(this._msEntity, _dsSourse);
- }
- else if (_formType == Constant.FormMode.CopyAndAdd)
- {
- this._msEntity.CopyId = Convert.ToInt32(this._entityId);
- return TATModuleProxy.Service.AddManagerSalary(this._msEntity, _dsSourse);
- }
- else if (_formType == Constant.FormMode.Display)
- {
- return TATModuleProxy.Service.AuditManagerSalary(this._msEntity);
- }
- return null;
- }
- /// <summary>
- /// 为实体绑定页面属性
- /// </summary>
- private void BindEntity()
- {
- this._msEntity.ManagerSalaryName = this.txtManagerSalaryName.Text.Trim();
- this._msEntity.BeginAccountMonth = this.dtpStartTime.Value.Date;
- this._msEntity.Remarks = this.txtRemarks.Text;
- this._msEntity.AuditStatus = 0;
- }
- /// <summary>
- /// 验证必填项
- /// </summary>
- /// <returns>是否通过</returns>
- private bool ValidationInput()
- {
- if (string.IsNullOrWhiteSpace(this.txtManagerSalaryName.Text))
- {
- this.txtManagerSalaryName.Focus();
- return false;
- }
- //循环列表,除新行外,工资类别和比例都不可为空
- foreach (DataGridViewRow gvrFor in this.dgvManagers.Rows)
- {
- if (gvrFor.IsNewRow)
- {
- break;
- }
- if (gvrFor.Cells["SalaryType"].Value == DBNull.Value ||
- gvrFor.Cells["SalaryPercent"].Value == DBNull.Value)
- {
- this.dgvManagers.Rows[gvrFor.Index].Selected = true;
- return false;
- }
- }
- return true;
- }
- /// <summary>
- /// 保存时单元格必输项不能为空
- /// </summary>
- private int Conservation()
- {
- int isConservation = Constant.INT_IS_ZERO;
- DataTable datatManagers = (DataTable)this.dgvManagers.DataSource;
- foreach (DataRow drproductionData in datatManagers.Rows)
- {
- if (drproductionData.RowState == DataRowState.Added || drproductionData.RowState == DataRowState.Modified)
- {
- if (drproductionData["SalaryType"].ToString() == "")
- {
- isConservation = Constant.INT_IS_ONE;
- break;
- }
- if (drproductionData["SalaryPercent"].ToString() == "")
- {
- isConservation = Constant.INT_IS_TWO;
- break;
- }
- }
- }
- return isConservation;
- }
- #endregion
- }
- }
|