Пример #1
0
        public static List <EncabezadoFacturaEntidad> ObtenerTodosxProducto(DateTime fecha1, DateTime fecha2, int vIdProduct)
        {
            List <EncabezadoFacturaEntidad> lista = new List <EncabezadoFacturaEntidad>();
            DataSet ds = EncabezadoFacturaDatos.SeleccionarTodosXProducto(vIdProduct, fecha1, fecha2);

            foreach (DataRow fila in ds.Tables[0].Rows)
            {
                EncabezadoFacturaEntidad elemento = new EncabezadoFacturaEntidad();
                elemento.idEncabezadoFactura = Convert.ToInt16(fila["id"].ToString());
                elemento.encabezadoPedido.idEncabezadoPedido = Convert.ToInt16(fila["idEncabezadoPedido"].ToString());
                elemento.encabezadoPedido.mesa.idMesa        = Convert.ToInt16(fila["idMesa"].ToString());
                elemento.restaurante.idRestaurante           = Convert.ToInt16(fila["idRestaurante"].ToString());
                elemento.usuario.idUsuario = fila["idUsuario"].ToString();
                elemento.fecha             = Convert.ToDateTime(fila["fecha"].ToString());
                elemento.IV       = Convert.ToDecimal(fila["iv"].ToString());
                elemento.Subtotal = Convert.ToDecimal(fila["subTotal"].ToString());
                elemento.Total    = Convert.ToDecimal(fila["total"].ToString());

                List <MontoPorTipoPagoEntidad> listaPagos = new List <MontoPorTipoPagoEntidad>();

                listaPagos = MontoPorTipoPagoLN.ObtenerTodos(elemento.idEncabezadoFactura);
                elemento.listaFormaPago = listaPagos;

                lista.Add(elemento);
            }



            return(lista);
        }
        private void cargarDatos()
        {
            EncabezadoFacturaEntidad factu  = (EncabezadoFacturaEntidad)Session["factura"];
            EncabezadoPedidoEntidad  pedido = EncabezadoPedidoLN.obtenerEncabezadoPedidoXID(factu.encabezadoPedido.idEncabezadoPedido);
            Decimal subTotal = 0;
            Decimal iv       = 0;
            Decimal total    = 0;

            //DateTime fecha = DateTime.Today;
            //lblFecha.Text = "Fecha: " + fecha.ToString("dd/MM/yyyy");
            cargarPedidoEnDataGridView(pedido);

            foreach (DetallePedidoEntidad item in pedido.listaDetalles)
            {
                subTotal += item.cantidad * item.producto.precio;
            }

            iv    = subTotal * PORC_IV;
            total = iv + subTotal;

            lblIV.Text             = "₡" + iv;
            lblSubtotal.Text       = "₡" + (subTotal + 0.00M);
            lblTotal.Text          = "₡" + total;
            lblFecha.Text          = factu.fecha.ToString("dd/MM/yyyy");
            this.imgLogo.ImageUrl  = "img/infoRestaurante/FactDALEX.jpg";
            this.lblNombre.Text    = factu.nombreCliente;
            this.lblIdFactura.Text = factu.idEncabezadoFactura.ToString();
        }
        private String facturaHTML()
        {
            String HTML = "";
            EncabezadoFacturaEntidad factu  = (EncabezadoFacturaEntidad)Session["factura"];
            EncabezadoPedidoEntidad  pedido = EncabezadoPedidoLN.obtenerEncabezadoPedidoXID(factu.encabezadoPedido.idEncabezadoPedido);

            HTML += "<style>table{font - family: arial, sans - serif;border - collapse: collapse;width: 100 %;}th{border: 1px solid black;text - align: center;";
            HTML += "padding: 8px;background - color: black;color: white;}td {border: 1px solid black;text - align: center;padding: 8px;}tr: nth - child(even) {";
            HTML += "background - color: #BDBDBD;}</ style >< center >< h1 > Factura </ h1 ></ center >< div style = 'width:49%; height:190px; float:left; margin-left:1%' >";
            HTML += "< img src = 'C:/Users/Alex/Documents/ProyectoFinalASPX/Restaurante/Restaurante/ProyectoRestaurante/ProyectoRestaurante/img/infoRestaurante/FactDALEX.jpg' alt = ''";
            HTML += "style = 'width:150px; height:150px; margin-top:20px; display: block;margin - left: auto;margin - right: auto;'></ div >< div style = 'width:49%; height:160px;float:left; padding-top:30px'>";
            HTML += "<span style='font-size:18px; font-weight:bold ; margin-left:5%'>Restaurante DALEX </ span ><br/><br/><span style = 'font-size:18px; font-weight:bold; margin-left:5%'> Fecha:&nbsp; &nbsp; ";
            HTML += factu.fecha.ToString("dd/MM/yyyy");
            HTML += "</span><br/><br/><span style = 'font-size:18px; font-weight:bold ; margin-left:5%'> Numero Factura: &nbsp; &nbsp;";
            HTML += factu.idEncabezadoFactura;
            HTML += "</span></div><br><br><div style = 'width:49%; height:50px; float:left; margin-left:1%; padding-top:10px'><span style = 'font-size:18px; font-weight:bold ; margin-left:50%'>Nombre:</ span ></ div >";
            HTML += "<div style = 'width:49%; height:50px;float:left; padding-top:10px'><label style = 'font-size:18px; font-weight:bold'>";
            HTML += factu.nombreCliente;
            HTML += "</label></div><div style = 'width:90%; height:250px; float:left; margin-left:5%; padding-top:10px'>< table ><tr><th>Producto</th><th>Cantidad</th><th>Precio</th></tr>";

            foreach (DetallePedidoEntidad item in pedido.listaDetalles)
            {
                HTML += "<tr><td>";
                HTML += item.producto.nombre + "</td>";
                HTML += "<td>";
                HTML += item.cantidad + "</td>";
                HTML += "<td>";
                HTML += item.precio + "</td>";
                HTML += "</td></tr>";
            }



            Decimal subTotal = 0;
            Decimal iv       = 0;
            Decimal total    = 0;

            foreach (DetallePedidoEntidad item in pedido.listaDetalles)
            {
                subTotal += item.cantidad * item.producto.precio;
            }

            iv    = subTotal * PORC_IV;
            total = iv + subTotal;

            HTML += "<tr><td colspan = '2' ><b>Impuesto Venta</b></td><td><b>";
            HTML += iv;
            HTML += "</b></td></tr><tr><td colspan = '2' ><b>Subtotal</b></td><td><b>";
            HTML += subTotal;
            HTML += "</b></td></tr><tr><td colspan = '2'><b>Total</b></td><td><b>";
            HTML += total;
            HTML += "</b></td></tr></table></div>";


            return(HTML);
        }
        public static void Modificar(EncabezadoFacturaEntidad encabezado)
        {
            SqlCommand comando = new SqlCommand("PA_ModificarEncabezadoFactura");

            comando.CommandType = CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@id", encabezado.idEncabezadoFactura);
            comando.Parameters.AddWithValue("@idEncabezadoPedido", encabezado.encabezadoPedido.idEncabezadoPedido);
            comando.Parameters.AddWithValue("@idRestaurante", encabezado.restaurante.idRestaurante);
            comando.Parameters.AddWithValue("@idUsuario", encabezado.usuario.idUsuario);
            comando.Parameters.AddWithValue("@nombreCliente", encabezado.nombreCliente);
            comando.Parameters.AddWithValue("@fecha", encabezado.fecha);


            using (Database db = DatabaseFactory.CreateDatabase("Default"))
            {
                db.ExecuteNonQuery(comando);
            }
        }
