/*******************************************************************************
* Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_TAT_0101.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.Client.DataModels;
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_0101 : DockPanelBase
{
#region 成员变量
// 单例模式
private static F_TAT_0101 _instance;
// 检索用加载条件实体
private DefectFineEntity _dfEntity = new DefectFineEntity();
// 审核状态选择值
private int? _auditStatusValue;
// 缺陷扣罚选择值
private int? _defectFineValue;
// 策略类型选择值
private int? _salaryTypeValue;
// 扣罚类型选择值
private int? _fineTypeValue;
#endregion
#region 构造函数
///
/// 窗体构造函数
///
private F_TAT_0101()
{
InitializeComponent();
this.Text = FormTitles.F_TAT_0101;
this.btnSearch.Text = ButtonText.BTN_SEARCH;
this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
this.tsbtnCopy.Text = ButtonText.TSBTN_COPY;
this.tsbtnDetail.Text = ButtonText.TSBTN_DETAIL;
this.tsbtnDisable.Text = ButtonText.TSBTN_DISABLE;
this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
}
#endregion
#region 单例模式
///
/// 单例模式
///
public static F_TAT_0101 Instance
{
get
{
if (_instance == null)
{
_instance = new F_TAT_0101();
}
return _instance;
}
}
#endregion
#region 事件处理
///
/// 窗体加载
///
///
///
private void F_TAT_0101_Load(object sender, EventArgs e)
{
try
{
// 加载权限
//FormPermissionManager.FormPermissionControl(this.Name, this,
// LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
this.dgvDefectFine.AutoGenerateColumns = false;
//绑定页面各查询条件的数据源
this.BindSelectData();
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 查询一览
///
///
///
private void btnSearch_Click(object sender, EventArgs e)
{
try
{
//绑定下拉框数据
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 btnClearCondition_Click(object sender, EventArgs e)
{
this.txtDefectFineName.Text = string.Empty;
this.lbxAuditStatus.Text = string.Empty;
this._auditStatusValue = null;
this.lbxDefectFine.Text = string.Empty;
this._defectFineValue = null;
this.txtRemarks.Text = string.Empty;
this.cbStartTime.Checked = false;
this.cbEndTime.Checked = false;
this.lbxFineType.Text = string.Empty;
this._fineTypeValue = null;
this.lbxSalaryType.Text = string.Empty;
this._salaryTypeValue = null;
}
///
/// 新建信息
///
///
///
private void tsbtnAdd_Click(object sender, EventArgs e)
{
try
{
//以新建模式打开信息窗体
F_TAT_0103 frmTAT0103 = new F_TAT_0103(Constant.FormMode.Add, 0);
DialogResult dialogResult = frmTAT0103.ShowDialog();
//操作成功后刷新数据源
if (dialogResult == DialogResult.OK)
{
this.dgvDefectFine.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.dgvDefectFine.CurrentRow;
if (currentRow != null)
{
//获取需要添加明细的信息ID
int entityId = Convert.ToInt32(currentRow.Cells["colDefectFineID"].Value);
//以复制模式打开信息窗体
F_TAT_0103 frmTAT0103 = new F_TAT_0103(Constant.FormMode.CopyAndAdd, entityId);
DialogResult dialogResult = frmTAT0103.ShowDialog();
//操作成功后刷新数据源
if (dialogResult == DialogResult.OK)
{
this.dgvDefectFine.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.dgvDefectFine.CurrentRow;
if (currentRow != null)
{
//获取需要添加明细的信息ID
int entityId = Convert.ToInt32(currentRow.Cells["colDefectFineID"].Value);
//以编辑模式打开信息窗体
F_TAT_0103 frmTAT0103 = new F_TAT_0103(Constant.FormMode.Edit, entityId);
DialogResult dialogResult = frmTAT0103.ShowDialog();
//操作成功后刷新数据源
if (dialogResult == DialogResult.OK)
{
this.dgvDefectFine.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.dgvDefectFine.CurrentRow;
if (currentRow != null)
{
//获取需要添加明细的信息ID
int entityId = Convert.ToInt32(currentRow.Cells["colDefectFineID"].Value);
//以编辑模式打开明细窗体
F_TAT_0102 frmTAT0102 = new F_TAT_0102(Constant.FormMode.Edit, entityId);
DialogResult dialogResult = frmTAT0102.ShowDialog();
//操作成功后刷新数据源
if (dialogResult == DialogResult.OK)
{
this.dgvDefectFine.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.dgvDefectFine.CurrentRow;
if (currentRow != null)
{
//获取需审核的信息ID
int entityId = Convert.ToInt32(currentRow.Cells["colDefectFineID"].Value);
//编辑窗体以审核模式开启
F_TAT_0103 frmTAT0103 = new F_TAT_0103(Constant.FormMode.Display, entityId);
DialogResult dialogResult = frmTAT0103.ShowDialog();
//操作成功后刷新数据源与列表
if (dialogResult == DialogResult.OK)
{
this.dgvDefectFine.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.dgvDefectFine.CurrentRow;
if (currentRow != null)
{
DefectFineEntity dfEntity = new DefectFineEntity();
//获取ID以及时间戳
dfEntity.DefectFineID = Convert.ToInt32(currentRow.Cells["colDefectFineID"].Value);
dfEntity.OPTimeStamp = Convert.ToDateTime(currentRow.Cells["colOPTimeStamp"].Value);
ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(() =>
{
return TATModuleProxy.Service.StopDefectFine(dfEntity);
});
//服务实体共通处理
ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
//成功后刷新数据源
if (srEntity.Status == Constant.ServiceResultStatus.Success)
{
this.dgvDefectFine.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.dgvDefectFine.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_0101_FormClosed(object sender, FormClosedEventArgs e)
{
_instance = null;
}
///
/// 选择信息后,工具条按钮的变化
///
///
///
private void dgvDefectFine_SelectionChanged(object sender, EventArgs e)
{
DataGridViewRow gvrNow = this.dgvDefectFine.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;
//同时如果是按照金额扣罚的,还可以进行明细操作以及复制操作
if (gvrNow.Cells["colFineType"].Value.ToString() == Constant.FineTypeName[1])
{
this.tsbtnDetail.Enabled = true;
this.tsbtnCopy.Enabled = true;
}
else
{
this.tsbtnDetail.Enabled = false;
this.tsbtnCopy.Enabled = false;
}
}
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;
this.tsbtnDetail.Enabled = false;
if (gvrNow.Cells["colFineType"].Value.ToString() == Constant.FineTypeName[1])
{
this.tsbtnCopy.Enabled = true;
}
else
{
this.tsbtnCopy.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 = "";
//绑定缺陷扣罚
DataTable dtDefectFine = SystemModuleProxy.Service.GetDataDictionaryByType(Constant.DictionaryType.ASE002, Constant.INT_IS_ONE);
if (dtDefectFine != null)
{
this.lbxDefectFine.DisplayMember = "DictionaryValue";
this.lbxDefectFine.ValueMember = "DictionaryID";
this.lbxDefectFine.DataSource = dtDefectFine;
this.lbxDefectFine.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 = "";
//绑定扣罚类型
DataTable dtFineType = new DataTable();
dtFineType.Columns.Add("FineTypeValue");
dtFineType.Columns.Add("FineTypeName");
Type FineTypeEnum = typeof(Constant.FineType);
Array FineTypeArray = Enum.GetValues(FineTypeEnum);
for (int i = 0; i < Constant.FineTypeName.Length; i++)
{
dtFineType.Rows.Add(Convert.ToInt32(FineTypeArray.GetValue(i)), Constant.FineTypeName[i]);
}
this.lbxFineType.DisplayMember = "FineTypeName";
this.lbxFineType.ValueMember = "FineTypeValue";
this.lbxFineType.DataSource = dtFineType;
this.lbxFineType.Text = "";
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 获取页面的输入值
///
private void BindSelectedData()
{
try
{
this.dgvDefectFine.DataSource = null;
//下拉框的值
if (this.lbxDefectFine.SelectedValue != null)
{
this._defectFineValue = Convert.ToInt32(this.lbxDefectFine.SelectedValue);
}
else
{
this._defectFineValue = null;
}
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;
}
if (this.lbxFineType.SelectedValue != null)
{
this._fineTypeValue = Convert.ToInt32(this.lbxFineType.SelectedValue);
}
else
{
this._fineTypeValue = null;
}
//为查询用实体赋值
this._dfEntity = new DefectFineEntity();
if (!string.IsNullOrWhiteSpace(this.txtDefectFineName.Text))
{
this._dfEntity.DefectFineName = this.txtDefectFineName.Text.Trim();
}
if (this._defectFineValue != null)
{
this._dfEntity.DefectFine = this._defectFineValue;
}
if (this._auditStatusValue != null)
{
this._dfEntity.AuditStatus = this._auditStatusValue;
}
if (!string.IsNullOrWhiteSpace(this.txtRemarks.Text))
{
this._dfEntity.Remarks = this.txtRemarks.Text;
}
if (this.cbStartTime.Checked)
{
this._dfEntity.BeginAccountMonth = this.dtpStartTimeBetween.Value.Date;
this._dfEntity.BeginAccountMonthEnd = this.dtpStartTimeAfter.Value.Date
.AddHours(23).AddMinutes(59).AddSeconds(59);
}
if (this.cbEndTime.Checked)
{
this._dfEntity.EndAccountMonth = this.dtpEndTimeBetween.Value;
this._dfEntity.EndAccountMonthEnd = this.dtpEndTimeAfter.Value.Date
.AddHours(23).AddMinutes(59).AddSeconds(59);
}
if (this._salaryTypeValue != null)
{
this._dfEntity.SalaryType = Convert.ToInt32(this._salaryTypeValue);
}
if (this._fineTypeValue != null)
{
this._dfEntity.FineType = Convert.ToInt32(this._fineTypeValue);
}
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 绑定列表查询数据
///
private ServiceResultEntity GetDate()
{
try
{
return TATModuleProxy.Service.GetDefectFine(this._dfEntity);
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 绑定页面数据源
///
/// 数据源TABLE
private void BindGridView(DataTable dtSourse)
{
this.dgvDefectFine.DataSource = dtSourse;
this.dgvDefectFine.ReadOnly = true;
}
#endregion
}
}