From ccc1b0d541d8f3bdd2bcb72dd0b5533e68b886d5 Mon Sep 17 00:00:00 2001
From: lu <99954486@qq.com>
Date: 星期一, 09 六月 2025 09:53:37 +0800
Subject: [PATCH] 采购明细报表

---
 DevApp/Gs.DevApp/DevFrm/User/Role.cs |  357 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 357 insertions(+), 0 deletions(-)

diff --git a/DevApp/Gs.DevApp/DevFrm/User/Role.cs b/DevApp/Gs.DevApp/DevFrm/User/Role.cs
new file mode 100644
index 0000000..ec3ff79
--- /dev/null
+++ b/DevApp/Gs.DevApp/DevFrm/User/Role.cs
@@ -0,0 +1,357 @@
+锘縰sing DevExpress.XtraEditors;
+using Gs.DevApp.Entity;
+using Gs.DevApp.ToolBox;
+using Gs.DevApp.UserControl;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Gs.DevApp.DevFrm.User
+{
+    public partial class Role : XtraForm
+    {
+        private StringBuilder _actionLst = new StringBuilder();
+        private List<FilterEntity> _filterList = new List<FilterEntity>();
+        public Role()
+        {
+            InitializeComponent();
+            toolBarMenu1.btnAddClick += ToolBarMenu1_btnAddClick;
+            toolBarMenu1.btnEdtClick += ToolBarMenu1_btnEdtClick;
+            toolBarMenu1.btnSaveClick += ToolBarMenu1_btnSaveClick;
+            toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick;
+            toolBarMenu1.btnDelClick += ToolBarMenu1_btnDelClick1;
+            toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick;
+            toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;
+            this.toolBarMenu1.getXmlConfig();
+            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, null, null, "", "", (value) =>
+            {
+                Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 0);
+            }, tips);
+            Gs.DevApp.ToolBox.UtilityHelper.SetTabParameter(gridView1, xtraTabControl1, pageBar1, (value) =>
+            {
+                getModel(value);
+            }, (value) =>
+            {
+                getPageList(this.pageBar1.CurrentPage);
+            }, lbGuid);
+            getPageList(1);
+            pageBar1.PagerEvent += PageBar1_PagerEvent;
+        }
+        private void GridView1_ColumnFilterChanged(object sender, EventArgs e)
+        {
+            _filterList = Gs.DevApp.ToolBox.UtilityHelper.GetDilter(gridView1.Columns, gridView1);
+            Task.Delay(100);
+            getPageList(1);
+        }
+
+        /// <summary>
+        ///     鍒嗛〉浜嬩欢
+        /// </summary>
+        /// <param name="curPage"></param>
+        /// <param name="pageSize"></param>
+        private void PageBar1_PagerEvent(int curPage, int pageSize)
+        {
+            getPageList(curPage);
+        }
+
+        /// <summary>
+        ///     鏌ヨ浜嬩欢
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ToolBarMenu1_btnQueryClick(object sender, EventArgs e)
+        {
+            gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
+            gridView1.ActiveFilter.Clear();
+            gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
+            var frm = new ShowFilter(gridView1.Columns, _filterList, this.GetType().FullName);
+            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);
+        }
+
+        /// <summary>
+        ///     鍙栨秷浜嬩欢
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ToolBarMenu1_btnEscClick(object sender, EventArgs e)
+        {
+            Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 1);
+        }
+
+        /// <summary>
+        ///     鍒犻櫎浜嬩欢
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ToolBarMenu1_btnDelClick1(object sender, EventArgs e)
+        {
+            string rowGuid, rowName;
+            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1,
+                lbGuid, txt_roleName, gridView1, "roleName");
+            if (string.IsNullOrEmpty(rowGuid))
+            {
+                MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
+                return;
+            }
+            if (!MsgHelper.AskQuestion("浣犻�夋嫨浜嗐��" + rowName + "銆戯紝纭畾鍒犻櫎鍚楋紵\n璇ユ搷浣滃皢浼氭竻绌虹浉搴旂殑鐢ㄦ埛鏉冮檺"))
+                return;
+            var lst = new List<string>();
+            lst.Add(rowGuid);
+            var _obj = lst;
+            try
+            {
+                var strJson = UtilityHelper.HttpPost("", "Role/DeleteModel",
+                    JsonConvert.SerializeObject(_obj));
+                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
+                if (_rtn.rtnCode > 0)
+                {
+                    if (xtraTabControl1.SelectedTabPageIndex == 0)
+                    { }
+                    else
+                        Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 2);
+                    getPageList(this.pageBar1.CurrentPage);
+                }
+                MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
+            }
+            catch (Exception ex)
+            {
+                MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+            }
+        }
+
+        /// <summary>
+        ///     鍒锋柊浜嬩欢
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e)
+        {
+            if (xtraTabControl1.SelectedTabPageIndex == 1)
+                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);
+                getPageList(this.pageBar1.CurrentPage);
+            }
+        }
+
+        /// <summary>
+        ///     淇敼浜嬩欢
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ToolBarMenu1_btnEdtClick(object sender, EventArgs e)
+        {
+            string rowGuid = "", rowName = "";
+            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_roleName, gridView1);
+            if (string.IsNullOrEmpty(rowGuid))
+            {
+                ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
+                return;
+            }
+            Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 3);
+            if (xtraTabControl1.SelectedTabPageIndex == 1)
+            {
+                getModel(rowGuid);
+            }
+            else
+            {
+                UtilityHelper.ChangeEnableByControl(this.layoutMx1.Controls, true);
+            }
+        }
+
+        /// <summary>
+        ///     鏂板浜嬩欢
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ToolBarMenu1_btnAddClick(object sender, EventArgs e)
+        {
+            lbGuid.Text = "";
+            Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 4);
+            UtilityHelper.CleanValueByControl(this.layoutMx1.Controls, true);
+        }
+
+        /// <summary>
+        ///     淇濆瓨浜嬩欢
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ToolBarMenu1_btnSaveClick(object sender, EventArgs e)
+        {
+            toolBarMenu1.isSetBtn = false;
+            if (string.IsNullOrEmpty(txt_roleName.Text.Trim()))
+            {
+                MsgHelper.Warning("瑙掕壊鍚嶇О涓嶈兘涓虹┖锛�");
+                txt_roleName.Focus();
+                return;
+            }
+
+            if (string.IsNullOrEmpty(txt_roleRemark.Text.Trim()))
+            {
+                MsgHelper.Warning("瑙掕壊澶囨敞涓嶈兘涓虹┖锛�");
+                txt_roleRemark.Focus();
+                return;
+            }
+            var _obj = new
+            {
+                guid = UtilityHelper.ToGuid(lbGuid.Text.Trim()),
+                roleName = txt_roleName.Text.Trim(),
+                roleRemark = txt_roleRemark.Text.Trim(),
+                isStatus = txt_isStatus.Checked //鐘舵��
+            };
+            try
+            {
+                var strJson = UtilityHelper.HttpPost("", "Role/EditModel",
+                    JsonConvert.SerializeObject(_obj));
+                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
+                MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
+                if (_rtn.rtnCode > 0)
+                {
+                    lbGuid.Text = _rtn.rtnData;
+                    toolBarMenu1.isSetBtn = true;
+                    UtilityHelper.ChangeEnableByControl(this.layoutMx1.Controls, false);
+                    toolBarMenu1.currentAction = "";
+                    Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 6);
+                }
+            }
+            catch (Exception ex)
+            {
+                MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+            }
+        }
+
+        /// <summary>
+        /// </summary>
+        /// <param name="curPage">绗嚑椤�</param>
+        /// <param name="pageSize">姣忛〉鍑犳潯</param>
+        private void getPageList(int curPage)
+        {
+            gcMain1.DataSource = null;var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList);
+            var pgq = new PageQueryModel(curPage, this.pageBar1.RowsCount, "ROLE_NAME asc,CREATE_TIME ", "desc", "", _sbSqlWhere.ToString());
+            var json = JsonConvert.SerializeObject(pgq);
+            try
+            {
+                var strReturn =
+                    UtilityHelper.HttpPost("", "Role/GetListPage", json);
+                var dd = UtilityHelper.ReturnToTablePage(strReturn);
+                if (dd.rtnCode > 0)
+                {
+                    DataTable dt = dd.rtnData.list;
+                    gcMain1.BindingContext = new BindingContext();
+                    gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
+                    if (dt.Rows.Count > 0)
+                    {
+                        gcMain1.DataSource = dt;
+                        gcMain1.ForceInitialize();
+                        gridView1.BestFitColumns(); Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gridView1);
+                    }
+                    else
+                        UtilityHelper.SetDefaultTable(gcMain1, gridView1);
+                    gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
+                    pageBar1.TotalPages = dd.rtnData.pages;//鎬婚〉
+                    pageBar1.CurrentPage = curPage;//褰撳墠椤�
+                    pageBar1.RecordCount = dd.rtnData.total;//鎬昏褰曟暟
+                }
+                else
+                {
+                    ToolBox.MsgHelper.ShowError("鎻愮ず锛�" + dd.rtnMsg);
+                }
+            }
+            catch (Exception ex)
+            {
+                MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+            }
+        }
+        /// <summary>
+        /// 璇诲彇瀹炰綋
+        /// </summary>
+        /// <param name="strGuid"></param>
+        private void getModel(string strGuid)
+        {
+            bool isEdit = false;
+            if (toolBarMenu1.currentAction == "add") return;
+            if (toolBarMenu1.currentAction == "edit") isEdit = true;
+            if (string.IsNullOrEmpty(strGuid))
+            {
+                MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
+                return;
+            }
+            var _obj = new
+            {
+                guid = strGuid //涓诲缓
+            };
+            var strJson = "";
+            try
+            {
+                strJson = UtilityHelper.HttpPost("", "Role/GetModel",
+                    JsonConvert.SerializeObject(_obj));
+                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
+                if (_rtn.rtnCode > 0)
+                {
+                    var dy = _rtn.rtnData;
+                    lbGuid.Text = strGuid;
+                    UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, isEdit);
+                }
+                else
+                {
+                    MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
+                }
+            }
+            catch (Exception ex)
+            {
+                MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+            }
+        }
+        // 閬嶅巻TreeView涓殑鎵�鏈夎妭鐐�
+        private void TraverseTreeViewNodes(TreeNodeCollection nodes)
+        {
+            foreach (TreeNode node in nodes)
+            {
+                if (node.Checked)
+                    _actionLst.Append(node.Name + "~");
+                // 閫掑綊閬嶅巻瀛愯妭鐐�
+                if (node.Nodes.Count > 0) TraverseTreeViewNodes(node.Nodes);
+            }
+        }
+        /// <summary>
+        /// 寮瑰嚭閰嶇疆鏉冮檺
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
+        {
+            if (e.Button.Index == 0)
+            {
+                var rowhandle = gridView1.FocusedRowHandle;
+                var dr = gridView1.GetDataRow(rowhandle);
+                var roleGuid = dr["guid"].ToString();
+                var frm = new RoleSelectAction(roleGuid,"璁剧疆瑙掕壊鏉冮檺");
+                frm.ShowDialog();
+            }
+        }
+    }
+}
\ No newline at end of file

--
Gitblit v1.9.3