/*******************************************************************************
* Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_HR_1201.cs
* 2.功能描述:工资结算记录查询
* 编辑履历:
* 作者 日期 版本 修改内容
* 庄天威 2014/09/12 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.Basics.Library;
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.HRModuleService;
namespace Dongke.IBOSS.PRD.Client.HRModule
{
public partial class F_HR_1201 : DockPanelBase
{
#region 成员变量
// 单例模式
private static F_HR_1201 _instance;
#endregion
#region 构造函数
///
/// 构造函数
///
public F_HR_1201()
{
InitializeComponent();
}
#endregion
#region 单例模式
///
/// 单例模式,防止重复创建窗体
///
public static F_HR_1201 Instance
{
get
{
if (_instance == null)
{
_instance = new F_HR_1201();
}
return _instance;
}
}
#endregion
private void btnSearch_Click(object sender, EventArgs e)
{
try
{
this.dgvSettlement.DataSource = null;
BindData();
if (this.dgvSettlement.Rows.Count == 0)
{
// 提示未查找到数据
MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch(Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
private void btnClearCondition_Click(object sender, EventArgs e)
{
this.txtRemarks.Text = string.Empty;
}
private void tsbtnAdd_Click(object sender, EventArgs e)
{
try
{
//以新建模式打开信息窗体
F_HR_1202 frmHR1202 = new F_HR_1202(0,Constant.FormMode.Add);
DialogResult dialogResult = frmHR1202.ShowDialog();
//操作成功后刷新数据源
if (dialogResult == DialogResult.OK)
{
this.dgvSettlement.DataSource = null;
this.BindData();
if (this.dgvSettlement.Rows.Count == 0)
{
// 提示未查找到数据
MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
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.dgvSettlement.CurrentRow;
if (currentRow != null)
{
int entityId = Convert.ToInt32(currentRow.Cells["SalarySettlementID"].Value);
//以新建模式打开信息窗体
F_HR_1202 frmHR1202 = new F_HR_1202(entityId, Constant.FormMode.Edit);
DialogResult dialogResult = frmHR1202.ShowDialog();
//操作成功后刷新数据源
if (dialogResult == DialogResult.OK)
{
this.dgvSettlement.DataSource = null;
this.BindData();
if (this.dgvSettlement.Rows.Count == 0)
{
// 提示未查找到数据
MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
}
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.dgvSettlement.CurrentRow;
if (currentRow != null)
{
int entityId = Convert.ToInt32(currentRow.Cells["SalarySettlementID"].Value);
//以新建模式打开信息窗体
F_HR_1202 frmHR1202 = new F_HR_1202(entityId, Constant.FormMode.Display);
DialogResult dialogResult = frmHR1202.ShowDialog();
//操作成功后刷新数据源
if (dialogResult == DialogResult.OK)
{
this.dgvSettlement.DataSource = null;
this.BindData();
if (this.dgvSettlement.Rows.Count == 0)
{
// 提示未查找到数据
MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
private void tsbtnAdaptive_Click(object sender, EventArgs e)
{
this.dgvSettlement.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}
private void tsbtnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void BindData()
{
try
{
GetSalaryEntity gsEntity = new GetSalaryEntity();
gsEntity.SalaryDateS = Convert.ToDateTime(this.dtpSalaryDateS.Value.Year + "/" + this.dtpSalaryDateS.Value.Month + "/" + "01");
gsEntity.SalaryDateE = Convert.ToDateTime(this.dtpSalaryDateE.Value.Year + "/" + this.dtpSalaryDateE.Value.Month + "/" + "01");
gsEntity.Remarks = this.txtRemarks.Text;
DataSet dsSourse = (DataSet)DoAsync(new AsyncMethod(() =>
{
return HRModuleProxy.Service.GetSettlementMain(gsEntity);
}));
if(dsSourse != null)
{
this.dgvSettlement.AutoGenerateColumns = false;
this.dgvSettlement.DataSource = dsSourse.Tables[0];
this.dgvSettlement.ReadOnly = true;
}
}
catch(Exception ex)
{
throw ex;
}
}
private void F_HR_1201_FormClosed(object sender, FormClosedEventArgs e)
{
_instance = null;
}
private void dgvSettlement_SelectionChanged(object sender, EventArgs e)
{
if(this.dgvSettlement.SelectedRows.Count !=0)
{
this.tsbtnEdit.Enabled = true;
this.tsbtnAudit.Enabled = true;
}
}
}
}