private void btnRegistrarDocente_Click(object sender, EventArgs e) { try { // Verifica si la validacion pasa if (this.ValidateUpdate()) { // Asignar valores al modelo DocenteModel docenteModel = new DocenteModel() { DNI = Convert.ToInt64(txtDNI.Text.ToString().Trim()), apellidoMaterno = txtApellidoMaterno.Text.Trim(), apellidoPaterno = txtApellidoPaterno.Text.Trim(), Nombres = txtNombres.Text.Trim(), }; // LLama al metodo de servicio y lo asigna a una variable de retorno var successDocente = this.docenteService.RegisterDocente(docenteModel); // Si es verdadero , muestra el mensaje de registro satisfactorio, sino uno de error if (successDocente) { // Muestra el mensaje de registro satisfactoriodisplay the message box MessageBox.Show( Resources.Registration_Satisfactorio_Mensaje, Resources.Registration_Satisfactorio_Mensaje_Titulo, MessageBoxButtons.OK, MessageBoxIcon.Information); // Resetea los controles de docentes ControlUtilities.ResetAllControls(groupBoxInfoDocente); } else { // Muestra mensaje de error MessageBox.Show( Resources.Registration_Error_Mensaje, Resources.Registration_Error_Mensaje_Titulo, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { // Muestra mensaje de validacion fallida MessageBox.Show( this.errorMessage, Resources.Registration_Error_Mensaje_Titulo, MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { this.ShowErrorMessage(ex); } }
private void btnActualizarDocente_Click(object sender, EventArgs e) { try { // Valida para que se actualicen los datos if (this.ValidateUpdate()) { // Asigna los valores a el modelo Docente DocenteModel docenteModel = new DocenteModel() { DNI = Convert.ToInt64(txtDNI.Text.ToString().Trim()), apellidoMaterno = txtApellidoMaterno.Text.Trim(), apellidoPaterno = txtApellidoPaterno.Text.Trim(), Nombres = txtNombres.Text.Trim(), }; // LLama al metodo de servicio y lo asigna a una variable de retorno var flag = this.docenteService.UpdateDocente(docenteModel); if (flag) { // Carga otra vez todo el datagridview despues de eliminar DataTable data = this.docenteService.GetAllDocentes(); this.LoadDataGridViewDocentes(data); // Muestra mensaje de modificacion correcta MessageBox.Show( Resources.Update_Satisfactorio_Mensaje, Resources.Update_Satisfactorio_Mensaje_Titulo, MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { // Muestra mensaje de error de registro MessageBox.Show( this.errorMessage, Resources.Registration_Error_Mensaje_Titulo, MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { this.ShowErrorMessage(ex); } }
public IActionResult AggiungiDocente(DocenteModel docente) { if (ModelState.IsValid) { try { repository.AggiungiDocente(docente.UnDocente, docente.RegistraMaterie()); return(RedirectToAction("Completo")); } catch (Exception) { return(RedirectToAction("Incompleto")); } } return(View(docente)); }
public bool UpdateDocente(DocenteModel docente) { using (SqlConnection openConnection = new SqlConnection(this.ConnectionString)) { using (SqlCommand sqlcommand = new SqlCommand()) { sqlcommand.CommandType = CommandType.Text; sqlcommand.CommandText = Scripts.sqlUpdateDocente; sqlcommand.Connection = openConnection; sqlcommand.Parameters.AddWithValue("@DNI", (Int64)docente.DNI); sqlcommand.Parameters.AddWithValue("@Nombres", docente.Nombres); sqlcommand.Parameters.AddWithValue("@ApellidoPaterno", docente.apellidoPaterno); sqlcommand.Parameters.AddWithValue("@ApellidoMaterno", docente.apellidoMaterno); sqlcommand.Connection.Open(); var rowsAffected = sqlcommand.ExecuteNonQuery(); sqlcommand.Connection.Close(); return(rowsAffected > 0); } } }
public bool UpdateDocente(DocenteModel docente) { return(this.docenteAccess.UpdateDocente(docente)); }
public bool RegisterDocente(DocenteModel docente) { return(this.docenteAccess.AddDocente(docente)); }
private void listarDocentes() { DocenteModel docenteModel = new DocenteModel(); this.dgv_Docentes.DataSource = docenteModel.listarDocentes(); }