예제 #1
0
 private void btoSalida_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvPedidos.CurrentRow.Cells[1].Value.Equals("COMPLETO"))
         {
             PedidoCompletoE p = (PedidoCompletoE)dgvPedidos.CurrentRow.Cells[0].Value;
             p.HoraSalidaBodega = dtpSalida.Value;
             pl.GuardarPedidoCompletoBodega(p);
         }
         else if (dgvPedidos.CurrentRow.Cells[1].Value.Equals("SOLO SERVICIO"))
         {
             PedidoSoloServicioE p = (PedidoSoloServicioE)dgvPedidos.CurrentRow.Cells[0].Value;
             p.HoraSalidaBodega = dtpSalida.Value;
             pl.GuardarPedidoSoloServicioBodega(p);
         }
         else if (dgvPedidos.CurrentRow.Cells[1].Value.Equals("CLIENTE"))
         {
             PedidoClienteE p = (PedidoClienteE)dgvPedidos.CurrentRow.Cells[0].Value;
             p.HoraSalidaBodega = dtpSalida.Value;
             p.Estado           = "ENVIADO";
             pl.GuardarPedidoClienteBodega(p);
         }
         CargarPedidos();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Agregando Hora Salida", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 /// <summary>
 /// Updates an order selected by the cashier on to the database
 /// </summary>
 /// <param name="pc">
 /// Instance of the class PedidoSoloServicio
 /// </param>
 /// <returns>
 /// True if the order is updated
 /// </returns>
 public bool GuardarPedidoSoloServicioFactura(PedidoSoloServicioE pss)
 {
     using (FerreteriaEntities db = new FerreteriaEntities())
     {
         return(db.Database.ExecuteSqlCommand("sp_upedido_solo_servicio_factura @p0, @p1, @p2",
                                              pss.Id, pss.FechaFactura, pss.CodigoCajero) > 0);
     }
 }
 /// <summary>
 /// Updates an order selected by the carrier on to the database
 /// </summary>
 /// <param name="pc">
 /// Instance of the class PedidoSoloServicio
 /// </param>
 /// <returns>
 /// True if the order is updated
 /// </returns>
 public bool GuardarPedidoSoloServicioTransporte(PedidoSoloServicioE pss)
 {
     using (FerreteriaEntities db = new FerreteriaEntities())
     {
         return(db.Database.ExecuteSqlCommand("sp_upedido_solo_servicio_transporte @p0, @p1, @p2, @p3",
                                              pss.Id, pss.CodigoConductor, pss.HoraIniciaTransporte, pss.HoraFinalizaTransporte) > 0);
     }
 }
 /// <summary>
 /// Updates an order selected by the builder or the carrier on to the database
 /// </summary>
 /// <param name="pc">
 /// Instance of the class PedidoSoloServicio
 /// </param>
 /// <returns>
 /// True if the order is updated
 /// </returns>
 public bool GuardarPedidoSoloServicioBodega(PedidoSoloServicioE pss)
 {
     using (FerreteriaEntities db = new FerreteriaEntities())
     {
         return(db.Database.ExecuteSqlCommand("sp_upedido_solo_servicio_bodega @p0, @p1, @p2",
                                              pss.Id, pss.HoraRecibidoBodega, pss.HoraSalidaBodega) > 0);
     }
 }
 /// <summary>
 /// Saves a new order made by the builder or the carrier on to the database
 /// </summary>
 /// <param name="pc">
 /// Instance of the class PedidoSoloServicio
 /// </param>
 /// <returns>
 /// True if the order is saved
 /// </returns>
 public bool GuardarPedidoSoloServicioConstructor(PedidoSoloServicioE pss)
 {
     using (FerreteriaEntities db = new FerreteriaEntities())
     {
         return(db.Database.ExecuteSqlCommand("sp_ipedido_solo_servicio_constructor @p0, @p1, @p2, @p3, @p4, @p5",
                                              pss.CedulaCliente, pss.CodigoUsuario, pss.Observaciones,
                                              pss.SubTotal, pss.IVA, pss.Total) > 0);
     }
 }
