private void Btn_update_Click(object sender, RoutedEventArgs e) { try { if (!validate()) { return; } if (_mysql == null) { _mysql = new MysqlClass(constring); } string query = "update qpaper set title = '" + title.Text + "', _desc = '" + _desc.Text + "', dept = '" + class_dept.Text + "' , sem = '" + sem.Text + "', url = '" + url_add.Text + "' where id = '" + id.Content + "'"; MessageBoxResult result = MessageBox.Show("Are you sure?, The Question paper record will be updated.", "Confirmation", MessageBoxButton.OKCancel, MessageBoxImage.Warning); if (result == MessageBoxResult.OK) { _mysql.Execute_query(query); MessageBox.Show("The Question paper Record has been updated successfully.", "St. Anne's Admin DashBoard", MessageBoxButton.OK, MessageBoxImage.Information); } else { } _mysql.CloseConnection(); _mysql = null; loadgrid(); btn_add.IsEnabled = true; clear(); } catch (Exception ex) { MessageBox.Show(ex.Message, "St. Anne's Admin DashBoard", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btn_add_Click(object sender, RoutedEventArgs e) { try { string pass = getpassword(); if (!validate()) { return; } if (IsAlreadyRegistered(reg_no.Text)) { MessageBox.Show("The Student record with " + reg_no.Text + " already Exists", "St. Anne's Admin DashBoard", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (_mysql == null) { _mysql = new MysqlClass(constring); } string query = "insert into std_register(name,reg_no,password,dept,sem,designation,ph_no,email,address,gender,dob) values ('" + std_name.Text + "','" + reg_no.Text + "','" + pass + "','" + class_dept.Text + "','" + sem.Text + "','student','" + ph_no.Text + "','" + email.Text + "','" + address.Text + "','" + gender.Text + "','" + dob.Text + "')"; _mysql.Execute_query(query); _mysql.CloseConnection(); _mysql = null; bool status = emailClass.SendEmail(email.Text, Username_emailId, "Application - Registration", "Dear " + std_name.Text + "," + message1 + "Username: "******" Password: "******"Student Detail added sucessfully", "St. Anne's Admin DashBoard", MessageBoxButton.OK, MessageBoxImage.Information); } else { if (_mysql == null) { _mysql = new MysqlClass(constring); } string delquery = "delete from std_register where reg_no = '" + reg_no.Text + "'"; _mysql.Execute_query(delquery); _mysql.CloseConnection(); _mysql = null; MessageBox.Show("Check your internet connection", "St. Anne's Admin DashBoard", MessageBoxButton.OK, MessageBoxImage.Error); } loadgrid(); clear(); } catch (Exception ex) { MessageBox.Show(ex.Message, "St. Anne's Admin DashBoard", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
public bool addTimeTable(string day, string time, string cls, string sem, string sub, string staffid) { try { if (_mysql == null) { _mysql = new MysqlClass(constring); } string query = "insert into timetable(day,time,course,sem,subject,staffid) values ('" + day + "','" + time + "','" + cls + "','" + sem + "','" + sub + "','" + staffid + "')"; _mysql.Execute_query(query); _mysql.CloseConnection(); _mysql = null; } catch (Exception ex) { MessageBox.Show(ex.Message, "St. Anne's Admin DashBoard", MessageBoxButton.OK, MessageBoxImage.Stop); return(false); } return(true); }
private bool change_pass(string query) { try { if (_mysql == null) { _mysql = new MysqlClass(constring); } _mysql.Execute_query(query); } catch (Exception ex) { MessageBox.Show(ex.Message, "St. Anne's Admin DashBoard", MessageBoxButton.OK, MessageBoxImage.Error); return(false); } return(true); }