schangxiang@126.com
2025-09-01 92fea996bf287e90c590cb30c0b1aac5969d0f17
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
using Sunny.UI;
using System;
using System.Diagnostics;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using WMS;
using WMS.EnumDefine;
 
namespace sunui.forms
{
    public partial class FLogin : UILoginForm
    {
        public static List<string> modules = new List<string>();
        public static bool userLogined = false;//用户已登录
        public static WMS.yunneiWCS.IyunneiWcfClient wcsWcf = new WMS.yunneiWCS.IyunneiWcfClient();
        public static User user = new User();
        public FLogin()
        {
            InitializeComponent();
        }
 
        private void FLogin_ButtonLoginClick(object sender, System.EventArgs e)
        {
            try
            {
                if (userLogined != true)
                {
                    //UserName就是封装了界面里用户名输入框的值
                    //Password就是封装了界面里密码输入框的值
                    if (UserName.Trim() == "")
                    {
                        ShowWarningTip("用户名不能为空");
                        return;
                    }
                    if (Password.Trim() == "")
                    {
                        ShowWarningTip("密码不能为空");
                        return;
                    }
                    string uname = UserName.Trim();
                    string upwd = Password.Trim();
                    string password = WZ.Useful.Commons.MD5Util.GetMD5_32(upwd);
                    var user_ = wcsWcf.login(uname, password);
                    if (user_.status == 200)
                    {
                        IsLogin = true;
                        user.id = user_.date[0].id;
                        user.UserName = user_.date[0].UserName;
                        user.WorkNo = user_.date[0].WorkNo;
                        user.roleId = user_.date[0].roleId;
                        user.Password = user_.date[0].Password;
                        modules = user_.dateList.ToList();
                        userLogined = true;
                        WMSFrmMain wms = new WMSFrmMain();
                        wms.WindowState = System.Windows.Forms.FormWindowState.Maximized;
                        wms.Show();
                        this.Hide();
 
                    }
                    else
                    {
                        ShowWarningTip(user_.msg + "- 警告");
                    }
                }
            }
            catch (Exception)
            {
                ShowWarningTip("执行异常" + "- 警告");
 
            }
        }
 
        private void FLogin_Load(object sender, System.EventArgs e)
        {
            #region 只允许单启动和绑定电脑
            SubText = DateTime.Now.ToLocalTime().ToString();//DateTime.Now.ToShortDateString() +
            Process current = Process.GetCurrentProcess();
            Process[] processes = Process.GetProcessesByName(current.ProcessName);
            foreach (Process process in processes)
            {
                if (process.Id != current.Id)
                {
                    if (process.MainModule.FileName == current.MainModule.FileName)
                    {
                        ShowErrorTip("不允许重复开启 - 错误");
                        Environment.Exit(0);
                        return;
                    }
                }
            }
 
            #endregion
        }
 
        private void FLogin_ButtonCancelClick(object sender, EventArgs e)
        {
            this.Close();
            Environment.Exit(0);
        }
 
        //  
        // ShowWarningTip("轻便消息提示框 - 警告");
        // ShowSuccessTip("轻便消息提示框 - 成功");
    }
}