Beispiel #1
0
 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);
         }
     }
 }