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 modules = new List(); 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("轻便消息提示框 - 成功"); } }