lu
2025-04-21 b8b5785627c262546c296b8586998a5f5447e6a9
DevApp/Gs.DevApp/DevFrm/PDA/Frm_UserBind.cs
@@ -1,17 +1,11 @@
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using Gs.DevApp.DevFrm.User;
using DevExpress.XtraEditors.Controls;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Gs.DevApp.UserControl;
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;
@@ -24,22 +18,19 @@
        {
            InitializeComponent();
            toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick;
            toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;
            List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
            gvList.Add(gridView1);
            Gs.DevApp.ToolBox.UtilityHelper.getGridViewConfig(this.GetType().FullName, gvList);
            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;
        }
@@ -70,7 +61,7 @@
            gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
            gridView1.ActiveFilter.Clear();
            gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
            var frm = new ShowFilter(gridView1.Columns, _filterList);
            var frm = new ShowFilter(gridView1.Columns, _filterList, this.GetType().FullName);
            frm.UpdateParent += Frm_UpdateParent;
            frm.ShowDialog();
        }
@@ -86,58 +77,6 @@
            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_userName, gridView1, "userName");
            if (string.IsNullOrEmpty(rowGuid))
            {
                MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
            if (!MsgHelper.AskQuestion("你选择了【" + rowName + "】,确定删除吗?"))
                return;
            var lst = new List<string>();
            lst.Add(rowGuid);
            var _obj = lst;
            try
            {
                var strJson = UtilityHelper.HttpPost("", "User/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>
        ///     刷新事件
@@ -161,100 +100,6 @@
            }
        }
        /// <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))
            {
                MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
            Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 3);
            UtilityHelper.ChangeEnableByControl(panel1.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(panel1.Controls, true);
            txt_password.Visible = lbPwd.Visible = true;
            txt_account.Enabled = txt_password.Enabled = 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()))
            {
                MsgHelper.Warning("登录账号不能为空!");
                txt_account.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txt_password.Text.Trim()))
            {
                MsgHelper.Warning("密码不能为空!");
                txt_password.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txt_userName.Text.Trim()))
            {
                MsgHelper.Warning("姓名不能为空!");
                txt_userName.Focus();
                return;
            }
            var _obj = new
            {
                Guid = UtilityHelper.ToGuid(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.Checked,
                remark = txt_remark.Text.Trim(),
                isSys = 0,
                staffId = txt_staffId.GetId()
            };
            try
            {
                var strJson = UtilityHelper.HttpPost("", "User/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(panel1.Controls, false);
                }
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        /// <summary>
        /// </summary>
@@ -262,7 +107,7 @@
        /// <param name="pageSize">每页几条</param>
        private void getPageList(int curPage)
        {
            var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList);
            gcMain1.DataSource = null;var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList);
            var pgq = new PageQueryModel(curPage, this.pageBar1.RowsCount, "a.ACCOUNT asc ,a.CREATE_TIME",
                "desc", "", _sbSqlWhere.ToString());
            var json = JsonConvert.SerializeObject(pgq);
@@ -274,16 +119,16 @@
                if (dd.rtnCode > 0)
                {
                    DataTable dt = dd.rtnData.list;
                    gcMain.BindingContext = new BindingContext();
                    gcMain1.BindingContext = new BindingContext();
                    gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
                    if (dt.Rows.Count > 0)
                    {
                        gcMain.DataSource = dt;
                        gcMain.ForceInitialize();
                        gridView1.BestFitColumns();
                        gcMain1.DataSource = dt;
                        gcMain1.ForceInitialize();
                        gridView1.BestFitColumns(); Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gridView1);
                    }
                    else
                        UtilityHelper.SetDefaultTable(gcMain, gridView1);
                        UtilityHelper.SetDefaultTable(gcMain1, gridView1);
                    gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
                    pageBar1.TotalPages = dd.rtnData.pages;//总页
                    pageBar1.CurrentPage = curPage;//当前页
@@ -324,10 +169,7 @@
                {
                    var dy = _rtn.rtnData;
                    lbGuid.Text = strGuid;
                    UtilityHelper.SetValueByObj(panel1.Controls, dy, isEdit);
                    txt_account.Enabled = txt_password.Enabled =
                        txt_password.Visible =
                            lbPwd.Visible = tipPwd.Visible = false;
                    UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, isEdit);
                }
                else
                {
@@ -339,23 +181,7 @@
                MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        /// <summary>
        /// 角色
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void repositoryItemButtonEdit1_ButtonClick(object sender,
            ButtonPressedEventArgs e)
        {
            if (e.Button.Index == 0)
            {
                var rowhandle = gridView1.FocusedRowHandle;
                var dr = gridView1.GetDataRow(rowhandle);
                var userGuid = dr["guid"].ToString();
                var frm = new UserSelectRole(userGuid);
                frm.ShowDialog();
            }
        }
        /// <summary>
        /// pda页面
        /// </summary>
@@ -369,7 +195,7 @@
                var rowhandle = gridView1.FocusedRowHandle;
                var dr = gridView1.GetDataRow(rowhandle);
                var userGuid = dr["guid"].ToString();
                var frm = new UserSetPwd(userGuid);
                var frm = new SelectPage(userGuid);
                frm.ShowDialog();
            }
        }
@@ -385,7 +211,7 @@
                var rowhandle = gridView1.FocusedRowHandle;
                var dr = gridView1.GetDataRow(rowhandle);
                var userGuid = dr["guid"].ToString();
                var frm = new RoleSelectAction(userGuid);
                var frm = new SelectCk(userGuid);
                frm.ShowDialog();
            }
        }
@@ -402,7 +228,7 @@
                var rowhandle = gridView1.FocusedRowHandle;
                var dr = gridView1.GetDataRow(rowhandle);
                var userGuid = dr["guid"].ToString();
                var frm = new ViewRole(userGuid);
                var frm = new SelectPrint(userGuid);
                frm.ShowDialog();
            }
        }