| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Text; |
| | | using System.Windows.Forms; |
| | | using DevExpress.XtraEditors; |
| | | using DevExpress.XtraEditors.Controls; |
| | | using DevExpress.XtraGrid.Columns; |
| | | using Gs.DevApp.ToolBox; |
| | | using static Gs.DevApp.ToolBox.UtilityHelper; |
| | | |
| | | |
| | | namespace Gs.DevApp.UserControl |
| | | { |
| | | public partial class ShowFilter : DevExpress.XtraEditors.XtraForm |
| | | public partial class ShowFilter : XtraForm |
| | | { |
| | | /// <summary> |
| | | /// 回调事件 |
| | | /// </summary> |
| | | public event EventHandler<UpdateParentEventArgs> UpdateParent; |
| | | private readonly GridColumnCollection _columns; |
| | | |
| | | public ShowFilter(GridColumnCollection Columns, |
| | | List<FilterEntity> list = null) |
| | | { |
| | | FilterList = list; |
| | | _columns = Columns; |
| | | InitializeComponent(); |
| | | repositoryItemComboBox1.TextEditStyle = |
| | | TextEditStyles.DisableTextEditor; |
| | | repositoryItemComboBox1.SelectedIndexChanged += |
| | | RepositoryItemComboBox1_SelectedIndexChanged; |
| | | repositoryItemComboBox1.ParseEditValue += |
| | | RepositoryItemComboBox1_ParseEditValue; |
| | | repositoryItemComboBox2.TextEditStyle = |
| | | TextEditStyles.DisableTextEditor; |
| | | repositoryItemComboBox2.SelectedIndexChanged += |
| | | RepositoryItemComboBox2_SelectedIndexChanged; |
| | | repositoryItemComboBox2.ParseEditValue += |
| | | RepositoryItemComboBox2_ParseEditValue; |
| | | gridView1.OptionsFind.ShowSearchNavButtons = false; |
| | | // this.gridView1.OptionsView.ShowAutoFilterRow = true; |
| | | gridView1.OptionsView.ShowGroupPanel = false; |
| | | btnEsc.Click += BtnEsc_Click; |
| | | btnQuery.Click += BtnQuery_Click; |
| | | getPageList(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 查询集合 |
| | | /// 查询集合 |
| | | /// </summary> |
| | | public List<FilterEntity> FilterList { get; set; } |
| | | |
| | | |
| | | private GridColumnCollection _columns; |
| | | public ShowFilter(GridColumnCollection Columns, List<FilterEntity> list = null) |
| | | { |
| | | this.FilterList = list; |
| | | this._columns = Columns; |
| | | InitializeComponent(); |
| | | repositoryItemComboBox1.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; |
| | | repositoryItemComboBox1.SelectedIndexChanged += RepositoryItemComboBox1_SelectedIndexChanged; |
| | | repositoryItemComboBox1.ParseEditValue += RepositoryItemComboBox1_ParseEditValue; |
| | | repositoryItemComboBox2.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; |
| | | repositoryItemComboBox2.SelectedIndexChanged += RepositoryItemComboBox2_SelectedIndexChanged; |
| | | repositoryItemComboBox2.ParseEditValue += RepositoryItemComboBox2_ParseEditValue; |
| | | this.gridView1.OptionsFind.ShowSearchNavButtons = false; |
| | | // this.gridView1.OptionsView.ShowAutoFilterRow = true; |
| | | this.gridView1.OptionsView.ShowGroupPanel = false; |
| | | this.btnEsc.Click += BtnEsc_Click; |
| | | this.btnQuery.Click += BtnQuery_Click; |
| | | getPageList(); |
| | | } |
| | | /// <summary> |
| | | /// 回调事件 |
| | | /// </summary> |
| | | public event EventHandler<UpdateParentEventArgs> UpdateParent; |
| | | |
| | | private void BtnQuery_Click(object sender, EventArgs e) |
| | | { |
| | | gridView1.CloseEditor(); |
| | | gridView1.UpdateCurrentRow(); |
| | | System.Text.StringBuilder sbWhere = new System.Text.StringBuilder(); |
| | | List<FilterEntity> list = new List<FilterEntity>(); |
| | | for (int i = 0; i < gridView1.DataRowCount; i++) |
| | | var sbWhere = new StringBuilder(); |
| | | var list = new List<FilterEntity>(); |
| | | for (var i = 0; i < gridView1.DataRowCount; i++) |
| | | { |
| | | if (string.IsNullOrEmpty(this.gridView1.GetRowCellValue(i, "field").ToString()) |
| | | || string.IsNullOrEmpty(this.gridView1.GetRowCellValue(i, "fieldWhere").ToString()) |
| | | || string.IsNullOrEmpty(this.gridView1.GetRowCellValue(i, "fieldValue").ToString()) |
| | | ) |
| | | if (string.IsNullOrEmpty(gridView1.GetRowCellValue(i, "field") |
| | | .ToString()) |
| | | || string.IsNullOrEmpty(gridView1 |
| | | .GetRowCellValue(i, "fieldWhere").ToString()) |
| | | || string.IsNullOrEmpty(gridView1 |
| | | .GetRowCellValue(i, "fieldValue").ToString()) |
| | | ) |
| | | continue; |
| | | string _fieId, _fileIdDec; |
| | | (_fieId, _fileIdDec) = _getFiled(this.gridView1.GetRowCellValue(i, "field").ToString()); |
| | | (_fieId, _fileIdDec) = |
| | | _getFiled(gridView1.GetRowCellValue(i, "field").ToString()); |
| | | string _fileWhere, _fileWhereDec; |
| | | (_fileWhere, _fileWhereDec) = _getFiled(this.gridView1.GetRowCellValue(i, "fieldWhere").ToString()); |
| | | string _fieldValue = this.gridView1.GetRowCellValue(i, "fieldValue").ToString(); |
| | | (_fileWhere, _fileWhereDec) = _getFiled(gridView1 |
| | | .GetRowCellValue(i, "fieldWhere").ToString()); |
| | | var _fieldValue = gridView1.GetRowCellValue(i, "fieldValue") |
| | | .ToString(); |
| | | if (_fileWhere.Contains("like")) |
| | | { |
| | | _fileWhere = " like "; |
| | | _fieldValue = "%" + _fieldValue + "%"; |
| | | } |
| | | list.Add(new FilterEntity(_fieId, _fileIdDec, _fileWhere, _fileWhereDec, _fieldValue)); |
| | | |
| | | list.Add(new FilterEntity(_fieId, _fileIdDec, _fileWhere, |
| | | _fileWhereDec, _fieldValue)); |
| | | } |
| | | UpdateParent?.Invoke(this, new UpdateParentEventArgs { FilterList = list }); |
| | | this.Close(); |
| | | |
| | | UpdateParent?.Invoke(this, |
| | | new UpdateParentEventArgs { FilterList = list }); |
| | | Close(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <summary> |
| | | /// </summary> |
| | | private void getPageList() |
| | | { |
| | | foreach (GridColumn col in _columns) |
| | | { |
| | | if (col.Tag != null && col.Tag.ToString().StartsWith("query")) |
| | | { |
| | | CboItemEntity item = new CboItemEntity(); |
| | | item.Text = col.Tag.ToString().Replace("query_a.", "") + "(" + col.Caption + ")"; |
| | | var item = new CboItemEntity(); |
| | | item.Text = col.Tag.ToString().Replace("query_a.", "") + |
| | | "(" + col.Caption + ")"; |
| | | //item.Value = col.FieldName; |
| | | item.Value = col.Tag.ToString().Replace("query_a.", ""); |
| | | repositoryItemComboBox1.Items.Add(item); |
| | | } |
| | | } |
| | | Dictionary<string, string> d2 = new Dictionary<string, string>(); |
| | | |
| | | var d2 = new Dictionary<string, string>(); |
| | | d2.Add(">", "大于"); |
| | | d2.Add("<", "小于"); |
| | | d2.Add("=", "等于"); |
| | | d2.Add("<>", "不等于"); |
| | | d2.Add("like", "包含"); |
| | | foreach (KeyValuePair<string, string> kvp in d2) |
| | | foreach (var kvp in d2) |
| | | { |
| | | CboItemEntity item = new CboItemEntity(); |
| | | var item = new CboItemEntity(); |
| | | item.Text = kvp.Key + "(" + kvp.Value + ")"; |
| | | item.Value = kvp.Key; |
| | | repositoryItemComboBox2.Items.Add(item); |
| | | } |
| | | |
| | | try |
| | | { |
| | | DataTable dt = new DataTable(); |
| | | var dt = new DataTable(); |
| | | dt.Columns.Add("field", typeof(string)); |
| | | dt.Columns.Add("fieldWhere", typeof(string)); |
| | | dt.Columns.Add("fieldValue", typeof(string)); |
| | | foreach (FilterEntity _sql in FilterList) |
| | | foreach (var _sql in FilterList) |
| | | { |
| | | DataRow dr = dt.NewRow(); |
| | | var dr = dt.NewRow(); |
| | | dr["field"] = _sql.fileId + "(" + _sql.fileIdDec; |
| | | dr["fieldWhere"] = _sql.fileOper + "(" + _sql.fileOperDec; |
| | | dr["fieldValue"] = _sql.fileValue.Replace("%", ""); |
| | | dt.Rows.Add(dr); |
| | | } |
| | | |
| | | gcMain.BindingContext = new BindingContext(); |
| | | gcMain.DataSource = dt; |
| | | gcMain.ForceInitialize(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ToolBox.MsgHelper.Warning("提示:" + ex.Message); |
| | | MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | return (_field.Split('(')[0], _field.Split('(')[1]); |
| | | } |
| | | |
| | | private void BtnEsc_Click(object sender, EventArgs e) |
| | | { |
| | | this.Close(); |
| | | Close(); |
| | | } |
| | | private void RepositoryItemComboBox2_ParseEditValue(object sender, DevExpress.XtraEditors.Controls.ConvertEditValueEventArgs e) |
| | | |
| | | private void RepositoryItemComboBox2_ParseEditValue(object sender, |
| | | ConvertEditValueEventArgs e) |
| | | { |
| | | if (e.Value != null) |
| | | { |
| | | e.Value = e.Value.ToString(); e.Handled = true; |
| | | e.Value = e.Value.ToString(); |
| | | e.Handled = true; |
| | | } |
| | | } |
| | | |
| | | private void RepositoryItemComboBox2_SelectedIndexChanged(object sender, EventArgs e) |
| | | private void RepositoryItemComboBox2_SelectedIndexChanged(object sender, |
| | | EventArgs e) |
| | | { |
| | | |
| | | } |
| | | |
| | | private void RepositoryItemComboBox1_ParseEditValue(object sender, DevExpress.XtraEditors.Controls.ConvertEditValueEventArgs e) |
| | | private void RepositoryItemComboBox1_ParseEditValue(object sender, |
| | | ConvertEditValueEventArgs e) |
| | | { |
| | | if (e.Value != null) |
| | | { |
| | | e.Value = e.Value.ToString(); e.Handled = true; |
| | | e.Value = e.Value.ToString(); |
| | | e.Handled = true; |
| | | } |
| | | } |
| | | |
| | | private void RepositoryItemComboBox1_SelectedIndexChanged(object sender, EventArgs e) |
| | | private void RepositoryItemComboBox1_SelectedIndexChanged(object sender, |
| | | EventArgs e) |
| | | { |
| | | |
| | | } |
| | | } |
| | | } |