| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355 |
- /*******************************************************************************
- * 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
- {
- /// <summary>
- /// 报表数据来源
- /// </summary>
- 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 单例模式
- /// <summary>
- /// 单例模式,防止重复创建窗体
- /// </summary>
- public static F_MST_0701 Instance
- {
- get
- {
- if (_instance == null)
- {
- _instance = new F_MST_0701();
- }
- return _instance;
- }
- }
- #endregion
- #region 事件
- /// <summary>
- /// 窗体加载
- /// </summary>
- private void F_MST_0701_Load(object sender, EventArgs e)
- {
- //绑定报表工序类型
- BindSelectData();
- this.dgvRptProcedure.AutoGenerateColumns = false;
- this.dgvRptSProcedure.AutoGenerateColumns = false;
- this.dgvRptTProcedure.AutoGenerateColumns = false;
- }
- /// <summary>
- /// 查询事件
- /// </summary>
- 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);
- }
- }
- /// <summary>
- /// 清空事件
- /// </summary>
- private void btnClearCondition_Click(object sender, EventArgs e)
- {
- this.txtRptProcedureName.Text = string.Empty;
- }
- /// <summary>
- /// 关闭窗体事件
- /// </summary>
- private void tsbtnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 自适应事件
- /// </summary>
- private void tsbtnAdaptive_Click(object sender, EventArgs e)
- {
- this.dgvRptProcedure.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- this.dgvRptSProcedure.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- this.dgvRptTProcedure.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- }
- /// <summary>
- /// 窗体关闭事件
- /// </summary>
- private void F_MST_0701_FormClosed(object sender, FormClosedEventArgs e)
- {
- _instance = null;
- }
- /// <summary>
- /// 添加事件
- /// </summary>
- 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);
- }
- }
- /// <summary>
- ///编辑事件
- /// </summary>
- 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);
- }
- }
- /// <summary>
- /// 停用事件
- /// </summary>
- 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);
- }
- }
- /// <summary>
- /// 行选中事件
- /// </summary>
- 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 私有方法
- /// <summary>
- /// 绑定数据来源类型
- /// </summary>
- 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;
- }
- /// <summary>
- /// 获取查询条件值
- /// </summary>
- 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
- }
- }
|