/******************************************************************************* * Copyright(c) 2015 dongke All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_PC_0401_1.cs * 2.功能描述:班次配置一览 * 编辑履历: * 作者 日期 版本 修改内容 * 袁新成 2015/04/22 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.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.PCModule { /// /// 班次配置一览 /// public partial class F_PC_0401_1 : DKDockPanelBase { #region 成员变量 // 窗体的单例模式 private static F_PC_0401_1 _instance; // 正在查询 private bool _isSearching = false; #endregion #region 构造函数 /// /// 构造函数 /// public F_PC_0401_1() { this.InitializeComponent(); // 为各个控件文本赋值 this.InitializeControls(); } #endregion #region 单例模式 /// /// 单例模式,防止重复创建窗体 /// public static F_PC_0401_1 Instance { get { if (_instance == null) { _instance = new F_PC_0401_1(); } return _instance; } } #endregion #region 事件 /// /// 页面加载事件 /// /// /// private void F_PC_0401_Load(object sender, EventArgs e) { try { // 加载权限 FormPermissionManager.FormPermissionControl(this.Name, this, LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData); } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 窗体关闭事件 /// /// /// private void F_PC_0401_FormClosed(object sender, FormClosedEventArgs e) { _instance = null; } /// /// 关闭按钮事件 /// /// /// private void tsbtnClose_Click(object sender, EventArgs e) { this.Close(); } /// /// 自动适应列宽 /// /// /// private void tsbtnAdaptive_Click(object sender, EventArgs e) { this.dgvClassesSet.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); this.dgvClassesDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); } /// /// 查询按钮 /// /// /// private void btnSearch_Click(object sender, EventArgs e) { try { this._isSearching = true; this.dgvClassesSet.DataSource = null; this.dgvClassesDetail.DataSource = null; this.DataSource = this.GetSearchData(); if (this.DataSource != null) { this.dgvClassesSet.DataSource = this.DataSource.Tables[0]; if (this.DataSource.Tables.Count > 1) { this.dgvClassesDetail.DataSource = this.DataSource.Tables[1]; } } this._isSearching = false; } catch (Exception ex) { this._isSearching = false; // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 新建按钮 /// /// /// private void tsbtnAdd_Click(object sender, EventArgs e) { try { F_PC_0402_1 frmPC0402 = new F_PC_0402_1(Constant.FormMode.Add); DialogResult dialogresult = frmPC0402.ShowDialog(); if (dialogresult == DialogResult.OK) { // todo this.btnSearch_Click(sender, e); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 逻辑按钮 /// /// /// private void tsbtnEdit_Click(object sender, EventArgs e) { try { DataGridViewRow currentRow = this.dgvClassesSet.CurrentRow; if (currentRow != null) { int classesSettingID = Convert.ToInt32(this.dgvClassesSet.CurrentRow.Cells["ClassesSettingID"].Value.ToString()); int userId = Convert.ToInt32(this.dgvClassesSet.CurrentRow.Cells["userId"].Value.ToString()); F_PC_0402_1 frmPC0402 = new F_PC_0402_1(Constant.FormMode.Edit); frmPC0402.ClassesSettingID = classesSettingID; frmPC0402.UserId = userId; frmPC0402.UserCode = this.dgvClassesSet.CurrentRow.Cells["CSUserCode"].Value.ToString(); frmPC0402.UserName1 = this.dgvClassesSet.CurrentRow.Cells["CSUserName"].Value.ToString(); frmPC0402.Remark = this.dgvClassesSet.CurrentRow.Cells["Remarks"].Value.ToString(); frmPC0402.AccountDate = DateTime.Parse(this.dgvClassesSet.CurrentRow.Cells["AccountDate"].Value.ToString()); DialogResult dialogresult = frmPC0402.ShowDialog(); if (dialogresult == DialogResult.OK) { this.btnSearch_Click(sender, e); } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 单元格鼠标双击事件 /// /// /// private void dgvClassesSet_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0 || e.ColumnIndex < 0) { return; } this.tsbtnEdit_Click(sender, e); } /// /// 行选中事件 /// /// /// private void dgvClassesSet_SelectionChanged(object sender, EventArgs e) { if (this._isSearching) { return; } try { DataGridViewRow currentRow = this.dgvClassesSet.CurrentRow; if (currentRow != null) { int id = Convert.ToInt32(currentRow.Cells["ClassesSettingID"].Value); this.dgvClassesDetail.DataSource = null; // 调用服务器端获取数据集 ServiceResultEntity sre = DoAsync(() => { return PCModuleProxyNew.Service.GetFPC0401SDData(id); } ); if (sre.Status == Constant.ServiceResultStatus.Success) { this.dgvClassesDetail.DataSource = sre.Data.Tables[0]; } } else { DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_001); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 清空条件按钮 /// /// /// private void btnClearCondition_Click(object sender, EventArgs e) { this.txtUserCode.Clear(); this.txtRemarks.Clear(); this.dtpDateBegin.Value = DateTime.Now.Date; this.dtpDateEnd.Value = DateTime.Now.Date; } #endregion #region 私有方法/函数 /// /// 初始化控件 /// private void InitializeControls() { this.Text = FormTitles.F_PC_0401; this.tsbtnAdd.Text = ButtonText.TSBTN_ADD; this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT; this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE; this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE; this.btnSearch.Text = ButtonText.BTN_SEARCH; this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION; this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS; // 取客户端当天日期 this.dtpDateBegin.Value = DateTime.Now.Date; this.dtpDateEnd.Value = DateTime.Now.Date; this.dgvClassesSet.AutoGenerateColumns = false; this.dgvClassesSet.ReadOnly = true; this.dgvClassesDetail.AutoGenerateColumns = false; this.dgvClassesDetail.ReadOnly = true; } /// /// 根据界面查询条件获取数据集 /// private DataSet GetSearchData() { try { FPC0401_SE se = new FPC0401_SE(); se.UserCode = this.txtUserCode.Text; se.DateBegin = this.dtpDateBegin.Value.Date; se.DateEnd = this.dtpDateEnd.Value.Date; se.Remarks = this.txtRemarks.Text; // 调用服务器端获取数据集 ServiceResultEntity sre = DoAsync(() => { return PCModuleProxyNew.Service.GetFPC0401SData(se); } ); if (sre.Data == null || sre.Data.Tables[0]==null || sre.Data.Tables[0].Rows.Count == 0) { // 提示未查找到数据 MessageBox.Show(Messages.MSG_CMN_I002, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); //清空数据 return null; } if (sre.Status == Constant.ServiceResultStatus.Success) { return sre.Data; } return null; } catch (Exception ex) { throw ex; } } #endregion } }