private void BtnGrabar_Click(object sender, EventArgs e) { if (Valida() == true) { if (TxtUsuarioId.Text == "") { int PersonaId = ClPersona.Get_Max_Persona(); int UniversidadId = 0; ClPersona.Insert_Persona(PersonaId, Convert.ToInt32(CboAlias.SelectedValue), TxtNombres.Value, TxtApellidos.Value, Convert.ToInt32(CboGenero.SelectedValue), TxtIdNo.Value, TxtDireccion.Value, Convert.ToInt32(CboMunicipio.SelectedValue), TxtTelCasa.Value, TxtTelMovil.Value, UniversidadId, "", "", Convert.ToDateTime(TxtFecNac.Value)); int UsuarioId = ClUsuario.Get_Max_Usuario(); string Clave = ClUtilitarios.Encrypt(ClUtilitarios.GenerarPass(6, 10), true); ClUsuario.Insert_Usuario(UsuarioId, Convert.ToInt32(Session["ClienteId"]), Convert.ToInt32(CboTipoUsuario.SelectedValue), TxtCorreo.Value, Clave, PersonaId); ClUsuario.Create_Permisos(UsuarioId, Convert.ToInt32(CboTipoUsuario.SelectedValue)); string Asunto = ClTraductor.BuscaString(Session["Idioma"].ToString(), "91"); string Mensaje = Mensaje = "<body><table><tr><td>" + ClTraductor.BuscaString(Session["Idioma"].ToString(), "92") + " " + TxtCorreo.Value + " " + ClTraductor.BuscaString(Session["Idioma"].ToString(), "21") + " " + Clave + "</td></tr></table>"; ClUtilitarios.EnvioCorreo(TxtCorreo.Value, TxtNombres.Value + " " + TxtApellidos.Value, Asunto, Mensaje, 0, "", ""); Limpiar(); ClUsuario.Insert_Relacion_Usuario_Clinica(UsuarioId, Convert.ToInt32(Session["ClinicaId"])); ScriptManager.RegisterStartupScript(this, this.GetType(), "Popup", "ShowPopup('', '" + ClTraductor.BuscaString(Session["Idioma"].ToString(), "76") + "','success','" + ClTraductor.BuscaString(Session["Idioma"].ToString(), "9") + "');", true); GrdDetalle.Rebind(); } else { int UsuarioId = Convert.ToInt32(TxtUsuarioId.Text); int PersonaId = Convert.ToInt32(TxtPersonaId.Text); ClUsuario.Update_DatosUsuario(2, UsuarioId, TxtCorreo.Value, "", Convert.ToInt32(CboTipoUsuario.SelectedValue)); ClPersona.Update_Persona(PersonaId, Convert.ToInt32(CboAlias.SelectedValue), TxtNombres.Value, TxtApellidos.Value, Convert.ToInt32(CboGenero.SelectedValue), TxtIdNo.Value, TxtDireccion.Value, Convert.ToInt32(CboMunicipio.SelectedValue), TxtTelCasa.Value, TxtTelMovil.Value, 0, "", "", Convert.ToDateTime(TxtFecNac.Value)); Limpiar(); ClUsuario.Insert_Relacion_Usuario_Clinica(UsuarioId, Convert.ToInt32(Session["ClinicaId"])); ScriptManager.RegisterStartupScript(this, this.GetType(), "Popup", "ShowPopup('', '" + ClTraductor.BuscaString(Session["Idioma"].ToString(), "76") + "','success','" + ClTraductor.BuscaString(Session["Idioma"].ToString(), "9") + "');", true); GrdDetalle.Rebind(); } } ValidaGrabar(); }
private void BtnGrabar_Click(object sender, EventArgs e) { if (Valida() == true) { if (Convert.ToInt32(Session["Fase_ClienteId"]) == 1) { int PersonaId = ClPersona.Get_Max_Persona(); int UniversidadId = 0; if (CboUniverisidad.SelectedIndex > 0) { UniversidadId = Convert.ToInt32(CboUniverisidad.SelectedValue); } ClPersona.Insert_Persona(PersonaId, Convert.ToInt32(CboAlias.SelectedValue), TxtNombres.Value, TxtApellidos.Value, Convert.ToInt32(CboGenero.SelectedValue), TxtIdNo.Value, TxtDireccion.Value, Convert.ToInt32(CboMunicipio.SelectedValue), TxtTelCasa.Value, TxtTelMovil.Value, UniversidadId, TxtNoCol.Value, TxtTitulo.Value, Convert.ToDateTime(TxtFecNac.Value)); Clcliente.Update_Estado_Fase_Cliente(Convert.ToInt32(Session["ClienteId"])); ClUsuario.Actualiza_PersonaID_Usuario(PersonaId, Convert.ToInt32(Session["UsuarioId"])); ClUsuario.Update_DatosUsuario(1, Convert.ToInt32(Session["UsuarioId"]), TxtCorreo.Value, TxtUsuario.Value, 0); ClUsuario.Create_Permisos(Convert.ToInt32(Session["UsuarioId"]), 1); Session["PersonaId"] = PersonaId; if (TxtFotoPerfil.UploadedFiles.Count > 0) { Stream fileStream = TxtFotoPerfil.UploadedFiles[0].InputStream; byte[] attachmentBytes = new byte[fileStream.Length]; fileStream.Read(attachmentBytes, 0, Convert.ToInt32(fileStream.Length)); ClPersona.Insert_Foto_Perfil(PersonaId, attachmentBytes, TxtFotoPerfil.UploadedFiles[0].ContentType, TxtFotoPerfil.UploadedFiles[0].FileName); fileStream.Close(); } if (TxtFotoTitulo.UploadedFiles.Count > 0) { Stream fileStream = TxtFotoTitulo.UploadedFiles[0].InputStream; byte[] attachmentBytes = new byte[fileStream.Length]; fileStream.Read(attachmentBytes, 0, Convert.ToInt32(fileStream.Length)); ClPersona.Insert_Foto_Titulo(PersonaId, attachmentBytes, TxtFotoTitulo.UploadedFiles[0].ContentType, TxtFotoTitulo.UploadedFiles[0].FileName); fileStream.Close(); } Response.Redirect("~/WebForms/Wfrm_Inicio.aspx"); } else { int UniversidadId = 0; if (CboUniverisidad.SelectedIndex > 0) { UniversidadId = Convert.ToInt32(CboUniverisidad.SelectedValue); } ClPersona.Update_Persona(Convert.ToInt32(Session["PersonaId"]), Convert.ToInt32(CboAlias.SelectedValue), TxtNombres.Value, TxtApellidos.Value, Convert.ToInt32(CboAlias.SelectedValue), TxtIdNo.Value, TxtDireccion.Value, Convert.ToInt32(CboMunicipio.SelectedValue), TxtTelCasa.Value, TxtTelMovil.Value, UniversidadId, TxtNoCol.Value, TxtTitulo.Value, Convert.ToDateTime(TxtFecNac.Value)); ClUsuario.Update_DatosUsuario(1, Convert.ToInt32(Session["UsuarioId"]), TxtCorreo.Value, TxtUsuario.Value, 0); if (TxtFotoPerfil.UploadedFiles.Count > 0) { Stream fileStream = TxtFotoPerfil.UploadedFiles[0].InputStream; byte[] attachmentBytes = new byte[fileStream.Length]; fileStream.Read(attachmentBytes, 0, Convert.ToInt32(fileStream.Length)); ClPersona.Insert_Foto_Perfil(Convert.ToInt32(Session["PersonaId"]), attachmentBytes, TxtFotoPerfil.UploadedFiles[0].ContentType, TxtFotoPerfil.UploadedFiles[0].FileName); fileStream.Close(); } if (TxtFotoTitulo.UploadedFiles.Count > 0) { Stream fileStream = TxtFotoTitulo.UploadedFiles[0].InputStream; byte[] attachmentBytes = new byte[fileStream.Length]; fileStream.Read(attachmentBytes, 0, Convert.ToInt32(fileStream.Length)); ClPersona.Insert_Foto_Titulo(Convert.ToInt32(Session["PersonaId"]), attachmentBytes, TxtFotoTitulo.UploadedFiles[0].ContentType, TxtFotoTitulo.UploadedFiles[0].FileName); fileStream.Close(); } ScriptManager.RegisterStartupScript(this, this.GetType(), "CloseWindow", "ShowPopup('" + ClTraductor.BuscaString(Session["Idioma"].ToString(), "76") + "', '" + ClTraductor.BuscaString(Session["Idioma"].ToString(), "76") + "','success','" + ClTraductor.BuscaString(Session["Idioma"].ToString(), "9") + "');", true); } } }