//private void Button_Click(object sender, RoutedEventArgs e) //{ // //if (string.IsNullOrEmpty(StudName.Text.Trim()) || string.IsNullOrEmpty(StudID.Text.Trim()) || string.IsNullOrEmpty(StudPassword.Text.Trim()) || StudYear.SelectedIndex == -1) // //{ // // MessageBox.Show("Please Enter Missing Data"); // //} // //else if (WelcomePage.ThereIsNoDelimiter(StudName.Text.Trim()) == false || WelcomePage.ThereIsNoDelimiter(StudID.Text.Trim()) == false || WelcomePage.ThereIsNoDelimiter(StudPassword.Text.Trim()) == false) // //{ // // MessageBox.Show("Please Don't Use special characters: (% , # , *) "); // //} // //else if (WelcomePage.IsNotAlphabet(StudName.Text.Trim()) == true) // //{ // // MessageBox.Show("Please Enter Correct Name"); // //} // //else if(WelcomePage.NoSpace(StudPassword.Text.Trim())==false || WelcomePage.NoSpace(StudID.Text.Trim())==false) // //{ // // MessageBox.Show("ID and Password Must Not Contain Spaces"); // //} // //else // //{ // // string name = StudName.Text.Trim(); // // string id = StudID.Text.Trim(); // // string pass = StudPassword.Text.Trim(); // // string year = StudYear.SelectedItem.ToString(); // // Student s = new Student(id, name, pass, year); // // if (WelcomePage.AllStudentsDictionary.ContainsKey(id)) // // { // // MessageBox.Show("this ID already exist"); // // } // // else // // { // // WelcomePage.AllStudentsDictionary[id]=s; // // MessageBox.Show("Student Added"); // // StudName.Clear(); // // StudID.Clear(); // // StudPassword.Clear(); // // StudYear.SelectedIndex = -1; // // /* if(StudYear.SelectedValue.ToString()!= "1st year") // // { // // FinishedCourses.Visibility = Visibility.Visible; // // } // // */ // // CheckBox.Visibility = Visibility.Visible; // // } // //} //} private void Image_MouseUp(object sender, MouseButtonEventArgs e) { if (string.IsNullOrEmpty(StudName.Text.Trim()) || string.IsNullOrEmpty(StudID.Text.Trim()) || string.IsNullOrEmpty(StudPassword.Text.Trim()) || StudYear.SelectedIndex == -1) { MessageBox.Show("Please enter the missing data."); } else if (WelcomePage.ThereIsNoDelimiter(StudName.Text.Trim()) == false || WelcomePage.ThereIsNoDelimiter(StudID.Text.Trim()) == false || WelcomePage.ThereIsNoDelimiter(StudPassword.Text.Trim()) == false) { MessageBox.Show("Please don't use special characters: (% , # , *) "); } else if (WelcomePage.IsNotAlphabet(StudName.Text.Trim()) == true) { MessageBox.Show("Please enter a correct name."); } else if (WelcomePage.NoSpace(StudPassword.Text.Trim()) == false || WelcomePage.NoSpace(StudID.Text.Trim()) == false) { MessageBox.Show("ID and password must not contain spaces."); } else { string name = StudName.Text.Trim(); string id = StudID.Text.Trim(); string pass = StudPassword.Text.Trim(); string year = StudYear.SelectedItem.ToString(); Student s = new Student(id, name, pass, year); if (WelcomePage.AllStudentsDictionary.ContainsKey(id)) { MessageBox.Show("This ID already exists."); } else { WelcomePage.AllStudentsDictionary[id] = s; MessageBox.Show("Student had been added."); StudName.Clear(); StudID.Clear(); StudPassword.Clear(); StudYear.SelectedIndex = -1; } } }
private void SLLoginButton(object sender, EventArgs e) { //Do Validation if (StudID.Text == "") { MessageBox.Show("You have not entered Username"); StudID.Focus(); } else if (StudPass.Text == "") { MessageBox.Show("You have not entered Password"); StudPass.Focus(); } else { try { //Opening Connection ServerInfo.MySQLConnect.Open(); //Creating objects MySqlCommand MySQLCommand = new MySqlCommand(); //Connecting the Command MySQLCommand.Connection = ServerInfo.MySQLConnect; //Passing MySQL Statement MySQLCommand.CommandText = "Select count(*) from UserMaster Where UserName = '******' " + "and UserPassword = '******' "; MySQLCommand.ExecuteNonQuery(); MySqlDataAdapter MySQLDataAdapt = new MySqlDataAdapter(MySQLCommand); //Creating a new Data Table DataTable DatTable = new DataTable(); MySQLDataAdapt.Fill(DatTable); int i = Convert.ToInt32(DatTable.Rows.Count.ToString()); if (i == 0) { MessageBox.Show("Wrong Input"); } else { this.Hide(); _3___DataEntry.DataEntry_Activities dataEntry_Act = new _3___DataEntry.DataEntry_Activities(); dataEntry_Act.Show(); } // MessageBox.Show("Successful Connection"); } catch { MessageBox.Show("Failed to Connect"); } finally { ServerInfo.MySQLConnect.Close(); } } }