private void Login()
        {
            if (this.cmbName.Text.Trim() == "")
            {
                txtMsg.Text = "*用户名不能为空!";
                return;
            }

            if (_password.Password.Trim() == "")
            {
                txtMsg.Text = "*密码不能为空!";
                return;
            }

            try
            {
                IDBOperation dbOperation = new DBOperation_MySQL();
                try
                {
                    MD5      md5      = new MD5CryptoServiceProvider();
                    string   password = BitConverter.ToString(md5.ComputeHash(Encoding.Default.GetBytes(this._password.Password))).Replace("-", "");
                    UserInfo userInfo = dbOperation.GetMenu(this.cmbName.Text, password);
                    //if (userInfo.Menus.Count > 0)
                    if (userInfo.ID != "" && userInfo.ID != null)
                    {
                        UserLoginInfo userLoginInfo = new UserLoginInfo()
                        {
                            UserName = this.cmbName.Text, Password = _password.Password, LastLoginTime = DateTime.Now
                        };

                        if (list == null)
                        {
                            list = new List <UserLoginInfo>();
                        }
                        var query = from item in list where item.UserName == userLoginInfo.UserName select item;

                        if (query.Count() > 0)
                        {
                            foreach (UserLoginInfo item in list)
                            {
                                if (item.UserName == userLoginInfo.UserName)
                                {
                                    item.Password      = userLoginInfo.Password;
                                    item.LastLoginTime = userLoginInfo.LastLoginTime;
                                }
                            }
                        }
                        else
                        {
                            if (_rememberPassword.IsChecked == true)
                            {
                                list.Add(userLoginInfo);
                            }
                        }

                        try
                        {
                            //将用户列表写入文件
                            Common.SerializerTool.SerializeToFile(list, rememberPasswordPath);
                        }
                        catch (Exception e)
                        {
                            txtMsg.Text = "请以管理员身份运行软件!";
                            return;
                        }

                        Application.Current.Resources.Add("User", userInfo);

                        string current_version = ConfigurationManager.AppSettings["version"];

                        string new_version = dbOperation.GetDbHelper().GetSingle("select version from t_version where id = (select max(id) from t_version)").ToString();

                        if (Convert.ToDouble(new_version == "" ? "0" : new_version) > Convert.ToDouble(current_version))
                        {
                            if (Toolkit.MessageBox.Show("当前有新版本,是否升级?", "系统询问", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                            {
                                //this.Close();
                                //Process openupdatedexe = new Process();
                                //openupdatedexe.StartInfo.FileName = "AutoUpdate.exe";
                                //openupdatedexe.Start();
                                ProcessStartInfo info = new ProcessStartInfo("AutoUpdate.exe", new_version);
                                Process.Start(info);
                            }
                            else
                            {
                                MainWindow mainWindow = new MainWindow(dbOperation);
                                mainWindow.Show();
                                Common.SysLogEntry.WriteLog("", this.cmbName.Text, Common.OperationType.Login, "登录系统");
                                this.Close();
                            }
                        }
                        else
                        {
                            MainWindow mainWindow = new MainWindow(dbOperation);
                            mainWindow.Show();
                            Common.SysLogEntry.WriteLog("", this.cmbName.Text, Common.OperationType.Login, "登录系统");
                            this.Close();
                        }
                    }
                    else
                    {
                        txtMsg.Text = "用户名或密码错误,请确认!";
                        return;
                    }
                }
                catch (Exception e)
                {
                    txtMsg.Text = "数据库处理失败!";
                    writeLog(e.Message);
                    return;
                }
            }
            catch (Exception ex)
            {
                txtMsg.Text = "数据库连接失败!";
                writeLog(ex.Message);
                return;
            }
        }
        private void Login()
        {
            if (this.cmbName.Text.Trim() == "")
            {
                txtMsg.Text = "*用户名不能为空!";
                return;
            }

            if (_password.Password.Trim() == "")
            {
                txtMsg.Text = "*密码不能为空!";
                return;
            }

            try
            {
                IDBOperation dbOperation = new DBOperation_MySQL();
                try
                {
                    MD5      md5      = new MD5CryptoServiceProvider();
                    string   password = BitConverter.ToString(md5.ComputeHash(Encoding.Default.GetBytes(this._password.Password))).Replace("-", "");
                    UserInfo userInfo = dbOperation.GetMenu(this.cmbName.Text, password);
                    if (userInfo.Menus.Count > 0)
                    {
                        UserLoginInfo userLoginInfo = new UserLoginInfo()
                        {
                            UserName = this.cmbName.Text, Password = _password.Password, LastLoginTime = DateTime.Now
                        };

                        if (list == null)
                        {
                            list = new List <UserLoginInfo>();
                        }
                        var query = from item in list where item.UserName == userLoginInfo.UserName select item;

                        if (query.Count() > 0)
                        {
                            foreach (UserLoginInfo item in list)
                            {
                                if (item.UserName == userLoginInfo.UserName)
                                {
                                    item.Password      = userLoginInfo.Password;
                                    item.LastLoginTime = userLoginInfo.LastLoginTime;
                                }
                            }
                        }
                        else
                        {
                            if (_rememberPassword.IsChecked == true)
                            {
                                list.Add(userLoginInfo);
                            }
                        }

                        //将用户列表写入文件
                        Common.SerializerTool.SerializeToFile(list, rememberPasswordPath);
                        Application.Current.Resources.Add("User", userInfo);
                        //if (_style.IsChecked == true)
                        //{
                        //    MainWindowTradition mainWindowTradition = new MainWindowTradition(dbOperation);
                        //    mainWindowTradition.Show();
                        //}
                        //else
                        //{
                        MainWindow mainWindow = new MainWindow(dbOperation);
                        mainWindow.Show();

                        //}
                        Common.SysLogEntry.WriteLog("", this.cmbName.Text, Common.OperationType.Login, "登录系统");

                        this.Close();
                    }
                    else
                    {
                        txtMsg.Text = "登录失败!请重试!";
                        return;
                    }
                }
                catch (Exception e)
                {
                    txtMsg.Text = "数据库处理失败!";
                    return;
                }
            }
            catch (Exception ex)
            {
                txtMsg.Text = ex.Message;
                return;
            }
        }