Пример #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            AdminDB db = new AdminDB();

            if (AltaMailProf.Text != "")
            {
                if (TextBox7.Text != "")
                {
                    if (AltaApeProf.Text != "")
                    {
                        if (AltaNomProf.Text != "")
                        {
                            if (db.Validar_Usuario(TextBox6.Text) == true)
                            {
                                if (db.Validar_Mail_Profesor(AltaMailProf.Text) == true)
                                {
                                    int    user      = (int)Session["ID_User"];
                                    string idusuario = db.Nuevo_Usuario(TextBox6.Text, TextBox7.Text, AltaMailProf.Text, "2");
                                    bool   r         = db.Alta_Profesor(AltaNomProf.Text, AltaApeProf.Text, AltaDNIProf.Text, AltaMailProf.Text, AltaTelProf.Text, int.Parse(idusuario));
                                    if (r == true)
                                    {
                                        this.divprofesor.Visible     = true;
                                        this.divaltaprofesor.Visible = false;
                                        //Response.Redirect("Profesores.aspx");
                                    }
                                    else
                                    {
                                        Label1.Text = "Error al agregar el profesor";
                                        this.divaltaprofesor.Visible = true;
                                    }
                                }
                                else
                                {
                                    Label3.Text                  = "El correo electronico ya existe";
                                    AltaMailProf.Text            = "";
                                    this.divaltaprofesor.Visible = true;
                                }
                            }
                            else
                            {
                                Label4.Text   = "El nombre se usuario ya existe";
                                TextBox6.Text = "";
                                this.divaltaprofesor.Visible = true;
                            }
                        }
                        else
                        {
                            LabelNom.Text = "Este campo es obligatorio";
                            this.divaltaprofesor.Visible = true;
                        }
                    }
                    else
                    {
                        LabelApe.Text = "Este campo es obligatorio";
                        this.divaltaprofesor.Visible = true;
                    }
                }
                else
                {
                    Label1.Text = "Este campo es obligatorio";
                    this.divaltaprofesor.Visible = true;
                }
            }
            else
            {
                Label3.Text = "Este campo es obligatorio";
                this.divaltaprofesor.Visible = true;
            }
        }