public ActionResult GetOrdervsGRVReport(DateTimeFromToQuery ins)
        {
            List <OrdervsGRVReport> report = reportrepo.GetOrdervsGRVReport(ins);

            StringWriter sw = new StringWriter();

            sw.WriteLine("\"Day\",\"Date\",\"Order Total\",\"Friday Total\",\"GRV Total\",\"Friday Total\"");

            string name = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();

            Response.ClearContent();
            Response.AddHeader("content-disposition", "attachment;filename=OrdervsGRV_" + name + ".csv");
            Response.ContentType = "text/csv";

            foreach (OrdervsGRVReport ex in report)
            {
                sw.WriteLine(string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\"",
                                           ex.Day
                                           , ex.Date
                                           , ex.OrderTotal
                                           , ex.FridayOrderTotal
                                           , ex.GRVTotal
                                           , ex.FridayGRVTotal));
            }

            Response.Write(sw.ToString());
            Response.End();
            return(null);
        }
        public ActionResult GetOrdersExpectedDateReport(DateTimeFromToQuery ins)
        {
            List <PinkslipOrderReport> report = reportrepo.GetOrdersPerExpectedDeliveryDate(ins);

            StringWriter sw = new StringWriter();

            sw.WriteLine("\"Pink Slip Number\",\"Order Date\",\"Order Total\"");

            string name = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();

            Response.ClearContent();
            Response.AddHeader("content-disposition", "attachment;filename=Orders_for_" + ins.From.ToShortDateString() + "_" + name + ".csv");
            Response.ContentType = "text/csv";

            foreach (PinkslipOrderReport ex in report)
            {
                sw.WriteLine(string.Format("\"{0}\",\"{1}\",\"{2}\"",
                                           ex.PinkslipNumber
                                           , ex.OrderDate
                                           , ex.OrderTotal
                                           ));
            }

            Response.Write(sw.ToString());
            Response.End();
            return(null);
        }
        public ActionResult GetCashOfficeReport(DateTimeFromToQuery ins)
        {
            List <CashOfficeReport> report = reportrepo.GetCashOfficeReport(ins);

            StringWriter sw = new StringWriter();

            sw.WriteLine("\"Money Unit\",\"Sealed\",\"Opened\",\"Notes\",\"Cashiers\",\"Total\",\"Drops\",\"Transits\","
                         + "\"Day End Balance\"");

            string name = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();

            Response.ClearContent();
            Response.AddHeader("content-disposition", "attachment;filename=Cashoffice" + "_" + name + ".csv");
            Response.ContentType = "text/csv";

            decimal notestotal   = 0;
            decimal cashiertotal = 0;
            decimal droptotal    = 0;
            decimal trasittotal  = 0;

            foreach (CashOfficeReport ex in report)
            {
                notestotal   += ex.Sealed + ex.Opened + ex.TotalInOffice;
                cashiertotal += ex.CashierTotal;
                droptotal    += ex.Drop;
                trasittotal  += 0;

                sw.WriteLine(string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\",\"{7}\",\"{8}\"",
                                           ex.MoneyUnit
                                           , ex.Sealed
                                           , ex.Opened
                                           , (ex.Sealed + ex.Opened + ex.TotalInOffice)
                                           , ex.CashierTotal
                                           , (ex.Sealed + ex.Opened + ex.TotalInOffice + ex.CashierTotal)
                                           , ex.Drop
                                           , 0
                                           , (ex.Sealed + ex.Opened + ex.TotalInOffice + ex.CashierTotal - ex.Drop - 0)
                                           ));
            }

            decimal pickuptotal = reportrepo.GetPickUpTotal(ins.From);

            sw.WriteLine(", , ,{0},{1},{2},{3},{4},{5}"
                         , notestotal, cashiertotal, (notestotal + cashiertotal), droptotal, trasittotal, (notestotal + cashiertotal - droptotal - trasittotal));

            sw.WriteLine("\" \"");
            sw.WriteLine(", , , , , , ,\"Total Pickups\",\"{0}\"", pickuptotal);
            sw.WriteLine(", , , , , , ,\"Day end Total\",\"{0}\"", (notestotal + cashiertotal - droptotal - trasittotal + pickuptotal));

            Response.Write(sw.ToString());
            Response.End();
            return(null);
        }
        public ActionResult GetSparReconReport(DateTimeFromToQuery ins)
        {
            List <SparReconReport> report = reportrepo.GetSparReconReport(ins);

            StringWriter sw = new StringWriter();

            sw.WriteLine("\"Status\",\"GRV Invoice Number\",\"Sate Date\",\"GRV Pay Date\",\"Excluding VAT\",\"Including VAT\",\"Pink Slip Number\",\"GRV Type\" "
                         + " ,\"Supplier\",\"Recon Invoice Number\",\"Recon GRV Date\", Recon Amount, Recon GRV Type");

            string name = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();

            Response.ClearContent();
            Response.AddHeader("content-disposition", "attachment;filename=SparInvoiceRecon" + "_" + name + ".csv");
            Response.ContentType = "text/csv";

            sw.WriteLine("\"GRV's not on Spar Invoice\"");

            foreach (SparReconReport ex in report)
            {
                if (ex.ReconInvoiceNumber.Equals("No GRV"))
                {
                    sw.WriteLine(string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\",\"{7}\",\"{8}\",\"{9}\",\"{10}\",\"{11}\",\"{12}\"",
                                               "No Recon"
                                               , ex.GRVInvoiceNumber
                                               , ex.StateDate
                                               , ex.GRVPayDate
                                               , ex.GRVExVAT
                                               , ex.GRVInVAT
                                               , ex.GRVPinkSlipNumber
                                               , (ex.GRVType.Equals("1")) ? "GRV" : "CLM"
                                               , ex.Supplier
                                               , ""
                                               , ""
                                               , ""
                                               , ""
                                               ));
                }
            }

            sw.WriteLine("\" \"");
            sw.WriteLine("\"Spar Invoices not in GRV List\"");

            foreach (SparReconReport ex in report)
            {
                if (ex.GRVInvoiceNumber.Equals("No Recon"))
                {
                    sw.WriteLine(string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\",\"{7}\",\"{8}\",\"{9}\",\"{10}\",\"{11}\",\"{12}\"",
                                               ex.Status
                                               , ""
                                               , ""
                                               , ""
                                               , ""
                                               , ""
                                               , ""
                                               , ""
                                               , ex.Supplier
                                               , ex.ReconInvoiceNumber
                                               , ex.ReconDate
                                               , ex.ReconAmount
                                               , (ex.ReconType.Equals("1")) ? "GRV" : "CLM"
                                               ));
                }
            }

            sw.WriteLine("\" \"");
            sw.WriteLine("\"Matched on GRV List and Spar Invoice\"");

            foreach (SparReconReport ex in report)
            {
                if ((!ex.GRVInvoiceNumber.Equals("No Recon")) && (!ex.ReconInvoiceNumber.Equals("No GRV")))
                {
                    sw.WriteLine(string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\",\"{7}\",\"{8}\",\"{9}\",\"{10}\",\"{11}\",\"{12}\"",
                                               ex.Status
                                               , ex.GRVInvoiceNumber
                                               , ex.StateDate
                                               , ex.GRVPayDate
                                               , ex.GRVExVAT
                                               , ex.GRVInVAT
                                               , ex.GRVPinkSlipNumber
                                               , (ex.GRVType.Equals("1")) ? "GRV" : "CLM"
                                               , ex.Supplier
                                               , ex.ReconInvoiceNumber
                                               , ex.ReconDate
                                               , ex.ReconAmount
                                               , (ex.ReconType.Equals("1")) ? "GRV" : "CLM"
                                               ));
                }
            }


            Response.Write(sw.ToString());
            Response.End();
            return(null);
        }