From bd06bb837fa0c7edeeae56cb0fe4fb844f53fb2f Mon Sep 17 00:00:00 2001
From: lu <99954486@qq.com>
Date: 星期三, 23 十月 2024 16:42:34 +0800
Subject: [PATCH] 修改了报表设计器

---
 DevApp/Gs.DevApp/DevFrm/User/Role.cs |  163 ++++++++++++++++++++++++++++++++----------------------
 1 files changed, 96 insertions(+), 67 deletions(-)

diff --git a/DevApp/Gs.DevApp/DevFrm/User/Role.cs b/DevApp/Gs.DevApp/DevFrm/User/Role.cs
index 72eddd5..b663200 100644
--- a/DevApp/Gs.DevApp/DevFrm/User/Role.cs
+++ b/DevApp/Gs.DevApp/DevFrm/User/Role.cs
@@ -1,20 +1,19 @@
 锘縰sing DevExpress.XtraGrid.Views.Base;
-using DevExpress.XtraGrid.Views.Grid;
-using DevExpress.XtraGrid.Views.Grid.ViewInfo;
 using Gs.DevApp.Entity;
 using Gs.DevApp.ToolBox;
 using Newtonsoft.Json;
 using System;
+using System.Collections.Generic;
 using System.Data;
+using System.Drawing;
 using System.Windows.Forms;
 
 namespace Gs.DevApp.DevFrm.User
 {
-    //https://www.cnblogs.com/mkmkbj/p/16771297.html
-    //https://blog.csdn.net/m0_54035969/article/details/140716675
     public partial class Role : DevExpress.XtraEditors.XtraForm
     {
-        System.Text.StringBuilder actionLst = new System.Text.StringBuilder();
+        System.Text.StringBuilder _actionLst = new System.Text.StringBuilder();
+        List<FilterEntity> _filterList = new List<FilterEntity>();
         public Role()
         {
             InitializeComponent();
@@ -25,11 +24,27 @@
             this.toolBarMenu1.btnDelClick += ToolBarMenu1_btnDelClick1;
             this.toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick;
             this.toolBarMenu1.btnRoleClick += ToolBarMenu1_btnRoleClick;
+            this.toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;
             gcMain.MouseDoubleClick += GcMain_MouseDoubleClick;
             gridView1.FocusedRowChanged += GridView1_FocusedRowChanged;
-            pageBar1.PagerEvent += PageBar1_PagerEvent;
             getPageList(1, UtilityHelper.GetPageSize());
+            pageBar1.PagerEvent += PageBar1_PagerEvent;
             trv.AfterCheck += Trv_AfterCheck;
+            gridView1.IndicatorWidth = 50;
+            gridView1.CustomDrawRowIndicator += (s, e) =>
+            {
+                if (e.Info.IsRowIndicator && e.RowHandle >= 0)
+                {
+                    e.Info.DisplayText = (e.RowHandle + 1).ToString();
+                }
+            };
+            gridView1.CustomDrawEmptyForeground += (s, e) =>
+            {
+                string str = "鏆傛湭鏌ユ壘鍒板尮閰嶇殑鏁版嵁!";
+                Font f = new Font("寰蒋闆呴粦", 16);
+                Rectangle r = new Rectangle(gridView1.GridControl.Width / 2 - 100, e.Bounds.Top + 45, e.Bounds.Right - 5, e.Bounds.Height - 5);
+                e.Graphics.DrawString(str, f, Brushes.Gray, r);
+            };
         }
         /// <summary>
         /// 鎹㈠垏鎹簨浠�
@@ -40,6 +55,7 @@
         {
             string rowGuid = "";
             DataRow myDataRow = gridView1.GetDataRow(e.FocusedRowHandle);
+            if (myDataRow == null) return;
             rowGuid = myDataRow["guid"].ToString();
             getTree(rowGuid);
             groupBox1.Text = "璇峰嬀閫夈��" + myDataRow["roleName"].ToString() + "銆戠殑鏉冮檺";
@@ -51,20 +67,10 @@
         /// <param name="e"></param>
         private void GcMain_MouseDoubleClick(object sender, MouseEventArgs e)
         {
-            GridHitInfo info = gridView1.CalcHitInfo(e.Location);
-            if (info.InRow)
-            {
-                GridView view = info.View as GridView;
-                if (view != null)
-                {
-                    DataRow row = view.GetDataRow(info.RowHandle);
-                    if (row != null)
-                    {
-                        string rowGuid = (row["guid"].ToString());
-                        getModel(rowGuid, false, 999);
-                    }
-                }
-            }
+            string rowGuid = Gs.DevApp.ToolBox.UtilityHelper.GetCurrentDoubleRow(gridView1, e, "guid");
+            if (!string.IsNullOrEmpty(rowGuid))
+                getModel(rowGuid, false, 999);
+
         }
         /// <summary>
         /// 鍒嗛〉浜嬩欢
@@ -76,13 +82,35 @@
             getPageList(curPage, pageSize);
         }
         /// <summary>
+        /// 鏌ヨ浜嬩欢
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ToolBarMenu1_btnQueryClick(object sender, EventArgs e)
+        {
+            Gs.DevApp.UserControl.ShowFilter frm = new Gs.DevApp.UserControl.ShowFilter(gridView1.Columns, _filterList);
+            frm.UpdateParent += Frm_UpdateParent;
+            frm.ShowDialog();
+        }
+        /// <summary>
+        /// 鏌ヨ鍥炶皟
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void Frm_UpdateParent(object sender, UpdateParentEventArgs e)
+        {
+            _filterList = e.FilterList;
+            getPageList(1, pageBar1.RowsCount);
+        }
+
+        /// <summary>
         /// 鍙栨秷浜嬩欢
         /// </summary>
         /// <param name="sender"></param>
         /// <param name="e"></param>
         private void ToolBarMenu1_btnEscClick(object sender, EventArgs e)
         {
-            UtilityHelper.ChangeTab(xtraTabControl1, 0);
+            UtilityHelper.JumpToTab(xtraTabControl1, 0);
         }
         /// <summary>
         /// 鍒犻櫎浜嬩欢
@@ -91,26 +119,25 @@
         /// <param name="e"></param>
         private void ToolBarMenu1_btnDelClick1(object sender, EventArgs e)
         {
-            DataRow dr = gridView1.GetFocusedDataRow();
-            if (dr == null || string.IsNullOrEmpty(dr["guid"].ToString()))
+            string rowGuid, rowName;
+            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_roleName, gridView1, 2);
+            if (string.IsNullOrEmpty(rowGuid))
             {
                 ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
                 return;
             }
-            if (!MsgHelper.AskQuestion("浣犻�夋嫨浜嗐��" + dr["roleName"].ToString() + "銆戯紝纭畾鍒犻櫎鍚楋紵\n璇ユ搷浣滃皢浼氭竻绌虹浉搴旂殑鐢ㄦ埛鏉冮檺"))
+            if (!MsgHelper.AskQuestion("浣犻�夋嫨浜嗐��" + rowName + "銆戯紝纭畾鍒犻櫎鍚楋紵\n璇ユ搷浣滃皢浼氭竻绌虹浉搴旂殑鐢ㄦ埛鏉冮檺"))
                 return;
-            var _obj = new
-            {
-                guid = dr["guid"].ToString(),//涓诲缓
-            };
-            string strJson = "";
+            List<string> lst = new List<string>();
+            lst.Add(rowGuid);
+            var _obj = lst;
             try
             {
-                strJson = UtilityHelper.HttpPost("", "Role/DeleteModel", JsonConvert.SerializeObject(_obj));
-                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson);
+                string strJson = UtilityHelper.HttpPost("", "Role/DeleteModel", JsonConvert.SerializeObject(_obj));
+                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                 if (_rtn.rtnCode > 0)
                 {
-                    UtilityHelper.ChangeTab(xtraTabControl1, 0);
+                    UtilityHelper.JumpToTab(xtraTabControl1, 0);
                     getPageList(1, UtilityHelper.GetPageSize());
                 }
                 ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
@@ -127,7 +154,7 @@
         /// <param name="e"></param>
         private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e)
         {
-            UtilityHelper.ChangeTab(xtraTabControl1, 0);
+            UtilityHelper.JumpToTab(xtraTabControl1, 0);
             getPageList(1, UtilityHelper.GetPageSize());
         }
         /// <summary>
@@ -137,14 +164,14 @@
         /// <param name="e"></param>
         private void ToolBarMenu1_btnEdtClick(object sender, EventArgs e)
         {
-            DataRow dr = gridView1.GetFocusedDataRow();
-            if (dr == null || string.IsNullOrEmpty(dr["guid"].ToString()))
+            string rowGuid, rowName;
+            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_roleName, gridView1);
+            if (string.IsNullOrEmpty(rowGuid))
             {
                 ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
                 return;
             }
-            getModel(dr["guid"].ToString(), true, 1);
-
+            getModel(rowGuid, true, 1);
         }
         /// <summary>
         /// 鏂板浜嬩欢
