private void Home_Click(object sender, RoutedEventArgs e) { Application app = App.Current; IS3MainWindow mw = app.MainWindow as IS3MainWindow; mw.SwitchToProjectListPage(); }
//登陆验证 private void LoginButton_Click(object sender, RoutedEventArgs e) { XDocument xml = XDocument.Load(Runtime.configurationPath); if ((LoginNameTB.Text == "") || (LoginPasswordTB.Password == "")) { MessageBox.Show("账号或密码不为空"); return; } if ((LoginNameTB.Text != xml.Root.Element("user").Value) || (LoginPasswordTB.Password != xml.Root.Element("password").Value)) { MessageBox.Show("账号或密码错误"); return; } App app = Application.Current as App; IS3MainWindow mw = (IS3MainWindow)app.MainWindow; mw.SwitchToProjectListPage(); }
//登陆验证 private void LoginButton_Click(object sender, RoutedEventArgs e) { ServiceImporter.UpdateMainConnect(Runtime.configurationPath); XDocument xml = XDocument.Load(Runtime.configurationPath); string key = "Data Source =" + xml.Root.Element("ipaddress")?.Value + "; Initial Catalog = " + xml.Root.Element("database")?.Value + "; User Id = " + xml.Root.Element("user")?.Value + "; Password = "******"password")?.Value + ";Connect Timeout=1"; SqlConnection sqlConnection = new SqlConnection(key); try { sqlConnection.QuickOpen(1000); } catch (Exception) { MessageBox.Show("连接超时"); sqlConnection.Close(); sqlConnection.Dispose(); return; } sqlConnection.Close(); if ((LoginNameTB.Text == "") || (LoginPasswordTB.Password == "")) { MessageBox.Show("账号或密码不为空"); return; } Globals.userID = Globals.iS3Service.PrivilegeService.CheckIfValidLoginInfo(LoginNameTB.Text, LoginPasswordTB.Password); if (Globals.userID > 0) { App app = Application.Current as App; IS3MainWindow mw = (IS3MainWindow)app.MainWindow; mw.SwitchToProjectListPage(); } else { MessageBox.Show("密码错误"); } }