예제 #1
0
        public static DataTable listarCupondesDeProveedor(int proveeedor_id, string codigo = null)
        {
            SqlConnection conn  = ConexionBD.getConexion();
            var           tabla = new DataTable();

            try
            {
                SqlCommand cmd = new SqlCommand("JARDCOUD.listar_cupones_de_proveedor", conn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@proveedor_id", proveeedor_id);
                if (codigo != "" && codigo != null)
                {
                    cmd.Parameters.AddWithValue("@codigo", codigo);
                }
                cmd.Parameters.AddWithValue("@fecha", FechaAplicacion.get());

                using (var adaptador = new SqlDataAdapter(cmd))
                {
                    adaptador.Fill(tabla);
                }
            }
            catch (SqlException e)
            {
                MessageBox.Show(e.Message);
                return(tabla);
            }
            conn.Close();
            return(tabla);
        }
예제 #2
0
        private void btnSeleccionar_Click(object sender, EventArgs e)
        {
            if (dgvClientes.RowCount != 0)
            {
                Cliente cliente_seleccionado = this.get_cliente_seleccionado();
                cupon.fecha_de_consumo = FechaAplicacion.get();

                if (CuponDAO.darBajaCupon(cliente_seleccionado, cupon))
                {
                    MessageBox.Show("Cupon cajenado correctamente");
                    form_anterior.cargarDatos();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("No se pudo dar de baja el cupon");
                    form_anterior.cargarDatos();
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Seleccione un Cliente");
            }
        }
예제 #3
0
        private void CargaCredito_Load(object sender, EventArgs e)
        {
            cmbTipoPago.DataSource    = TipoPagoDAO.listarDatosTarjetas();
            cmbTipoPago.DisplayMember = "descripcion"; //muestra solo los datos de esa columna
            cmbTipoPago.ValueMember   = "id";
            cmbTipoPago.SelectedIndex = -1;            // para que no seleccione nada

            txtNombreCliente.Text = cliente.nombre + " " + cliente.apellido;
            txtFecha.Text         = FechaAplicacion.get().ToString("dd/MM/yyyy");

            txtNumeroTarjeta1.MaxLength  = 4;
            txtNumeroTarjeta2.MaxLength  = 4;
            txtNumeroTarjeta3.MaxLength  = 4;
            txtNumeroTarjeta4.MaxLength  = 4;
            txtMes.MaxLength             = 2;
            txtAño.MaxLength             = 2;
            txtCodigoSeguridad.MaxLength = 3;
        }
예제 #4
0
        private void btnGenerar_Click(object sender, EventArgs e)
        {
            if (dgvOfertas.RowCount != 0)
            {
                double total_facturacion  = 0;
                List <Item_Factura> items = new List <Item_Factura> {
                };

                foreach (DataGridViewRow row in dgvOfertas.Rows)
                {
                    Item_Factura item = new Item_Factura();
                    item.oferta = new Oferta()
                    {
                        id = Int32.Parse(row.Cells[0].Value.ToString())
                    };
                    item.importe       = Double.Parse(row.Cells[5].Value.ToString());
                    item.cantidad      = Int32.Parse(row.Cells[4].Value.ToString());
                    total_facturacion += Double.Parse(row.Cells[5].Value.ToString());

                    items.Add(item);
                }

                Factura factura = new Factura();
                factura.total     = total_facturacion;
                factura.numero    = this.obtenerNumeroFacturacionAleatorio();
                factura.proveedor = proveedor;
                factura.fecha     = FechaAplicacion.get();

                if (FacturacionFacadeDAO.agregarFacturacion(factura, items))
                {
                    (new Facturacion(this, factura)).ShowDialog();
                }
                else
                {
                    MessageBox.Show("Error al agragar Facturación");
                }
            }
            else
            {
                MessageBox.Show("No se encontraron ofertas");
                this.Close();
            }
        }
예제 #5
0
        private void btnComprar_Click(object sender, EventArgs e)
        {
            if (this.siguiente())
            {
                Oferta oferta_seleccionada = this.get_oferta_seleccionada();
                int    cantidad_ingresada  = int.Parse(numCantidad.Value.ToString());

                if (cantidad_ingresada <= 0)
                {
                    MessageBox.Show("La cantidad ingresada es invalida");
                    return;
                }

                if (cantidad_ingresada <= oferta_seleccionada.cantidad_disponible)
                {
                    if (cantidad_ingresada <= oferta_seleccionada.cantidad_max_cliente)
                    {
                        double total_importe = oferta_seleccionada.precio_oferta * cantidad_ingresada;
                        if (cliente.credito >= (total_importe))
                        {
                            if (MessageBox.Show("¿Está a punto de comprar " + cantidad_ingresada.ToString() + " unidad/es de " + oferta_seleccionada.descripcion + " por $" + total_importe + " en total, desea continuar?", "ComprarOferta", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                            {
                                Compra compra = new Compra();
                                compra.oferta   = oferta_seleccionada;
                                compra.cliente  = cliente;
                                compra.fecha    = FechaAplicacion.get();
                                compra.cantidad = cantidad_ingresada;

                                Cupon cupon = new Cupon();
                                //cupon.codigo = this.obtenerCodigoCuponAleatorio().ToString();
                                cupon.fecha_vencimiento = FechaAplicacion.get().AddDays(15); //15 dias desde la compra
                                cupon.canjeado          = false;

                                if (CompraFacadeDAO.agregarCompraYGenerarCupon(compra, cupon))
                                {
                                    if (form_clientes != null)
                                    {
                                        form_clientes.cargarDatos();
                                    }
                                    (new CompraDetalle(this, compra, cupon)).ShowDialog();
                                }
                                else
                                {
                                    MessageBox.Show("Error al realizar la compra");
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("No dispone de credito suficiente para realizar la compra");
                        }
                    }
                    else
                    {
                        MessageBox.Show("La cantidad ingresada supera la cantidad maxima por cliente de la oferta");
                    }
                }
                else
                {
                    MessageBox.Show("La cantidad ingresada supera la cantidad disponible de la oferta");
                }
            }
            else
            {
                MessageBox.Show("Datos invalidos");
            }
        }
예제 #6
0
 private bool fechasValidas()
 {
     return(dtmFechaPublicacion.Value.Date >= FechaAplicacion.get().Date&& dtmFechaVencimiento.Value.Date > dtmFechaPublicacion.Value.Date);
 }