Пример #1
0
        private void but_modificar_carrera_Click(object sender, EventArgs e)
        {
            if (this.validardatos())
            {
                if (ingreso != 1)
                {
                    MessageBox.Show("Debe ingresar el nombre y promoción, y a continuación presionar enter",
                                    "Modificar Materia",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
                }
                else
                {
                    ca.v_nombre      = tex_nombre.Text;
                    ca.v_promocion   = tex_promocion.Text;
                    ca.v_descripcion = tex_descripcion.Text;
                    ca.v_Dfacultad   = com_facultad.SelectedItem.ToString();
                    ca.v_usuario_m   = this.usuario;

                    if (che_activar_carrera.Checked == true)
                    {
                        ca.v_estado = 'A';
                    }


                    try
                    {
                        if (ca.ModificarCarrera(ca) != 0)
                        {
                            MessageBox.Show("Carrera modifacada correctamente" + "\n" + "Nombre: " + ca.v_nombre,
                                            "Modificar Carrera",
                                            MessageBoxButtons.OK,
                                            MessageBoxIcon.Information);
                            this.inicializarDatos();
                            tex_nombre.Enabled          = true;
                            tex_promocion.Enabled       = true;
                            tex_descripcion.Enabled     = false;
                            che_activar_carrera.Enabled = false;
                            che_activar_carrera.Checked = false;
                            ingreso = 0;

                            com_facultad.DataSource = null;
                            com_facultad.Show();
                            com_facultad.Enabled = false;
                            SLfacultad.Clear();
                            ca.v_facultad.Clear();

                            but_materia_asignar.Enabled = false;
                        }
                    }
                    catch (SqlException ex)
                    {
                        for (int i = 0; i < ex.Errors.Count; i++)
                        {
                            errorMessages.Append("Index #" + i + "\n" +
                                                 "Message: " + ex.Errors[i].Message + "\n" +
                                                 "LineNumber: " + ex.Errors[i].LineNumber + "\n" +
                                                 "Source: " + ex.Errors[i].Source + "\n" +
                                                 "Procedure: " + ex.Errors[i].Procedure + "\n");
                        }
                        Console.WriteLine(errorMessages.ToString());

                        MessageBox.Show(ex.Errors[0].Message.ToString(),
                                        "Modificar Carrera",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Warning);
                    }
                }
            }
        }