| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347 |
- /*******************************************************************************
- * Copyright(c) 2012 dongke All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:S_CMN_023.cs
- * 2.功能描述:窑炉信息控件查询界面
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 王鑫 2015/09/10 1.00 新建
- *******************************************************************************/
- using System;
- using System.ComponentModel;
- using System.Data;
- using System.Text;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseControls;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Basics.Library;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- namespace Dongke.IBOSS.PRD.Client.Controls.FormCommon
- {
- public partial class S_CMN_023 : FormBase
- {
- #region 成员变量
- // 单例模式
- private static S_CMN_023 _instance;
- // 最后选择行
- private int _selecedRow;
- #endregion
- #region 属性
- /// <summary>
- /// 选择的数据
- /// </summary>
- public DataTable SelTable { get; set; }
- /// <summary>
- /// 传入的窑炉编码
- /// </summary>
- public string SetKilnCode { get; set; }
- #endregion
- #region 单例模式
- /// <summary>
- /// 单例模式,防止重复创建窗体
- /// </summary>
- public static S_CMN_023 Instance
- {
- get
- {
- if (_instance == null)
- {
- _instance = new S_CMN_023();
- }
- return _instance;
- }
- }
- #endregion
- #region 构造函数
- public S_CMN_023()
- {
- InitializeComponent();
- this.Text ="窑炉选择";
-
- this.btnSearch.Text = ButtonText.BTN_SEARCH;
- //this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
- this.btnOK.Text = ButtonText.BTN_OK;
- this.btnClose.Text = ButtonText.BTN_CANCEL;
- this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
- }
- #endregion
- #region 事件
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void FrmUser_Load(object sender, EventArgs e)
- {
- try
- {
- // 设置表格不自动创建列
- this.dgvKiln.AutoGenerateColumns = false;
- this.dgvKiln.Columns["Sel"].ReadOnly = false;
- this.txtKilnCode.Text = this.SetKilnCode;
- this.btnSearch_Click(null, null);
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 释放成员变量
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void FrmOrganization_FormClosed(object sender, FormClosedEventArgs e)
- {
- _instance = null;
- }
- /// <summary>
- /// 搜索按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSearch_Click(object sender, EventArgs e)
- {
- try
- {
- // 根据页面设定用户实体值
- //this.GetUserEntityFromLayout();
- // 记录当前选中行
- int selectRowIndex = this._selecedRow;
- // 异步处理
- this.btnSearch.Enabled = false;
- //this.btnClearCondition.Enabled = false;
- DataSet userDataSet = (DataSet)DoAsync(new BaseAsyncMethod(this.SearchKilnData));
- this.btnSearch.Enabled = true;
-
- if (userDataSet != null)
- {
- string sql = null;
- if (!string.IsNullOrWhiteSpace(this.txtKilnCode.Text))
- {
- sql = " kilncode like '%" + this.txtKilnCode.Text.Trim() + "%' ";
- }
- if (!string.IsNullOrWhiteSpace(this.txtKilnName.Text))
- {
- if (sql != null)
- {
- sql += " and ";
- }
- sql += " kilnname like '%" + this.txtKilnName.Text.Trim() + "%' ";
- }
- userDataSet.Tables[0].DefaultView.RowFilter = sql;
- base.DataSource = (DataSet)userDataSet;
- if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
- {
- this.dgvKiln.DataSource = this.DataSource.Tables[0];
- if (this.DataSource.Tables[0].DefaultView.Count <= Constant.INT_IS_ZERO)
- {
- // 提示未查找到数据
- MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else
- {
- //if (selectRowIndex >= Constant.INT_IS_ZERO)
- //{
- // if (selectRowIndex >= userDataSet.Tables[0].Rows.Count)
- // {
- // this.dgvKiln.Rows[this.dgvKiln.Rows.Count - 1].Selected = true;
- // this.dgvKiln.CurrentCell = this.dgvKiln.Rows[this.dgvKiln.Rows.Count - 1].Cells["kilnCode"];
- // }
- // else
- // {
- // this.dgvKiln.Rows[selectRowIndex].Selected = true;
- // this.dgvKiln.CurrentCell = this.dgvKiln.Rows[selectRowIndex].Cells["kilnCode"];
- // }
- //}
- }
- }
- }
- this.dgvKiln.IsSetInputColumnsColor = true;
- }
- catch (Exception ex)
- {
- this.btnSearch.Enabled = true;
-
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 选中行发生改变时 有效停用相互切换
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvUser_CellEnter(object sender, DataGridViewCellEventArgs e)
- {
- if (dgvKiln.Rows.Count > Constant.INT_IS_ZERO)
- {
- this._selecedRow = this.dgvKiln.CurrentCell.RowIndex;
- }
- }
- /// <summary>
- /// 窗体关闭事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_MST_0203_FormClosed(object sender, FormClosedEventArgs e)
- {
- _instance = null;
- }
- /// <summary>
- /// 自动适应列宽事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAdaptive_Click(object sender, EventArgs e)
- {
- this.dgvKiln.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- }
- /// <summary>
- /// 全选
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void chkChooseAll_CheckedChanged(object sender, EventArgs e)
- {
- try
- {
- for (int i = 0; i < this.dgvKiln.Rows.Count; i++)
- {
- this.dgvKiln.Rows[i].Cells["Sel"].Value = this.chkChooseAll.Checked;
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 确定
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnOK_Click(object sender, EventArgs e)
- {
- try
- {
- this.Commit();
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 关闭窗体
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 点击确定或者回车键时调用
- /// </summary>
- private void Commit()
- {
- try
- {
- DataTable invDt = (DataTable)this.dgvKiln.DataSource;
- if (invDt == null || invDt.Rows.Count == Constant.INT_IS_ZERO)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
- "没有选择数据"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- invDt.AcceptChanges();
- invDt = invDt.Copy();
- string filter = "Sel = 1";
- invDt.DefaultView.RowFilter = filter;
- invDt = invDt.DefaultView.ToTable();
- // 如果选中了数据就关闭窗体,反之则不关
- if (invDt.Rows.Count > Constant.INT_IS_ZERO)
- {
- SelTable = invDt;
- this.DialogResult = DialogResult.OK;
- this.Close();
- }
- else
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
- "没有选择数据"),this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning);
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 获取窑炉列表
- /// </summary>
- /// <returns></returns>
- private DataSet SearchKilnData()
- {
- try
- {
- return SystemModuleProxy.Service.GetKilnData(1);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- private void btnClearCondition_Click(object sender, EventArgs e)
- {
- this.txtKilnCode.Clear();
- this.txtKilnName.Clear();
- }
- }
- }
|