/*******************************************************************************
* Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_TAT_0301.cs
* 2.功能描述:基本工资策略一览
* 编辑履历:
* 作者 日期 版本 修改内容
* 任海 2014/12/10 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.DockPanel;
using Dongke.IBOSS.PRD.WCF.Proxys.TATModuleService;
using Dongke.IBOSS.PRD.Basics.BaseResources;
using Dongke.IBOSS.PRD.Client.CommonModule;
using Dongke.IBOSS.PRD.WCF.Proxys;
using Dongke.IBOSS.PRD.WCF.DataModels;
namespace Dongke.IBOSS.PRD.Client.TATModule
{
///
/// 基本工资策略一览
///
public partial class F_TAT_0301 : DockPanelBase
{
#region 成员变量
// 单例模式
private static F_TAT_0301 _instance;
// 检索用加载条件实体
private BasicSalaryEntity _basicSalaryEntity = new BasicSalaryEntity();
// 审核状态选择值
private int? _auditStatusValue;
// 策略类型选择值
private int? _salaryTypeValue;
#endregion
#region 构造函数
///
/// 窗体构造
///
public F_TAT_0301()
{
InitializeComponent();
}
#endregion
#region 单例模式
///
/// 单例模式
///
public static F_TAT_0301 Instance
{
get
{
if (_instance == null)
{
_instance = new F_TAT_0301();
}
return _instance;
}
}
#endregion
#region 事件处理
///
/// 窗体加载
///
///
///
private void F_TAT_0301_Load(object sender, EventArgs e)
{
try
{
this.Text = FormTitles.F_TAT_0301;
this.dgvBasicSalary.AutoGenerateColumns = false;
//绑定页面各查询条件的数据源
this.BindSelectData();
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 窗体关闭后
///
///
///
private void F_TAT_0301_FormClosed(object sender, FormClosedEventArgs e)
{
_instance = null;
}
///
/// 开始时间启用/关闭
///
///
///
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 btnClearCondition_Click(object sender, EventArgs e)
{
this.txtWagesName.Text = string.Empty;
this.lbxAuditStatus.Text = string.Empty;
this._auditStatusValue = null;
this.txtRemarks.Text = string.Empty;
this.cbStartTime.Checked = false;
this.cbEndTime.Checked = false;
this.lbxSalaryType.Text = string.Empty;
this._salaryTypeValue = null;
}
///
/// 查询一览
///
///
///
private void btnSearch_Click(object sender, EventArgs e)
{
try
{
//置空列表
this.dgvBasicSalary.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 dgvBasicSalary_SelectionChanged(object sender, EventArgs e)
{
DataGridViewRow gvrNow = this.dgvBasicSalary.CurrentRow;
if (gvrNow != null)
{
//如果是待审核就可以进行修改,审核,停用
if (Convert.ToInt32(gvrNow.Cells["colAuditStatus"].Value)
== Convert.ToInt32(Constant.AuditStatus.Pending))
{
this.tsbtnEdit.Enabled = true;
this.tsbtnApprover.Enabled = true;
this.tsbtnDisable.Enabled = true;
}
else //否则不可以
{
//如果是审批通过的则不可以删除
if (Convert.ToInt32(gvrNow.Cells["colAuditStatus"].Value)
== Convert.ToInt32(Constant.AuditStatus.Agree))
{
this.tsbtnDisable.Enabled = false;
}
else
{
this.tsbtnDisable.Enabled = true;
}
this.tsbtnEdit.Enabled = false;
this.tsbtnApprover.Enabled = false;
}
}
}
///
/// 新建信息
///
///
///
private void tsbtnAdd_Click(object sender, EventArgs e)
{
try
{
//以新建模式打开信息窗体
F_TAT_0303 frmTAT0303 = new F_TAT_0303(Constant.FormMode.Add, 0);
DialogResult dialogResult = frmTAT0303.ShowDialog();
//操作成功后刷新数据源
if (dialogResult == DialogResult.OK)
{
this.dgvBasicSalary.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.dgvBasicSalary.CurrentRow;
if (currentRow != null)
{
//获取需要添加明细的信息ID
int entityId = Convert.ToInt32(currentRow.Cells["colWagesID"].Value);
//以编辑模式打开信息窗体
F_TAT_0303 frmTAT0303 = new F_TAT_0303(Constant.FormMode.Edit, entityId);
DialogResult dialogResult = frmTAT0303.ShowDialog();
//操作成功后刷新数据源
if (dialogResult == DialogResult.OK)
{
this.dgvBasicSalary.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 tsbtnDetail_Click(object sender, EventArgs e)
{
try
{
DataGridViewRow currentRow = this.dgvBasicSalary.CurrentRow;
if (currentRow != null)
{
//获取需要添加明细的信息ID
int entityId = Convert.ToInt32(currentRow.Cells["colWagesID"].Value);
String entityname = Convert.ToString(currentRow.Cells["colWagesName"].Value);
//以编辑模式打开明细窗体
F_TAT_0302 frmTAT0302 = new F_TAT_0302(Constant.FormMode.Edit, entityId, entityname);
DialogResult dialogResult = frmTAT0302.ShowDialog();
//操作成功后刷新数据源
if (dialogResult == DialogResult.OK)
{
this.dgvBasicSalary.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 tsbtnApprover_Click(object sender, EventArgs e)
{
try
{
DataGridViewRow currentRow = this.dgvBasicSalary.CurrentRow;
if (currentRow != null)
{
//获取需审核的信息ID
int entityId = Convert.ToInt32(currentRow.Cells["colWagesID"].Value);
//编辑窗体以审核模式开启
F_TAT_0303 frmTAT0303 = new F_TAT_0303(Constant.FormMode.Display, entityId);
DialogResult dialogResult = frmTAT0303.ShowDialog();
//操作成功后刷新数据源与列表
if (dialogResult == DialogResult.OK)
{
this.dgvBasicSalary.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 tsbtnDisable_Click(object sender, EventArgs e)
{
try
{
DataGridViewRow currentRow = this.dgvBasicSalary.CurrentRow;
if (currentRow != null)
{
BasicSalaryEntity dfEntity = new BasicSalaryEntity();
//获取ID以及时间戳
dfEntity.BasicSalaryID = Convert.ToInt32(currentRow.Cells["colWagesID"].Value);
dfEntity.OPTimeStamp = Convert.ToDateTime(currentRow.Cells["colOPTimeStamp"].Value);
ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(() =>
{
return TATModuleProxy.Service.StopBasicSalary(dfEntity);
});
//服务实体共通处理
ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
//成功后刷新数据源
if (srEntity.Status == Constant.ServiceResultStatus.Success)
{
this.dgvBasicSalary.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 tsbtnCopy_Click(object sender, EventArgs e)
{
try
{
DataGridViewRow currentRow = this.dgvBasicSalary.CurrentRow;
if (currentRow != null)
{
//获取需要添加明细的信息ID
int entityId = Convert.ToInt32(currentRow.Cells["colWagesID"].Value);
//以复制模式打开信息窗体
F_TAT_0303 frmTAT0303 = new F_TAT_0303(Constant.FormMode.CopyAndAdd, entityId);
DialogResult dialogResult = frmTAT0303.ShowDialog();
//操作成功后刷新数据源
if (dialogResult == DialogResult.OK)
{
this.dgvBasicSalary.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 tsbtnAdaptive_Click(object sender, EventArgs e)
{
this.dgvBasicSalary.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}
///
/// 窗体关闭
///
///
///
private void tsbtnClose_Click(object sender, EventArgs e)
{
this.Close();
}
#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 = "";
//绑定策略类型
DataTable dtSalaryType = new DataTable();
dtSalaryType.Columns.Add("SalaryTypeValue");
dtSalaryType.Columns.Add("SalaryTypeName");
Type SalaryTypeEnum = typeof(Constant.SalaryType);
Array SalaryTypeArray = Enum.GetValues(SalaryTypeEnum);
for (int i = 0; i < Constant.SalaryTypeName.Length; i++)
{
dtSalaryType.Rows.Add(Convert.ToInt32(SalaryTypeArray.GetValue(i)), Constant.SalaryTypeName[i]);
}
this.lbxSalaryType.DisplayMember = "SalaryTypeName";
this.lbxSalaryType.ValueMember = "SalaryTypeValue";
this.lbxSalaryType.DataSource = dtSalaryType;
this.lbxSalaryType.Text = "";
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 获取页面的输入值
///
private void BindSelectedData()
{
try
{
if (this.lbxSalaryType.SelectedValue != null)
{
this._salaryTypeValue = Convert.ToInt32(this.lbxSalaryType.SelectedValue);
}
else
{
this._salaryTypeValue = null;
}
if (this.lbxAuditStatus.SelectedValue != null)
{
this._auditStatusValue = Convert.ToInt32(this.lbxAuditStatus.SelectedValue);
}
else
{
this._auditStatusValue = null;
}
//为查询用实体赋值
this._basicSalaryEntity = new BasicSalaryEntity();
if (!string.IsNullOrWhiteSpace(this.txtWagesName.Text))
{
this._basicSalaryEntity.BasicSalaryName = this.txtWagesName.Text.Trim();
}
if (this._auditStatusValue != null)
{
this._basicSalaryEntity.AuditStatus = this._auditStatusValue;
}
if (!string.IsNullOrWhiteSpace(this.txtRemarks.Text))
{
this._basicSalaryEntity.Remarks = this.txtRemarks.Text;
}
if (this.cbStartTime.Checked)
{
this._basicSalaryEntity.BeginAccountMonth = this.dtpStartTimeBetween.Value;
this._basicSalaryEntity.BeginAccountMonthEnd = this.dtpStartTimeAfter.Value.AddDays(1);
}
if (this.cbEndTime.Checked)
{
this._basicSalaryEntity.EndAccountMonth = this.dtpEndTimeBetween.Value;
this._basicSalaryEntity.EndAccountMonthEnd = this.dtpEndTimeAfter.Value.AddDays(1);
}
if (this._salaryTypeValue != null)
{
this._basicSalaryEntity.SalaryType = Convert.ToInt32(this._salaryTypeValue);
}
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 绑定列表查询数据
///
private ServiceResultEntity GetDate()
{
try
{
return TATModuleProxy.Service.GetBasicSalary(this._basicSalaryEntity);
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 绑定页面数据源
///
/// 数据源TABLE
private void BindGridView(DataTable dtSourse)
{
this.dgvBasicSalary.DataSource = dtSourse;
this.dgvBasicSalary.ReadOnly = true;
}
#endregion
}
}