void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.main = ((FireWall.DataBaseSettingWindow)(target)); return; case 2: this.Tip = ((System.Windows.Controls.Grid)(target)); return; case 3: this.Yes = ((System.Windows.Controls.Button)(target)); #line 14 "..\..\..\Window\DataBaseSettingWindow.xaml" this.Yes.Click += new System.Windows.RoutedEventHandler(this.Yes_Click); #line default #line hidden return; case 4: this.DatabaseSettingGrid = ((System.Windows.Controls.Grid)(target)); return; case 5: this.DataBaseBox = ((System.Windows.Controls.TextBox)(target)); return; case 6: this.DataSourceBox = ((System.Windows.Controls.TextBox)(target)); return; case 7: this.UserIDBox = ((System.Windows.Controls.TextBox)(target)); return; case 8: this.PassWordBox = ((System.Windows.Controls.TextBox)(target)); return; case 9: this.ClearButton = ((System.Windows.Controls.Button)(target)); #line 26 "..\..\..\Window\DataBaseSettingWindow.xaml" this.ClearButton.Click += new System.Windows.RoutedEventHandler(this.ClearButton_Click); #line default #line hidden return; case 10: this.SaveButton = ((System.Windows.Controls.Button)(target)); #line 27 "..\..\..\Window\DataBaseSettingWindow.xaml" this.SaveButton.Click += new System.Windows.RoutedEventHandler(this.SaveButton_Click); #line default #line hidden return; } this._contentLoaded = true; }
/*---------------------------------------------------------------- * //函数说明:登录按键// * //输入:无// * //输出:无// * //----------------------------------------------------------------*/ private void loginbutton_Click(object sender, RoutedEventArgs e) { WriteUserLog(); userBox.IsEnabled = false; passwordBox.IsEnabled = false; if ((userBox.Text == "") || (passwordBox.Password == "")) { userBox.IsEnabled = true; passwordBox.IsEnabled = true; //MessageBox.Show("用户名密码不能为空!"); UserMessageBox.Show("提示", "用户名和密码不能为空!"); } else { bool loginflag = false; if (StaticGlobal.firstloginflag == true) { if ((userBox.Text == "admin") && (passwordBox.Password == "admin")) { loginflag = true; StaticGlobal.UserName = "******"; StaticGlobal.UserID = 0; StaticGlobal.UserRole = "SUPER"; } else { userBox.IsEnabled = true; passwordBox.IsEnabled = true; //MessageBox.Show("用户名密码错误!"); UserMessageBox.Show("提示", "用户名或密码错误!"); passwordBox.Clear(); loginflag = false; } } else { string CommandText = "select * from useraccount where UserName = '******'and Password = '******'"; DataSet result = new DataSet(); try { MySqlConnection conn = new MySqlConnection(StaticGlobal.ConnectionString); conn.Open(); MySqlDataAdapter s = new MySqlDataAdapter(CommandText, conn); s.Fill(result); conn.Close(); if (result.Tables[0].Rows.Count == 0) { userBox.IsEnabled = true; passwordBox.IsEnabled = true; //MessageBox.Show("用户名密码错误!"); UserMessageBox.Show("提示", "用户名或密码错误!"); passwordBox.Clear(); loginflag = false; } else { StaticGlobal.UserName = userBox.Text; StaticGlobal.UserID = Convert.ToInt16(result.Tables[0].Rows[0][0]); StaticGlobal.UserRole = result.Tables[0].Rows[0][3].ToString(); loginflag = true; } } catch (Exception) { userBox.IsEnabled = true; passwordBox.IsEnabled = true; //MessageBox.Show("数据库未连接"); UserMessageBox.Show("提示", "数据库未连接!"); } } if (loginflag == true) { LoginSuccess.Visibility = Visibility.Visible; LoginGrid.Visibility = Visibility.Collapsed; Welcome.Content = userBox.Text; t = new Thread(new ThreadStart(() => { Thread.Sleep(100); this.Dispatcher.BeginInvoke(new Action(() => { Log.addlog(StaticGlobal.UserID, "用户登录", 0); StaticGlobal.LoginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); if (StaticGlobal.UserRole == "SUPER") { UserMessageBox.Show("提示", "您当前身份为:超级用户!"); } else if (StaticGlobal.UserRole == "OPER") { UserMessageBox.Show("提示", "您当前身份为:操作员!"); } else { UserMessageBox.Show("提示", "您当前身份为:游客!"); } if (StaticGlobal.firstloginflag == true) { DataBaseSettingWindow dbsettingwindow = new DataBaseSettingWindow(); dbsettingwindow.Show(); } MainWindow mainwindow = new MainWindow(); mainwindow.Show(); this.Close(); })); t.Abort(); })); t.Start(); } } }