Пример #5
0
        public static List <EncabezadoFacturaEntidad> ObtenerTodos(DateTime fecha1, DateTime fecha2)
        {
            /*public int idEncabezadoFactura { get; set; }
             * public EncabezadoPedidoEntidad encabezadoPedido { get; set; }
             * public RestauranteEntidad restaurante { get; set; }
             * public UsuarioEntidad usuario { get; set; }
             * public String nombreCliente { get; set; }
             * public DateTime fecha { get; set; }
             * public List<MontoPorTipoPagoEntidad> listaFormaPago { get; set; }
             * public Decimal IV { get; set; }
             * public Decimal Subtotal { get; set; }
             * public Decimal Total { get; set; }*/

            List <EncabezadoFacturaEntidad> lista = new List <EncabezadoFacturaEntidad>();
            DataSet ds = EncabezadoFacturaDatos.SeleccionarTodos(fecha1, fecha2);

            foreach (DataRow fila in ds.Tables[0].Rows)
            {
                EncabezadoFacturaEntidad elemento = new EncabezadoFacturaEntidad();
                elemento.idEncabezadoFactura = Convert.ToInt16(fila["id"].ToString());
                elemento.encabezadoPedido.idEncabezadoPedido = Convert.ToInt16(fila["idEncabezadoPedido"].ToString());
                elemento.encabezadoPedido.mesa.idMesa        = Convert.ToInt16(fila["idMesa"].ToString());
                elemento.restaurante.idRestaurante           = Convert.ToInt16(fila["idRestaurante"].ToString());
                elemento.usuario.idUsuario = fila["idUsuario"].ToString();
                elemento.fecha             = Convert.ToDateTime(fila["fecha"].ToString());
                elemento.IV       = Convert.ToDecimal(fila["iv"].ToString());
                elemento.Subtotal = Convert.ToDecimal(fila["subTotal"].ToString());
                elemento.Total    = Convert.ToDecimal(fila["total"].ToString());

                List <MontoPorTipoPagoEntidad> listaPagos = new List <MontoPorTipoPagoEntidad>();

                listaPagos = MontoPorTipoPagoLN.ObtenerTodos(elemento.idEncabezadoFactura);
                elemento.listaFormaPago = listaPagos;

                lista.Add(elemento);
            }



            return(lista);
        }
