| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_MST_0202.cs
- * 2.功能描述:新建/编辑用户管理
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 王鑫 2014/09/12 1.00 新建
- *******************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Text;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseControls;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Basics.Library;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.Client.Controls;
- using Dongke.IBOSS.PRD.Client.DataModels;
- 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_0202 : FormBase
- {
- #region 成员变量
- // 页面传过来用户ID
- private int _userID;
- // 用户实体类
- private SUserEntity _userEntity;
- // 编辑状态
- private Constant.FormMode _editStatus;
- // 新建的用户ID集合
- private List<int> _userIDList = new List<int>();
- // 用户代码
- private string _userCode;
- // 工种集合
- private DataTable _dtJobs;
- // 工种关联数据源
- private DataTable _dtUserJobs = new DataTable();
- // 记录编辑前的缺陷编码
- private string _jobsCodeValue;
- // 控制弹窗标识
- private bool _ShowFlag = true;
- #endregion
- #region 构造函数
- public F_MST_0202()
- {
- InitializeComponent();
- }
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="frmStatus">窗体状态</param>
- public F_MST_0202(Constant.FormMode frmStatus)
- {
- InitializeComponent();
- _editStatus = frmStatus;
- // 设置窗口标题,当为新建状态时显示新建用户,当为编辑状态时显示编辑用户
- if (frmStatus == Constant.FormMode.Add)
- {
- this.Text = FormTitles.F_MST_0202_ADD;
- this.dtpLimitStartTime.Text = "8:00:00";
- this.dtpLimitEndTime.Text = "17:00:00";
- }
- else if (frmStatus == Constant.FormMode.Edit)
- {
- this.Text = FormTitles.F_MST_0202_EDIT;
- this.txtUserCode.Enabled = false;
- }
- // 工具栏按钮文本赋值
- this.btnSave.Text = ButtonText.BTN_SAVE;
- this.btnCancel.Text = ButtonText.BTN_CLOSE;
- }
- #endregion
- #region 属性
- /// <summary>
- /// 页面传过来的用户ID
- /// </summary>
- public int UserID
- {
- get
- {
- return this._userID;
- }
- set
- {
- this._userID = value;
- }
- }
- /// <summary>
- /// 页面传过来的用户代码
- /// </summary>
- public string UserCode
- {
- get
- {
- return this._userCode;
- }
- set
- {
- this._userCode = value;
- }
- }
- /// <summary>
- /// 用户ID集合
- /// </summary>
- public List<int> UserIDList
- {
- get
- {
- return _userIDList;
- }
- set
- {
- _userIDList = value;
- }
- }
- #endregion
- #region 事件
- /// <summary>
- /// 保存按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSave_Click(object sender, EventArgs e)
- {
- try
- {
- // 验证输入是否正确
- if (!this.CheckInputValidity())
- {
- return;
- }
- //校验绑定工种情况
- int rowCount = 0;
- foreach (DataGridViewRow gvrFor in this.dgvDataJobs.Rows)
- {
- if (gvrFor.IsNewRow == false)
- {
- //JobsID
- if (gvrFor.Cells["JobsID"].Value != null && gvrFor.Cells["JobsID"].Value.ToString() != "")
- {
- rowCount++;
- }
- }
- }
- if (chkIsWorker.Checked == true)
- {
- if (rowCount == Constant.INT_IS_ZERO)
- {
- // 提示信息
- MessageBox.Show("生产工号必须绑定至少一个工种!",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- else
- {
- if (rowCount > Constant.INT_IS_ONE)
- {
- // 提示信息
- MessageBox.Show("非生产工号只能绑定一个工种!",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- int returnUserID = Constant.INT_IS_ZERO;
- _userEntity = this.SetUserEntity();
- if (_editStatus == Constant.FormMode.Add || _editStatus == Constant.FormMode.CopyAndAdd)
- {
- // 判断是否存在重复的用户编号
- DataSet userCodeData = (DataSet)DoAsync(new BaseAsyncMethod(IsExistsUserCode));
- if (userCodeData.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W011, this.txtUserCode.Text.Trim(), "用户信息"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtUserCode.Focus();
- return;
- }
- if (_editStatus == Constant.FormMode.CopyAndAdd)
- {
- _userEntity.UserID = UserID;
- }
- // 新建用户,返回新建的用户ID
- this.btnSave.Enabled = false;
- this.btnCancel.Enabled = false;
- returnUserID = (int)DoAsync(new BaseAsyncMethod(AddUserInfo));
- this.btnSave.Enabled = true;
- this.btnCancel.Enabled = true;
- if (returnUserID > Constant.INT_IS_ZERO)
- {
- // 提示信息
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "新建用户", "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- this._userIDList.Add(returnUserID);
- if (_editStatus == Constant.FormMode.CopyAndAdd)
- {
- this.Close();
- return;
- }
- this.InitializationForm();
- }// 组织机构不存在
- else if (returnUserID == -Constant.INT_IS_ONE)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "不存在所选择的组织机构"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- // 组织机构是一级组织机构不允许建立用户
- else if (returnUserID == -Constant.INT_IS_TWO)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "\r\n所选择的组织机构是一级组织机构,不允许创建用户"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- // 该组织机构下存在子级组织机构,不允许建立用户
- else if (returnUserID == -Constant.INT_IS_THREE)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "\r\n所选择的组织机构存在子级组织,不允许创建用户"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else if (returnUserID == -Constant.INT_IS_FIVE)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "\r\n系统活动的用户数已经超过授权数,不允许创建用户"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else
- {
- // 提示信息
- MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "新建用户", "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- else
- {
- // 编辑
- this.btnSave.Enabled = false;
- this.btnCancel.Enabled = false;
- _userEntity.UserID = UserID;
- returnUserID = (int)DoAsync(new BaseAsyncMethod(EditUserInfo));
- this.btnSave.Enabled = true;
- this.btnCancel.Enabled = true;
- if (returnUserID > Constant.INT_IS_ZERO)
- {
- // 提示信息
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "编辑用户", "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- this.Close();
- }
- // 组织机构不存在
- else if (returnUserID == -Constant.INT_IS_ONE)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "不存在所选择的组织机构"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- // 组织机构是一级组织机构不允许建立用户
- else if (returnUserID == -Constant.INT_IS_TWO)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "\r\n所选择的组织机构是一级组织机构,不允许创建用户"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- // 该组织机构下存在子级组织机构,不允许建立用户
- else if (returnUserID == -Constant.INT_IS_THREE)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "\r\n所选择的组织机构存在子级组织,不允许创建用户"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else if (returnUserID == -Constant.INT_IS_FIVE)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "\r\n系统活动的用户数已经超过授权数,不允许创建用户"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else if (returnUserID == -Constant.INT_IS_SIX)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "\r\n在审批流程节点中存在的用户不能停用"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else
- {
- // 提示信息
- MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "编辑用户", "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- }
- catch (Exception ex)
- {
- this.btnSave.Enabled = true;
- this.btnCancel.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 F_MST_0202_Load(object sender, EventArgs e)
- {
- try
- {
- if (this._editStatus == Constant.FormMode.CopyAndAdd)
- {
- this.Text = "复制工号【" + this.UserCode + "】";
- this.dtpLimitStartTime.Text = "8:00:00";
- this.dtpLimitEndTime.Text = "17:00:00";
- }
- //获取工种集合
- //GetJobs();
- // 为画面控件赋初始值
- this.chkValueFlag.Checked = true;
- this.dgvDataJobs.AutoGenerateColumns = false;
- // 加载打印机数据
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "MST0412";
- cre.Name = "GetBarcodePrinter";
- ServiceResultEntity sre = CommonModuleProxy.Service.DoRequest(cre);
- if (sre != null && sre.Status == Constant.ServiceResultStatus.Success)
- {
- DataTable dt = sre.Data.Tables[0];
- DataRow dr = dt.NewRow();
- dr["PrinterName"] = "无";
- dt.Rows.InsertAt(dr, 0);
- this.cobBarcodePrinter.DataSource = sre.Data.Tables[0];
- this.cobBarcodePrinter.DisplayMember = "PrinterName";
- this.cobBarcodePrinter.ValueMember = "PrinterID";
- }
- // 加载PLC
- cre = new ClientRequestEntity();
- cre.NameSpace = "MST0413";
- cre.Name = "GetPLC";
- sre = CommonModuleProxy.Service.DoRequest(cre);
- if (sre != null && sre.Status == Constant.ServiceResultStatus.Success)
- {
- DataTable dt = sre.Data.Tables[0];
- DataRow dr = dt.NewRow();
- dr["PLCName"] = "无";
- dt.Rows.InsertAt(dr, 0);
- this.cobPLC.DataSource = sre.Data.Tables[0];
- this.cobPLC.DisplayMember = "PLCName";
- this.cobPLC.ValueMember = "PLCID";
- }
- // 获取用户信息数据集
- DataSet userInfoData = (DataSet)DoAsync(new BaseAsyncMethod(GetUserRowData));
- int isJobsHave = 0;
- if (userInfoData != null && userInfoData.Tables.Count > Constant.INT_IS_ZERO)
- {
- // 编辑数据 给页面所有项赋值
- if (this._editStatus != Constant.FormMode.Add && userInfoData.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- DataRow userData = userInfoData.Tables[0].Rows[0];
- if (this._editStatus == Constant.FormMode.Edit)
- {
- this.txtUserCode.Text = userData["UserCode"].ToString();
- this.txtUserCode.Enabled = false;
- this.txtUserName.Text = userData["UserName"].ToString();
- }
- this.txtMAC.Text = userData["LIMITMAC"].ToString();
- this.txtRemarks.Text = userData["Remarks"].ToString();
- this.chkValueFlag.Checked = userData["ValueFlag"].ToString() == "1" ? true : false;
- this.chkCanSmartLogin.Checked = userData["CanSmartLogin"].ToString() == "1" ? true : false;
- this.chkCanPCLogin.Checked = userData["CanPCLogin"].ToString() == "1" ? true : false;
- scbOrganization.CheckedData = userInfoData.Tables[0];
- scbOrganization.Text = userData["OrganizationName"].ToString();
- this.chkIsWorker.Checked = userData["IsWorker"].ToString() == "1" ? true : false;
- this.chkIsGroutingWorker.Checked = userData["IsGroutingWorker"].ToString() == "1" ? true : false;
- this.chkPublicBody.Checked = userData["ispublicbody"].ToString() == "1" ? true : false;
- this.chkPRD.Checked = userData["CanLoginPRD"].ToString() == "1" ? true : false;
- this.chkMBC.Checked = userData["CanLoginMBC"].ToString() == "1" ? true : false;
- if (userData["POST"] != DBNull.Value && userData["POST"] != null)
- {
- this.dkPost.PostName = userData["POSTName"].ToString();
- this.dkPost.PostID = Convert.ToInt32(userData["POSTId"]);
- }
- if (userData["LimitStartTime"] != DBNull.Value && userData["LimitStartTime"] != null)
- {
- this.cbTime.Checked = true;
- this.dtpLimitStartTime.Text = userData["LimitStartTime"].ToString();
- this.dtpLimitEndTime.Text = userData["LimitEndTime"].ToString();
- }
- else
- {
- this.cbTime.Checked = false;
- this.dtpLimitStartTime.Text = "8:00:00";
- this.dtpLimitEndTime.Text = "17:00:00";
- }
- // 条码打印机
- this.cobBarcodePrinter.SelectedValue = userData["BarcodePrinterID"];
- this.cobPLC.SelectedValue = userData["plcID"];
- }
- if (this._editStatus != Constant.FormMode.Add && userInfoData.Tables[1].Rows.Count > Constant.INT_IS_ZERO)
- {
- this.dgvDataJobs.AutoGenerateColumns = false;
- this.dgvDataJobs.DataSource = userInfoData.Tables[1];
- isJobsHave++;
- }
- }
- if (isJobsHave == Constant.INT_IS_ZERO)
- {
- _dtUserJobs.Columns.Add("JobsCode", System.Type.GetType("System.String"));
- _dtUserJobs.Columns.Add("JobsID", System.Type.GetType("System.String"));
- _dtUserJobs.Columns.Add("JobsName", System.Type.GetType("System.String"));
- _dtUserJobs.Columns.Add("Remarks", System.Type.GetType("System.String"));
- this.dgvDataJobs.DataSource = _dtUserJobs;
- }
- this.dgvDataJobs.IsSetInputColumnsColor = true;
- this.dtpLimitStartTime.Enabled = this.cbTime.Checked;
- this.dtpLimitEndTime.Enabled = this.cbTime.Checked;
- }
- 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 dgvDataJobs_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
- {
- try
- {
- if (this.dgvDataJobs.Rows.Count <= Constant.INT_IS_ONE)
- {
- return;
- }
- DataGridViewColumn columnItem = this.dgvDataJobs.Columns[e.ColumnIndex];
- if ("JobsCode".Equals(columnItem.Name))
- {
- this._jobsCodeValue = this.dgvDataJobs.Rows[e.RowIndex].Cells[columnItem.Name].Value + "";
- }
- }
- 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 dgvDataJobs_CellValueChanged(object sender, DataGridViewCellEventArgs e)
- {
- #region 改用弹出窗体模式
- /*
- if (e.RowIndex != -1)
- {
- if (this.dgvDataJobs.Columns[e.ColumnIndex].Name == "JobsCode")
- {
- string JobsCode = this.dgvDataJobs.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
- //看看这条记录有没有被选过
- for (int i = 0; i < this.dgvDataJobs.Rows.Count; i++)
- {
- if (i != e.RowIndex)
- {
- if (this.dgvDataJobs.Rows[i].Cells["JobsCode"].Value != null)
- {
- if (JobsCode == this.dgvDataJobs.Rows[i].Cells["JobsCode"].Value.ToString())
- {
- // 提示信息
- MessageBox.Show("已经选择了该工种!",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.dgvDataJobs.Rows.RemoveAt(e.RowIndex);
- return;
- }
- }
- }
- }
- StringBuilder strbFilterExpressions = new StringBuilder();
- strbFilterExpressions.Append(string.Format("JobsId='{0}'", JobsCode));
- DataTable TableCopy = _dtJobs.Copy();
- TableCopy.DefaultView.RowFilter = strbFilterExpressions.ToString();
- DataTable EndTable = TableCopy.DefaultView.ToTable();
- if (EndTable.Rows.Count != 0)
- {
- this.dgvDataJobs.Rows[e.RowIndex].Cells["JobsName"].Value = EndTable.Rows[0]["JobsName"].ToString();
- this.dgvDataJobs.Rows[e.RowIndex].Cells["Remarks"].Value = EndTable.Rows[0]["Remarks"].ToString();
- this.dgvDataJobs.Rows[e.RowIndex].Cells["JobsID"].Value = EndTable.Rows[0]["JobsID"].ToString();
- }
- else
- {
- this.dgvDataJobs.Rows.RemoveAt(e.RowIndex);
- }
- }
- }
- */
- #endregion
- try
- {
- if (this.dgvDataJobs.Rows.Count <= Constant.INT_IS_ONE || !_ShowFlag)
- {
- return;
- }
- DataGridViewRow rowItem = this.dgvDataJobs.Rows[e.RowIndex];
- DataGridViewColumn columnItem = this.dgvDataJobs.Columns[e.ColumnIndex];
- // 工种编号获取产品信息
- if ("JobsCode".Equals(columnItem.Name))
- {
- _ShowFlag = false;
- FormUtility.BindJobsRowDataSource(this.dgvDataJobs,
- e.RowIndex, columnItem.Name, _jobsCodeValue);
- // 设置可输入单元格的颜色
- this.dgvDataJobs.IsSetInputColumnsColor = true;
- }
- this._ShowFlag = true;
- }
- 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 cbTime_CheckedChanged(object sender, EventArgs e)
- {
- this.dtpLimitStartTime.Enabled = this.cbTime.Checked;
- this.dtpLimitEndTime.Enabled = this.cbTime.Checked;
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 获取用户明细数据
- /// </summary>
- /// <returns></returns>
- private DataSet GetUserRowData()
- {
- try
- {
- return SystemModuleProxy.Service.GetUserRowData(UserID);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 添加用户数据
- /// </summary>
- /// <returns></returns>
- private object AddUserInfo()
- {
- try
- {
- DataTable dtJobs = (DataTable)this.dgvDataJobs.DataSource;
- dtJobs.TableName = "dtJobs";
- this._userEntity.UserJobs = dtJobs;
- return SystemModuleProxy.Service.AddUserInfo(_userEntity);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 是否存在相同的用户编码
- /// </summary>
- /// <returns></returns>
- private DataSet IsExistsUserCode()
- {
- try
- {
- return SystemModuleProxy.Service.IsExistsUserCode(this.txtUserCode.Text);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 绑定下拉数据源
- /// </summary>
- /// <returns></returns>
- public DataTable datasourceCombox()
- {
- DataTable dt = new DataTable();
- dt.Columns.Add("ValueID");
- dt.Columns.Add("TextString");
- DataRow dr = dt.NewRow();
- dr["ValueID"] = 0;
- dr["TextString"] = "没有关联";
- dt.Rows.Add(dr);
- dr = dt.NewRow();
- dr["ValueID"] = 1;
- dr["TextString"] = "关联员工";
- dt.Rows.Add(dr);
- dr = dt.NewRow();
- dr["ValueID"] = 2;
- dr["TextString"] = "关联员工组";
- dt.Rows.Add(dr);
- return dt;
- }
- /// <summary>
- /// 编辑用户信息
- /// </summary>
- /// <returns></returns>
- private object EditUserInfo()
- {
- try
- {
- DataTable dtJobs = (DataTable)this.dgvDataJobs.DataSource;
- dtJobs.TableName = "dtJobs";
- this._userEntity.UserJobs = dtJobs;
- return SystemModuleProxy.Service.EditUserInfo(this._userEntity);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 清空输入项
- /// </summary>
- private void InitializationForm()
- {
- this.txtUserCode.Clear();
- this.txtUserName.Clear();
- this.txtMAC.Clear();
- this.txtRemarks.Clear();
- this.scbOrganization.ClearValue();
- this.chkValueFlag.Checked = true;
- this._dtUserJobs.Rows.Clear();
- this.dgvDataJobs.IsSetInputColumnsColor = true;
- this.cobBarcodePrinter.SelectedIndex = 0;
- }
- /// <summary>
- /// 根据页面输入值,给用户对象实体赋值
- /// </summary>
- /// <returns></returns>
- private SUserEntity SetUserEntity()
- {
- SUserEntity userEntity = new SUserEntity();
- userEntity.UserCode = this.txtUserCode.Text.Trim();
- userEntity.UserName = this.txtUserName.Text.Trim();
- userEntity.OrganizationID = scbOrganization.SearchedPKMember;
- userEntity.IsWorker = chkIsWorker.Checked ? 1 : 0;
- userEntity.IsGroutingWorker = chkIsGroutingWorker.Checked ? 1 : 0;
- userEntity.LimitMAC = txtMAC.Text;
- if (this.cbTime.Checked == true)
- {
- userEntity.LimitStartTime = Convert.ToDateTime(dtpLimitStartTime.Text);
- userEntity.LimitEndTime = Convert.ToDateTime(dtpLimitEndTime.Text);
- }
- else
- {
- userEntity.LimitStartTime = null;
- userEntity.LimitEndTime = null;
- }
- if (this.dkPost.PostID != null)
- {
- userEntity.PostID = Convert.ToInt32(this.dkPost.PostID);
- }
- userEntity.CanSmartLogin = chkCanSmartLogin.Checked ? 1 : 0;
- userEntity.CanPCLogin = chkCanPCLogin.Checked ? 1 : 0;
- userEntity.Remarks = txtRemarks.Text;
- userEntity.ValueFlag = chkValueFlag.Checked ? 1 : 0;
- userEntity.Ispublicbody = chkPublicBody.Checked ? 1 : 0;
- userEntity.CanLoginPRD = "1"; // chkPRD.Checked ? "1" : "0";
- userEntity.CanLoginMBC = "0"; // chkMBC.Checked ? "1" : "0";
- // 新建用户默认密码
- DataSet ds = (DataSet)CommonModuleProxy.Service.GetSysSettingBySettingType("S_CMN_0001");
- string pwd = "dongke";
- if (ds.Tables[0].Rows.Count > 0)
- {
- pwd = ds.Tables[0].Rows[0]["SETTINGVALUE"].ToString();
- }
- userEntity.Password = Encryption.GetMD5String(pwd);
- if (this.cobBarcodePrinter.SelectedValue != null && this.cobBarcodePrinter.SelectedValue != DBNull.Value)
- {
- userEntity.BarcodePrinterID = Convert.ToInt32(this.cobBarcodePrinter.SelectedValue);
- }
- if (this.cobPLC.SelectedValue != null && this.cobPLC.SelectedValue != DBNull.Value)
- {
- userEntity.PLCID = Convert.ToInt32(this.cobPLC.SelectedValue);
- }
- return userEntity;
- }
- /// <summary>
- /// 验证输入格式是否正确
- /// </summary>
- /// <returns></returns>
- private bool CheckInputValidity()
- {
- if (string.IsNullOrEmpty(this.txtUserCode.Text.Trim()))
- {
- this.txtUserCode.IsMustInput = true;
- this.txtUserCode.Focus();
- return false;
- }
- this.txtUserCode.IsMustInput = false;
- if (string.IsNullOrEmpty(this.txtUserName.Text.Trim()))
- {
- this.txtUserName.IsMustInput = true;
- this.txtUserName.Focus();
- return false;
- }
- this.txtUserName.IsMustInput = false;
- if (this.scbOrganization.SearchedPKMember == 0)
- {
- lblOrganization.IsMustInput = true;
- this.scbOrganization.Focus();
- return false;
- }
- lblOrganization.IsMustInput = false;
- return true;
- }
- /// <summary>
- /// 获取工种方法
- /// </summary>
- private void GetJobs()
- {
- try
- {
- //byte valueFlag = Convert.ToByte(false);
- //_dtJobs = SystemModuleProxy.Service.GetJobsData(valueFlag).Tables[0];
- //foreach(DataRow dr in _dtJobs.Rows)
- //{
- // dr["JobsCode"] = dr["JobsCode"].ToString() + "-" + dr["JobsName"].ToString();
- //}
- //this.JobsCode.DisplayMember = "JobsCode";
- //this.JobsCode.ValueMember = "JobsId";
- //this.JobsCode.DataSource = _dtJobs;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- }
- }
|