/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_MST_0701.cs * 2.功能描述:报表数据来源 * 编辑履历: * 作者 日期 版本 修改内容 * 宋扬 2014/12/25 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.SystemModuleService; namespace Dongke.IBOSS.PRD.Client.SystemModule { /// /// 报表数据来源 /// public partial class F_MST_0701 : DockPanelBase { #region 成员变量 //单例模式 private static F_MST_0701 _instance; //实体类 private RptProcedureEntity _rptProcedureEntity; #endregion #region 构造函数 public F_MST_0701() { InitializeComponent(); this.Text = FormTitles.F_MST_0701; this.btnSearch.Text = ButtonText.BTN_SEARCH; this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION; this.tsbtnAdd.Text = ButtonText.TSBTN_ADD; this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT; this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE; this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE; this.tsbtnDisable.Text = ButtonText.TSBTN_DISABLE; this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS; } #endregion #region 单例模式 /// /// 单例模式,防止重复创建窗体 /// public static F_MST_0701 Instance { get { if (_instance == null) { _instance = new F_MST_0701(); } return _instance; } } #endregion #region 事件 /// /// 窗体加载 /// private void F_MST_0701_Load(object sender, EventArgs e) { //绑定报表工序类型 BindSelectData(); this.dgvRptProcedure.AutoGenerateColumns = false; this.dgvRptSProcedure.AutoGenerateColumns = false; this.dgvRptTProcedure.AutoGenerateColumns = false; } /// /// 查询事件 /// private void btnSearch_Click(object sender, EventArgs e) { try { //获取查询条件 BindSelectedData(); DataSet dsSearchRptProcedure = (DataSet)DoAsync(() => { return SystemModuleProxy.Service.GetRptProcedureModule(_rptProcedureEntity); }); if (dsSearchRptProcedure != null) { if (dsSearchRptProcedure.Tables[Constant.INT_IS_ZERO].Rows.Count <= Constant.INT_IS_ZERO) { // 提示未查找到数据 MessageBox.Show(Messages.MSG_CMN_I002, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); //清空数据 this.dgvRptProcedure.DataSource = null; } else { this.dgvRptProcedure.DataSource = dsSearchRptProcedure.Tables[Constant.INT_IS_ZERO]; } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 清空事件 /// private void btnClearCondition_Click(object sender, EventArgs e) { this.txtRptProcedureName.Text = string.Empty; } /// /// 关闭窗体事件 /// private void tsbtnClose_Click(object sender, EventArgs e) { this.Close(); } /// /// 自适应事件 /// private void tsbtnAdaptive_Click(object sender, EventArgs e) { this.dgvRptProcedure.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); this.dgvRptSProcedure.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); this.dgvRptTProcedure.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); } /// /// 窗体关闭事件 /// private void F_MST_0701_FormClosed(object sender, FormClosedEventArgs e) { _instance = null; } /// /// 添加事件 /// private void tsbtnAdd_Click(object sender, EventArgs e) { try { //以新建模式打开信息窗体 F_MST_0702 frmMST0702 = new F_MST_0702(Constant.FormMode.Add, Constant.INT_IS_ZERO); DialogResult dialogResult = frmMST0702.ShowDialog(); if (dialogResult == DialogResult.OK) { btnSearch_Click(sender, e); } } 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.dgvRptProcedure.CurrentRow; if (currentRow != null) { //获取需要的信息ID int entityId = Convert.ToInt32(currentRow.Cells["RptProcedureID"].Value); //以复制模式打开信息窗体 F_MST_0702 frmMST0702 = new F_MST_0702(Constant.FormMode.Edit, entityId); DialogResult dialogResult = frmMST0702.ShowDialog(); //操作成功后刷新数据源 if (dialogResult == DialogResult.OK) { btnSearch_Click(sender, e); } } } 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.dgvRptProcedure.CurrentRow; if (currentRow != null) { this._rptProcedureEntity = new RptProcedureEntity(); //获取需要的信息ID this._rptProcedureEntity.RptProcedureID = Convert.ToInt32(currentRow.Cells["RptProcedureID"].Value); this._rptProcedureEntity.OPTimeStamp = Convert.ToDateTime(currentRow.Cells["OPTimeStamp"].Value); int resultCount = (int)DoAsync(() => { return SystemModuleProxy.Service.StopRptProcedure(this._rptProcedureEntity); }); if (resultCount > Constant.INT_IS_ZERO) { MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "报表数据来源", "停用"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); //获取条件 BindSelectedData(); //清空 this.dgvRptProcedure.DataSource = null; DataSet dsSearchRptProcedure = (DataSet)DoAsync(new AsyncMethod(() => { return SystemModuleProxy.Service.GetRptProcedureModule(_rptProcedureEntity); })); if (dsSearchRptProcedure != null) { if (dsSearchRptProcedure.Tables[Constant.INT_IS_ZERO].Rows.Count <= Constant.INT_IS_ZERO) { // 提示未查找到数据 MessageBox.Show(Messages.MSG_CMN_I002, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); //清空数据 this.dgvRptProcedure.DataSource = null; } else { this.dgvRptProcedure.DataSource = dsSearchRptProcedure.Tables[Constant.INT_IS_ZERO]; } } } else { MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "报表数据来源", "停用"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 行选中事件 /// private void dgvRptProcedure_SelectionChanged(object sender, EventArgs e) { if (this.dgvRptProcedure.SelectedRows.Count != Constant.INT_IS_ZERO) { DataGridViewRow gvrNow = this.dgvRptProcedure.SelectedRows[Constant.INT_IS_ZERO]; if (gvrNow.Cells["RptProcedureID"].Value != DBNull.Value && gvrNow.Cells["RptProcedureID"].Value != null) { int rptProcedureId = Convert.ToInt32(gvrNow.Cells["RptProcedureID"].Value.ToString()); DataSet dsSearchProcedure = SystemModuleProxy.Service.GetRptProcedureIdByProcedureInfo(rptProcedureId); if (dsSearchProcedure != null) { //绑定来源工序 if (dsSearchProcedure.Tables[Constant.INT_IS_ZERO].Rows.Count <= Constant.INT_IS_ZERO) { // 提示未查找到数据 //MessageBox.Show(Messages.MSG_CMN_I002, this.Text, // MessageBoxButtons.OK, MessageBoxIcon.Information); //清空数据 this.dgvRptSProcedure.DataSource = null; } else { this.dgvRptSProcedure.DataSource = dsSearchProcedure.Tables[Constant.INT_IS_ZERO]; } //绑定统计工序 if (dsSearchProcedure.Tables[Constant.INT_IS_ONE].Rows.Count <= Constant.INT_IS_ZERO) { // 提示未查找到数据 //MessageBox.Show(Messages.MSG_CMN_I002, this.Text, // MessageBoxButtons.OK, MessageBoxIcon.Information); //清空数据 this.dgvRptTProcedure.DataSource = null; } else { this.dgvRptTProcedure.DataSource = dsSearchProcedure.Tables[Constant.INT_IS_ONE]; } } } } } #endregion #region 私有方法 /// /// 绑定数据来源类型 /// private void BindSelectData() { DataTable newdtb = new DataTable(); newdtb.Columns.Add("RptProcedureTypeId", typeof(string)); newdtb.Columns.Add("RptProcedureType", typeof(string)); DataRow newRow = newdtb.NewRow(); newRow["RptProcedureTypeId"] = "A0001"; newRow["RptProcedureType"] = "出窑统计"; newdtb.Rows.Add(newRow); this.cobRptProcedureType.DisplayMember = "RptProcedureType"; this.cobRptProcedureType.ValueMember = "RptProcedureTypeId"; this.cobRptProcedureType.DataSource = newdtb; } /// /// 获取查询条件值 /// private void BindSelectedData() { this._rptProcedureEntity = new RptProcedureEntity(); this._rptProcedureEntity.RptProcedureName = this.txtRptProcedureName.Text.Trim(); if (this.cobRptProcedureType.SelectedValue != null) { this._rptProcedureEntity.RptProcedureTpye = this.cobRptProcedureType.SelectedValue.ToString(); } } #endregion } }