Пример #6
0
        public static EncabezadoFacturaEntidad Nuevo(EncabezadoFacturaEntidad encabezado)
        {
            DataSet ds = EncabezadoFacturaDatos.Insertar(encabezado);;
            EncabezadoFacturaEntidad elemento = new EncabezadoFacturaEntidad();

            DataRow fila = ds.Tables[0].Rows[0];

            elemento.idEncabezadoFactura = Convert.ToInt16(fila["id"].ToString());
            elemento.encabezadoPedido.idEncabezadoPedido = Convert.ToInt16(fila["idEncabezadoPedido"].ToString());
            elemento.restaurante.idRestaurante           = Convert.ToInt16(fila["idRestaurante"].ToString());
            elemento.usuario.idUsuario = fila["idUsuario"].ToString();
            elemento.nombreCliente     = fila["nombreCliente"].ToString();
            elemento.fecha             = Convert.ToDateTime(fila["fecha"].ToString());

            foreach (MontoPorTipoPagoEntidad item in encabezado.listaFormaPago)
            {
                item.encabezadoFactura = elemento.idEncabezadoFactura;
                MontoPorTipoPagoLN.Nuevo(item);
            }
            return(elemento);
        }
        public static DataSet Insertar(EncabezadoFacturaEntidad encabezado)
        {
            SqlCommand comando = new SqlCommand("PA_InsertarEncabezadoFactura");

            comando.CommandType = CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@idEncabezadoPedido", encabezado.encabezadoPedido.idEncabezadoPedido);
            comando.Parameters.AddWithValue("@idRestaurante", encabezado.restaurante.idRestaurante);
            comando.Parameters.AddWithValue("@idUsuario", encabezado.usuario.idUsuario);
            comando.Parameters.AddWithValue("@nombreCliente", encabezado.nombreCliente);
            comando.Parameters.AddWithValue("@fecha", encabezado.fecha);
            comando.Parameters.AddWithValue("@iv", encabezado.IV);
            comando.Parameters.AddWithValue("@subTotal", encabezado.Subtotal);
            comando.Parameters.AddWithValue("@total", encabezado.Total);
            DataSet ds = null;

            using (Database db = DatabaseFactory.CreateDatabase("Default"))
            {
                ds = db.ExecuteReader(comando, "EncabezadoFactura");
            }

            return(ds);
        }
