private void LoginButton_Click(object sender, EventArgs e) { //define local variables from the user inputs string user = nametxtbox.Text; string pass = pwdtxtbox.Text; //check if eligible to be logged in if (login.IsLoggedIn(user, pass)) { /* var Landingpage = (LandingPage.LandingPageForm)Tag; * Hide(); * Landingpage.Show();*/ try { var dateTimeToday = DateTime.Today.ToString("yyyy-MM-dd"); MySqlConnection conCal = DietTracker.DatabaseConnect.OpenDefaultDBConnection(); MySqlConnection conCCal = DietTracker.DatabaseConnect.OpenDefaultDBConnection(); MySqlCommand WhatIsCurrentCalorieCommand = new MySqlCommand(); WhatIsCurrentCalorieCommand.CommandText = "SELECT Calories FROM diettracker.day WHERE UserID = '" + user + "' AND Date = '" + dateTimeToday + "';"; WhatIsCurrentCalorieCommand.Connection = conCCal; conCCal.Open(); MySqlDataReader ReadCalories = WhatIsCurrentCalorieCommand.ExecuteReader(); if (ReadCalories.Read() == false) { int CaloriesRead = 0; MessageBox.Show("You are logged in successfully!"); MainPageForm mainPage = new MainPageForm(user, CaloriesRead); mainPage.Tag = this; Hide(); mainPage.Show(this); } else { int CaloriesRead = ReadCalories.GetInt32(0); conCCal.Close(); MessageBox.Show("You are logged in successfully!"); MainPageForm mainPage = new MainPageForm(user, CaloriesRead); mainPage.Tag = this; Hide(); mainPage.Show(this); } } catch { MessageBox.Show("Couldn't log in"); } } }
private void button1_Click(object sender, EventArgs e) { string user = textBox1.Text; string pass = textBox2.Text; if (login.IsLoggedIn(user, pass)) { MessageBox.Show("You are logged in successfully"); new Form2().Show(); this.Hide(); } else { MessageBox.Show("Login Error!"); } }
private void button1_Click(object sender, EventArgs e) { //define local variables from the user inputs string user = nametxtbox.Text; string pass = pwdtxtbox.Text; //check if eligible to be logged in if (login.IsLoggedIn(user, pass)) { MessageBox.Show("You are logged in successfully"); } else { //show default login error message MessageBox.Show("Login Error!"); } }