| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 | using CCWin;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;using WCS_Client.UC;using WCS_Client.Utility;namespace WCS_Client.From{    public partial class FormEditUser : CCSkinMain    {        DataRow _dr;        public FormEditUser(DataRow dr)        {            InitializeComponent();            _dr = dr;        }        private void RefreshUser()        {            try            {                txtUSER_NO.Text = _dr["USER_NO"].ToString();                txtUse_Name.Text = _dr["Use_Name"].ToString();                chbUse_IsStop.Checked = Convert.ToBoolean(_dr["Use_IsStop"]);                cboSex.SelectedValue = Convert.ToInt32(_dr["Use_Sex"]);                cboRole.SelectedValue = Convert.ToInt32(_dr["Use_RoleId"]);                txtUse_Email.Text = _dr["Use_Email"].ToString();                if (_dr["Use_ContactText"] != null)                    txtUse_ContactText.Text = _dr["Use_ContactText"].ToString();                if (_dr["Use_Address"] != null)                    txtUse_Address.Text = _dr["Use_Address"].ToString();                if (_dr["Use_Notes"] != null)                    txtUse_Notes.Text = _dr["Use_Notes"].ToString();            }            catch            {            }        }        //加载用户角色下拉列表        private void SelectUserRole()        {            try            {                DataTable dt = BaseWorkflow.QueryUse_Role();                if (dt == null || dt.Rows.Count == 0)                {                    cboRole.Items.Clear();                }                else                {                    cboRole.DisplayMember = "MEP_MAPPINGCHNAME";                    cboRole.ValueMember = "MEP_MAPPINGNO";                    cboRole.DataSource = dt;                    cboRole.SelectedIndex = 0;                }            }            catch (Exception ex)            {            }        }        //加载性别下拉列表        private void SelectSex()        {            try            {                DataTable dt = BaseWorkflow.QuerySex();                if (dt == null || dt.Rows.Count == 0)                {                    cboSex.Items.Clear();                }                else                {                    cboSex.DisplayMember = "MEP_MAPPINGCHNAME";                    cboSex.ValueMember = "MEP_MAPPINGNO";                    cboSex.DataSource = dt;                    cboSex.SelectedIndex = 0;                }            }            catch (Exception ex)            {            }        }        private void btnSave_Click(object sender, EventArgs e)        {            string loginname = txtUSER_NO.Text.Trim();            if (string.IsNullOrWhiteSpace(loginname))            {                MessageUtil.ShowError("请输入登录名!");                Clear();                return;            }            string username = txtUse_Name.Text.Trim();            if (string.IsNullOrWhiteSpace(username))            {                MessageUtil.ShowError("请输入用户名!");                return;            }            var user = new WCS_Users();            user.USER_NO = txtUSER_NO.Text.Trim();            user.Use_Name = txtUse_Name.Text.Trim();            user.Use_IsStop = chbUse_IsStop.Checked ? true : false;            user.Use_Sex = Convert.ToInt32(cboSex.SelectedValue);            user.Use_SexCh = cboSex.Text.ToString();            user.Use_RoleId = Convert.ToInt32(cboRole.SelectedValue);            user.Use_RoleName = cboRole.Text.ToString();            user.Use_Email = txtUse_Email.Text.Trim();            user.Use_ContactText = txtUse_ContactText.Text.Trim();            user.Use_Address = txtUse_Address.Text.Trim();            user.Use_Notes = txtUse_Notes.Text.Trim();            user.Use_EditUserNo = CurrentHelper.User.Use_AddUserNo;            user.Use_EditDateTime = DateTime.Now;            string result = BaseWorkflow.AddEditUser(user);            if (string.IsNullOrWhiteSpace(result))            {                MessageUtil.ShowTips("修改成功");                this.Close();            }            else            {                MessageUtil.ShowError(result);            }        }        private void Clear()        {            txtUSER_NO.Text = string.Empty;            txtUse_Name.Text = string.Empty;            txtUse_Email.Text = string.Empty;            txtUse_ContactText.Text = string.Empty;            txtUse_Address.Text = string.Empty;            txtUse_Notes.Text = string.Empty;        }        private void FormEditUser_Load(object sender, EventArgs e)        {            SelectUserRole();            SelectSex();            RefreshUser();        }        private void btn_Cancel_Click(object sender, EventArgs e)        {            this.Close();        }    }}
 |