public TOResponsable SelectResp(int id) { MySqlConnection con = null; TOResponsable i = new TOResponsable(); try { string sql = "select * from tbl_resp where resp_id = " + id + ";"; con = ConnectionFactory.Connection(); MySqlCommand cmd = new MySqlCommand(sql, con); con.Open(); MySqlDataReader dtreader = cmd.ExecuteReader(); if (dtreader.Read())//If there's any data. { i.Resp_birthDate = dtreader.GetString("resp_birthDate"); i.Resp_block = dtreader.GetString("resp_block"); i.Resp_cep = dtreader.GetString("resp_cep"); i.Resp_city = dtreader.GetString("resp_city"); i.Resp_cpf = dtreader.GetString("resp_cpf").ToString(); i.Resp_id = dtreader.GetInt16("resp_id"); i.Resp_name = dtreader.GetString("resp_name"); i.Resp_number = dtreader.GetString("resp_number"); i.Resp_obs = dtreader.GetString("resp_obs"); i.Resp_phone = dtreader.GetString("resp_phone"); i.Resp_rg = dtreader.GetString("resp_rg"); i.Resp_sex = dtreader.GetString("resp_sex"); i.Resp_state = dtreader.GetString("resp_state"); i.Resp_street = dtreader.GetString("resp_street"); i.Resp_whatsApp = dtreader.GetString("resp_whatsApp"); } else { } } catch (MySqlException e) { throw new Exception(e.Message); } finally { con.Close(); } return(i); }
public bool Registration(TOStudent student, TOResponsable resp) { bool i = false; TOClass _class = new TOClass(); try { if (resp != null) { string insert_resp = @"insert into tbl_resp(resp_name, resp_rg, resp_cpf, resp_birthDate, resp_sex, resp_phone, resp_whatsApp, resp_cep, resp_state, resp_city, resp_block, resp_street,resp_number, resp_obs) values('" + resp.Resp_name + "', '" + resp.Resp_rg + "', '" + resp.Resp_cpf + "', '" + resp.Resp_birthDate + "', '" + resp.Resp_sex + "', '" + resp.Resp_phone + "', '" + resp.Resp_whatsApp + "', '" + resp.Resp_cep + "', '" + resp.Resp_state + "', '" + resp.Resp_city + "', '" + resp.Resp_block + "', '" + resp.Resp_street + "', '" + resp.Resp_number + "', '" + resp.Resp_obs + "');"; con = ConnectionFactory.Connection(); MySqlCommand cmdInsertResp = new MySqlCommand(insert_resp, con); con.Open(); cmdInsertResp.ExecuteNonQuery(); con.Close(); string select_resp = "select resp_id from tbl_resp where resp_rg = '" + resp.Resp_rg + "';"; MySqlCommand cmdSelect = new MySqlCommand(select_resp, con); con.Open(); MySqlDataReader reader = cmdSelect.ExecuteReader(); if (reader.Read()) { resp.Resp_id = reader.GetInt16("resp_id"); } con.Close(); string sql = @"insert into tbl_student(student_name, student_ctr, student_status, student_subscriptionDate, student_rg, student_cpf, student_birthDate, student_sex, student_phone, student_whatsApp, student_cep, student_state, student_city, student_block, student_street, student_number, student_obs, class_id, resp_id) values('" + student.Student_name + "', '" + student.Student_ctr + "', 'Ativo', '" + student.Student_subscriptionDate + "', '" + student.Student_rg + "', '" + student.Student_cpf + "', '" + student.Student_birthDate + "', '" + student.Student_sex + "', '" + student.Student_phone + "', '" + student.Student_whatsApp + "', '" + student.Student_cep + "', '" + student.Student_state + "', '" + student.Student_city + "', '" + student.Student_block + "', '" + student.Student_street + "', '" + student.Student_number + "', '" + student.Student_obs + "', " + student.Class_id + ", " + resp.Resp_id + ");"; con = ConnectionFactory.Connection(); MySqlCommand cmd = new MySqlCommand(sql, con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); string select = "select * from tbl_student where student_ctr = '" + student.Student_ctr + "';"; con.Open(); MySqlCommand cmdSelectStudent = new MySqlCommand(select, con); MySqlDataReader dtReaderSelect = cmdSelectStudent.ExecuteReader(); if (dtReaderSelect.Read()) { i = true; int v = 0; string select_vacancys = "select class_vacancys from tbl_class where class_id = " + student.Class_id + ";"; MySqlConnection conSelect = ConnectionFactory.Connection(); conSelect.Open(); MySqlCommand cmdSelect_Vacancys = new MySqlCommand(select_vacancys, conSelect); MySqlDataReader dtReaderVacancys = cmdSelect_Vacancys.ExecuteReader(); if (dtReaderVacancys.Read()) { v = dtReaderVacancys.GetInt16("class_vacancys"); } conSelect.Close(); string update = "update tbl_class set class_vacancys = " + (v - 1) + " where class_id = " + student.Class_id + ";"; conSelect.Open(); MySqlCommand cmdUpdate = new MySqlCommand(update, conSelect); cmdUpdate.ExecuteNonQuery(); conSelect.Close(); } else { i = false; } } else { string sql = @"insert into tbl_student(student_name, student_ctr, student_status, student_subscriptionDate, student_rg, student_cpf, student_birthDate, student_sex, student_phone, student_whatsApp, student_cep, student_state, student_city, student_block, student_street, student_number, student_obs, class_id, resp_id) values('" + student.Student_name + "', '" + student.Student_ctr + "', 'Ativo', '" + student.Student_subscriptionDate + "', '" + student.Student_rg + "', '" + student.Student_cpf + "', '" + student.Student_birthDate + "', '" + student.Student_sex + "', '" + student.Student_phone + "', '" + student.Student_whatsApp + "', '" + student.Student_cep + "', '" + student.Student_state + "', '" + student.Student_city + "', '" + student.Student_block + "', '" + student.Student_street + "', '" + student.Student_number + "', '" + student.Student_obs + "', " + student.Class_id + ", null);"; con = ConnectionFactory.Connection(); MySqlCommand cmd = new MySqlCommand(sql, con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); string select = "select * from tbl_student where student_ctr = '" + student.Student_ctr + "';"; con.Open(); MySqlCommand cmdSelect = new MySqlCommand(select, con); MySqlDataReader dtReaderSelect = cmdSelect.ExecuteReader(); if (dtReaderSelect.Read()) { i = true; int v = 0; string select_vacancys = "select class_vacancys from tbl_class where class_id = " + student.Class_id + ";"; MySqlConnection conSelect = ConnectionFactory.Connection(); conSelect.Open(); MySqlCommand cmdSelect_Vacancys = new MySqlCommand(select_vacancys, conSelect); MySqlDataReader dtReaderVacancys = cmdSelect_Vacancys.ExecuteReader(); if (dtReaderVacancys.Read()) { v = dtReaderVacancys.GetInt16("class_vacancys"); } conSelect.Close(); string update = "update tbl_class set class_vacancys = " + (v - 1) + " where class_id = " + student.Class_id + ";"; conSelect.Open(); MySqlCommand cmdUpdate = new MySqlCommand(update, conSelect); cmdUpdate.ExecuteNonQuery(); conSelect.Close(); } else { i = false; } } } catch (MySqlException e) { throw new Exception(e.Message); } finally { con.Close(); } return(i); }
public REG_student(TOStudent student) { InitializeComponent(); op = 1; btnRegisterStudent.Content = "Editar"; _student = student; txtName.Text = _student.Student_name; txtRG.Text = _student.Student_rg; txtCPF.Text = _student.Student_cpf; if (_student.Student_birthDate != String.Empty) { birthDate.SelectedDate = DateTime.Parse(_student.Student_birthDate); } else { } txtPhone.Text = _student.Student_phone; txtWhatsApp.Text = _student.Student_whatsApp; txtCEP.Text = _student.Student_cep; txtState.Text = _student.Student_state; txtCity.Text = _student.Student_city; txtBlock.Text = _student.Student_block; txtNumber.Text = _student.Student_number; txtAdd.Text = _student.Student_obs; txtCtr.Text = _student.Student_ctr; txtStreet.Text = _student.Student_street; if (_student.Student_sex == "Feminino") { cbxSex.SelectedIndex = 0; } else if (_student.Student_sex == "Masculino") { cbxSex.SelectedIndex = 1; } DateTime _birth = DateTime.Parse(_student.Student_birthDate); int age = (int)Math.Floor((DateTime.Now - _birth).TotalDays / 365.25D); if (age >= 18) { _resp = null; } else { DAOStudents dao = new DAOStudents(); TOResponsable r = new TOResponsable(); r = dao.SelectResp(_student.Resp_id); _resp = r; txtName_resp.Text = r.Resp_name; txtRG_resp.Text = r.Resp_rg; txtCPF_resp.Text = r.Resp_cpf; if (r.Resp_birthDate != String.Empty) { birthDate_resp.SelectedDate = DateTime.Parse(r.Resp_birthDate); } else { } if (_resp.Resp_cep == _student.Student_cep && _resp.Resp_number == _student.Student_number || _resp.Resp_street == _student.Student_street && _resp.Resp_number == _student.Student_number) { checkBox_sameAdress.IsChecked = true; } else { checkBox_sameAdress.IsChecked = false; } txtPhone_resp.Text = r.Resp_phone; txtWhatsApp_resp.Text = r.Resp_whatsApp; txtCEP_resp.Text = r.Resp_cep; txtState_resp.Text = r.Resp_state; txtCity_resp.Text = r.Resp_city; txtBlock_resp.Text = r.Resp_block; txtNumber_resp.Text = r.Resp_number; txtAdd_resp.Text = r.Resp_obs; txtStreet_resp.Text = r.Resp_street; if (r.Resp_sex == "Feminino") { cbxSex_resp.SelectedIndex = 0; } else if (r.Resp_sex == "Masculino") { cbxSex_resp.SelectedIndex = 1; } } //loads the table. DAOClass _class = new DAOClass(); tblClass.CanUserAddRows = false; tblClass.IsReadOnly = true; tblClass.AutoGenerateColumns = false; List <TOClass> c = new List <TOClass>(); c = _class.LoadClass(_student.Class_id); foreach (TOClass _c in c) { if (_c.Type == "Hardware") { rdbtn_hard.IsChecked = true; } else if (_c.Type == "Informática") { rdbtn_info.IsChecked = true; } else if (_c.Type == "Inglês") { rdbtn_en.IsChecked = true; } else if (_c.Type == "Administração") { rdbtn_adm.IsChecked = true; } else if (_c.Type == "Interativo") { rdbtn_int.IsChecked = true; } else if (_c.Type == "Game") { rdbtn_game.IsChecked = true; } } tblClass.ItemsSource = _class.LoadClass(_student.Class_id); tabClass_Grid.IsEnabled = false; tabStudent_Grid.IsEnabled = false; tabParent_Grid.IsEnabled = false; txtCtr.IsEnabled = false; }
public bool Update(TOStudent student, TOResponsable resp) { bool i = false; TOClass _class = new TOClass(); try { if (resp != null) { string sql = @"update tbl_student set student_name = '" + student.Student_name + "', student_ctr = '" + student.Student_ctr + "', student_status = '" + student.Student_state + "', student_rg = '" + student.Student_rg + "', student_cpf = '" + student.Student_cpf + "', student_birthDate = '" + student.Student_birthDate + "', student_sex = '" + student.Student_sex + "', student_phone = '" + student.Student_phone + "', student_whatsApp = '" + student.Student_whatsApp + "', student_cep = '" + student.Student_cep + "', student_state = '" + student.Student_state + "', student_city = '" + student.Student_city + "', student_block = '" + student.Student_block + "', student_street = '" + student.Student_street + "', student_number = '" + student.Student_number + "', student_obs = '" + student.Student_obs + "', class_id = " + student.Class_id + ", resp_id = " + student.Resp_id + " where student_id = " + student.Student_id + ";"; con = ConnectionFactory.Connection(); MySqlCommand cmd = new MySqlCommand(sql, con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); string select = "select * from tbl_student where student_ctr = '" + student.Student_ctr + "';"; con.Open(); MySqlCommand cmdSelectStudent = new MySqlCommand(select, con); MySqlDataReader dtReaderSelect = cmdSelectStudent.ExecuteReader(); if (dtReaderSelect.Read()) { i = true; } else { i = false; } con.Close(); string update_resp = @"update tbl_resp set resp_name = '" + resp.Resp_name + "', resp_rg = '" + resp.Resp_rg + "', resp_cpf = '" + resp.Resp_cpf + "', resp_birthDate = '" + resp.Resp_birthDate + "', resp_sex = '" + resp.Resp_sex + "', resp_phone = '" + resp.Resp_phone + "', resp_whatsApp = '" + resp.Resp_whatsApp + "', resp_cep = '" + resp.Resp_cep + "', resp_state = '" + resp.Resp_state + "', resp_city = '" + resp.Resp_city + "', resp_block = '" + resp.Resp_block + "', resp_street = '" + resp.Resp_street + "', resp_number = '" + resp.Resp_number + "', resp_obs = '" + resp.Resp_obs + "' where resp_id = " + resp.Resp_id + ";"; con = ConnectionFactory.Connection(); MySqlCommand cmdUpdateResp = new MySqlCommand(update_resp, con); con.Open(); cmdUpdateResp.ExecuteNonQuery(); } else { string sql = @"update tbl_student set student_name = '" + student.Student_name + "', student_ctr = '" + student.Student_ctr + "', student_status = '" + student.Student_state + "', student_subscriptionDate = '" + student.Student_subscriptionDate + "', student_rg = '" + student.Student_rg + "', student_cpf = '" + student.Student_cpf + "', student_birthDate = '" + student.Student_birthDate + "', student_sex = '" + student.Student_sex + "', student_phone = '" + student.Student_phone + "', student_whatsApp = '" + student.Student_whatsApp + "', student_cep = '" + student.Student_cep + "', student_state = '" + student.Student_state + "', student_city = '" + student.Student_city + "', student_block = '" + student.Student_block + "', student_street = '" + student.Student_street + "', student_number = '" + student.Student_number + "', student_obs = '" + student.Student_obs + "', class_id = " + student.Class_id + ", resp_id = null where student_id = " + student.Resp_id + ";"; con = ConnectionFactory.Connection(); MySqlCommand cmd = new MySqlCommand(sql, con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); string select = "select * from tbl_student where student_ctr = '" + student.Student_ctr + "';"; con.Open(); MySqlCommand cmdSelect = new MySqlCommand(select, con); MySqlDataReader dtReaderSelect = cmdSelect.ExecuteReader(); if (dtReaderSelect.Read()) { i = true; } else { i = false; } } } catch (MySqlException e) { throw new Exception(e.Message); } finally { con.Close(); } return(i); }
private void btnRegisterStudent_Click(object sender, RoutedEventArgs e) { if (btnRegisterStudent.Content.ToString() == "Editar") { btnRegisterStudent.Content = "Atualizar"; tabClass_Grid.IsEnabled = true; tabStudent_Grid.IsEnabled = true; tabParent_Grid.IsEnabled = true; txtCtr.IsEnabled = true; } else { if (op == 0) { if (txtCtr.Text.ToString() == String.Empty || txtName.Text.ToString() == String.Empty || _student.Student_birthDate == String.Empty) { Xceed.Wpf.Toolkit.MessageBox.Show("Campos obrigatórios não podem estar vazios", "Aviso!", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK); } else if (_student.Class_id != 0) { _student.Student_name = txtName.Text; _student.Student_rg = txtRG.Text; _student.Student_cpf = txtCPF.Text; _student.Student_birthDate = birthDate.SelectedDate.ToString(); _student.Student_phone = txtPhone.Text; _student.Student_whatsApp = txtWhatsApp.Text; _student.Student_cep = txtCEP.Text; _student.Student_state = txtState.Text; _student.Student_city = txtCity.Text; _student.Student_block = txtBlock.Text; _student.Student_number = txtNumber.Text; _student.Student_obs = txtAdd.Text; _student.Student_ctr = txtCtr.Text; _student.Student_subscriptionDate = DateTime.Now.ToString(); if (checkBox_permission.IsChecked == false && txtName_resp.Text.ToString() == String.Empty || txtRG_resp.Text.ToString() == String.Empty) { Xceed.Wpf.Toolkit.MessageBox.Show("Os campos de nome e RG do responsável são obrigatórios.", "Aviso!", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK); tabParent.Focus(); } else if (checkBox_permission.IsChecked == true) { _resp = null; DAOStudents dao = new DAOStudents(); if (dao.CheckVacancys(_student.Class_id)) { if (dao.CheckCTR(_student.Student_ctr)) { if (dao.Registration(_student, _resp)) { Xceed.Wpf.Toolkit.MessageBox.Show("Aluno cadastrado com sucesso!", "Sucesso!", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK); this.Close(); } else { Xceed.Wpf.Toolkit.MessageBox.Show("Algo de errado aconteceu durante o cadastro.", "Erro!", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); } } else { Xceed.Wpf.Toolkit.MessageBox.Show("Já existe um aluno com este CTR.", "Erro!", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); } } else { Xceed.Wpf.Toolkit.MessageBox.Show("Não existem mais vagas nesta turma. Por favor, tente outra.", "Erro!", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); } } else { _student.Student_name = txtName.Text; _student.Student_rg = txtRG.Text; _student.Student_cpf = txtCPF.Text; _student.Student_birthDate = birthDate.SelectedDate.ToString(); _student.Student_phone = txtPhone.Text; _student.Student_whatsApp = txtWhatsApp.Text; _student.Student_cep = txtCEP.Text; _student.Student_state = txtState.Text; _student.Student_street = txtStreet.Text; _student.Student_city = txtCity.Text; _student.Student_block = txtBlock.Text; _student.Student_number = txtNumber.Text; _student.Student_obs = txtAdd.Text; _student.Student_ctr = txtCtr.Text; _resp.Resp_name = txtName_resp.Text; _resp.Resp_rg = txtRG_resp.Text; _resp.Resp_cpf = txtCPF_resp.Text; _resp.Resp_birthDate = birthDate_resp.SelectedDate.ToString(); _resp.Resp_phone = txtPhone_resp.Text; _resp.Resp_whatsApp = txtWhatsApp_resp.Text; _resp.Resp_cep = txtCEP_resp.Text; _resp.Resp_state = txtState_resp.Text; _resp.Resp_city = txtCity_resp.Text; _resp.Resp_street = txtStreet_resp.Text; _resp.Resp_block = txtBlock_resp.Text; _resp.Resp_number = txtNumber_resp.Text; _resp.Resp_obs = txtAdd_resp.Text; DAOStudents dao = new DAOStudents(); if (dao.CheckVacancys(_student.Class_id)) { if (dao.CheckCTR(_student.Student_ctr)) { if (dao.Registration(_student, _resp)) { Xceed.Wpf.Toolkit.MessageBox.Show("Aluno cadastrado com sucesso!", "Sucesso!", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK); this.Close(); } else { Xceed.Wpf.Toolkit.MessageBox.Show("Algo de errado aconteceu durante o cadastro.", "Erro!", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); } } else { Xceed.Wpf.Toolkit.MessageBox.Show("Já existe um aluno com este CTR.", "Erro!", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); } } else { Xceed.Wpf.Toolkit.MessageBox.Show("Não existem mais vagas nesta turma. Por favor, tente outra.", "Erro!", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); } } } else { Xceed.Wpf.Toolkit.MessageBox.Show("Por favor, selecione uma aula para o aluno.", "Aviso!", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK); tabClass.Focus(); } } else { if (txtCtr.Text.ToString() == String.Empty || txtName.Text.ToString() == String.Empty || _student.Student_birthDate == String.Empty) { Xceed.Wpf.Toolkit.MessageBox.Show("Campos obrigatórios não podem estar vazios", "Aviso!", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK); } else if (_student.Class_id != 0) { _student.Student_name = txtName.Text; _student.Student_rg = txtRG.Text; _student.Student_cpf = txtCPF.Text; _student.Student_birthDate = birthDate.SelectedDate.ToString(); _student.Student_phone = txtPhone.Text; _student.Student_whatsApp = txtWhatsApp.Text; _student.Student_cep = txtCEP.Text; _student.Student_state = txtState.Text; _student.Student_city = txtCity.Text; _student.Student_block = txtBlock.Text; _student.Student_number = txtNumber.Text; _student.Student_obs = txtAdd.Text; _student.Student_ctr = txtCtr.Text; if (checkBox_permission.IsChecked == false && txtName_resp.Text.ToString() == String.Empty || txtRG_resp.Text.ToString() == String.Empty) { Xceed.Wpf.Toolkit.MessageBox.Show("Os campos de nome e RG do responsável são obrigatórios.", "Aviso!", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK); tabParent.Focus(); } else if (checkBox_permission.IsChecked == true) { _resp = null; DAOStudents dao = new DAOStudents(); if (dao.CheckVacancys(_student.Class_id)) { if (dao.Update(_student, _resp)) { Xceed.Wpf.Toolkit.MessageBox.Show("Aluno atualizado com sucesso!", "Sucesso!", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK); this.Close(); } else { Xceed.Wpf.Toolkit.MessageBox.Show("Algo de errado aconteceu durante o cadastro.", "Erro!", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); } } else { Xceed.Wpf.Toolkit.MessageBox.Show("Não existem mais vagas nesta turma. Por favor, tente outra.", "Erro!", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); } } else { _student.Student_name = txtName.Text; _student.Student_rg = txtRG.Text; _student.Student_cpf = txtCPF.Text; _student.Student_birthDate = birthDate.SelectedDate.ToString(); _student.Student_phone = txtPhone.Text; _student.Student_whatsApp = txtWhatsApp.Text; _student.Student_cep = txtCEP.Text; _student.Student_state = txtState.Text; _student.Student_street = txtStreet.Text; _student.Student_city = txtCity.Text; _student.Student_block = txtBlock.Text; _student.Student_number = txtNumber.Text; _student.Student_obs = txtAdd.Text; _student.Student_ctr = txtCtr.Text; _student.Student_subscriptionDate = DateTime.Now.ToString(); _resp.Resp_name = txtName_resp.Text; _resp.Resp_rg = txtRG_resp.Text; _resp.Resp_cpf = txtCPF_resp.Text; _resp.Resp_birthDate = birthDate_resp.SelectedDate.ToString(); _resp.Resp_phone = txtPhone_resp.Text; _resp.Resp_whatsApp = txtWhatsApp_resp.Text; _resp.Resp_cep = txtCEP_resp.Text; _resp.Resp_state = txtState_resp.Text; _resp.Resp_city = txtCity_resp.Text; _resp.Resp_street = txtStreet_resp.Text; _resp.Resp_block = txtBlock_resp.Text; _resp.Resp_number = txtNumber_resp.Text; _resp.Resp_obs = txtAdd_resp.Text; DAOStudents dao = new DAOStudents(); if (dao.CheckVacancys(_student.Class_id)) { if (dao.Update(_student, _resp)) { Xceed.Wpf.Toolkit.MessageBox.Show("Aluno atualizado com sucesso!", "Sucesso!", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK); this.Close(); } else { Xceed.Wpf.Toolkit.MessageBox.Show("Algo de errado aconteceu durante o cadastro.", "Erro!", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); } } else { Xceed.Wpf.Toolkit.MessageBox.Show("Não existem mais vagas nesta turma. Por favor, tente outra.", "Erro!", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); } } } } } }