/*******************************************************************************
* Copyright(c) 2012 dongke All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:S_CMN_009.cs
* 2.功能描述:成型线控件查询界面
* 编辑履历:
* 作者 日期 版本 修改内容
* 庄天威 2014/09/17 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
{
///
/// 成型线控件查询界面
///
public partial class S_CMN_009 : FormBase
{
#region 成员变量
private DataTable _dataSource; // 画面的数据源
private DataRow _dataRow; // 返回原画面的DataRow
private DataTable _dataDT; //返回选择数据源
#endregion
#region 构造函数
///
/// 构造函数
///
public S_CMN_009()
{
InitializeComponent();
// 按钮
this.btnSearch.Text = ButtonText.BTN_SEARCH;
this.btnOK.Text = ButtonText.BTN_OK;
this.btnClose.Text = ButtonText.BTN_CANCEL;
this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
this.cbSelectAll.Visible = false;
}
public S_CMN_009(int flag)
{
InitializeComponent();
// 按钮
this.btnSearch.Text = ButtonText.BTN_SEARCH;
this.btnOK.Text = ButtonText.BTN_OK;
this.btnClose.Text = ButtonText.BTN_CANCEL;
this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
if (flag == 1)
{
this.sel.Visible = true;
this.cbSelectAll.Visible = true;
}
else
{
this.sel.Visible = false;
this.cbSelectAll.Visible = false;
}
}
public S_CMN_009(int flag,int NoGroutingFlag)
{
InitializeComponent();
// 按钮
// 按钮
this.btnSearch.Text = ButtonText.BTN_SEARCH;
this.btnOK.Text = ButtonText.BTN_OK;
this.btnClose.Text = ButtonText.BTN_CANCEL;
this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
if (flag == 1)
{
this.sel.Visible = true;
this.cbSelectAll.Visible = true;
}
else
{
this.sel.Visible = false;
this.cbSelectAll.Visible = false;
}
if(NoGroutingFlag == 1)
{
this.NoGroutingRreason.Visible = true;
}
else
{
this.NoGroutingRreason.Visible = false;
}
}
#endregion
#region 属性
///
/// 获取或者设定画面的数据源。
///
[Description("获取或者设定画面的数据源。")]
public new DataTable DataSource
{
get
{
return _dataSource;
}
set
{
_dataSource = value;
}
}
///
/// 返回选择的数据行
///
public DataRow DataRow
{
get
{
return _dataRow;
}
set
{
_dataRow = value;
}
}
///
/// 返回选择的组织多行
///
public DataTable dataDT
{
get
{
return _dataDT;
}
set
{
_dataDT = value;
}
}
#endregion
#region 私有方法/函数
///
/// 查询方法
///
private void Search()
{
this.dgvGroutingLine.AutoGenerateColumns = false;
// 清空之前的查询结果
this.dgvGroutingLine.DataSource = null;
// 根据查询条件查询数据源中的数据,并显示
DataTable MouldTypeTable = this.DataSource.Copy();
MouldTypeTable.DefaultView.RowFilter = GetFilterExpression();
this.dgvGroutingLine.DataSource = MouldTypeTable.DefaultView.ToTable();
this.dgvGroutingLine.Focus();
// 当没有查询结果时,提示无查询结构消息
if (this.dgvGroutingLine.RowCount <= 0)
{
MessageBox.Show(ControlsTips.DK_SearchBox_NoResult,
this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning);
this.txtUserCode.Focus();
this.btnOK.Enabled = false;
return;
}
this.btnOK.Enabled = true;
//绑定未注浆原因
BindNoGroutingRreason();
}
///
/// 提交时给取得的行赋值
///
private void Commit()
{
if (this.sel.Visible)
{
if (this.dgvGroutingLine.CurrentCell != null)
{
this.dataDT = (DataTable)this.dgvGroutingLine.DataSource;
this.DialogResult = DialogResult.OK;
}
}
else
{
if (this.dgvGroutingLine.CurrentCell != null)
{
DataRow = this.dgvGroutingLine.GetDataRow(this.dgvGroutingLine.CurrentCell.RowIndex);
this.DialogResult = DialogResult.OK;
}
}
this.Close();
}
///
/// 根据画面输入内容拼接过滤条件
///
///
private string GetFilterExpression()
{
StringBuilder strbFilterExpressions = new StringBuilder();
strbFilterExpressions.Append("(1=1");
if (!string.IsNullOrEmpty(this.txtGroutingLineCode.Text))
{
// 成型线编码
strbFilterExpressions.Append(string.Format(" AND GroutingLineCode LIKE '%{0}%'",
Utility.SelectFilterLike(this.txtGroutingLineCode.Text.Trim())));
}
if (!string.IsNullOrEmpty(this.txtGroutingLineName.Text))
{
// 成型线名称
strbFilterExpressions.Append(string.Format(" AND GroutingLineName LIKE '%{0}%'",
Utility.SelectFilterLike(this.txtGroutingLineName.Text.Trim())));
}
if(!string.IsNullOrEmpty(this.txtUserCode.Text))
{
// 注浆编号
//strbFilterExpressions.Append( " AND instr(','||:DefectTypeIDS||',',','||TP_MST_DefectType.DefectTypeID||',')>0 ");
//strbFilterExpressions.Append(string.Format(" AND instr(','||{0}||',',','||UserCode||',')>0 ",
// Utility.SelectFilterLike(this.txtUserCode.Text.Trim())));
strbFilterExpressions.Append(string.Format(" AND UserCodeList LIKE '%{0}%'",
Utility.SelectFilterLike(this.txtUserCode.Text.Trim())));
}
strbFilterExpressions.Append(")");
return strbFilterExpressions.ToString();
}
///
/// 绑定未注浆状态
///
private void BindNoGroutingRreason()
{
try
{
DataTable dtNoGroutingRreason = SystemModuleProxy.Service.GetDataDictionaryByType(
Constant.DictionaryType.TPC004, Constant.INT_IS_ONE);
DataRow drNull = dtNoGroutingRreason.NewRow();
drNull["DICTIONARYID"] = -1;
drNull["DICTIONARYTYPE"] = -1;
drNull["DICTIONARYVALUE"] = "";
drNull["REMARKS"] = "";
dtNoGroutingRreason.Rows.InsertAt(drNull, 0);
this.NoGroutingRreason.DataSource = dtNoGroutingRreason;
this.NoGroutingRreason.ValueMember = "DictionaryID";
this.NoGroutingRreason.DisplayMember = "DictionaryValue";
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 控件事件
///
/// 双击事件
///
private void dgvGroutingLine_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
try
{
// 判断是否是双击列头,如果是双击列头的话,不做任何操作
if (-1 < e.RowIndex && -1 < e.ColumnIndex)
{
//判断有没有复选框,如果有不做任何操作
if (!this.sel.Visible)
{
Commit();
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
private void S_CMN_007_Load(object sender, EventArgs e)
{
try
{
this.dgvGroutingLine.AutoGenerateColumns = false;
if (!string.IsNullOrEmpty(this.txtGroutingLineCode.Text))
{
Search();
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 查询按钮按下事件
///
///
///
private void btnSearch_Click(object sender, System.EventArgs e)
{
try
{
Search();
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// KeyDown事件
///
///
///
private void dgvOrganization_KeyDown(object sender, KeyEventArgs e)
{
try
{
// 拷贝单元格文本到剪切板
if (e.KeyData == (Keys.Control | Keys.C))
{
if (dgvGroutingLine.CurrentRow != null
&& !string.IsNullOrEmpty(dgvGroutingLine.CurrentRow.Cells[dgvGroutingLine.CurrentCell.ColumnIndex].EditedFormattedValue + ""))
{
Clipboard.SetText(dgvGroutingLine.CurrentRow.Cells[dgvGroutingLine.CurrentCell.ColumnIndex].EditedFormattedValue + "");
}
}
else if (e.KeyData == Keys.Enter)
{
Commit();
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 确定按钮按下事件
///
///
///
private void btnOK_Click(object sender, System.EventArgs e)
{
try
{
Commit();
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 关闭按钮按下事件
///
///
///
private void btnClose_Click(object sender, System.EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
#endregion
private void cbSelectAll_CheckedChanged(object sender, EventArgs e)
{
foreach (DataGridViewRow gvrNow in this.dgvGroutingLine.Rows)
{
gvrNow.Cells["sel"].Value = this.cbSelectAll.Checked ? 1 : 0;
}
}
private void btnClearCondition_Click(object sender, EventArgs e)
{
this.txtGroutingLineCode.Clear();
this.txtGroutingLineName.Clear();
this.txtUserCode.Clear();
}
}
}