/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_TAT_0201.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_0201 : DockPanelBase { #region 成员变量 // 单例模式 private static F_TAT_0201 _instance; // 检索用加载条件实体 private WagesEntity _wagesEntity = new WagesEntity(); // 审核状态选择值 private int? _auditStatusValue; // 策略类型选择值 private int? _salaryTypeValue; #endregion #region 构造函数 /// /// 窗体构造 /// public F_TAT_0201() { InitializeComponent(); } #endregion #region 单例模式 /// /// 单例模式 /// public static F_TAT_0201 Instance { get { if (_instance == null) { _instance = new F_TAT_0201(); } return _instance; } } #endregion #region 事件处理 /// /// 窗体加载 /// /// /// private void F_TAT_0201_Load(object sender, EventArgs e) { try { this.Text = FormTitles.F_TAT_0201; this.dgvWages.AutoGenerateColumns = false; //绑定页面各查询条件的数据源 this.BindSelectData(); } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 查询一览 /// /// /// private void btnSelect_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 btnClear_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 dgvWages_SelectionChanged(object sender, EventArgs e) { DataGridViewRow gvrNow = this.dgvWages.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_0202 frmTAT0202 = new F_TAT_0202(Constant.FormMode.Add, 0); DialogResult dialogResult = frmTAT0202.ShowDialog(); //操作成功后刷新数据源 if (dialogResult == DialogResult.OK) { this.dgvWages.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.dgvWages.CurrentRow; if (currentRow != null) { //获取需要添加明细的信息ID int entityId = Convert.ToInt32(currentRow.Cells["colWagesID"].Value); //以复制模式打开信息窗体 F_TAT_0202 frmTAT0202 = new F_TAT_0202(Constant.FormMode.CopyAndAdd, entityId); DialogResult dialogResult = frmTAT0202.ShowDialog(); //操作成功后刷新数据源 if (dialogResult == DialogResult.OK) { this.dgvWages.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.dgvWages.CurrentRow; if (currentRow != null) { //获取需要添加明细的信息ID int entityId = Convert.ToInt32(currentRow.Cells["colWagesID"].Value); //以编辑模式打开信息窗体 F_TAT_0202 frmTAT0202 = new F_TAT_0202(Constant.FormMode.Edit, entityId); DialogResult dialogResult = frmTAT0202.ShowDialog(); //操作成功后刷新数据源 if (dialogResult == DialogResult.OK) { this.dgvWages.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.dgvWages.CurrentRow; if (currentRow != null) { //获取需审核的信息ID int entityId = Convert.ToInt32(currentRow.Cells["colWagesID"].Value); //编辑窗体以审核模式开启 F_TAT_0202 frmTAT0202 = new F_TAT_0202(Constant.FormMode.Display, entityId); DialogResult dialogResult = frmTAT0202.ShowDialog(); //操作成功后刷新数据源与列表 if (dialogResult == DialogResult.OK) { this.dgvWages.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.dgvWages.CurrentRow; if (currentRow != null) { WagesEntity wagesEntity = new WagesEntity(); //获取ID以及时间戳 wagesEntity.WagesID = Convert.ToInt32(currentRow.Cells["colWagesID"].Value); wagesEntity.OPTimeStamp = Convert.ToDateTime(currentRow.Cells["colOPTimeStamp"].Value); ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(() => { return TATModuleProxy.Service.StopWages(wagesEntity); }); //服务实体共通处理 ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text); //成功后刷新数据源 if (srEntity.Status == Constant.ServiceResultStatus.Success) { this.dgvWages.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.dgvWages.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_0201_FormClosed(object sender, FormClosedEventArgs e) { _instance = null; } #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._wagesEntity = new WagesEntity(); if (!string.IsNullOrWhiteSpace(this.txtWagesName.Text)) { this._wagesEntity.WagesName = this.txtWagesName.Text.Trim(); } if (this._auditStatusValue != null) { this._wagesEntity.AuditStatus = this._auditStatusValue; } if (!string.IsNullOrWhiteSpace(this.txtRemarks.Text)) { this._wagesEntity.Remarks = this.txtRemarks.Text; } if (this.cbStartTime.Checked) { this._wagesEntity.BeginAccountMonth = this.dtpStartTimeBetween.Value.Date; this._wagesEntity.BeginAccountMonthEnd = this.dtpStartTimeAfter.Value.Date .AddHours(23).AddMinutes(59).AddSeconds(59); } if (this.cbEndTime.Checked) { this._wagesEntity.EndAccountMonth = this.dtpEndTimeBetween.Value.Date; this._wagesEntity.EndAccountMonthEnd = this.dtpEndTimeAfter.Value.Date .AddHours(23).AddMinutes(59).AddSeconds(59); } if (this._salaryTypeValue != null) { this._wagesEntity.SalaryType = Convert.ToInt32(this._salaryTypeValue); } } catch (Exception ex) { throw ex; } } /// /// 绑定列表查询数据 /// private ServiceResultEntity GetDate() { try { return TATModuleProxy.Service.GetWages(this._wagesEntity); } catch (Exception ex) { throw ex; } } /// /// 绑定页面数据源 /// /// 数据源TABLE private void BindGridView(DataTable dtSourse) { this.dgvWages.DataSource = dtSourse; this.dgvWages.ReadOnly = true; } #endregion } }