schangxiang@126.com
2025-09-04 b4add98f10dc26f24c6fd0765ebf4806bb6d3dda
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
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<int, string> roleList = new Dictionary<int, string>();//键值集合
        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<string> roles = new List<string>();
                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());
            }
 
        }
    }
 
}