private void btnDeleteStudent_Click(object sender, RoutedEventArgs e) { if (TableValues(0) != null) { MessageBoxResult result = Xceed.Wpf.Toolkit.MessageBox.Show("Você tem certeza de que gostaria de excluir este aluno?", "Aviso!", MessageBoxButton.YesNoCancel, MessageBoxImage.Information); if (result == MessageBoxResult.Yes) { DAOStudents dao = new DAOStudents(); if (dao.DeleteStudent(TableValues(0))) { Xceed.Wpf.Toolkit.MessageBox.Show("Aluno excluído com sucesso.", "Sucesso!", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK); } else { Xceed.Wpf.Toolkit.MessageBox.Show("Algo errado aconteceu durante a exclusão.", "Erro!", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); } } else { //Do nothing. } } else { } LoadScreen(); }
public void LoadTable(int id) { DAOStudents dao = new DAOStudents(); //loads the table. tblStudents.CanUserAddRows = false; tblStudents.IsReadOnly = true; tblStudents.AutoGenerateColumns = false; tblStudents.ItemsSource = dao.LoadStudents(id); lblCount.Content = tblStudents.Items.Count; if (_class.Class_vacancys == 0) { tblStudents.ItemsSource = null; lblCount_Vacancy.Content = "0"; lblCount.Content = "10"; lblNoVancacys.Visibility = Visibility.Visible; } else { int i = tblStudents.Items.Count; lblCount_Vacancy.Content = _class.Class_vacancys; lblNoVancacys.Visibility = Visibility.Hidden; } }
public void LoadScreen() { DAOStudents dao = new DAOStudents(); //loads the table. tblStudents.CanUserAddRows = false; tblStudents.IsReadOnly = true; tblStudents.AutoGenerateColumns = false; tblStudents.ItemsSource = dao.LoadStudents(); lblCount.Content = tblStudents.Items.Count; }
private void btnEditStudent_Click(object sender, RoutedEventArgs e) { if (TableValues(0) != null) { DAOStudents dao = new DAOStudents(); TOStudent i = new TOStudent(); i = dao.Selection(TableValues(0)); REG_student reg_s = new REG_student(i); reg_s.ShowDialog(); LoadScreen(); } }
private void tblStudents_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (TableValues(0) != null) { DAOStudents dao = new DAOStudents(); TOStudent i = new TOStudent(); i = dao.Selection(TableValues(0)); REG_student reg_s = new REG_student(i); reg_s.ShowDialog(); LoadScreen(); } }
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; }
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); } } } } } }