예제 #6
0
        private void btoRealizarCompra_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(txtCedulaCliente.Text))
                {
                    throw new ArgumentNullException("Debe ingresar un número de cédula del cliente");
                }
                if (string.IsNullOrWhiteSpace(txtCedulaCliente.Text))
                {
                    throw new ArgumentNullException("Debe ingresar las observaciones");
                }
                ps = new PedidoSoloServicioE();
                ps.CedulaCliente = txtCedulaCliente.Text.Trim();
                ps.CodigoUsuario = u.Codigo;
                ps.Observaciones = txtObservaciones.Text.Trim().ToUpper();
                ps.SubTotal      = subtotal;
                ps.IVA           = iva;
                ps.Total         = total;
                pl.GuardarPedidoSoloServicioConstructor(ps);

                List <PedidoSoloServicioE> pedidos = pl.CargarPedidoSoloServicio();
                int last = pedidos.Count - 1;
                ps.Id = pedidos[last].Id;

                foreach (PedidoSoloServicioServicioE p in servicios)
                {
                    p.IdPedido = ps.Id;
                    pl.GuardarPedidoSoloServicioServicio(p);
                }

                MessageBox.Show(ps.CedulaCliente + "\n" + DateTime.Now.TimeOfDay, "Notificación",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);

                Limpiar();
                Activar(false);
            }
            catch (ArgumentNullException ex)
            {
                MessageBox.Show(ex.Message, "Realizando Compra", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Realizando Compra", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #7
0
        private void btnAgregarInicio_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgvTransportes.CurrentRow.Cells[1].Value.Equals("COMPLETO"))
                {
                    PedidoCompletoE p = (PedidoCompletoE)dgvTransportes.CurrentRow.Cells[0].Value;
                    p.CodigoConductor      = u.Codigo;
                    p.HoraIniciaTransporte = dtpInicia.Value;
                    pl.GuardarPedidoCompletoTransporte(p);
                }
                else if (dgvTransportes.CurrentRow.Cells[1].Value.Equals("SOLO SERVICIO"))
                {
                    PedidoSoloServicioE p = (PedidoSoloServicioE)dgvTransportes.CurrentRow.Cells[0].Value;
                    p.CodigoConductor      = u.Codigo;
                    p.HoraIniciaTransporte = dtpInicia.Value;
                    pl.GuardarPedidoSoloServicioTransporte(p);
                }
                else if (dgvTransportes.CurrentRow.Cells[1].Value.Equals("CLIENTE"))
                {
                    PedidoClienteE p = (PedidoClienteE)dgvTransportes.CurrentRow.Cells[0].Value;
                    p.CodigoConductor      = u.Codigo;
                    p.HoraIniciaTransporte = dtpInicia.Value;
                    pl.GuardarPedidoClienteTransporte(p);
                }
                CargarPedidosTransporte();

                foreach (TransporteE t in tl.CargarTransportes())
                {
                    if (t.CodigoConductor == u.Codigo)
                    {
                        t.Disponible = false;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Agregando Hora Inicio", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
        }
        /// <summary>
        /// Generates a bill for the products and services sold
        /// </summary>
        /// <param name="tipoFactura">
        /// string bill type: only the products or everything
        /// </param>
        private void Factura(string tipoFactura)
        {
            try
            {
                DialogResult result = MessageBox.Show("¿Seguro que desea realizar el pago seleccionado?",
                                                      "Realizando Pago", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (result == DialogResult.Yes)
                {
                    decimal subtotal = 0;
                    decimal iva      = 0;
                    decimal total    = 0;

                    if (tipoFactura.Equals("Productos"))
                    {
                        if (dgvPedidos.CurrentRow.Cells[1].Value.Equals("COMPLETO"))
                        {
                            PedidoCompletoE p = (PedidoCompletoE)dgvPedidos.CurrentRow.Cells[0].Value;
                            p.CodigoCajero     = u.Codigo;
                            p.FechaFactura     = dtpFecha.Value;
                            p.PagaSoloProducto = true;
                            pl.GuardarPedidoCompletoFactura(p);

                            WindowReceipt factura = new WindowReceipt();
                            factura.lblNumeroFacturaT.Text = p.Id.ToString();
                            factura.lblFechaT.Text         = p.FechaFactura.ToString();
                            factura.lblCedulaClienteT.Text = p.CedulaCliente;

                            foreach (UsuarioE i in ul.CargarUsuario())
                            {
                                if (i.Codigo == p.CodigoCajero)
                                {
                                    factura.lblCajeroT.Text = i.Nombre;
                                }
                            }

                            foreach (PedidoCompletoProductoE i in pl.CargarPedidoCompletoProducto())
                            {
                                if (i.IdPedido == p.Id)
                                {
                                    foreach (ProductoE pr in prl.CargarProducto("", ""))
                                    {
                                        if (pr.Id == i.IdPedido)
                                        {
                                            subtotal += (pr.Precio * i.Cantidad);
                                            factura.txtVentas.Text += "\n" + pr.Nombre + "\n" + i.Cantidad
                                                                      + "\t" + pr.Precio.ToString("0.00") + "\t" + i.PrecioTotal.ToString("0.00") + "\n";
                                            break;
                                        }
                                    }
                                }
                            }

                            iva   = subtotal * (decimal)0.13;
                            total = subtotal + iva;

                            factura.lblSubtotalT.Text = subtotal.ToString();
                            factura.lblIVAT.Text      = iva.ToString();
                            factura.lblTotalT.Text    = total.ToString();

                            factura.ShowDialog();
                        }
                        else if (dgvPedidos.CurrentRow.Cells[1].Value.Equals("CLIENTE"))
                        {
                            PedidoClienteE p = (PedidoClienteE)dgvPedidos.CurrentRow.Cells[0].Value;
                            p.CodigoCajero     = u.Codigo;
                            p.FechaFactura     = dtpFecha.Value;
                            p.PagaSoloProducto = true;
                            pl.GuardarPedidoClienteFactura(p);

                            WindowReceipt factura = new WindowReceipt();
                            factura.lblNumeroFacturaT.Text = p.Id.ToString();
                            factura.lblFechaT.Text         = p.FechaFactura.ToString();
                            factura.lblCedulaClienteT.Text = p.CedulaCliente;

                            foreach (UsuarioE i in ul.CargarUsuario())
                            {
                                if (i.Codigo == p.CodigoCajero)
                                {
                                    factura.lblCajeroT.Text = i.Nombre;
                                }
                            }

                            foreach (PedidoClienteProductoE i in pl.CargarPedidoClienteProducto())
                            {
                                if (i.IdPedido == p.Id)
                                {
                                    foreach (ProductoE pr in prl.CargarProducto("", ""))
                                    {
                                        if (pr.Id == i.IdPedido)
                                        {
                                            subtotal += (pr.Precio * i.Cantidad);
                                            factura.txtVentas.Text += "\n" + pr.Nombre + "\n" + i.Cantidad
                                                                      + "\t" + pr.Precio.ToString("0.00") + "\t" + i.PrecioTotal.ToString("0.00") + "\n";
                                            break;
                                        }
                                    }
                                }
                            }

                            iva   = subtotal * (decimal)0.13;
                            total = subtotal + iva;

                            factura.lblSubtotalT.Text = subtotal.ToString();
                            factura.lblIVAT.Text      = iva.ToString();
                            factura.lblTotalT.Text    = total.ToString();

                            factura.ShowDialog();
                        }
                    }
                    else
                    {
                        if (dgvPedidos.CurrentRow.Cells[1].Value.Equals("COMPLETO"))
                        {
                            PedidoCompletoE p = (PedidoCompletoE)dgvPedidos.CurrentRow.Cells[0].Value;
                            p.CodigoCajero = u.Codigo;
                            p.FechaFactura = dtpFecha.Value;


                            WindowReceipt factura = new WindowReceipt();
                            factura.lblNumeroFacturaT.Text = p.Id.ToString();
                            factura.lblFechaT.Text         = p.FechaFactura.ToString();
                            factura.lblCedulaClienteT.Text = p.CedulaCliente;

                            foreach (UsuarioE i in ul.CargarUsuario())
                            {
                                if (i.Codigo == p.CodigoCajero)
                                {
                                    factura.lblCajeroT.Text = i.Nombre;
                                }
                            }

                            if (p.PagaSoloProducto != true)
                            {
                                foreach (PedidoCompletoProductoE i in pl.CargarPedidoCompletoProducto())
                                {
                                    if (i.IdPedido == p.Id)
                                    {
                                        foreach (ProductoE pr in prl.CargarProducto("", ""))
                                        {
                                            if (pr.Id == i.IdPedido)
                                            {
                                                subtotal += (pr.Precio * i.Cantidad);
                                                factura.txtVentas.Text += "\n" + pr.Nombre + "\n" + i.Cantidad
                                                                          + "\t" + pr.Precio.ToString("0.00") + "\t" + i.PrecioTotal.ToString("0.00") + "\n";
                                                break;
                                            }
                                        }
                                    }
                                }
                            }

                            foreach (PedidoCompletoServicioE i in pl.CargarPedidoCompletoServicio())
                            {
                                if (i.IdPedido == p.Id)
                                {
                                    foreach (ServicioE se in sel.CargarServicio("", ""))
                                    {
                                        if (se.Id == i.IdPedido)
                                        {
                                            subtotal += (se.Precio * i.Cantidad);
                                            factura.txtVentas.Text += "\n" + se.Nombre + "\n" + i.Cantidad
                                                                      + "\t" + se.Precio.ToString("0.00") + "\t" + i.PrecioTotal.ToString("0.00") + "\n";
                                            break;
                                        }
                                    }
                                }
                            }

                            iva   = subtotal * (decimal)0.13;
                            total = subtotal + iva;

                            p.PagaSoloProducto = false;
                            pl.GuardarPedidoCompletoFactura(p);

                            factura.lblSubtotalT.Text = subtotal.ToString();
                            factura.lblIVAT.Text      = iva.ToString();
                            factura.lblTotalT.Text    = total.ToString();

                            factura.ShowDialog();
                        }
                        else if (dgvPedidos.CurrentRow.Cells[1].Value.Equals("SOLO SERVICIO"))
                        {
                            PedidoSoloServicioE p = (PedidoSoloServicioE)dgvPedidos.CurrentRow.Cells[0].Value;
                            p.CodigoCajero = u.Codigo;
                            p.FechaFactura = dtpFecha.Value;
                            pl.GuardarPedidoSoloServicioFactura(p);

                            WindowReceipt factura = new WindowReceipt();
                            factura.lblNumeroFacturaT.Text = p.Id.ToString();
                            factura.lblFechaT.Text         = p.FechaFactura.ToString();
                            factura.lblCedulaClienteT.Text = p.CedulaCliente;

                            foreach (UsuarioE i in ul.CargarUsuario())
                            {
                                if (i.Codigo == p.CodigoCajero)
                                {
                                    factura.lblCajeroT.Text = i.Nombre;
                                }
                            }

                            foreach (PedidoSoloServicioServicioE i in pl.CargarPedidoSoloServicioServicio())
                            {
                                if (i.IdPedido == p.Id)
                                {
                                    foreach (ServicioE se in sel.CargarServicio("", ""))
                                    {
                                        if (se.Id == i.IdPedido)
                                        {
                                            factura.txtVentas.Text += "\n" + se.Nombre + "\n" + i.Cantidad
                                                                      + "\t" + se.Precio.ToString("0.00") + "\t" + i.PrecioTotal.ToString("0.00") + "\n";
                                            break;
                                        }
                                    }
                                }
                            }

                            factura.lblSubtotalT.Text = p.SubTotal.ToString();
                            factura.lblIVAT.Text      = p.IVA.ToString();
                            factura.lblTotalT.Text    = p.Total.ToString();

                            factura.ShowDialog();
                        }
                        else if (dgvPedidos.CurrentRow.Cells[1].Value.Equals("CLIENTE"))
                        {
                            PedidoClienteE p = (PedidoClienteE)dgvPedidos.CurrentRow.Cells[0].Value;
                            p.CodigoCajero = u.Codigo;
                            p.FechaFactura = dtpFecha.Value;

                            WindowReceipt factura = new WindowReceipt();
                            factura.lblNumeroFacturaT.Text = p.Id.ToString();
                            factura.lblFechaT.Text         = p.FechaFactura.ToString();
                            factura.lblCedulaClienteT.Text = p.CedulaCliente;

                            foreach (UsuarioE i in ul.CargarUsuario())
                            {
                                if (i.Codigo == p.CodigoCajero)
                                {
                                    factura.lblCajeroT.Text = i.Nombre;
                                }
                            }

                            if (p.PagaSoloProducto != true)
                            {
                                foreach (PedidoClienteProductoE i in pl.CargarPedidoClienteProducto())
                                {
                                    if (i.IdPedido == p.Id)
                                    {
                                        foreach (ProductoE pr in prl.CargarProducto("", ""))
                                        {
                                            if (pr.Id == i.IdPedido)
                                            {
                                                subtotal += (pr.Precio * i.Cantidad);
                                                factura.txtVentas.Text += "\n" + pr.Nombre + "\n" + i.Cantidad
                                                                          + "\t" + pr.Precio.ToString("0.00") + "\t" + i.PrecioTotal.ToString("0.00") + "\n";
                                                break;
                                            }
                                        }
                                    }
                                }
                            }

                            foreach (PedidoClienteServicioE i in pl.CargarPedidoClienteServicio())
                            {
                                if (i.IdPedido == p.Id)
                                {
                                    foreach (ServicioE se in sel.CargarServicio("", ""))
                                    {
                                        if (se.Id == i.IdPedido)
                                        {
                                            subtotal += (se.Precio * i.Cantidad);
                                            factura.txtVentas.Text += "\n" + se.Nombre + "\n" + i.Cantidad
                                                                      + "\t" + se.Precio.ToString("0.00") + "\t" + i.PrecioTotal.ToString("0.00") + "\n";
                                            break;
                                        }
                                    }
                                }
                            }

                            iva   = subtotal * (decimal)0.13;
                            total = subtotal + iva;

                            p.PagaSoloProducto = false;
                            pl.GuardarPedidoClienteFactura(p);

                            factura.lblSubtotalT.Text = subtotal.ToString();
                            factura.lblIVAT.Text      = iva.ToString();
                            factura.lblTotalT.Text    = total.ToString();

                            factura.ShowDialog();
                        }
                    }
                    CargarPedidos();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Generando Factura", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }