Exemplo n.º 1
0
        static void Main(string[] args)
        {
            using (var facade = new Facade())
            {

                //var category = facade.AddCategory("test");

                //var product = facade.AddProduct(category.Id, 30, "test1");

                //var sale = facade.CreateOTCSale(new Guid("80a94d23-780e-4fa6-a907-2a83373388a3"), new Guid("376b44b3-2235-4bf8-b560-ed085692b30d"),new Guid("8511fbff-63d8-411b-aa62-3696fb7d7a70"));
                //var sli = facade.AddSaleLineItem(new Guid("80a94d23-780e-4fa6-a907-2a83373388a3"), new Guid("376b44b3-2235-4bf8-b560-ed085692b30d"),sale.Id, new Guid("82fc4620-68c4-4084-b2ec-6629be19caeb"));
                //Console.ReadKey();
            }
        }
Exemplo n.º 2
0
        private void btnXRead_Click(object sender, EventArgs e)
        {
            var facade = new Facade();
            ArrayList source = new ArrayList();
            var register = facade.Restaurant.Areas.SelectMany(a => a.Registers);
            var people = from p in facade.People select new { Id = p.Id, FirstName = p.FirstName, LastName = p.LastName };

            var sales = facade.Restaurant.Areas.SelectMany(a => a.Registers.SelectMany(r => r.Sales)).ToList();
            var salesTotal = sales.Sum(s => s.SaleTotal);
            var gst = sales.Sum(s => s.GSTTotal);

            var cashPayments = sales.SelectMany(s => s.Payments.Where(p => p.PaymentType.Equals(PaymentType.Cash))).ToList();
            var cashTotal = cashPayments.Sum(p => p.Sale.SaleTotal);
            var eftposPayments = sales.SelectMany(s => s.Payments.Where(p => p.PaymentType.Equals(PaymentType.Eftpos))).ToList();
            var eftposTotal = eftposPayments.Sum(p => p.Sale.SaleTotal);

            foreach (var s in sales)
            {
                source.Add(new
                {
                    RegisterName = register.First().Name,
                    SaleNumber = sales.Count,
                    SaleTotal = salesTotal,
                    GstTotal = gst,
                    CashCount = cashPayments.Count,
                    CashTotal = cashTotal,
                    EftposCount = eftposPayments.Count,
                    EftposTotal = eftposTotal,
                    UserFirstName = s.UserAccount.ToString(),
                    UserSalesTotal = sales.Sum(sum => sales.Where(u => u.UserId.Equals(sum.UserAccount.Id)).FirstOrDefault().SaleTotal)
                });
            }
            var report = new XReadReport();
            report.SetDataSource(source);

            crystalReportViewer1.ReportSource = report;
            ConnectReporter();
            crystalReportViewer1.RefreshReport();
        }
Exemplo n.º 3
0
        public Form1()
        {
            var facade = new Facade();

            var register = from reg in facade.Restaurant.Areas.SelectMany(a => a.Registers)
                           select new { Name = reg.Name };

            var people = from ppl in facade.People select new { FirstName = ppl.FirstName, LastName = ppl.LastName };

            var payment = from pay in facade.Restaurant.Areas.SelectMany(a => a.Registers.SelectMany(r => r.Sales.SelectMany(p => p.Payments)))
                          select new { SaleId = pay.SaleId, Amount = pay.Amount };

            var report = new CrystalReport1();
            ArrayList records = new ArrayList();
            records.Add(register);
            records.Add(people);
            records.Add(payment);
            report.SetDataSource(records);

            crystalReportViewer1.ReportSource = report;
            crystalReportViewer1.RefreshReport();
        }
Exemplo n.º 4
0
        private void PrintReceipt()
        {
            var facade = new Facade();
            ArrayList source = new ArrayList();
            var register = facade.Restaurant.Areas.SelectMany(a => a.Registers);
            var sale = (Controller as PaymentViewController).MainTask.Sale as ISale;
            var saleLineItems = sale.SaleLineItems;

            var categories = facade.Categories;
            var products = categories.SelectMany(p => p.Products);

            foreach (var sli in saleLineItems)
            {
                source.Add(new
                {
                    RegisterName = register.First().Name,
                    UserFirstName = sale.UserAccount.ToString(),
                    SaleId = sale.Id,
                    ProductDescription = products.Where(p => p.Id.Equals(sli.MenuProduct.ProductId)).FirstOrDefault().Description,
                    Quantity = sli.Quantity,
                    ProductPrice = sli.Total,
                    GstTotal = sale.GSTTotal,
                    SaleTotal = sale.SaleTotal,
                });
            }

            var report = new SalesReport();
            report.SetDataSource(source);

            crystalReportViewer1.ReportSource = report;
            ConnectReporter();
            crystalReportViewer1.RefreshReport();
            report.PrintToPrinter(1, false, 1, 1);
        }