@@ -153,9 +180,9 @@
         /// <param name="e"></param>
         private void ToolBarMenu1_btnAddClick(object sender, EventArgs e)
         {
-            UtilityHelper.ChangeTab(xtraTabControl1, 1);
+            UtilityHelper.JumpToTab(xtraTabControl1, 1);
             lbGuid.Text = "";
-            UtilityHelper.CleanValue(this.panel1.Controls, true);
+            UtilityHelper.CleanValueByControl(this.panel1.Controls, true);
         }
         /// <summary>
         /// 淇濆瓨浜嬩欢
@@ -171,35 +198,30 @@
                 txt_roleName.Focus();
                 return;
             }
-            if (string.IsNullOrEmpty(txt_rolRemark.Text.Trim()))
+            if (string.IsNullOrEmpty(txt_roleRemark.Text.Trim()))
             {
                 Gs.DevApp.ToolBox.MsgHelper.Warning("瑙掕壊澶囨敞涓嶈兘涓虹┖锛�");
-                txt_rolRemark.Focus();
-                return;
-            }
-            if (txt_status.SelectedIndex <= 0)
-            {
-                Gs.DevApp.ToolBox.MsgHelper.Warning("瑙掕壊鐘舵�佷笉鑳戒负绌猴紒");
-                txt_status.Focus();
+                txt_roleRemark.Focus();
                 return;
             }
             var _obj = new
             {
                 guid = lbGuid.Text.Trim(),
                 roleName = txt_roleName.Text.Trim(),
-                rolRemark = txt_rolRemark.Text.Trim(),
-                status = txt_status.SelectedIndex,//鐘舵��
+                roleRemark = txt_roleRemark.Text.Trim(),
+                isStatus = txt_isStatus.Checked,//鐘舵��
             };
             try
             {
                 string strJson = UtilityHelper.HttpPost("", "Role/EditModel", JsonConvert.SerializeObject(_obj));
-                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson);
+                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                 ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
                 if (_rtn.rtnCode > 0)
                 {
                     lbGuid.Text = _rtn.rtnData;
                     toolBarMenu1.isSetBtn = true;
-                    UtilityHelper.ChangeEnable(this.panel1.Controls, false);
+                    UtilityHelper.ChangeEnableByControl(this.panel1.Controls, false);
+
                 }
             }
             catch (Exception ex)
