lu
2024-10-23 bd06bb837fa0c7edeeae56cb0fe4fb844f53fb2f
DevApp/Gs.DevApp/DevFrm/User/User.cs
@@ -1,16 +1,18 @@
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
{
    public partial class User : DevExpress.XtraEditors.XtraForm
    {
        List<FilterEntity> _filterList = new List<FilterEntity>();
        public User()
        {
            InitializeComponent();
@@ -20,12 +22,10 @@
            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());
            pageBar1.PagerEvent += PageBar1_PagerEvent;
            gridView1.IndicatorWidth = 50;
            gridView1.CustomDrawRowIndicator += (s, e) =>
            {
@@ -34,24 +34,13 @@
                    e.Info.DisplayText = (e.RowHandle + 1).ToString();
                }
            };
        }
        private void ToolBarMenu1_btnReportClick(object sender, EventArgs e)
        {
            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());
            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>
@@ -61,20 +50,9 @@
        /// <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>
        /// 分页事件
@@ -92,7 +70,7 @@
        /// <param name="e"></param>
        private void ToolBarMenu1_btnQueryClick(object sender, EventArgs e)
        {
            Gs.DevApp.UserControl.ShowFilter frm = new Gs.DevApp.UserControl.ShowFilter(gridView1.Columns);
            Gs.DevApp.UserControl.ShowFilter frm = new Gs.DevApp.UserControl.ShowFilter(gridView1.Columns, _filterList);
            frm.UpdateParent += Frm_UpdateParent;
            frm.ShowDialog();
        }
@@ -103,8 +81,8 @@
        /// <param name="e"></param>
        private void Frm_UpdateParent(object sender, UpdateParentEventArgs e)
        {
            string strWhere = e.Data;
            MessageBox.Show(strWhere);
            _filterList = e.FilterList;
            getPageList(1, pageBar1.RowsCount);
        }
        /// <summary>
@@ -133,10 +111,9 @@
            }
            if (!MsgHelper.AskQuestion("你选择了【" + rowName + "】,确定删除吗?"))
                return;
            var _obj = new
            {
                guidList = rowGuid,//主建
            };
            List<string> lst = new List<string>();
            lst.Add(rowGuid);
            var _obj = lst;
            try
            {
                string strJson = UtilityHelper.HttpPost("", "User/DeleteModel", JsonConvert.SerializeObject(_obj));
@@ -191,6 +168,7 @@
            lbGuid.Text = "";
            UtilityHelper.CleanValueByControl(this.panel1.Controls, true);
            txt_password.Visible = lbPwd.Visible = true;
            txt_account.Enabled = txt_password.Enabled = true;
        }
        /// <summary>
        /// 保存事件
@@ -218,12 +196,6 @@
                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(),//主建
@@ -233,13 +205,8 @@
                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 = "",
                isStatus = txt_isStatus.Checked,
                remark = txt_remark.Text.Trim(),
                departGuid = "",
                isSys = 0
            };
            try
@@ -267,7 +234,12 @@
        /// <param name="pageSize">每页几条</param>
        private void getPageList(int curPage, int pageSize)
        {
            PageQueryModel pgq = new PageQueryModel(curPage, pageSize, "edtTime", "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", "asc", "", _sbSqlWhere.ToString());
            string json = JsonConvert.SerializeObject(pgq);
            try
            {
@@ -310,8 +282,7 @@
                    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;
                    txt_account.Enabled = txt_password.Enabled = txt_password.Visible = lbPwd.Visible = tipPwd.Visible = false;
                }
                else
                    ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
@@ -332,6 +303,17 @@
                frm.ShowDialog();
            }
        }
        private void repositoryItemButtonEdit2_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();
                Gs.DevApp.DevFrm.User.UserSetPwd frm = new Gs.DevApp.DevFrm.User.UserSetPwd(userGuid);
                frm.ShowDialog();
            }
        }
    }
}