From c78ffe15080b3218671f03c7d85a5e8edd484b62 Mon Sep 17 00:00:00 2001
From: lg <999544862qq.com>
Date: 星期日, 22 九月 2024 20:54:15 +0800
Subject: [PATCH] 仓库管理

---
 DevApp/Gs.DevApp/DevFrm/User/User.cs |  330 +++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 297 insertions(+), 33 deletions(-)

diff --git a/DevApp/Gs.DevApp/DevFrm/User/User.cs b/DevApp/Gs.DevApp/DevFrm/User/User.cs
index a8ce05c..8e14f84 100644
--- a/DevApp/Gs.DevApp/DevFrm/User/User.cs
+++ b/DevApp/Gs.DevApp/DevFrm/User/User.cs
@@ -1,17 +1,10 @@
-锘縰sing DevExpress.XtraEditors;
-using DevExpress.XtraGrid.Columns;
-using DevExpress.XtraGrid.Views.Grid;
-using Gs.DevApp.Models;
+锘縰sing 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.ComponentModel;
 using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using System.Windows.Forms;
 
 namespace Gs.DevApp.DevFrm.User
@@ -22,21 +15,249 @@
         {
             InitializeComponent();
             this.toolBarMenu1.btnAddClick += ToolBarMenu1_btnAddClick;
-            PageBar1.williamPagerEvent += CtrlGridPaging1_williamPagerEvent;
-            GetPageList(1, 10);
-             
+            this.toolBarMenu1.btnEdtClick += ToolBarMenu1_btnEdtClick;
+            this.toolBarMenu1.btnSaveClick += ToolBarMenu1_btnSaveClick;
+            this.toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick;
+            this.toolBarMenu1.btnDelClick += ToolBarMenu1_btnDelClick1;
+            this.toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick;
+            this.toolBarMenu1.btnReportClick += ToolBarMenu1_btnReportClick;
+            this.toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;
+            gcMain.MouseDoubleClick += GcMain_MouseDoubleClick;
+            gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
+            pageBar1.PagerEvent += PageBar1_PagerEvent;
+            getPageList(1, UtilityHelper.GetPageSize());
+            gridView1.IndicatorWidth = 50;
+            gridView1.CustomDrawRowIndicator += (s, e) =>
+            {
+                if (e.Info.IsRowIndicator && e.RowHandle >= 0)
+                {
+                    e.Info.DisplayText = (e.RowHandle + 1).ToString();
+                }
+            };
         }
 
-        private void CtrlGridPaging1_williamPagerEvent(int curPage, int pageSize)
+        private void ToolBarMenu1_btnReportClick(object sender, EventArgs e)
         {
-            //MessageBox.Show("褰撳墠椤碉細" + curPage + "锛屾瘡椤靛睍绀猴細" + pageSize + "鏉�");
-            GetPageList(curPage, pageSize);
+            Rpt.RptPreview frm = new Rpt.RptPreview("001");
+            frm.Show();
         }
 
