/*******************************************************************************
* Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_TAT_0701.cs
* 2.功能描述:管理岗位工资策略一览
* 编辑履历:
* 作者 日期 版本 修改内容
* 庄天威 2014/11/18 1.00 新建
*******************************************************************************/
using System;
using System.Data;
using System.Windows.Forms;
using Dongke.IBOSS.PRD.Basics.BaseResources;
using Dongke.IBOSS.PRD.Basics.DockPanel;
using Dongke.IBOSS.PRD.Client.CommonModule;
using Dongke.IBOSS.PRD.WCF.DataModels;
using Dongke.IBOSS.PRD.WCF.Proxys;
using Dongke.IBOSS.PRD.WCF.Proxys.TATModuleService;
namespace Dongke.IBOSS.PRD.Client.TATModule
{
///
/// 管理岗位工资策略一览
///
public partial class F_TAT_0701 : DockPanelBase
{
#region 成员变量
// 单例模式
private static F_TAT_0701 _instance;
// 检索用加载条件实体
private ManagerSalaryEntity _msEntity = new ManagerSalaryEntity();
// 审核状态选择值
private int? _auditStatusValue;
#endregion
#region 构造函数
///
/// 构造函数
///
public F_TAT_0701()
{
InitializeComponent();
}
#endregion
#region 单例模式
///
/// 单例模式
///
public static F_TAT_0701 Instance
{
get
{
if (_instance == null)
{
_instance = new F_TAT_0701();
}
return _instance;
}
}
#endregion
#region 私有方法/函数
///
/// 窗体加载
///
///
///
private void F_TAT_0701_Load(object sender, EventArgs e)
{
try
{
this.Text = FormTitles.F_TAT_0701;
this.dgvManagerSalary.AutoGenerateColumns = false;
//绑定页面各查询条件的数据源
this.BindSelectData();
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 添加信息
///
///
///
private void tsbtnAdd_Click(object sender, EventArgs e)
{
try
{
//以新建模式打开信息窗体
F_TAT_0702 frmTAT0702 = new F_TAT_0702(Constant.FormMode.Add, 0);
DialogResult dialogResult = frmTAT0702.ShowDialog();
//操作成功后刷新数据源
if (dialogResult == DialogResult.OK)
{
this.dgvManagerSalary.DataSource = null;
this.BindSelectedData();
ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(this.GetDate);
if (srEntity.Data != null && srEntity.Data.Tables.Count != 0)
{
this.BindGridView(srEntity.Data.Tables[0]);
}
//服务实体共通处理
ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 添加并复制明细
///
///
///
private void tsbtnCopy_Click(object sender, EventArgs e)
{
try
{
DataGridViewRow currentRow = this.dgvManagerSalary.CurrentRow;
if (currentRow != null)
{
//获取需要添加明细的信息ID
int entityId = Convert.ToInt32(currentRow.Cells["colManagerSalaryID"].Value);
//以复制模式打开信息窗体
F_TAT_0702 frmTAT0702 = new F_TAT_0702(Constant.FormMode.CopyAndAdd, entityId);
DialogResult dialogResult = frmTAT0702.ShowDialog();
//操作成功后刷新数据源
if (dialogResult == DialogResult.OK)
{
this.dgvManagerSalary.DataSource = null;
this.BindSelectedData();
ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(this.GetDate);
if (srEntity.Data != null && srEntity.Data.Tables.Count != 0)
{
this.BindGridView(srEntity.Data.Tables[0]);
}
//服务实体共通处理
ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 编辑信息
///
///
///
private void tsbtnEdit_Click(object sender, EventArgs e)
{
try
{
DataGridViewRow currentRow = this.dgvManagerSalary.CurrentRow;
if (currentRow != null)
{
//获取需要添加明细的信息ID
int entityId = Convert.ToInt32(currentRow.Cells["colManagerSalaryID"].Value);
//以编辑模式打开信息窗体
F_TAT_0702 frmTAT0702 = new F_TAT_0702(Constant.FormMode.Edit, entityId);
DialogResult dialogResult = frmTAT0702.ShowDialog();
//操作成功后刷新数据源
if (dialogResult == DialogResult.OK)
{
this.dgvManagerSalary.DataSource = null;
this.BindSelectedData();
ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(this.GetDate);
if (srEntity.Data != null && srEntity.Data.Tables.Count != 0)
{
this.BindGridView(srEntity.Data.Tables[0]);
}
//服务实体共通处理
ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 审批信息
///
///
///
private void tsbtnAudit_Click(object sender, EventArgs e)
{
try
{
DataGridViewRow currentRow = this.dgvManagerSalary.CurrentRow;
if (currentRow != null)
{
//获取需审核的信息ID
int entityId = Convert.ToInt32(currentRow.Cells["colManagerSalaryID"].Value);
//编辑窗体以审核模式开启
F_TAT_0702 frmTAT0702 = new F_TAT_0702(Constant.FormMode.Display, entityId);
DialogResult dialogResult = frmTAT0702.ShowDialog();
//操作成功后刷新数据源与列表
if (dialogResult == DialogResult.OK)
{
this.dgvManagerSalary.DataSource = null;
this.BindSelectedData();
ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(this.GetDate);
if (srEntity.Data != null && srEntity.Data.Tables.Count != 0)
{
this.BindGridView(srEntity.Data.Tables[0]);
}
//服务实体共通处理
ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 删除信息
///
///
///
private void tsbtnDelete_Click(object sender, EventArgs e)
{
try
{
DataGridViewRow currentRow = this.dgvManagerSalary.CurrentRow;
if (currentRow != null)
{
ManagerSalaryEntity msEntity = new ManagerSalaryEntity();
//获取ID以及时间戳
msEntity.ManagerSalaryID = Convert.ToInt32(currentRow.Cells["colManagerSalaryID"].Value);
msEntity.OPTimeStamp = Convert.ToDateTime(currentRow.Cells["colOPTimeStamp"].Value);
ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(() =>
{
return TATModuleProxy.Service.StopManagerSalary(msEntity);
});
//服务实体共通处理
ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
//成功后刷新数据源
if (srEntity.Status == Constant.ServiceResultStatus.Success)
{
this.dgvManagerSalary.DataSource = null;
this.BindSelectedData();
srEntity = (ServiceResultEntity)DoAsync(this.GetDate);
if (srEntity.Data != null && srEntity.Data.Tables.Count != 0)
{
this.BindGridView(srEntity.Data.Tables[0]);
}
//服务实体共通处理
ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 自适应列宽
///
///
///
private void tsbtnAdaptive_Click(object sender, EventArgs e)
{
this.dgvManagerSalary.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}
///
/// 窗体关闭
///
///
///
private void tsbtnClose_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 开始时间启用/关闭
///
///
///
private void cbStartTime_CheckedChanged(object sender, EventArgs e)
{
this.dtpStartTimeBetween.Enabled = this.cbStartTime.Checked;
this.dtpStartTimeAfter.Enabled = this.cbStartTime.Checked;
}
///
/// 结束时间启用/关闭
///
///
///
private void cbEndTime_CheckedChanged(object sender, EventArgs e)
{
this.dtpEndTimeBetween.Enabled = this.cbEndTime.Checked;
this.dtpEndTimeAfter.Enabled = this.cbEndTime.Checked;
}
///
/// 窗体关闭后
///
///
///
private void F_TAT_0701_FormClosed(object sender, FormClosedEventArgs e)
{
_instance = null;
}
///
/// 查询一览
///
///
///
private void btnSelect_Click(object sender, EventArgs e)
{
try
{
this.dgvManagerSalary.DataSource = null;
//绑定下拉框数据
this.BindSelectedData();
//获取数据源
ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(this.GetDate);
if (srEntity.Data != null && srEntity.Data.Tables.Count != 0)
{
this.BindGridView(srEntity.Data.Tables[0]);
}
//服务实体共通处理
ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 清空条件
///
///
///
private void btnClear_Click(object sender, EventArgs e)
{
this.txtManagerSalaryName.Text = string.Empty;
this.lbxAuditStatus.Text = string.Empty;
this._auditStatusValue = null;
this.txtRemarks.Text = string.Empty;
this.cbStartTime.Checked = false;
this.cbEndTime.Checked = false;
}
///
/// 选中行改变
///
///
///
private void dgvManagerSalary_SelectionChanged(object sender, EventArgs e)
{
DataGridViewRow gvrNow = this.dgvManagerSalary.CurrentRow;
if (gvrNow != null)
{
//如果是待审核就可以进行修改,审核,停用
if (Convert.ToInt32(gvrNow.Cells["colAuditStatus"].Value)
== Convert.ToInt32(Constant.AuditStatus.Pending))
{
this.tsbtnEdit.Enabled = true;
this.tsbtnAudit.Enabled = true;
this.tsbtnDelete.Enabled = true;
}
else //否则不可以
{
//如果是审批通过的则不可以删除
if (Convert.ToInt32(gvrNow.Cells["colAuditStatus"].Value)
== Convert.ToInt32(Constant.AuditStatus.Agree))
{
this.tsbtnDelete.Enabled = false;
}
else
{
this.tsbtnDelete.Enabled = true;
}
this.tsbtnEdit.Enabled = false;
this.tsbtnAudit.Enabled = false;
}
}
}
#endregion
#region 私有方法/函数
///
/// 绑定检索条件数据
///
private void BindSelectData()
{
try
{
//绑定审核状态
DataSet dsStatus = SystemModuleProxy.Service.GetAuditStatus();
this.lbxAuditStatus.DataSource = dsStatus.Tables[0];
this.lbxAuditStatus.ValueMember = "AuditStatusID";
this.lbxAuditStatus.DisplayMember = "AuditStatusName";
this.lbxAuditStatus.Text = "";
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 获取页面的输入值
///
private void BindSelectedData()
{
try
{
if (this.lbxAuditStatus.SelectedValue != null)
{
this._auditStatusValue = Convert.ToInt32(this.lbxAuditStatus.SelectedValue);
}
else
{
this._auditStatusValue = null;
}
//为查询用实体赋值
this._msEntity = new ManagerSalaryEntity();
if (!string.IsNullOrWhiteSpace(this.txtManagerSalaryName.Text))
{
this._msEntity.ManagerSalaryName = this.txtManagerSalaryName.Text.Trim();
}
if (this._auditStatusValue != null)
{
this._msEntity.AuditStatus = this._auditStatusValue;
}
if (!string.IsNullOrWhiteSpace(this.txtRemarks.Text))
{
this._msEntity.Remarks = this.txtRemarks.Text;
}
if (this.cbStartTime.Checked)
{
this._msEntity.BeginAccountMonth = this.dtpStartTimeBetween.Value.Date;
this._msEntity.BeginAccountMonthEnd = this.dtpStartTimeAfter.Value.Date
.AddHours(23).AddMinutes(59).AddSeconds(59);
}
if (this.cbEndTime.Checked)
{
this._msEntity.EndAccountMonth = this.dtpEndTimeBetween.Value.Date;
this._msEntity.EndAccountMonthEnd = this.dtpEndTimeAfter.Value.Date
.AddHours(23).AddMinutes(59).AddSeconds(59); ;
}
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 绑定列表查询数据
///
private ServiceResultEntity GetDate()
{
try
{
return TATModuleProxy.Service.GetManagerSalary(this._msEntity);
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 绑定页面数据源
///
/// 数据源TABLE
private void BindGridView(DataTable dtSourse)
{
this.dgvManagerSalary.DataSource = dtSourse;
this.dgvManagerSalary.ReadOnly = true;
}
#endregion
}
}