yangyin
2024-08-12 2bc7800e9f02fed6652f6b0defe1d978f186e914
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
using DevExpress.CodeParser;
 
namespace HStation.WinFrmUI.Organize
{
    public partial class LoginUserInfoCtrl : DevExpress.XtraEditors.XtraUserControl
    {
        public LoginUserInfoCtrl()
        {
            InitializeComponent();
        }
 
        Vmo.UserLoginAccount _LoginAccount;
        public HStation.Vmo.UserLoginAccount NewBindingData(HStation.Vmo.UserLoginAccount LoginAccount, out string error)//新建用户
        {
            error = "";
            if(LoginAccount == null)//新建一个用户 
            {
                _LoginAccount = new Vmo.UserLoginAccount();
            }
            else
            {
                error = "用户已经存在,不能再次创建!";
                return null;
            }
            IsNoValid(out error);
            if (!string.IsNullOrEmpty(error))
            {
                return null;
            }
            _LoginAccount.LoginName= TextEditLoginName.Text;
            _LoginAccount.PassWord = TextEditPassWord.Text;
            return _LoginAccount;
        }
        public bool ShowLoginName(HStation.Vmo.UserLoginAccount LoginAccount, out string error)//展示用户名
        {
            error = "";
            if (LoginAccount == null)//判断目前是否需要修改用户信息
            {
                error = "用户不存在,请选择新建用户!";
                return false;
            }
            TextEditLoginName.Text = LoginAccount.LoginName;//展示登录用户名
            return true;
        }
        //public HStation.Vmo.UserLoginAccount UpdateBindingData(HStation.Vmo.UserLoginAccount LoginAccount, out string error)//修改用户
        //{
        //    error = "";
        //    if(!ShowLoginName(LoginAccount, out error))//判断目前是否需要修改用户信息
        //    {
        //        error = "用户不存在,请选择新建用户!";
        //        return null; 
        //    }
        //    if(LoginAccount.LoginName == null || LoginAccount.PassWord ==null)//判断传入的值是否有误
        //    {
        //        error = "用户存在,但传入用户名或传入密码为空!";
        //        return null;
        //    }
        //    IsNoValid(out error);
        //    if (string.IsNullOrEmpty(error))
        //    {
        //        return null;
        //    }
        //    _LoginAccount.LoginName = TextEditLoginName.Text;
        //    _LoginAccount.PassWord = TextEditPassWord.Text;
        //    return _LoginAccount;
        //}
        public void IsNoValid(out string error)//判断控件必填项
        {
            error = "";
            dxValidationProviderLoginUser.Validate();
            
            
            if (String.IsNullOrEmpty(TextEditLoginName.Text))
            {
                error = "用户名信息为空!";
                return;
            }
            if (String.IsNullOrEmpty(TextEditPassWord.Text))
            {
                error = "密码为空!";
                return;
            }
            if (String.IsNullOrEmpty(TextEditValidPassWord.Text))
            {
                error = "确认密码为空!";
                return;
            }
            if (TextEditPassWord.Text != TextEditValidPassWord.Text)
            {
                error = "两次输入密码不一致!请重新输入!";
                return;
            }
        }
        
        public void SetNoInput()
        {
            TextEditLoginName.Enabled = false;
            TextEditPassWord.Enabled = false;
            TextEditValidPassWord.Enabled = false;
        }
        public void SetOffInput()
        {
            TextEditLoginName.Enabled = true;
            TextEditPassWord.Enabled = true;
            TextEditValidPassWord.Enabled = true;
        }
        
    }
}