/*******************************************************************************
* Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_PAM_0101.cs
* 2.功能描述:工资方案参数设定
* 编辑履历:
* 作者 日期 版本 修改内容
* 王鑫 2015/08/17 1.00 新建
*******************************************************************************/
using System;
using System.Data;
using System.Reflection;
using System.Windows.Forms;
using Dongke.IBOSS.PRD.Basics.BaseControls;
using Dongke.IBOSS.PRD.Basics.BaseResources;
using Dongke.IBOSS.PRD.Basics.DockPanel;
using Dongke.IBOSS.PRD.Client.CommonModule;
using Dongke.IBOSS.PRD.Client.Controls;
using Dongke.IBOSS.PRD.Client.DataModels;
using Dongke.IBOSS.PRD.WCF.DataModels;
using Dongke.IBOSS.PRD.WCF.Proxys;
namespace Dongke.IBOSS.PRD.Client.PAMModule
{
///
/// 工资方案参数设定
///
public partial class F_PAM_0101 : DKDockPanelBase
{
#region 成员变量
// 单例模式
private static F_PAM_0101 _instance;
// 数据源
private DataTable _dtSourse;
// 选定行
private int _selectedRow = 0;
#endregion
#region 单例模式
///
/// 单例模式,防止重复创建窗体
///
public static F_PAM_0101 Instance
{
get
{
if (_instance == null)
{
_instance = new F_PAM_0101();
}
return _instance;
}
}
#endregion
#region 构造函数
public F_PAM_0101()
{
InitializeComponent();
this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
this.tsbtnSave.Text = ButtonText.BTN_SAVE;
this.Text = FormTitles.F_PAM_0101;
}
#endregion
#region 事件
///
/// 关闭按钮事件
///
///
///
private void tsbtnClose_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 自动适应列宽
///
///
///
private void tsbtnAdaptive_Click(object sender, EventArgs e)
{
this.dgvPayPlanSetting.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}
///
/// 窗体加载事件
///
///
///
private void F_PAM_0101_Load(object sender, EventArgs e)
{
try
{
// 设置datagridview不自动创建列
this.dgvPayPlanSetting.AutoGenerateColumns = false;
//this.dgvPayPlanSetting.IsSetInputColumnsColor = true;
this.dgvPayPlanSetting.AllowUserToDeleteRows = false;
// 加载数据源
this.GetPayPlanSetting();
//权限控制
FormPermissionManager.FormPermissionControl(this.Name, this,
LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
this.dgvPayPlanSetting.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect;
tsbtnSave.Size = new System.Drawing.Size(60,25);
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 窗体关闭事件
///
///
///
private void F_PAM_0101_FormClosed(object sender, FormClosedEventArgs e)
{
_instance = null;
}
///
/// 保存按钮事件
///
///
///
private void tsbtnSave_Click(object sender, EventArgs e)
{
try
{
//this.dgvPayPlanSetting.CommitEdit(DataGridViewDataErrorContexts.Commit);
this.dgvPayPlanSetting.EndEdit();
DataTable dt = this.dgvPayPlanSetting.DataSource as DataTable;
if (dt == null)
{
return;
}
int returnValue = (int)DoAsync(new AsyncMethod(() =>
{
return PAMModuleProxy.Service.SavePayPlanSetting(dt);
}));
if (returnValue > 0)
{
// 提示信息
MessageBox.Show(string.Format(Messages.MSG_CMN_I001, this.Text, "保存"),
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
GetPayPlanSetting();
}
//else if (returnValue == 0)
//{
// // 提示信息
// MessageBox.Show("保存失败",
// this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
//}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
#endregion
#region 私有方法
///
/// 获取数据
///
///
///
///
///
private void GetPayPlanSetting()
{
try
{
DataSet dsResultAccount = (DataSet)DoAsync(new AsyncMethod(() =>
{
return PAMModuleProxy.Service.GetPayPlanSetting();
}));
this._dtSourse = dsResultAccount.Tables[0];
this.dgvPayPlanSetting.DataSource = this._dtSourse;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
private void dgvPayPlanSetting_CurrentCellDirtyStateChanged(object sender, EventArgs e)
{
//try
//{
// if (this.dgvPayPlanSetting.CurrentRow != null && this.dgvPayPlanSetting.IsCurrentCellDirty)
// {
// if ("SettingValue".Equals(this.dgvPayPlanSetting.Columns
// [this.dgvPayPlanSetting.CurrentCell.ColumnIndex].Name))
// {
// this.dgvPayPlanSetting.CommitEdit(DataGridViewDataErrorContexts.Commit);
// }
// }
//}
//catch (Exception ex)
//{
// // 对异常进行共通处理
// ExceptionManager.HandleEventException(this.ToString(),
// System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
//}
}
private void F_PAM_0101_Shown(object sender, EventArgs e)
{
this.dgvPayPlanSetting.IsSetInputColumnsColor = true;
}
}
}