+        private void GridView1_ColumnFilterChanged(object sender, EventArgs e)
+        {
+            //// 鑾峰彇GridView缁勪欢
+            //GridView view = sender as GridView;
+            //// 纭繚view涓嶄负null
+            //if (view == null) return;
+            //// 鑾峰彇搴旂敤鐨勭瓫閫夊櫒淇℃伅
+            //string filter = view.ActiveFilterString;
+            //MessageBox.Show(filter);
+            //getPageList(1, UtilityHelper.GetPageSize());
+        }
+
+        /// <summary>
+        /// 鍙屽嚮浜嬩欢
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <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);
+                    }
+                }
+            }
+        }
+        /// <summary>
+        /// 鍒嗛〉浜嬩欢
+        /// </summary>
+        /// <param name="curPage"></param>
+        /// <param name="pageSize"></param>
+        private void PageBar1_PagerEvent(int curPage, int pageSize)
+        {
+            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);
+            frm.UpdateParent += Frm_UpdateParent;
+            frm.ShowDialog();
+        }
+        /// <summary>
+        /// 鏌ヨ鍥炶皟
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void Frm_UpdateParent(object sender, UpdateParentEventArgs e)
+        {
+            string strWhere = e.Data;
+            MessageBox.Show(strWhere);
+        }
+
+        /// <summary>
+        /// 鍙栨秷浜嬩欢
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ToolBarMenu1_btnEscClick(object sender, EventArgs e)
+        {
+            UtilityHelper.JumpToTab(xtraTabControl1, 0);
+        }
+
+        /// <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_userName, gridView1);
+            if (string.IsNullOrEmpty(rowGuid))
+            {
+                ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
+                return;
+            }
+            if (!MsgHelper.AskQuestion("浣犻�夋嫨浜嗐��" + rowName + "銆戯紝纭畾鍒犻櫎鍚楋紵"))
+                return;
+            var _obj = new
+            {
+                guidList = rowGuid,//涓诲缓
+            };
+            try
+            {
+                string strJson = UtilityHelper.HttpPost("", "User/DeleteModel", JsonConvert.SerializeObject(_obj));
+                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
+                if (_rtn.rtnCode > 0)
+                {
+                    UtilityHelper.JumpToTab(xtraTabControl1, 0);
+                    getPageList(1, UtilityHelper.GetPageSize());
+                }
+                ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
+            }
+            catch (Exception ex)
+            {
+                ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+            }
+        }
+
+        /// <summary>
+        /// 鍒锋柊浜嬩欢
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e)
+        {
+            UtilityHelper.JumpToTab(xtraTabControl1, 0);
+            getPageList(1, UtilityHelper.GetPageSize());
+        }
+        /// <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_userName, gridView1);
+            if (string.IsNullOrEmpty(rowGuid))
+            {
+                ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
+                return;
+            }
+            getModel(rowGuid, true, 1);
+        }
+        /// <summary>
+        /// 鏂板浜嬩欢
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
         private void ToolBarMenu1_btnAddClick(object sender, EventArgs e)
         {
-            UserAdd frm = new UserAdd("");
-            frm.ShowDialog();
+            UtilityHelper.JumpToTab(xtraTabControl1, 1);
+            lbGuid.Text = "";
+            UtilityHelper.CleanValueByControl(this.panel1.Controls, true);
+            txt_password.Visible = lbPwd.Visible = 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_account.Text.Trim()))
+            {
+                Gs.DevApp.ToolBox.MsgHelper.Warning("鐧诲綍璐﹀彿涓嶈兘涓虹┖锛�");
+                txt_account.Focus();
+                return;
+            }
+            if (string.IsNullOrEmpty(txt_password.Text.Trim()))
+            {
+                Gs.DevApp.ToolBox.MsgHelper.Warning("瀵嗙爜涓嶈兘涓虹┖锛�");
+                txt_password.Focus();
+                return;
+            }
+            if (string.IsNullOrEmpty(txt_userName.Text.Trim()))
+            {
+                Gs.DevApp.ToolBox.MsgHelper.Warning("濮撳悕涓嶈兘涓虹┖锛�");
+                txt_userName.Focus();
+                return;
+            }
+            if (txt_isStatus.SelectedIndex <= 0)
+            {
+                Gs.DevApp.ToolBox.MsgHelper.Warning("鐘舵�佷笉鑳戒负绌猴紒");
+                txt_isStatus.Focus();
+                return;
+            }
+            var _obj = new
+            {
+                guid = lbGuid.Text.Trim(),//涓诲缓
+                account = txt_account.Text.Trim(),
+                password = txt_password.Text.Trim(),
+                userName = txt_userName.Text.Trim(),
+                address = txt_address.Text.Trim(),
+                tel = txt_tel.Text.Trim(),
+                email = txt_email.Text.Trim(),
+                isStatus = txt_isStatus.SelectedIndex,
+                flagAdmin = 0,
+                flagOnline = 0,
+                loginCounter = 0,
+                workerID = "",
+                remark = txt_remark.Text.Trim(),
+                departGuid = "",
+                isSys = 0
+            };
+            try
+            {
+                string strJson = UtilityHelper.HttpPost("", "User/EditModel", JsonConvert.SerializeObject(_obj));
+                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
+                ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
+                if (_rtn.rtnCode > 0)
+                {
+                    lbGuid.Text = _rtn.rtnData;
+                    toolBarMenu1.isSetBtn = true;
+                    UtilityHelper.ChangeEnableByControl(this.panel1.Controls, false);
+                }
+            }
+            catch (Exception ex)
+            {
+                ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+            }
         }
 
         /// <summary>
