private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (dgvEmpleadoProfesor.Rows[e.RowIndex].Cells[e.ColumnIndex].FormattedValue.Equals("Asignar Categoría")) { if (MyMessageBox.Show("¿Seguro que desea Asignar la Categoría " + MiCategoria.Nombre + " al Empleado " + ((ModelEmpleadoPersona)dgvEmpleadoProfesor.CurrentRow.DataBoundItem).Apellido + ", " + ((ModelEmpleadoPersona)dgvEmpleadoProfesor.CurrentRow.DataBoundItem).Nombre + "?", "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.OK) { ControladorCategoria CCategoria = new ControladorCategoria(); var resultado = CCategoria.AsignarEmpleadoAlCategoria(((ModelEmpleadoPersona)dgvEmpleadoProfesor.CurrentRow.DataBoundItem).MiEmpleado, MiCategoria); if (resultado > 0) { Padre.ModificarMensaje("Se ha asignado un Profesor a la Categoría"); Dispose(); } else if (resultado == -2) { MyMessageBox.Show(this, "Ya esta asignado el Profesor a la Categoría", "Categoria"); } } } else if (dgvEmpleadoProfesor.Rows[e.RowIndex].Cells[e.ColumnIndex].FormattedValue.Equals("Eliminar Categoría")) { if (MyMessageBox.Show("¿Seguro que desea Eliminar de la Categoria " + MiCategoria.Nombre + " al Empleado " + ((ModelEmpleadoPersona)dgvEmpleadoProfesor.CurrentRow.DataBoundItem).Apellido + ", " + ((ModelEmpleadoPersona)dgvEmpleadoProfesor.CurrentRow.DataBoundItem).Nombre + "?", "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.OK) { ControladorCategoria CCategoria = new ControladorCategoria(); var resultado = CCategoria.EliminarEmpleadoDelCategoria(((ModelEmpleadoPersona)dgvEmpleadoProfesor.CurrentRow.DataBoundItem).MiEmpleado, MiCategoria); if (resultado > 0) { Padre.ModificarMensaje("Se ha eliminado el Profesor de la Categoría"); Dispose(); } else if (resultado == -2) { MyMessageBox.Show(this, "El Profesor no está asignado a la Categoría", "Categoria"); } } } }
private void BotonGuardarCategoria_Click(object sender, EventArgs e) { var hayError = false; if (dtpFinCategoria.Value.CompareTo(dtpInicioCategoria.Value) < 1) { hayError = true; errorProvider1.SetError(dtpInicioCategoria, "El día de comienzo debe ser antes que el día de fin del Categoría"); errorProvider1.SetError(dtpFinCategoria, "El día de comienzo debe ser antes que el día de fin del Categoría"); } else { errorProvider1.SetError(dtpInicioCategoria, ""); errorProvider1.SetError(dtpFinCategoria, ""); } if (long.Parse(txtImporteMensualCategoria.Text) > Int32.MaxValue || long.Parse(txtImporteMensualCategoria.Text) < Int32.MinValue) { hayError = true; errorProvider1.SetError(txtImporteMensualCategoria, "El importe mensual es un número demasiado grande"); } else if (txtImporteMensualCategoria.Text.Equals("") || Int32.Parse(txtImporteMensualCategoria.Text) == 0) { hayError = true; errorProvider1.SetError(txtImporteMensualCategoria, "El importe mensual debe ser un número mayor a cero"); } else { errorProvider1.SetError(txtImporteMensualCategoria, ""); } if (hayError) { return; } ControladorCategoria un_controlador_Categoria = new ControladorCategoria(); var resultado = un_controlador_Categoria.ModificarCategoria(Categoria.IdCategoria, txtNombreCategoria.Text, Int32.Parse(txtImporteMensualCategoria.Text), dtpInicioCategoria.Value, dtpFinCategoria.Value, Categoria.Deporte, Categoria.EstadoCategoria); if (resultado > 0) { Padre.ModificarMensaje("La CATEGORÍA ha sido modificado con ÉXITO"); Padre.Actualizar(); Dispose(); } else if (resultado == -2) { MyMessageBox.Show(this, "Ya existe el nombre de la Categoría", "Categoria"); } }
private void BotonGuardarCategoria_Click(object sender, EventArgs e) { var hayError = false; if (txtNombreCategoria.Text.Length < 3) { hayError = true; errorProvider1.SetError(txtNombreCategoria, "El nombre de la categoría debe contener entre 3 y 50 caracteres"); } else { errorProvider1.SetError(txtNombreCategoria, ""); } if (dtpFinCategoria.Value.CompareTo(dtpInicioCategoria.Value) < 1) { hayError = true; errorProvider1.SetError(dtpInicioCategoria, "El día de inicio de una categoría no debe ser mayor al día de fin la misma"); errorProvider1.SetError(dtpFinCategoria, "El día de fin de una categoria no debe ser menor al día inicio de la misma"); } else { errorProvider1.SetError(dtpInicioCategoria, ""); errorProvider1.SetError(dtpFinCategoria, ""); } if (txtImporteMensualCategoria.Text == "" || long.Parse(txtImporteMensualCategoria.Text) > Int32.MaxValue || long.Parse(txtImporteMensualCategoria.Text) < Int32.MinValue) { hayError = true; errorProvider1.SetError(txtImporteMensualCategoria, "El importe mensual de la categoría es un número demasiado grande"); } else if (txtImporteMensualCategoria.Text.Equals("") || Int32.Parse(txtImporteMensualCategoria.Text) == 0) { hayError = true; errorProvider1.SetError(txtImporteMensualCategoria, "El importe mensual categoría debe ser un número mayor a cero"); } else { errorProvider1.SetError(txtImporteMensualCategoria, ""); } if (hayError) { return; } ControladorCategoria un_controlador_Categoria = new ControladorCategoria(); var resultado = un_controlador_Categoria.CrearCategoria(txtNombreCategoria.Text, Int32.Parse(txtImporteMensualCategoria.Text), dtpInicioCategoria.Value, dtpFinCategoria.Value, ((ModelDeporte)cbxDeporte.SelectedItem).MiDeporte); if (resultado > 0) { Padre.ModificarMensaje("La CATEGORÍA ha sido creado con ÉXITO"); Padre.Actualizar(); Dispose(); } else if (resultado == -1) { Padre.ModificarMensaje("La CATEGORÍA ha sido recuperada con ÉXITO"); Padre.Actualizar(); Dispose(); } else if (resultado == -2) { MyMessageBox.Show(this, "Ya existe el nombre de la Categoría, intente con otro número", "Categoría"); } }