protected void Button2_Click(object sender, EventArgs e) { if (NumUsr.Text != "")//actualizar { pent.pentagSQL bd = new pent.pentagSQL(); string res = bd.getIDbyuser(User.Text, ConnectionString); if (res == NumUsr.Text || res == "") { bd.updateUsr(User.Text, Cont.Text, Rol.SelectedValue, RadioButtonList1.SelectedValue, NumUsr.Text, ConnectionString); bd.updateUsrDtl(NameUsr.Text, Email.Text, Comp.Text, AreaFun.SelectedValue, AreaReal.SelectedValue, usrinfo.Text, ConnectionString); //usrinfo.Text = ""; //NumUsr.Text = ""; //NameUsr.Text = ""; //Email.Text = ""; //Comp.Text = ""; //AreaFun.SelectedValue ="0"; //AreaReal.SelectedValue = "0"; //User.Text = ""; //Cont.Text =""; //Rol.SelectedValue ="0"; //HiddenField1.Value = "0"; Response.Redirect("AdminUsr.aspx"); } else { Response.Write("<script>alert('El nombre de usuario ya existe');</script>"); } } else //nuevo { pent.pentagSQL bd = new pent.pentagSQL(); //bd.updateUsr(User.Text, Cont.Text, Rol.SelectedValue, RadioButtonList1.SelectedValue, NumUsr.Text, ConnectionString); //bd.updateUsrDtl(NameUsr.Text, Email.Text, Comp.Text, AreaFun.SelectedValue, AreaReal.SelectedValue, usrinfo.Text, ConnectionString); string res = bd.getIDbyuser(User.Text, ConnectionString); if (res == NumUsr.Text) { int usrInfo = bd.InsertUsrDtl(NameUsr.Text, Email.Text, Comp.Text, AreaFun.SelectedValue, AreaReal.SelectedValue, ConnectionString); bd.InsertUser(User.Text, Cont.Text, Rol.SelectedValue, RadioButtonList1.SelectedValue, usrInfo.ToString(), ConnectionString); Response.Write("<script>alert('Guardado Correctamente');</script>"); Response.Redirect("AdminUsr.aspx"); } else { User.Text = ""; Cont.Text = ""; Response.Write("<script>alert('El nombre de usuario ya existe');</script>"); } } }