예제 #1
0
        private void eliminarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (!isMateriaGrupo)
                {
                    if (string.IsNullOrWhiteSpace(txtID.Text))
                    {
                        MessageBox.Show("Seleccione un registro");
                    }
                    else
                    {
                        esEditar = false;
                        esNuevo  = false;

                        int idGrupo = Convert.ToInt32(txtID.Text);

                        BaseResponse <int> carreras = gruposBLL.DeleteGrupo(idGrupo);
                        HabilitaDesHabilitaLimpia(false);
                        recargaGRID();
                    }
                }
                else if (isMateriaGrupo)
                {
                    if (string.IsNullOrWhiteSpace(txtGMID.Text))
                    {
                        MessageBox.Show("Seleccione un registro");
                    }
                    else
                    {
                        esEditar = false;
                        esNuevo  = false;

                        int idGrupo = Convert.ToInt32(txtGMID.Text);

                        BaseResponse <int> carreras = gruposBLL.DeleteGrupoMateria(idGrupo);
                        HabilitaDesHabilitaLimpia(false);
                        int IdGrupo = Convert.ToInt32(cmbGrupo.SelectedValue);
                        recargaGRID(IdGrupo);
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("The DELETE statement conflicted with the REFERENCE constraint"))
                {
                    MessageBox.Show("El registro se encuentra asignado y no se puede eliminar");
                }
                else
                {
                    MessageBox.Show(ex.Message + " TRACE : " + ex.StackTrace);
                }
            }
        }