Пример #8
0
 public static void Modificar(EncabezadoFacturaEntidad encabezado)
 {
     EncabezadoFacturaDatos.Modificar(encabezado);
 }
Пример #9
0
        public static List <EncabezadoFacturaEntidad> ObtenerTodosTipoPago(DateTime fecha1, DateTime fecha2, int vTipoPago)
        {
            List <EncabezadoFacturaEntidad> lista = new List <EncabezadoFacturaEntidad>();
            DataSet ds = EncabezadoFacturaDatos.SeleccionarTodosTipoPago(fecha1, fecha2);

            foreach (DataRow fila in ds.Tables[0].Rows)
            {
                EncabezadoFacturaEntidad elemento = new EncabezadoFacturaEntidad();
                elemento.idEncabezadoFactura = Convert.ToInt16(fila["id"].ToString());
                elemento.fecha    = Convert.ToDateTime(fila["fecha"].ToString());
                elemento.IV       = Convert.ToDecimal(fila["iv"].ToString());
                elemento.Subtotal = Convert.ToDecimal(fila["subTotal"].ToString());
                elemento.Total    = Convert.ToDecimal(fila["total"].ToString());
                MontoPorTipoPagoEntidad tipoPago = new MontoPorTipoPagoEntidad();
                tipoPago.encabezadoFactura               = Convert.ToInt16(fila["id"].ToString());
                tipoPago.monto                           = Convert.ToDecimal(fila["monto"].ToString());
                tipoPago.TipoPago.idTipoPago             = Convert.ToInt16(fila["idTipoPago"].ToString());
                tipoPago.TipoPago.descripcion            = fila["descripcion"].ToString();
                elemento.miTipoPago.encabezadoFactura    = Convert.ToInt16(fila["id"].ToString());
                elemento.miTipoPago.TipoPago.idTipoPago  = Convert.ToInt16(fila["idTipoPago"].ToString());
                elemento.miTipoPago.TipoPago.descripcion = fila["descripcion"].ToString();
                elemento.miTipoPago.monto                = Convert.ToDecimal(fila["monto"].ToString());

                List <MontoPorTipoPagoEntidad> listaPagos = new List <MontoPorTipoPagoEntidad>();
                listaPagos.Add(tipoPago);
                elemento.listaFormaPago = listaPagos;

                lista.Add(elemento);
            }
            List <EncabezadoFacturaEntidad> listaTipoPago = new List <EncabezadoFacturaEntidad>();
            EncabezadoFacturaEntidad        compara       = null;

            for (int i = 0; i < lista.Count; i++)
            {
                if (compara == null)
                {
                    compara = lista[i];
                }
                else
                {
                    if (compara.idEncabezadoFactura == lista[i].idEncabezadoFactura)
                    {
                        if (vTipoPago == 2)
                        {
                            listaTipoPago.Add(lista[i]);
                            listaTipoPago.Add(compara);
                            compara = null;
                        }
                        else
                        {
                            compara = lista[i];
                        }
                    }
                    else
                    {
                        if (vTipoPago == 0)
                        {
                            if (lista[i].miTipoPago.TipoPago.idTipoPago == 1)
                            {
                                listaTipoPago.Add(lista[i]);
                            }

                            compara = lista[i];
                        }
                        else
                        {
                            if (vTipoPago == 1)
                            {
                                if (lista[i].miTipoPago.TipoPago.idTipoPago == 2)
                                {
                                    listaTipoPago.Add(lista[i]);
                                }
                            }

                            compara = lista[i];
                        }
                    }
                }

                /*if(i == lista.Count - 1)
                 * {
                 *  if(compara != null)
                 *  {
                 *      if (vTipoPago == 0)
                 *      {
                 *          if(compara.miTipoPago.TipoPago.idTipoPago == 1)
                 *          {
                 *              listaTipoPago.Add(compara);
                 *              compara = null;
                 *          }
                 *
                 *      }
                 *      if (vTipoPago == 1)
                 *      {
                 *          if (compara.miTipoPago.TipoPago.idTipoPago == 2)
                 *          {
                 *              listaTipoPago.Add(compara);
                 *              compara = null;
                 *          }
                 *      }
                 *  }
                 * }*/
            }

            return(listaTipoPago);
        }
