protected void guardarUsuario_Click(object sender, EventArgs e) { String nombre = this.txtNombre.Text; String apellido = this.txtApellidos.Text; String correo = this.txtCorreo.Text; String fecha = this.txtFechaN.Text; String tel = this.txtTelefono.Text; String direccion = this.txtDireccion.Text; String duracion = this.txtContra.Text; String dui = this.txtDui.Text; String fechai = this.fechaInicio.Text; String fechaf = this.fechaFin.Text; int univ = int.Parse(ddlUniversidades.SelectedValue); int carr = int.Parse(ddlCarreras.SelectedValue); int nivel = int.Parse(ddlNivel.SelectedValue); int beca = int.Parse(this.ddlPrograma.SelectedValue); if (nombre != "") { if (apellido != "") { if (correo != "" && fecha != "" && tel != "" && direccion != "" && dui != "" && fechai != "" && fechaf != "") { if (beca > 0 && nivel > 0 && carr > 0 && univ > 0) { conexion conexionSQL = new conexion(); conexionSQL.conectar(); generadorContra c = new generadorContra(); String contra = c.generarContra(); encriptacion enc = new encriptacion(); String contraEnc = enc.encriptarContra(contra); String codB = conexionSQL.getCodigoB(beca); int codigo = conexionSQL.codigoMax() + 1; this.metodoCodigo(codB, codigo); int resp = conexionSQL.agregarBecario(nombre, apellido, correo, contra, univ, nivel, carr, beca, fecha, fechai, fechaf, tel, direccion, this.codigoB, dui, duracion); conexionSQL.desconectar(); if (resp > 0) { correo enviarCo = new correo(correo, "Credeciales de Usuario", "Estimado/a: " + nombre + ". Su password es: " + contra); if (enviarCo.Estado) { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "modificarCarrera();", true); } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "modificarCarrera();", true); } } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true); } } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true); } } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true); } } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true); } } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true); } }
protected void guardarUsuario_Click(object sender, EventArgs e) { try { String nombre = txtNombUsu.Text; String apellido = txtApelUsu.Text; String correo = txtCorreUsu.Text; int tipo = int.Parse(ddlTipoUsu.SelectedValue); if (nombre != "") { if (apellido != "") { if (correo != "") { if (tipo > 0) { conexion conexionSQL = new conexion(); conexionSQL.conectar(); generadorContra c = new generadorContra(); String contra = c.generarContra(); encriptacion enc = new encriptacion(); String contraEnc = enc.encriptarContra(contra); int resp = conexionSQL.agregarUsuario(nombre, apellido, correo, contraEnc, tipo); conexionSQL.desconectar(); if (resp > 0) { correo enviarCo = new correo(correo, "Credeciales de Usuario", "Estimado/a: " + nombre + ". Su password es: " + contra); if (enviarCo.Estado) { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "modificarCarrera();", true); } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "modificarCarrera();", true); } } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true); } } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true); } } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true); } } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true); } } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true); } }