| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_MST_0208.cs
- * 2.功能描述:用户管理
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 孔赫 2024/06/12 1.00 新建
- *******************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseControls;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Basics.DockPanel;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
- namespace Dongke.IBOSS.PRD.Client.SystemModule
- {
- /// <summary>
- /// 用户管理
- /// </summary>
- public partial class F_MST_0208 : DockPanelBase
- {
- #region 成员变量
- // 单例模式
- private static F_MST_0208 _instance;
- // 最后选择行
- private int _selecedRow;
- // 用户管理实体类
- private SUserEntity _userInfo;
- public enum ActionTypeEnum
- {
- /// <summary>
- /// pc登录
- /// </summary>
- PC登录 = 0,
- /// <summary>
- /// PC登出
- /// </summary>
- PC登出 = 1,
- /// <summary>
- /// 移动设备登录
- /// </summary>
- 移动设备登录 = 2,
- /// <summary>
- /// 移动设备登出
- /// </summary>
- 移动设备登出 = 3,
- /// <summary>
- /// PC登录MBC
- /// </summary>
- PC登录MBC = 4,
- /// <summary>
- /// PC登出MBC
- /// </summary>
- /// <param name=""></param>
- PC登出MBC = 5
- }
- #endregion
- #region 单例模式
- /// <summary>
- /// 单例模式,防止重复创建窗体
- /// </summary>
- public static F_MST_0208 Instance
- {
- get
- {
- if (_instance == null)
- {
- _instance = new F_MST_0208();
- }
- return _instance;
- }
- }
- #endregion
- #region 构造函数
- public F_MST_0208()
- {
- InitializeComponent();
- this.Text = FormTitles.F_MST_0208;
- this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
- this.btnSearch.Text = ButtonText.BTN_SEARCH;
- this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
- DataTable dt = new DataTable();
- dt.Columns.Add("id", typeof(string));
- dt.Columns.Add("actiontype", typeof(string));
- DataRow dr = dt.NewRow();
- int d = 0;
- var type = typeof(ActionTypeEnum);
- foreach (string name in Enum.GetNames(type))
- {
- dr = dt.NewRow();
- dr[0] = (int)Enum.Parse(type, name);
- dr[1] = name;
- dt.Rows.Add(dr);
- d++;
- }
- dr = dt.NewRow();
- dr[0] = 6;
- dr[1] = "WEB质量登记";
- dt.Rows.Add(dr);
- cbActionType.DisplayMember = "actiontype";
- cbActionType.DataSource = dt;
- cbActionType.Text = "";
- }
- #endregion
- #region 事件
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void FrmUser_Load(object sender, EventArgs e)
- {
- try
- {
- //加载权限
- //FormPermissionManager.FormPermissionControl(this.Name, this,
- // Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
- // Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
- // 设置表格不自动创建列
- this.dgvUserLogin.AutoGenerateColumns = false;
- this.SetToolStripButtonEnable();
- this.scbOrganization.EditReadOnly = true;
- this.opentime.Value = DateTime.Now.AddHours(-1);
- this.closetime.Value = DateTime.Now;
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 搜索按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSearch_Click(object sender, EventArgs e)
- {
- try
- {
- this.btnSearch.Enabled = false;
- this.btnClearCondition.Enabled = false;
- DataSet userDataSet = this.SearchUserData();
- this.btnSearch.Enabled = true;
- this.btnClearCondition.Enabled = true;
- this.scbOrganization.EditReadOnly = true;
- if (userDataSet != null)
- {
- base.DataSource = (DataSet)userDataSet;
- if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
- {
- this.dgvUserLogin.DataSource = this.DataSource.Tables[0];
- #region
- //foreach (DataGridViewRow gvrFor in this.dgvUser.Rows)
- //{
- // string ValueStr = "";
- // string ValueNum = gvrFor.Cells["ValueFlag"].Value.ToString();
- // switch (ValueNum)
- // {
- // case "1":
- // ValueStr = "正常";
- // break;
- // case "0":
- // ValueStr = "停用";
- // break;
- // default:
- // break;
- // }
- // gvrFor.Cells["checkValueFlag"].Value = ValueStr;
- // string StateStr = gvrFor.Cells["IsLocked"].Value.ToString();
- // if (StateStr == "1")
- // {
- // gvrFor.Cells["IsLocked"].Value = "锁死";
- // }
- // else
- // {
- // gvrFor.Cells["IsLocked"].Value = "正常";
- // }
- //}
- #endregion
- if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
- {
- // 提示未查找到数据
- MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- }
- this.SetToolStripButtonEnable();
- }
- catch (Exception ex)
- {
- this.btnSearch.Enabled = true;
- this.btnClearCondition.Enabled = true;
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 清空输入查询寻条件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnClear_Click(object sender, EventArgs e)
- {
- this.txtUserCode.Clear();
- this.txtUserName.Clear();
- this.scbOrganization.ClearValue();
- this.cbActionType.Text = "";
- this.opentime.Value = DateTime.Now.AddHours(-1);
- this.closetime.Value = DateTime.Now;
- }
- /// <summary>
- /// 窗体关闭事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_MST_0203_FormClosed(object sender, FormClosedEventArgs e)
- {
- _instance = null;
- }
- /// <summary>
- /// 自动适应列宽事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAdaptive_Click(object sender, EventArgs e)
- {
- this.dgvUserLogin.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- }
- /// <summary>
- /// 窗体关闭事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 数据表格鼠标点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvUser_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
- {
- //if (e.RowIndex != -Constant.INT_IS_ONE)
- //{
- // string ValueFlag = this.dgvUser.Rows[e.RowIndex].Cells["IsLocked"].Value.ToString();
- // if (ValueFlag == "锁死" || ValueFlag == "1")
- // {
- // this.tsbtnUnlock.Enabled = true;
- // }
- // else
- // {
- // this.tsbtnUnlock.Enabled = false;
- // }
- //}
- }
- /// <summary>
- /// 打印工号事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbPrintCode_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvUserLogin.Rows.Count == Constant.INT_IS_ZERO)
- {
- // 提示信息
- MessageBox.Show(Messages.MSG_CMN_W023,
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- List<string> codeList = new List<string>();
- foreach (DataGridViewRow row in this.dgvUserLogin.Rows)
- {
- codeList.Add(row.Cells["UserCode"].Value.ToString());
- }
- F_MST_0205 fMST0205 = new F_MST_0205();
- fMST0205.BarcodeList = codeList;
- fMST0205.ShowDialog();
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 获取用户列表
- /// </summary>
- /// <returns></returns>
- private DataSet SearchUserData()
- {
- try
- {
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "F_MST_0208";
- cre.Name = "GetUserLoginLog";
- cre.Properties["UserCode"] = this.txtUserCode.Text.Trim();
- cre.Properties["UserName"] = this.txtUserName.Text.Trim();
- cre.Properties["Organization"] = this.scbOrganization.CheckedValue + "";
- cre.Properties["ActionType"] = cbActionType.Text.ToUpper();
- cre.Properties["opentime"] =this.opentime.Value;
- cre.Properties["closetime"] = this.closetime.Value;
- ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
- if (sre.Status == Basics.BaseResources.Constant.ServiceResultStatus.Success)
- {
- return sre.Data;
- }
- return null;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 获取输入的用户信息
- /// </summary>
- /// <returns></returns>
- private SUserEntity GetUserEntityFromLayout()
- {
- this._userInfo = new SUserEntity();
- // 用户编码
- this._userInfo.UserCode = this.txtUserCode.Text.Trim();
- // 用户姓名
- this._userInfo.UserName = this.txtUserName.Text.Trim();
- // 所属部门
- this._userInfo.OrganizationCode = this.scbOrganization.SearchedValue + "";
- // 所属部门
- this._userInfo.OrganizationID = scbOrganization.SearchedPKMember;
- // MAC
- //this._userInfo.LimitMAC = this.txtMAC.Text.Trim();
- //// 备注
- //this._userInfo.Remarks = this.txtRemarks.Text.Trim();
- //if (this.chkVYes.Checked != this.chkVNo.Checked)
- //{
- // if (this.chkVNo.Checked)
- // {
- // this._userInfo.IsValueFlag = "0";
- // }
- // else if (this.chkVYes.Checked)
- // {
- // this._userInfo.IsValueFlag = "1";
- // }
- //}
- //if (this.chkLYes.Checked != this.chkLNo.Checked)
- //{
- // if (this.chkLNo.Checked)
- // {
- // this._userInfo.IsLocked = "1";
- // }
- // else if (this.chkLYes.Checked)
- // {
- // this._userInfo.IsLocked = "0";
- // }
- //}
- return _userInfo;
- }
- /// <summary>
- /// 设置工具按钮的可用状态
- /// </summary>
- private void SetToolStripButtonEnable()
- {
- //if (this.dgvUserLogin.CurrentCell != null)
- //{
- // //this.tsbtnUnlock.Enabled = true;
- // //this.tsbtnResetPassword.Enabled = true;
- // //this.tsbtnEdit.Enabled = true;
- // //this.tsbtnCopy.Enabled = true;
- // //this.tsbtnPurviewRight.Enabled = true;
- // //this.tsbtnFunctionRight.Enabled = true;
- // //int valueFlag = Convert.ToInt32(dgvUser.CurrentRow.Cells["valueFlag"].Value.ToString());
- // string valueFlag = this.dgvUserLogin.Rows[dgvUserLogin.CurrentCell.RowIndex].Cells["IsLocked"].Value.ToString();
- // if (valueFlag == "1")
- // {
- // //this.tsbtnUnlock.Enabled = true;
- // }
- // else
- // {
- // //this.tsbtnUnlock.Enabled = false;
- // }
- // // admin用户不能分配权限
- // //if ("ADMIN".Equals(dgvUser.CurrentRow.Cells["UserCode"].Value.ToString().ToUpper()))
- // //{
- // // this.tsbtnFunctionRight.Enabled = false;
- // //}
- //}
- //else
- //{
- // //this.tsbtnUnlock.Enabled = false;
- // //this.tsbtnResetPassword.Enabled = false;
- // //this.tsbtnEdit.Enabled = false;
- // //this.tsbtnCopy.Enabled = false;
- // //this.tsbtnPurviewRight.Enabled = false;
- // //this.tsbtnFunctionRight.Enabled = false;
- //}
- }
- /// <summary>
- /// 保存组织机构
- /// </summary>
- /// <returns>影响的行数</returns>
- private object UnlockUserStatus()
- {
- try
- {
- return SystemModuleProxy.Service.UnlockUserStatus(Convert.ToInt32(this.dgvUserLogin.CurrentRow.Cells["UserID"].Value));
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- }
- }
|