@@ -44,30 +265,73 @@
         /// </summary>
         /// <param name="curPage">绗嚑椤�</param>
         /// <param name="pageSize">姣忛〉鍑犳潯</param>
-        private void GetPageList(int curPage, int pageSize)
+        private void getPageList(int curPage, int pageSize)
         {
-            Models.PageQueryModel pgq = new Models.PageQueryModel(curPage, pageSize, "userName", "asc", "", "");
+            PageQueryModel pgq = new PageQueryModel(curPage, pageSize, "edtTime", "asc", "", "");
             string json = JsonConvert.SerializeObject(pgq);
-            string strReturn = "";
             try
             {
-                strReturn = UtilityHelper.HttpPost("", "User/GetListPage", json);
-                ReturnModel<PageListModel> dd = UtilityHelper.GetTableByJson(strReturn);
+                string strReturn = UtilityHelper.HttpPost("", "User/GetListPage", json);
+                ReturnModel<PageListModel> dd = UtilityHelper.ReturnToTablePage(strReturn);
                 DataTable dt = dd.rtnData.list;
-                gc_Main.BindingContext = new BindingContext();
-                gc_Main.DataSource = dt;
-                gc_Main.ForceInitialize();
+                gcMain.BindingContext = new BindingContext();
+                gcMain.DataSource = dt;
+                gcMain.ForceInitialize();
                 int dddd = dd.rtnData.pages;//鎬婚〉
-                PageBar1.TotalPages = dddd;
-                PageBar1.RecordCount = dd.rtnData.total;//璁板綍鎬绘暟
-                PageBar1.CurrentPage = curPage;//褰撳墠椤�
-                PageBar1.RowsCount = pageSize;//姣忛〉鏄剧ず
-                PageBar1.setTxt();
-    }
+                pageBar1.TotalPages = dddd;
+                pageBar1.RecordCount = dd.rtnData.total;//璁板綍鎬绘暟
+                pageBar1.CurrentPage = curPage;//褰撳墠椤�
+                pageBar1.RowsCount = pageSize;//姣忛〉鏄剧ず
+                pageBar1.setTxt();
+            }
             catch (Exception ex)
             {
                 ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
             }
         }
+        private void getModel(string strGuid, bool isEdit, int tabIdx)
+        {
+            if (string.IsNullOrEmpty(strGuid))
+            {
+                ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
+                return;
+            }
+            UtilityHelper.JumpToTab(xtraTabControl1, tabIdx);
+            var _obj = new
+            {
+                guid = strGuid,//涓诲缓
+            };
+            try
+            {
+                string strJson = UtilityHelper.HttpPost("", "User/GetModel", JsonConvert.SerializeObject(_obj));
+                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
+                if (_rtn.rtnCode > 0)
+                {
+                    dynamic dy = _rtn.rtnData;
+                    lbGuid.Text = strGuid;
+                    UtilityHelper.SetValueByObj(this.panel1.Controls, dy, isEdit);
+                    txt_account.Enabled = false;
+                    txt_password.Enabled = txt_password.Visible = lbPwd.Visible = tipPwd.Visible = false;
+                }
+                else
+                    ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
+            }
+            catch (Exception ex)
+            {
+                ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+            }
+        }
+        private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
+        {
+            if (e.Button.Index == 0)
+            {
+                int rowhandle = gridView1.FocusedRowHandle;
+                DataRow dr = gridView1.GetDataRow(rowhandle);
+                string userGuid = dr["guid"].ToString();
+                UserSelectRole frm = new UserSelectRole(userGuid);
+                frm.ShowDialog();
+            }
+        }
     }
-}
\ No newline at end of file
+}
+

--
Gitblit v1.9.3