From ff727efcd6dfb3f8ed5c671df6a25db5a37b1585 Mon Sep 17 00:00:00 2001 From: lu <99954486@qq.com> Date: 星期三, 15 一月 2025 16:29:50 +0800 Subject: [PATCH] 性能 --- DevApp/Gs.DevApp/DevFrm/BasicData/Frm_MesItems.Designer.cs | 3 + DevApp/Gs.DevApp/UserControl/ShowFilter.Designer.cs | 47 +++++++++++++-- DevApp/Gs.DevApp/DevFrm/BasicData/Frm_MesItems.cs | 30 ++++++---- DevApp/Gs.DevApp/UserControl/ShowFilter.cs | 25 +++++++ DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs | 69 +++++++++++++++++----- 5 files changed, 138 insertions(+), 36 deletions(-) diff --git a/DevApp/Gs.DevApp/DevFrm/BasicData/Frm_MesItems.Designer.cs b/DevApp/Gs.DevApp/DevFrm/BasicData/Frm_MesItems.Designer.cs index 977bb32..071f492 100644 --- a/DevApp/Gs.DevApp/DevFrm/BasicData/Frm_MesItems.Designer.cs +++ b/DevApp/Gs.DevApp/DevFrm/BasicData/Frm_MesItems.Designer.cs @@ -844,9 +844,12 @@ // gridColumn1 // this.gridColumn1.Caption = "鍚屾鏃堕棿"; + this.gridColumn1.DisplayFormat.FormatString = "d"; + this.gridColumn1.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime; this.gridColumn1.FieldName = "lastupdateDate"; this.gridColumn1.MinWidth = 180; this.gridColumn1.Name = "gridColumn1"; + this.gridColumn1.OptionsFilter.FilterPopupMode = DevExpress.XtraGrid.Columns.FilterPopupMode.Date; this.gridColumn1.Tag = "query_a.lastupdate_date"; this.gridColumn1.Visible = true; this.gridColumn1.VisibleIndex = 17; diff --git a/DevApp/Gs.DevApp/DevFrm/BasicData/Frm_MesItems.cs b/DevApp/Gs.DevApp/DevFrm/BasicData/Frm_MesItems.cs index ae05b6d..85f7f57 100644 --- a/DevApp/Gs.DevApp/DevFrm/BasicData/Frm_MesItems.cs +++ b/DevApp/Gs.DevApp/DevFrm/BasicData/Frm_MesItems.cs @@ -34,10 +34,11 @@ getPageList(1); pageBar1.PagerEvent += PageBar1_PagerEvent; } + private void GridView1_ColumnFilterChanged(object sender, EventArgs e) - { - _filterList = Gs.DevApp.ToolBox.UtilityHelper.GetDilter(gridView1.Columns); - Task.Delay(100); + { + _filterList = Gs.DevApp.ToolBox.UtilityHelper.GetDilter(gridView1.Columns, gridView1); + Task.Delay(100); getPageList(1); } /// <summary> @@ -87,14 +88,15 @@ getModel(lbGuid.Text.Trim()); else { - _filterList.Clear(); - if (gridView1.ActiveFilter.Count > 0) - { - gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged; - gridView1.ActiveFilter.Clear(); - gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged; - } - getPageList(1); + //_filterList.Clear(); + //if (gridView1.ActiveFilter.Count > 0) + //{ + // gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged; + // gridView1.ActiveFilter.Clear(); + // gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged; + //} + //getPageList(1); + getPageList(this.pageBar1.CurrentPage); } } @@ -105,7 +107,7 @@ private void getPageList(int curPage) { var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList); - var pgq = new PageQueryModel(curPage, this.pageBar1.RowsCount, "item_no", "asc", + var pgq = new PageQueryModel(curPage, this.pageBar1.RowsCount, "org.FNumber asc ,a.item_no asc", "", "", _sbSqlWhere.ToString()); var json = JsonConvert.SerializeObject(pgq); try @@ -178,5 +180,9 @@ MsgHelper.Warning("鎻愮ず锛�" + ex.Message); } } + + + + } } \ No newline at end of file diff --git a/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs b/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs index ce148f8..33668ba 100644 --- a/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs +++ b/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs @@ -83,27 +83,27 @@ request.Timeout = 150000; request.AllowAutoRedirect = false; request.ServicePoint.Expect100Continue = false; - wdf.SetCaption(_caption + "锛�10/100锛�" + meth); + // wdf.SetCaption(_caption + "锛�10/100锛�" + meth); HttpRequestCachePolicy noCachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore); request.CachePolicy = noCachePolicy; - wdf.SetCaption(_caption + "锛�20/100锛�" + meth); + // wdf.SetCaption(_caption + "锛�20/100锛�" + meth); requestStream = new StreamWriter(request.GetRequestStream()); requestStream.Write(param); requestStream.Close(); - wdf.SetCaption(_caption + "30/100锛�" + meth); + // wdf.SetCaption(_caption + "30/100锛�" + meth); response = request.GetResponse(); - wdf.SetCaption(_caption + "锛�40/100锛�"); + // wdf.SetCaption(_caption + "锛�40/100锛�"); if (response != null) { - wdf.SetCaption(_caption + "锛�50/100锛�" + meth); + // wdf.SetCaption(_caption + "锛�50/100锛�" + meth); var reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8); responseStr = reader.ReadToEnd(); //File.WriteAllText(Server.MapPath("~/") + @"\test.txt", responseStr); reader.Close(); - wdf.SetCaption(_caption + "锛�60/100锛�" + meth); + // wdf.SetCaption(_caption + "锛�60/100锛�" + meth); } - wdf.SetCaption(_caption + "锛�80/100锛�" + meth); + // wdf.SetCaption(_caption + "锛�80/100锛�" + meth); } catch (Exception ex) { @@ -117,7 +117,7 @@ requestStream = null; response = null; } - wdf.SetCaption(_caption + "锛�90/100锛�"); + // wdf.SetCaption(_caption + "锛�90/100锛�"); wdf.Close(); return responseStr; } @@ -1595,9 +1595,15 @@ { return new FilterEntity(getQueryWord(id), idDec + ")", " like ", "鍖呭惈)", "%" + val + "%"); } - public static List<FilterEntity> GetDilter(GridColumnCollection Columns) + public static List<FilterEntity> GetDilter(GridColumnCollection Columns, GridView gridView1 = null) { List<FilterEntity> fiList = new List<FilterEntity>(); + if (gridView1 != null) + { + bool b = gridView1.ActiveFilterEnabled; + if (b == false) + return fiList; + } foreach (DevExpress.XtraGrid.Columns.GridColumn col in Columns) { ColumnFilterInfo filter = col.FilterInfo; @@ -1652,12 +1658,12 @@ public static void SetGridViewParameter(GridView gridView1, PictureBox picCheckBox = null, Form fm = null, string fileName = "checkStatus", string icoName = "", DelegateGetModel action = null) { gridView1.OptionsView.ColumnAutoWidth = false;//鑷姩璋冩暣鍒楀 - // gridView1.BestFitColumns();//鏁版嵁缁戝畾鍒癎ridView涔嬪悗璋冪敤BestFitColumns()鏂规硶 foreach (GridColumn column in gridView1.Columns) { - column.OptionsFilter.AutoFilterCondition = AutoFilterCondition.Contains; - column.OptionsFilter.ImmediateUpdateAutoFilter = false; column.OptionsColumn.AllowEdit = true; + column.OptionsFilter.AutoFilterCondition = AutoFilterCondition.Contains; + column.OptionsFilter.AutoFilterCondition = DevExpress.XtraGrid.Columns.AutoFilterCondition.Contains; + column.OptionsFilter.ImmediateUpdateAutoFilter = false; if (column.Tag == null || column.Tag.ToString().EndsWith("edit")) column.OptionsColumn.ReadOnly = false; else @@ -1666,15 +1672,23 @@ column.OptionsFilter.AllowAutoFilter = false; } gridView1.OptionsFilter.AllowAutoFilterConditionChange = DevExpress.Utils.DefaultBoolean.False; + gridView1.OptionsView.ShowAutoFilterRow = true; gridView1.OptionsFilter.AllowFilterEditor = false; gridView1.OptionsFilter.ShowCustomFunctions = DevExpress.Utils.DefaultBoolean.False; + gridView1.OptionsFilter.AllowColumnMRUFilterList = false; + gridView1.OptionsFilter.AllowMRUFilterList = false; gridView1.OptionsCustomization.AllowFilter = false; gridView1.OptionsFind.ShowSearchNavButtons = false; - gridView1.OptionsView.ShowAutoFilterRow = true; gridView1.OptionsView.ShowGroupPanel = false; + //鏄惁鏄剧ず搴曢儴鐨勮繃婊ゆ潯 + // gridView1.OptionsView.ShowFilterPanelMode = DevExpress.XtraGrid.Views.Base.ShowFilterPanelMode.Never; gridView1.IndicatorWidth = 50; gridView1.CustomDrawRowIndicator += (s, e) => { + //if (e.RowHandle == GridControl.AutoFilterRowHandle) + //{ + // e.Info.DisplayText = "绛涢�夎"; + //} if (e.Info.IsRowIndicator && e.RowHandle >= 0) e.Info.DisplayText = (e.RowHandle + 1).ToString(); }; @@ -1747,22 +1761,45 @@ { xtraTabControl1.SelectedPageChanged += (s, e) => { + int _handle = gridView1.FocusedRowHandle; + //濡備綍鍒囨崲鍒�1鐨勬椂鍊欙紝鍏堝垽鏂┖鐧借 + if (_handle < 0) + { + if (xtraTabControl1.SelectedTabPageIndex == 1) + { + xtraTabControl1.SelectedTabPageIndex = -1; + Gs.DevApp.ToolBox.MsgHelper.ShowInformation("璇烽�夋嫨浣犺鏄剧ず鐨勮锛�" + _handle.ToString() + "tag" + xtraTabControl1.SelectedTabPageIndex.ToString()); + return; + } + } if (xtraTabControl1.SelectedTabPageIndex == 1) { - int _handle = gridView1.FocusedRowHandle; - if (_handle == -1) + _handle = gridView1.FocusedRowHandle; + if (_handle < 0) + { + xtraTabControl1.SelectedTabPageIndex = -1; + Gs.DevApp.ToolBox.MsgHelper.ShowInformation("璇烽�夋嫨浣犺鏄剧ず鐨勮锛�" + _handle.ToString()); return; + } DataRow row = gridView1.GetDataRow(_handle); if (row == null) + { + xtraTabControl1.SelectedTabPageIndex = -1; + Gs.DevApp.ToolBox.MsgHelper.ShowInformation("璇烽�夋嫨浣犺鏄剧ず鐨勮锛�" + _handle.ToString()); return; + } string _guid = row["guid"].ToString(); if (string.IsNullOrEmpty(_guid)) + { + xtraTabControl1.SelectedTabPageIndex = -1; + Gs.DevApp.ToolBox.MsgHelper.ShowInformation("璇烽�夋嫨浣犺鏄剧ず鐨勮锛�" + _handle.ToString()); return; + } action(_guid); } if (xtraTabControl1.SelectedTabPageIndex == 0) { - page(pageBar1.CurrentPage); + // page(pageBar1.CurrentPage); } }; } diff --git a/DevApp/Gs.DevApp/UserControl/ShowFilter.Designer.cs b/DevApp/Gs.DevApp/UserControl/ShowFilter.Designer.cs index a99bf07..c023f26 100644 --- a/DevApp/Gs.DevApp/UserControl/ShowFilter.Designer.cs +++ b/DevApp/Gs.DevApp/UserControl/ShowFilter.Designer.cs @@ -29,6 +29,11 @@ /// </summary> private void InitializeComponent() { + DevExpress.XtraEditors.Controls.EditorButtonImageOptions editorButtonImageOptions2 = new DevExpress.XtraEditors.Controls.EditorButtonImageOptions(); + DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject5 = new DevExpress.Utils.SerializableAppearanceObject(); + DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject6 = new DevExpress.Utils.SerializableAppearanceObject(); + DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject7 = new DevExpress.Utils.SerializableAppearanceObject(); + DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject8 = new DevExpress.Utils.SerializableAppearanceObject(); this.gcMain = new DevExpress.XtraGrid.GridControl(); this.gridView1 = new DevExpress.XtraGrid.Views.Grid.GridView(); this.gridColumn1 = new DevExpress.XtraGrid.Columns.GridColumn(); @@ -36,6 +41,8 @@ this.gridColumn2 = new DevExpress.XtraGrid.Columns.GridColumn(); this.repositoryItemComboBox2 = new DevExpress.XtraEditors.Repository.RepositoryItemComboBox(); this.gridColumn3 = new DevExpress.XtraGrid.Columns.GridColumn(); + this.gridColumn4 = new DevExpress.XtraGrid.Columns.GridColumn(); + this.repositoryItemButtonEdit1 = new DevExpress.XtraEditors.Repository.RepositoryItemButtonEdit(); this.panel1 = new System.Windows.Forms.Panel(); this.btnEsc = new DevExpress.XtraEditors.SimpleButton(); this.btnQuery = new DevExpress.XtraEditors.SimpleButton(); @@ -43,6 +50,7 @@ ((System.ComponentModel.ISupportInitialize)(this.gridView1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.repositoryItemComboBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.repositoryItemComboBox2)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.repositoryItemButtonEdit1)).BeginInit(); this.panel1.SuspendLayout(); this.SuspendLayout(); // @@ -54,8 +62,9 @@ this.gcMain.Name = "gcMain"; this.gcMain.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] { this.repositoryItemComboBox1, - this.repositoryItemComboBox2}); - this.gcMain.Size = new System.Drawing.Size(511, 255); + this.repositoryItemComboBox2, + this.repositoryItemButtonEdit1}); + this.gcMain.Size = new System.Drawing.Size(591, 285); this.gcMain.TabIndex = 0; this.gcMain.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] { this.gridView1}); @@ -65,7 +74,8 @@ this.gridView1.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] { this.gridColumn1, this.gridColumn2, - this.gridColumn3}); + this.gridColumn3, + this.gridColumn4}); this.gridView1.GridControl = this.gcMain; this.gridView1.Name = "gridView1"; this.gridView1.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom; @@ -116,14 +126,36 @@ this.gridColumn3.VisibleIndex = 2; this.gridColumn3.Width = 100; // + // gridColumn4 + // + this.gridColumn4.Caption = "绉诲嚭"; + this.gridColumn4.ColumnEdit = this.repositoryItemButtonEdit1; + this.gridColumn4.MaxWidth = 60; + this.gridColumn4.MinWidth = 60; + this.gridColumn4.Name = "gridColumn4"; + this.gridColumn4.Visible = true; + this.gridColumn4.VisibleIndex = 3; + this.gridColumn4.Width = 60; + // + // repositoryItemButtonEdit1 + // + this.repositoryItemButtonEdit1.AutoHeight = false; + editorButtonImageOptions2.Image = global::Gs.DevApp.Properties.Resources.removegroupfooter_16x16; + editorButtonImageOptions2.ImageToTextAlignment = DevExpress.XtraEditors.ImageAlignToText.LeftCenter; + this.repositoryItemButtonEdit1.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { + new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph, "绉诲嚭", -1, true, true, false, editorButtonImageOptions2, new DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None), serializableAppearanceObject5, serializableAppearanceObject6, serializableAppearanceObject7, serializableAppearanceObject8, "", null, null, DevExpress.Utils.ToolTipAnchor.Default)}); + this.repositoryItemButtonEdit1.Name = "repositoryItemButtonEdit1"; + this.repositoryItemButtonEdit1.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.HideTextEditor; + this.repositoryItemButtonEdit1.ButtonClick += new DevExpress.XtraEditors.Controls.ButtonPressedEventHandler(this.repositoryItemButtonEdit1_ButtonClick); + // // panel1 // this.panel1.Controls.Add(this.btnEsc); this.panel1.Controls.Add(this.btnQuery); this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom; - this.panel1.Location = new System.Drawing.Point(0, 255); + this.panel1.Location = new System.Drawing.Point(0, 285); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(511, 56); + this.panel1.Size = new System.Drawing.Size(591, 56); this.panel1.TabIndex = 1; // // btnEsc @@ -146,7 +178,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 18F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(511, 311); + this.ClientSize = new System.Drawing.Size(591, 341); this.Controls.Add(this.gcMain); this.Controls.Add(this.panel1); this.IconOptions.Image = global::Gs.DevApp.Properties.Resources.logo_png_black; @@ -160,6 +192,7 @@ ((System.ComponentModel.ISupportInitialize)(this.gridView1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.repositoryItemComboBox1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.repositoryItemComboBox2)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.repositoryItemButtonEdit1)).EndInit(); this.panel1.ResumeLayout(false); this.ResumeLayout(false); @@ -177,5 +210,7 @@ private DevExpress.XtraGrid.Columns.GridColumn gridColumn2; private DevExpress.XtraEditors.Repository.RepositoryItemComboBox repositoryItemComboBox2; private DevExpress.XtraGrid.Columns.GridColumn gridColumn3; + private DevExpress.XtraGrid.Columns.GridColumn gridColumn4; + private DevExpress.XtraEditors.Repository.RepositoryItemButtonEdit repositoryItemButtonEdit1; } } \ No newline at end of file diff --git a/DevApp/Gs.DevApp/UserControl/ShowFilter.cs b/DevApp/Gs.DevApp/UserControl/ShowFilter.cs index 8d41cfc..f0ece36 100644 --- a/DevApp/Gs.DevApp/UserControl/ShowFilter.cs +++ b/DevApp/Gs.DevApp/UserControl/ShowFilter.cs @@ -3,10 +3,12 @@ using System.Data; using System.Text; using System.Windows.Forms; +using DevExpress.Utils.DirectXPaint; using DevExpress.XtraEditors; using DevExpress.XtraEditors.Controls; using DevExpress.XtraGrid.Columns; using Gs.DevApp.ToolBox; +using Newtonsoft.Json; namespace Gs.DevApp.UserControl { @@ -117,7 +119,6 @@ item.Value = kvp.Key; repositoryItemComboBox2.Items.Add(item); } - try { var dt = new DataTable(); @@ -132,7 +133,6 @@ dr["fieldValue"] = _sql.fileValue.Replace("%", ""); dt.Rows.Add(dr); } - gcMain.BindingContext = new BindingContext(); gcMain.DataSource = dt; gcMain.ForceInitialize(); @@ -182,5 +182,26 @@ EventArgs e) { } + + + /// <summary> + /// 绉诲嚭涓�琛� + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void repositoryItemButtonEdit1_ButtonClick(object sender, ButtonPressedEventArgs e) + { + gridView1.CloseEditor(); + gridView1.UpdateCurrentRow(); + var rowhandle = gridView1.FocusedRowHandle; + if (rowhandle < 0) + return; + if (e.Button.Index == 0) + { + var dr = gridView1.GetDataRow(rowhandle); + gridView1.DeleteRow(rowhandle); + return; + } + } } } \ No newline at end of file -- Gitblit v1.9.3