From ede1325daa45b9ad104867278bd61fdc13d58641 Mon Sep 17 00:00:00 2001
From: lu <99954486@qq.com>
Date: 星期二, 08 四月 2025 10:02:23 +0800
Subject: [PATCH] fqc
---
DevApp/Gs.DevApp/DevFrm/User/User.cs | 395 +++++++++++++++++++++++++++++++++++--------------------
1 files changed, 249 insertions(+), 146 deletions(-)
diff --git a/DevApp/Gs.DevApp/DevFrm/User/User.cs b/DevApp/Gs.DevApp/DevFrm/User/User.cs
index 75a4ae6..40087df 100644
--- a/DevApp/Gs.DevApp/DevFrm/User/User.cs
+++ b/DevApp/Gs.DevApp/DevFrm/User/User.cs
@@ -1,171 +1,204 @@
-锘縰sing DevExpress.XtraEditors;
-using DevExpress.XtraGrid.Views.Base;
-using DevExpress.XtraGrid.Views.Grid;
-using DevExpress.XtraGrid.Views.Grid.ViewInfo;
+锘縰sing System;
+using System.Collections.Generic;
+using System.Data;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using DevExpress.XtraEditors;
+using DevExpress.XtraEditors.Controls;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
+using Gs.DevApp.UserControl;
using Newtonsoft.Json;
-using System;
-using System.Data;
-using System.Drawing;
-using System.Windows.Forms;
namespace Gs.DevApp.DevFrm.User
{
- public partial class User : DevExpress.XtraEditors.XtraForm
+ public partial class User : XtraForm
{
+ private List<FilterEntity> _filterList = new List<FilterEntity>();
public User()
{
InitializeComponent();
- this.toolBarMenu1.btnAddClick += ToolBarMenu1_btnAddClick;
- 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;
- gcMain.MouseDoubleClick += GcMain_MouseDoubleClick;
- gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
+ 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;
- getPageList(1, UtilityHelper.GetPageSize());
}
-
- private void ToolBarMenu1_btnReportClick(object sender, EventArgs e)
- {
- Rpt.RptUser frm = new Rpt.RptUser();
- 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());
+ _filterList = Gs.DevApp.ToolBox.UtilityHelper.GetDilter(gridView1.Columns, gridView1);
+ Task.Delay(100);
+ getPageList(1);
}
/// <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);
+ 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)
{
- UtilityHelper.ChangeTab(xtraTabControl1, 0);
+ 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)
{
- DataRow dr = gridView1.GetFocusedDataRow();
- if (dr == null || string.IsNullOrEmpty(dr["guid"].ToString()))
+ string rowGuid, rowName;
+ (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1,
+ lbGuid, txt_userName, gridView1, "userName");
+ if (string.IsNullOrEmpty(rowGuid))
{
- ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
+ MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
return;
}
- if (!MsgHelper.AskQuestion("浣犻�夋嫨浜嗐��" + dr["userName"].ToString() + "銆戯紝纭畾鍒犻櫎鍚楋紵"))
+
+ if (!MsgHelper.AskQuestion("浣犻�夋嫨浜嗐��" + rowName + "銆戯紝纭畾鍒犻櫎鍚楋紵"))
return;
- var _obj = new
- {
- guidList = dr["guid"].ToString(),//涓诲缓
- };
- string strJson = "";
+ var lst = new List<string>();
+ lst.Add(rowGuid);
+ var _obj = lst;
try
{
- strJson = UtilityHelper.HttpPost("", "User/DeleteModel", JsonConvert.SerializeObject(_obj));
- ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson);
+ var strJson = UtilityHelper.HttpPost("", "User/DeleteModel",
+ JsonConvert.SerializeObject(_obj));
+ var _rtn = UtilityHelper.ReturnToDynamic(strJson);
if (_rtn.rtnCode > 0)
{
- UtilityHelper.ChangeTab(xtraTabControl1, 0);
- getPageList(1, UtilityHelper.GetPageSize());
+ if (xtraTabControl1.SelectedTabPageIndex == 0)
+ { }
+ else
+ Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 2);
+ getPageList(this.pageBar1.CurrentPage);
}
- ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
+
+ MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
}
catch (Exception ex)
{
- ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+ MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
}
}
/// <summary>
- /// 鍒锋柊浜嬩欢
+ /// 鍒锋柊浜嬩欢
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e)
{
- UtilityHelper.ChangeTab(xtraTabControl1, 0);
- getPageList(1, UtilityHelper.GetPageSize());
+ 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);
+ }
}
+
/// <summary>
- /// 淇敼浜嬩欢
+ /// 淇敼浜嬩欢
/// </summary>
/// <param name="sender"></param>
/// <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_userName, gridView1);
+ if (string.IsNullOrEmpty(rowGuid))
{
ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
return;
}
- getModel(dr["guid"].ToString(), true, 1);
+ 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)
{
- UtilityHelper.ChangeTab(xtraTabControl1, 1);
lbGuid.Text = "";
- UtilityHelper.CleanValue(this.panel1.Controls, true);
- txt_password.Visible = lbPwd.Visible = true;
+ Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 4);
+ UtilityHelper.CleanValueByControl(this.layoutMx1.Controls, true);
+ txt_password.Enabled = true;
+ txt_account.Enabled = txt_password.Enabled = true;
}
+
/// <summary>
- /// 淇濆瓨浜嬩欢
+ /// 淇濆瓨浜嬩欢
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
@@ -174,136 +207,206 @@
toolBarMenu1.isSetBtn = false;
if (string.IsNullOrEmpty(txt_account.Text.Trim()))
{
- Gs.DevApp.ToolBox.MsgHelper.Warning("鐧诲綍璐﹀彿涓嶈兘涓虹┖锛�");
+ MsgHelper.Warning("鐧诲綍璐﹀彿涓嶈兘涓虹┖锛�");
txt_account.Focus();
return;
}
+
if (string.IsNullOrEmpty(txt_password.Text.Trim()))
{
- Gs.DevApp.ToolBox.MsgHelper.Warning("瀵嗙爜涓嶈兘涓虹┖锛�");
+ MsgHelper.Warning("瀵嗙爜涓嶈兘涓虹┖锛�");
txt_password.Focus();
return;
}
+
if (string.IsNullOrEmpty(txt_userName.Text.Trim()))
{
- Gs.DevApp.ToolBox.MsgHelper.Warning("濮撳悕涓嶈兘涓虹┖锛�");
+ MsgHelper.Warning("濮撳悕涓嶈兘涓虹┖锛�");
txt_userName.Focus();
return;
}
- if (txt_isLocked.SelectedIndex <= 0)
- {
- Gs.DevApp.ToolBox.MsgHelper.Warning("鐘舵�佷笉鑳戒负绌猴紒");
- txt_isLocked.Focus();
- return;
- }
+
var _obj = new
{
- guid = lbGuid.Text.Trim(),//涓诲缓
+ 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(),
- isLocked = txt_isLocked.SelectedIndex,
- flagAdmin = 0,
- flagOnline = 0,
- loginCounter = 0,
- workerID = "",
+ isStatus = txt_isStatus.Checked,
remark = txt_remark.Text.Trim(),
- departGuid = "",
- isSys = 0
+ isSys = 0,
+ staffId = txt_staffId.GetId()
};
try
{
- string strJson = UtilityHelper.HttpPost("", "User/EditModel", JsonConvert.SerializeObject(_obj));
- ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson);
- ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
+ 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.ChangeEnable(this.panel1.Controls, false);
+ UtilityHelper.ChangeEnableByControl(this.layoutMx1.Controls, false);
+ toolBarMenu1.currentAction = "";
+ Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 6);
}
}
catch (Exception ex)
{
- ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+ MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
}
}
/// <summary>
- ///
/// </summary>
/// <param name="curPage">绗嚑椤�</param>
/// <param name="pageSize">姣忛〉鍑犳潯</param>
- private void getPageList(int curPage, int pageSize)
+ private void getPageList(int curPage)
{
- PageQueryModel pgq = new PageQueryModel(curPage, pageSize, "createTime", "asc", "", "");
- string json = JsonConvert.SerializeObject(pgq);
+ 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);
try
{
- string strReturn = UtilityHelper.HttpPost("", "User/GetListPage", json);
- ReturnModel<PageListModel> dd = UtilityHelper.GetTableByJson(strReturn);
- DataTable dt = dd.rtnData.list;
- 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();
+ var strReturn =
+ UtilityHelper.HttpPost("", "User/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)
{
- ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+ MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
}
}
- private void getModel(string strGuid, bool isEdit, int tabIdx)
+
+ private void getModel(string strGuid)
{
+ bool isEdit = false;
+ if (toolBarMenu1.currentAction == "add") return;
+ if (toolBarMenu1.currentAction == "edit") isEdit = true;
if (string.IsNullOrEmpty(strGuid))
{
- ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
+ MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
return;
}
- UtilityHelper.ChangeTab(xtraTabControl1, tabIdx);
var _obj = new
{
- guid = strGuid,//涓诲缓
+ guid = strGuid //涓诲缓
};
try
{
- string strJson = UtilityHelper.HttpPost("", "User/GetModel", JsonConvert.SerializeObject(_obj));
- ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson);
+ var strJson = UtilityHelper.HttpPost("", "User/GetModel",
+ JsonConvert.SerializeObject(_obj));
+ var _rtn = UtilityHelper.ReturnToDynamic(strJson);
if (_rtn.rtnCode > 0)
{
- dynamic dy = _rtn.rtnData;
+ var 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;
+ UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, isEdit);
+ txt_account.Enabled = txt_password.Enabled = txt_password.Enabled = false;
}
else
- ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
+ {
+ MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
+ }
}
catch (Exception ex)
{
- ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+ MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
}
}
- private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
+ /// <summary>
+ /// 瑙掕壊
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ private void repositoryItemButtonEdit1_ButtonClick(object sender,
+ 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);
+ var rowhandle = gridView1.FocusedRowHandle;
+ var dr = gridView1.GetDataRow(rowhandle);
+ var userGuid = dr["guid"].ToString();
+ var frm = new UserSelectRole(userGuid);
+ frm.ShowDialog();
+ }
+ }
+ /// <summary>
+ /// 瀵嗙爜
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ private void repositoryItemButtonEdit2_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 UserSetPwd(userGuid);
+ frm.ShowDialog();
+ }
+ }
+ /// <summary>
+ /// 涓汉鏉冮檺
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ private void repositoryItemButtonEdit3_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 RoleSelectAction(userGuid);
+ frm.ShowDialog();
+ }
+ }
+
+ /// <summary>
+ /// 鏉冮檺闆嗗悎
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ private void repositoryItemButtonEdit4_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 ViewRole(userGuid);
frm.ShowDialog();
}
}
}
-}
-
+}
\ No newline at end of file
--
Gitblit v1.9.3