Пример #1
0
        private void Agregar_Cliente_Load(object sender, EventArgs e)
        {
            Pedir_Dni form = new Pedir_Dni();
            form.ShowDialog();
            this.txtDni.Text = form.dniIngresado;
            llenarDatos(this.txtDni.Text);
            try
            {

                using (SqlCommand cmd = new SqlCommand("BONDIOLA.listarButacasLibres", conn, ts))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    SQL_Library.agregarParametro(cmd, "@codigoViaje", codigoViaje);
                    SqlDataAdapter da = new SqlDataAdapter();
                    da.SelectCommand = cmd;
                    DataTable tabla = new DataTable();
                    da.Fill(tabla);
                    dgButacas.DataSource = tabla;
                    dgButacas.Refresh();
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #2
0
        private void btnComprar_Click(object sender, EventArgs e)
        {
            if (chkEncomienda.Checked)
            {
                if (String.IsNullOrEmpty(this.txtDniEncomienda.Text))
                {
                    MessageBox.Show("Ingrese un DNI para la encomienda.");
                    return;
                }
                try
                {
                    using (SqlCommand cmd = new SqlCommand("BONDIOLA.crearEncomienda", conn, ts))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        SQL_Library.agregarParametro(cmd, "@voucher", this.numeroVoucher);
                        SQL_Library.agregarParametro(cmd, "@peso", this.nudKg.Value);
                        SQL_Library.agregarParametro(cmd, "@dniCliente", this.txtDniEncomienda.Text);
                        SQL_Library.agregarParametro(cmd, "@codigoViaje", this.codigoViaje);
                        SQL_Library.agregarParametro(cmd, "@puntosAcumulados", Math.Round(this.nudMontoKg.Value/5));

                        cmd.ExecuteNonQuery();
                    }
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            if (pagoConTarjeta)
                new Checkout(this.nudTotal.Value, this.numeroVoucher, conn, ts).ShowDialog();
            else
            {
                if(MessageBox.Show("El pago es con tarjeta de crédito?","Consulta",MessageBoxButtons.YesNo) == DialogResult.Yes){
                    new Checkout(this.nudTotal.Value, this.numeroVoucher, conn, ts).ShowDialog();
                } else
                {
                    Pedir_Dni form = new Pedir_Dni();
                    form.ShowDialog();
                    String dniPagador = form.dniIngresado;

                    try
                    {
                        using (SqlCommand cmd = new SqlCommand("BONDIOLA.actualizarCompra", conn, ts))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            SQL_Library.agregarParametro(cmd, "@voucher", this.numeroVoucher);
                            SQL_Library.agregarParametro(cmd, "@dniPagador", dniPagador);
                            SQL_Library.agregarParametro(cmd, "@tipoPago", "Efectivo");
                            SQL_Library.agregarParametro(cmd, "@monto", this.nudTotal.Value);

                            cmd.ExecuteNonQuery();
                        }
                    }
                    catch (SqlException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            this.Close();
        }