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 WZ.Useful.Commons; using WMS.EnumDefine; using sunui.forms; namespace WMS.UI.Basic { public partial class AddUser : Form { protected Dictionary roleList = new Dictionary();//键值集合 int userOperation = 0; public AddUser(string workno, string username, string rolename) { InitializeComponent(); tBUserWorkNo.Text = workno; tBName.Text = username; tBPassWord.Text = ""; cmbRolea.Text = rolename; //cmbRolea userOperation = workno.Trim() == "" ? 1 : 3; if (userOperation==3) { tBUserWorkNo.Enabled = false; } } private void btnClose_Click(object sender, EventArgs e) { this.Close(); } private void AddUser_Load(object sender, EventArgs e) { try { List roles = new List(); yunneiWCS.paging papg = new yunneiWCS.paging(); papg.pagenum = 1; papg.pagesize = 10000; WMS.yunneiWCS.resMsgOfroleFj0h9u9J roleRes = FLogin.wcsWcf.findRole(papg, ""); if (roleRes.status == 200) { if (roleRes.date.Length > 0) { foreach (var item in roleRes.date) { roleList.Add(item.id, item.roleName); roles.Add(item.roleName); } cmbRolea.DataSource = roles; } } } catch (Exception ex) { WZ.Useful.Commons.LogTextHelper.WriteLine("AddUser", "AddUser_Load", ex.ToString()); } } private void btnSave_Click(object sender, EventArgs e) { try { string creator = FLogin.user.UserName; int id = roleList.FirstOrDefault(x => x.Value == cmbRolea.SelectedValue).Key; WMS.yunneiWCS.user data = new WMS.yunneiWCS.user { WorkNo = tBUserWorkNo.Text.Trim(), UserName = tBName.Text.Trim(), Password = tBPassWord.Text.Trim(), roleId = id }; WMS.yunneiWCS.resMsgOfstring res = FLogin.wcsWcf.addUser(data, creator, userOperation); if (res.status != 200) { WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(2, res.msg); ms.Show(); } else { if (userOperation == 1) { WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(1, "创建成功"); ms.Show(); this.Close(); } else { WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(1, "修改成功"); ms.Show(); this.Close(); } } } catch (Exception ex) { WZ.Useful.Commons.LogTextHelper.WriteLine("AddUser", "btnSave_Click", ex.ToString()); } } } }