public ActionResult GeneratePDF(int quoteID)
        {
            _activeQuoteSrv.UserVM = UserVM;
            OrderViewModel orderVM = _activeQuoteSrv.GeneratePDF(quoteID);

            var pdf = new RazorPDF.PdfResult(orderVM, "../TCPViews/GeneratePDF");

            pdf.ViewBag.Title = "Report Title";
            return(pdf);
        }
示例#2
0
        public ActionResult CartDWPdfGeneration(int cartDWID)
        {
            var pdf = new RazorPDF.PdfResult();

            _shoppingCartSrv.UserVM = UserVM;
            CartDWPdfModel orderVM = _shoppingCartSrv.GetQuotePdfDetails(cartDWID);

            pdf = new RazorPDF.PdfResult(orderVM, "../TCPViews/DWCartPdfGeneration");
            pdf.ViewBag.Title = "Attachment";
            //CartDWPdfGenerationforEmail(cartDWID);
            return(pdf);
        }
示例#3
0
        public ActionResult ViewListOfItems()
        {
            int  quoteID    = Convert.ToInt32(Request.QueryString["quoteDWID"]);
            bool isPdf      = Convert.ToBoolean(Request.QueryString["isPdf"]);
            bool invoicePdf = Convert.ToBoolean(Request.QueryString["invoicePdf"]);
            bool isExcel    = Convert.ToBoolean(Request.QueryString["isExcel"]);

            if (isPdf || isExcel)
            {
                ActiveQuoteService _activeQuoteSrv = new ActiveQuoteService();
                _activeQuoteSrv.UserVM = UserVM != null ? UserVM : null;
                OrderViewModel orderVM = _activeQuoteSrv.GeneratePDF(quoteID);
                orderVM.InvoiceModel.FederalID = ConfigurationManager.AppSettings["FederalID"];
                var pdf = new RazorPDF.PdfResult(orderVM, "../TCPViews/GeneratePDF");
                if (isExcel)
                {
                    StringBuilder sb         = new StringBuilder();
                    string        headerText = string.Format(Resources.TCPResources.QuoteEmailExcelHeaderTable, ConfigurationManager.AppSettings["imgLogoPath"], string.Format("{0:d}", DateTime.Today), orderVM.QuoteID, orderVM.CustNumber, orderVM.RepoAddress.RepName, orderVM.CustomerName, orderVM.RepoAddress.RepEmail, orderVM.RepoAddress.CustFirstName + ' ' + orderVM.RepoAddress.CustLastName);
                    sb.Append(headerText);
                    sb.Append(ConvertToString(orderVM.CartListView));
                    double totalPrice = orderVM.CartListView.Sum(e => e.Price);
                    double taxPrice   = 0;
                    if (orderVM.SalesTax > 0)
                    {
                        taxPrice = (totalPrice * (double)orderVM.SalesTax);
                    }
                    string footerText = string.Format(Resources.TCPResources.QuoteEmailExcelFooterTable, String.Format("{0:C}", taxPrice + totalPrice), String.Format("{0:C}", orderVM.ShippingCharge), String.Format("{0:C}", taxPrice + totalPrice));
                    sb.Append(footerText);
                    byte[] buffer = System.Text.Encoding.UTF8.GetBytes(sb.ToString());
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + orderVM.CustNumber + "_" + orderVM.QuoteID + ".xls");
                    Response.ContentType = "application//vnd.ms-excel";
                    Response.Buffer      = true;
                    Response.Cache.SetCacheability(HttpCacheability.NoCache);
                    Response.BinaryWrite(buffer);
                    Response.End();
                    Response.Close();
                }
                else if (isPdf)
                {
                    orderVM.Type = "Export";

                    //added by faraaz
                    if (invoicePdf)
                    {
                        orderVM.Type = "invoicePdf";
                    }

                    Response.ContentType = "application/pdf";
                    if (invoicePdf)
                    {
                        Response.AddHeader("Content-Disposition", "inline;" + orderVM.CustNumber + "_" + orderVM.QuoteID + ".pdf");
                    }
                    else
                    {
                        Response.AddHeader("Content-Disposition", "attachment;" + orderVM.CustNumber + "_" + orderVM.QuoteID + ".pdf");
                    }
                }
                pdf.ViewBag.Title = "Report Title";
                return(pdf);
            }
            else
            {
                _iItemListViewService.UserVM = UserVM;
                ItemListViewModel itemVM = _iItemListViewService.GetListOfItems(Convert.ToInt32(Request.QueryString["quoteDWID"]), "", "30", 1, "");
                this.AssignUserVM(_iItemListViewService.UserVM);
                ViewData["QuoteType"]  = itemVM.QuoteType;
                ViewData["QuoteTitle"] = itemVM.QuoteTitle;
                return(View("../TCPViews/ItemListView", itemVM));
            }
        }