@@ -215,25 +237,26 @@
         /// <param name="e"></param>
         private void ToolBarMenu1_btnRoleClick(object sender, EventArgs e)
         {
-            DataRow dr = gridView1.GetFocusedDataRow();
-            if (dr == null || string.IsNullOrEmpty(dr["guid"].ToString()))
+            string rowGuid, rowName;
+            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_roleName, gridView1);
+            if (string.IsNullOrEmpty(rowGuid))
             {
                 ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
                 return;
             }
-            if (!MsgHelper.AskQuestion("浣犻�夋嫨浜嗐��" + dr["roleName"].ToString() + "銆戯紝纭畾璁剧疆鏉冮檺鍚楋紵"))
+            if (!MsgHelper.AskQuestion("浣犻�夋嫨浜嗐��" + rowName + "銆戯紝纭畾璁剧疆鏉冮檺鍚楋紵"))
                 return;
-            actionLst = new System.Text.StringBuilder();
+            _actionLst = new System.Text.StringBuilder();
             TraverseTreeViewNodes(trv.Nodes);
             var _obj = new
             {
-                roleGuid = dr["guid"].ToString(),
-                actionLst = actionLst.ToString(),
+                roleGuid = rowGuid,
+                actionLst = _actionLst.ToString(),
             };
             try
             {
-                string strJson = UtilityHelper.HttpPost("", "MenuAction/SetMenuActionByRole", JsonConvert.SerializeObject(_obj));
-                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson);
+                string strJson = UtilityHelper.HttpPost("", "Role/SetRoleMenuAction", JsonConvert.SerializeObject(_obj));
+                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                 ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnData.outMsg);
             }
             catch (Exception ex)
