Beispiel #1
0
    protected void SubirBtn_Click(object sender, EventArgs e)
    {
        //Valida que se haya elegido una imagen
        string resultado = DatosPAISES.verificarPais(Cod_pais.SelectedValue, Nombretxt.Text);

        ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + resultado + "')", true);
        if (resultado.Equals("El código/nombre seleccionado ya fue asignado a un país, por favor compruebe con soporte el código correspondiente"))
        {
            Nombretxt.Text = "";
            SelectImag.Attributes.Clear();
            ImagenPais.ImageUrl = "~/images/search-engine-optimisation-settings-17.png";
        }
        else
        {
            if (SelectImag.HasFile == false)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Por favor suba una imagen en representación al país que desea agregar')", true);
            }
            else
            {
                //Obtener datos de imagen
                int Tamanio = SelectImag.PostedFile.ContentLength;
                ImagenOriginal = new byte[Tamanio];
                SelectImag.PostedFile.InputStream.Read(ImagenOriginal, 0, Tamanio);


                string ImagenDataURL64 = "data:image/jpg;base64, " + Convert.ToBase64String(ImagenOriginal);
                ImagenPais.ImageUrl = ImagenDataURL64;
                AgregarBtn.Visible  = true;
            }
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string resultado = DatosPAISES.obtenerDatosModificar(Global.cod_pais);
         ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + resultado + "')", true);
         ImagenPais.ImageUrl = "data:Image/jpg;base64," + Global.imagen_pais;
         Cod_pais.Text       = Global.cod_pais;
         Nombretxt.Text      = Global.nombre_pais;
     }
 }
    public static void registrarReserva()
    {
        conVue.Close();
        SqlCommand com = new SqlCommand("INSERT INTO Reserva(cod_reserva,id_usuario,cod_pais,cod_vuelo,cantidad) VALUES(@cod_compra,@id_usuario,@cod_pais,@cod_vuelo,@cantidad)", conVue);

        com.Parameters.AddWithValue("@cod_compra", obtenerCod_reserva());
        com.Parameters.AddWithValue("@id_usuario", Global.id);
        com.Parameters.AddWithValue("@cod_pais", DatosPAISES.obtenerCod_Pais(Global.lugar));
        com.Parameters.AddWithValue("@cod_vuelo", Global.cod_vuelo);
        com.Parameters.AddWithValue("@cantidad", Global.cantidad);
        conVue.Open();
        com.ExecuteNonQuery();
        conVue.Close();
        sumarConsecutivoReserva();
    }
    public static void registrarCompra()
    {
        conVue.Close();
        SqlCommand com = new SqlCommand("INSERT INTO Compra(cod_compra,id_usuario,cod_pais,cod_vuelo,total,tipo) VALUES(@cod_compra,@id_usuario,@cod_pais,@cod_vuelo,@total,@tipo)", conVue);

        com.Parameters.AddWithValue("@cod_compra", obtenerCod_compra());
        com.Parameters.AddWithValue("@id_usuario", Global.id);
        com.Parameters.AddWithValue("@cod_pais", DatosPAISES.obtenerCod_Pais(Global.lugar));
        com.Parameters.AddWithValue("@cod_vuelo", Global.cod_vuelo);
        com.Parameters.AddWithValue("@total", Global.precio);
        com.Parameters.AddWithValue("@tipo", Global.tipo);
        conVue.Open();
        com.ExecuteNonQuery();
        conVue.Close();
        sumarConsecutivoCompra();
    }
 protected void ModificarBtn_Click(object sender, EventArgs e)
 {
     if (Nombretxt.Text.Equals(""))
     {
         ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Por favor ingrese un nombre de país válido')", true);
     }
     else
     {
         // Llama al procedimiento de DatosPAISES que inserta los datos en la BD
         string resultado = DatosPAISES.actualizarPais(ImagenOriginal, Nombretxt.Text, Cod_pais.Text);
         ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + resultado + "')", true);
         if (resultado.Equals("País actualizado exitosamente"))
         {
             Response.Redirect("http://localhost:53551/IndexPaises.aspx");
         }
     }
 }
Beispiel #6
0
 protected void AgregarBtn_Click(object sender, EventArgs e)
 {
     //valida que todos los datos se hayan ingresado antes de ingresar a la BD
     if (Cod_pais.SelectedValue.Equals("") || Nombretxt.Text.Equals(""))
     {
         ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Por favor ingrese un código y nombre de país válidos')", true);
     }
     else
     {
         // Llama al procedimiento de DatosPAISES que inserta los datos en la BD
         string resultado = DatosPAISES.agregarPais(ImagenOriginal, Nombretxt.Text, Cod_pais.SelectedValue);
         ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + resultado + "')", true);
         if (resultado.Equals("País agregado con éxito."))
         {
             DatosPAISES.sumarConsecutivoPais();
             Response.Redirect("http://localhost:53551/IndexPaises.aspx");
         }
     }
 }