Пример #10
0
        protected void btnFacturar_Click(object sender, EventArgs e)
        {
            int tipoPago = Convert.ToInt16(ddlTipoPago.SelectedValue);

            if (validacionPago(tipoPago))
            {
                EncabezadoPedidoEntidad pedido = (EncabezadoPedidoEntidad)Session["pedido"];
                Decimal subTotal = 0;
                Decimal iv       = 0;
                Decimal total    = 0;
                foreach (DetallePedidoEntidad item in pedido.listaDetalles)
                {
                    subTotal += item.cantidad * item.producto.precio;
                }
                iv    = subTotal * PORC_IV;
                total = iv + subTotal;


                UsuarioEntidad           usuario = pedido.usuario;
                EncabezadoFacturaEntidad factura = new EncabezadoFacturaEntidad();
                factura.encabezadoPedido          = pedido;
                factura.restaurante.idRestaurante = 1;
                factura.usuario       = usuario;
                factura.nombreCliente = this.txtNombreCliente.Text;
                factura.fecha         = DateTime.Today;

                List <MontoPorTipoPagoEntidad> listaFormaPago = new List <MontoPorTipoPagoEntidad>();

                if (tipoPago == 1)
                {
                    MontoPorTipoPagoEntidad montoPorTipoPagoEfectivo = new MontoPorTipoPagoEntidad();
                    montoPorTipoPagoEfectivo.monto = Convert.ToDecimal(txtCantidadPagadaEfectivo.Text);
                    montoPorTipoPagoEfectivo.TipoPago.idTipoPago = 1;

                    listaFormaPago.Add(montoPorTipoPagoEfectivo);
                }
                else if (tipoPago == 2)
                {
                    MontoPorTipoPagoEntidad montoPorTipoPagoTarjeta = new MontoPorTipoPagoEntidad();
                    montoPorTipoPagoTarjeta.monto = Convert.ToDecimal(txtCantidadPagadaTarjeta.Text);
                    montoPorTipoPagoTarjeta.TipoPago.idTipoPago = 2;

                    listaFormaPago.Add(montoPorTipoPagoTarjeta);
                }
                else
                {
                    MontoPorTipoPagoEntidad montoPorTipoPagoEfectivo = new MontoPorTipoPagoEntidad();
                    montoPorTipoPagoEfectivo.monto = Convert.ToDecimal(txtCantidadPagadaEfectivo.Text);
                    montoPorTipoPagoEfectivo.TipoPago.idTipoPago = 1;
                    listaFormaPago.Add(montoPorTipoPagoEfectivo);

                    MontoPorTipoPagoEntidad montoPorTipoPagoTarjeta = new MontoPorTipoPagoEntidad();
                    montoPorTipoPagoTarjeta.monto = Convert.ToDecimal(txtCantidadPagadaTarjeta.Text);
                    montoPorTipoPagoTarjeta.TipoPago.idTipoPago = 2;

                    listaFormaPago.Add(montoPorTipoPagoTarjeta);
                }

                factura.listaFormaPago = listaFormaPago;
                factura.IV             = iv;
                factura.Subtotal       = subTotal;
                factura.Total          = total;
                EncabezadoFacturaEntidad fact = EncabezadoFacturaLN.Nuevo(factura);
                factura.idEncabezadoFactura = fact.idEncabezadoFactura;
                Session.Add("factura", factura);

                actualizarEstadoMesa(1, pedido.mesa.idMesa);
                Response.Redirect("FactImprimir.aspx");
            }
        }