@@ -249,12 +272,17 @@
         /// <param name="pageSize">姣忛〉鍑犳潯</param>
         private void getPageList(int curPage, int pageSize)
         {
-            PageQueryModel pgq = new PageQueryModel(curPage, pageSize, "createDate", "asc", "", "");
+            System.Text.StringBuilder _sbSqlWhere = new System.Text.StringBuilder();
+            foreach (FilterEntity itm in _filterList)
+            {
+                _sbSqlWhere.Append(" and " + itm.fileId + itm.fileOper + "'" + itm.fileValue + "'");
+            }
+            PageQueryModel pgq = new PageQueryModel(curPage, pageSize, "CREATE_TIME", "desc", "", _sbSqlWhere.ToString());
             string json = JsonConvert.SerializeObject(pgq);
             try
             {
                 string strReturn = UtilityHelper.HttpPost("", "Role/GetListPage", json);
-                ReturnModel<PageListModel> dd = UtilityHelper.GetTableByJson(strReturn);
+                ReturnModel<PageListModel> dd = UtilityHelper.ReturnToTablePage(strReturn);
                 DataTable dt = dd.rtnData.list;
                 gcMain.BindingContext = new BindingContext();
                 gcMain.DataSource = dt;
@@ -278,7 +306,7 @@
                 ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
                 return;
             }
-            UtilityHelper.ChangeTab(xtraTabControl1, tabIdx);
+            UtilityHelper.JumpToTab(xtraTabControl1, tabIdx);
             var _obj = new
             {
                 guid = strGuid,//涓诲缓
@@ -287,7 +315,7 @@
             try
             {
                 strJson = UtilityHelper.HttpPost("", "Role/GetModel", JsonConvert.SerializeObject(_obj));
-                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson);
+                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                 if (_rtn.rtnCode > 0)
                 {
                     dynamic dy = _rtn.rtnData;
@@ -315,11 +343,10 @@
             {
                 roleGuid = roleGuid,//涓诲缓
             };
-            string strReturn = "";
             try
             {
-                strReturn = UtilityHelper.HttpPost("", "MenuAction/GetListByRole", JsonConvert.SerializeObject(_obj));
-                ReturnModel<PageListModel> dd = UtilityHelper.GetTableByJson(strReturn);
+                string strReturn = UtilityHelper.HttpPost("", "Role/GetListByRole", JsonConvert.SerializeObject(_obj));
+                ReturnModel<PageListModel> dd = UtilityHelper.ReturnToTablePage(strReturn);
                 DataTable dt = dd.rtnData.list;
                 DataRow[] drGrp = dt.Select("upGuid='' or upGuid is null");
                 foreach (DataRow _dy in drGrp)
@@ -374,7 +401,9 @@
         {
             try
             {
+                trv.AfterCheck -= Trv_AfterCheck;
                 UtilityHelper.TreeViewCheck(e);
+                trv.AfterCheck += Trv_AfterCheck;
             }
             catch (Exception ex)
             {
@@ -387,7 +416,7 @@
             foreach (TreeNode node in nodes)
             {
                 if (node.Checked)
-                    actionLst.Append(node.Name + "~");
+                    _actionLst.Append(node.Name + "~");
                 // 閫掑綊閬嶅巻瀛愯妭鐐�
                 if (node.Nodes.Count > 0)
                 {

--
Gitblit v1.9.3