private void login_Click(object sender, RoutedEventArgs e) { Connector db = new Connector(); if (db.login(id.Text, password.Password)) { AttendanceVM.setSpecificFaculty(CurrentUser.user.id); LoadsVM.setLoads(CurrentUser.user.id); CurrentUser.user = FacultyVM.getFaculty(CurrentUser.user.id); new MainWindow().Show(); Close(); } }
private void btnSave_Click(object sender, RoutedEventArgs e) { string query = String.Format("update faculty set name = '{0}', undergrad = '{1}', " + "undergradYear = '{2}', postgrad = '{3}', postgradYear = '{4}', expectedDate = '{5}' " + "where id = {6};", name.Text, undergrad.Text, yearUnder.Text, postgrad.Text, yearPost.Text, yearExpected.Text, CurrentUser.user.id); Connector db = new Connector(); if (db.addData(query) != -1) { FacultyVM.getFaculty(CurrentUser.user.id).name = name.Text; FacultyVM.getFaculty(CurrentUser.user.id).undergrad = undergrad.Text; FacultyVM.getFaculty(CurrentUser.user.id).undergradYear = yearUnder.Text; FacultyVM.getFaculty(CurrentUser.user.id).postgrad = postgrad.Text; FacultyVM.getFaculty(CurrentUser.user.id).postgradYear = yearPost.Text; FacultyVM.getFaculty(CurrentUser.user.id).postgradExpectedYear = yearExpected.Text; } }
public bool login(string name, string pass) { string query = String.Format("select id, password from faculty where " + "id like '{0}' and password like '{1}';", name, pass); Console.WriteLine(query); openConnection(); MySqlCommand cmd = new MySqlCommand(query, dbConnect); using (MySqlDataReader read = cmd.ExecuteReader()) { while (read.Read()) { if (read.GetString(0) != null && read.GetString(1) != null) { CurrentUser.user = FacultyVM.getFaculty(read.GetInt32(0)); closeConnection(); return(true); } } } closeConnection(); return(false); }