public ActionResult PrintReceipt(PrintReceiptViewModel viewModel, FormCollection formCollection)
        {
            string Message = string.Empty;
            bool   Success = true;

            try
            {
                ReportDataSource[] repCol = new ReportDataSource[1];
                repCol[0] = GetInstallment(_installmentRepository, viewModel.LoanAcc, viewModel.InstallmentNo);

                HttpContext.Session["ReportData"] = repCol;
                Success = true;
                Message = "redirect";
            }
            catch (Exception ex)
            {
                Success = false;
                Message = "Error :\n" + ex.GetBaseException().Message;
            }

            var e = new
            {
                Success   = Success,
                Message   = Message,
                UrlReport = string.Format("{0}", EnumReports.RptPrintInstallment.ToString())
            };

            return(Json(e, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public IActionResult PrintReceipt(int customerId)
        {
            string username = this.HttpContext.Session.GetString(SessionConstant.UserNameSession);

            if (string.IsNullOrEmpty(username))
            {
                return(RedirectToAction("Login", "Account"));
            }

            var branchName = this.HttpContext.Session.GetString(
                SessionConstant.BranchNameSession
                );
            var branchAddress = this.HttpContext.Session.GetString(
                SessionConstant.BranchAddressSession
                );
            var branchContact = this.HttpContext.Session.GetString(
                SessionConstant.BranchContactSession
                );

            if (string.IsNullOrEmpty(branchAddress) && string.IsNullOrEmpty(branchName) &&
                string.IsNullOrEmpty(branchContact))
            {
                var branchInDb = this._branchRepository.GetOne();
                branchName    = branchInDb.Name;
                branchAddress = branchInDb.Address;
                branchContact = branchInDb.Contact;
            }

            var branch = new Branch
            {
                Name    = branchName,
                Address = branchAddress,
                Contact = branchContact
            };

            var salesOrderPrint = this._salesRepository.GeTheLastSalesOrderOf(customerId);
            var payment         = this._paymentRepository.GetPaymentBySalesID(salesOrderPrint.SalesId);
            var salesDetails    = this._salesRepository.GetListSalesDetailOf(salesOrderPrint.SalesId);

            var printOrder = new PrintReceiptViewModel();

            printOrder.Branch       = branch;
            printOrder.SalesOrder   = salesOrderPrint;
            printOrder.Payment      = payment;
            printOrder.SalesDetails = salesDetails;

            return(View(printOrder));
        }
        public void LoadData()
        {
            int billId = ReportDetail.BillId;
            //Getting Receipt data
            List <PrintReceiptA4Model>   printReceiptA4Models  = new List <PrintReceiptA4Model>();
            List <PrintReceiptItemModel> printReceiptItemModel = new List <PrintReceiptItemModel>();

            //Parameter pass global Customer Order Id
            PrintReceiptViewModel printReceiptViewModel = new PrintReceiptViewModel();

            if (billId > 0)
            {
                printReceiptA4Models  = printReceiptViewModel.GetPrintReceiptA4ByBillId(billId);
                printReceiptItemModel = printReceiptViewModel.GetPrintReceiptItemA4ByBillId(billId);

                dgItemList.ItemsSource = printReceiptItemModel;

                if (printReceiptA4Models.Count > 0)
                {
                    txtClientName.Text = printReceiptA4Models[0].ClientName;
                    //= printReceiptA4Models[0].ClientAddress1;
                    // = printReceiptA4Models[0].ClientAddress2;
                    txtClientEmail.Text      = printReceiptA4Models[0].ClientEmail;
                    txtClientPIN.Text        = printReceiptA4Models[0].ClientPhone;
                    txtSupplierName.Text     = printReceiptA4Models[0].CustomerName;
                    txtSupplierEmail.Text    = printReceiptA4Models[0].CustomerEmail;
                    txtSupplierAddress1.Text = printReceiptA4Models[0].CustomerAddress1;
                    txtSupplierAddres2.Text  = printReceiptA4Models[0].CustomerAddress2;
                    //= printReceiptA4Models.CustomerPhone;
                    txtInvoiceDate.Text = printReceiptA4Models[0].BillDateTime.ToString("dd/MM/yyyy");
                    txtInvoiceNo.Text   = printReceiptA4Models[0].SalesInvoiceNumber;
                    txtVatable.Text     = printReceiptA4Models[0].VatableAmount.ToString("0.00");
                    txtNonVatable.Text  = printReceiptA4Models[0].NonVatableAmount.ToString("0.00");
                    txtVat.Text         = printReceiptA4Models[0].TaxAmount.ToString("0.00");;
                    //  txtAmountinWords.Text = commonMethods.ConvertNumbertoWords((long) printReceiptA4Models[0].TotalAmount) + " ONLY";
                    txtTotalAmount.Text = printReceiptA4Models[0].TotalAmount.ToString("0.00");
                    txtUserName.Text    = LoginDetail.Firstname + ' ' + LoginDetail.Lastname;
                    txtPrintedDate.Text = DateTime.Now.ToString("dd-MMMM-yyyy HH:mm");
                    txtHeader.Text      = "INVOICE";
                    if (printReceiptA4Models[0].SalesInvoiceNumber == "" || printReceiptA4Models[0].SalesInvoiceNumber == null)
                    {
                        txtHeader.Text = "PROFORMA INVOICE";
                    }
                }
            }
        }
        public IActionResult PrintReceipt()
        {
            int salesId    = Convert.ToInt32(this.HttpContext.Session.GetInt32(SessionConstant.SalesId));
            var branchName = this.HttpContext.Session.GetString(
                SessionConstant.BranchNameSession
                );
            var branchAddress = this.HttpContext.Session.GetString(
                SessionConstant.BranchAddressSession
                );
            var branchContact = this.HttpContext.Session.GetString(
                SessionConstant.BranchContactSession
                );

            if (string.IsNullOrEmpty(branchAddress) && string.IsNullOrEmpty(branchName) &&
                string.IsNullOrEmpty(branchContact))
            {
                var branchInDb = this._branchRepository.GetOne();
                branchName    = branchInDb.Name;
                branchAddress = branchInDb.Address;
                branchContact = branchInDb.Contact;
            }

            var salesOrder   = this._salesRepository.GetSalesOrderTermPrint(salesId);
            var payment      = this._paymentRepository.GetPaymentBySalesID(salesOrder.SalesId);
            var salesDetails = this._salesRepository.GetListSalesDetailOf(salesOrder.SalesId);

            var branch = new Branch
            {
                Name    = branchName,
                Address = branchAddress,
                Contact = branchContact
            };

            var printOrder = new PrintReceiptViewModel();

            printOrder.Branch       = branch;
            printOrder.SalesOrder   = salesOrder;
            printOrder.Payment      = payment;
            printOrder.SalesDetails = salesDetails;

            return(View(printOrder));
        }
Esempio n. 5
0
        private void FormatPage(object sender, PrintPageEventArgs e)
        {
            graphics = e.Graphics;
            Font minifont   = new Font("Arial", 5);
            Font itemfont   = new Font("Arial", 6);
            Font smallfont  = new Font("Arial", 12);
            Font mediumfont = new Font("Arial", 14);
            Font largefont  = new Font("Arial", 16);

            int Offset = 10;
            int smallinc = 10, mediuminc = 12, largeinc = 17;

            //Getting Receipt data
            List <PrintKOTItemModel> printKOTItemModels = new List <PrintKOTItemModel>();

            //Parameter pass global Customer Order Id
            PrintReceiptViewModel printReceiptViewModel = new PrintReceiptViewModel();

            List <ReportOffsetModel> reportOffsetModels = new List <ReportOffsetModel>();

            printKOTItemModels = printReceiptViewModel.GetPrintKOTItemByBillId(billId);
            reportOffsetModels = printReceiptViewModel.GetReportOffsetByReportName("R1");

            int intClientName       = reportOffsetModels.Find(x => x.ReportColumn.Contains("ClientName")).ColumnOffset;
            int intHeader           = reportOffsetModels.Find(x => x.ReportColumn.Contains("Header")).ColumnOffset;
            int intAddress1         = reportOffsetModels.Find(x => x.ReportColumn.Contains("Address1")).ColumnOffset;
            int intAddress2         = reportOffsetModels.Find(x => x.ReportColumn.Contains("Address2")).ColumnOffset;
            int intEmail            = reportOffsetModels.Find(x => x.ReportColumn.Contains("Email")).ColumnOffset;
            int intPhone            = reportOffsetModels.Find(x => x.ReportColumn.Contains("Phone")).ColumnOffset;
            int intDate             = reportOffsetModels.Find(x => x.ReportColumn.Contains("Date")).ColumnOffset;
            int intItemHeader       = reportOffsetModels.Find(x => x.ReportColumn.Contains("Item-header")).ColumnOffset;
            int intItemFoodMenuName = reportOffsetModels.Find(x => x.ReportColumn.Contains("Item-FoodMenuName")).ColumnOffset;
            int intItemFoodMenuRate = reportOffsetModels.Find(x => x.ReportColumn.Contains("Item-FoodMenuRate")).ColumnOffset;
            int intItemFoodMenuQty  = reportOffsetModels.Find(x => x.ReportColumn.Contains("Item-FoodMenuQty")).ColumnOffset;
            int intItemPrice        = reportOffsetModels.Find(x => x.ReportColumn.Contains("Item-Price")).ColumnOffset;
            int intGROSSTotal       = reportOffsetModels.Find(x => x.ReportColumn.Contains("GROSSTotal")).ColumnOffset;
            int intVATABLE          = reportOffsetModels.Find(x => x.ReportColumn.Contains("VATABLE")).ColumnOffset;
            int intDISCOUNT         = reportOffsetModels.Find(x => x.ReportColumn.Contains("DISCOUNT")).ColumnOffset;
            int intDELIVERYCharge   = reportOffsetModels.Find(x => x.ReportColumn.Contains("DELIVERYCharge")).ColumnOffset;
            int intTOTAL            = reportOffsetModels.Find(x => x.ReportColumn.Contains("TOTAL")).ColumnOffset;
            int intPaid             = reportOffsetModels.Find(x => x.ReportColumn.Contains("Paid")).ColumnOffset;
            int intFooter           = reportOffsetModels.Find(x => x.ReportColumn.Contains("Footer")).ColumnOffset;
            int intFooter1          = reportOffsetModels.Find(x => x.ReportColumn.Contains("Footer1")).ColumnOffset;
            int intFooter2          = reportOffsetModels.Find(x => x.ReportColumn.Contains("Footer2")).ColumnOffset;
            int intFooter3          = reportOffsetModels.Find(x => x.ReportColumn.Contains("Footer3")).ColumnOffset;
            int intFooter4          = reportOffsetModels.Find(x => x.ReportColumn.Contains("Footer4")).ColumnOffset;
            int intPowerBy          = reportOffsetModels.Find(x => x.ReportColumn.Contains("PowerBy")).ColumnOffset;



            //Image image = Image.FromFile("d:\\2.jpg");

            //e.Graphics.DrawImage(image, startX + 50, startY + Offset, 100, 30);
            // e.Graphics.DrawImage(image, 50, 10 + Offset, 100, 30);

            Offset = Offset + Offset;

            graphics.DrawString(LoginDetail.ClientName, smallfont, new SolidBrush(Color.Black), intClientName, Offset);//50 + 22
            //graphics.DrawString(LoginDetail.ClientName, smallfont, new SolidBrush(Color.Black), ((LoginDetail.ClientName.Length)*2), Offset);//50 + 22
            Offset = Offset + mediuminc;
            DrawAtStartCenter("KOT", Offset, intHeader);

            Offset = Offset + mediuminc;

            //Offset = Offset + mediuminc;
            //DrawAtStartCenter(LoginDetail.Header, Offset, intHeader);

            //Offset = Offset + mediuminc;
            //DrawAtStartCenter(LoginDetail.Address1, Offset, intAddress1);

            //Offset = Offset + mediuminc;
            //DrawAtStartCenter(LoginDetail.Address2, Offset, intAddress2);

            //Offset = Offset + mediuminc;
            //DrawAtStartCenter("EMAIL: " + LoginDetail.Email, Offset, intEmail);

            //Offset = Offset + mediuminc;
            //DrawAtStartCenter("PHONE : " + LoginDetail.Phone, Offset, intPhone);

            String underLine = "---------------------------------";

            DrawLine(underLine, largefont, Offset, 0);

            Offset = Offset + mediuminc + 6;
            DrawAtStart("KOT NO: " + printKOTItemModels[0].KOTNumber.ToString().PadRight((intDate - printKOTItemModels[0].KOTNumber.ToString().Length) + 23) + "DATE: " + printKOTItemModels[0].KOTDateTime.ToString("dd/MM/yyyy HH:mm"), Offset);;

            //Offset = Offset + mediuminc;
            //DrawAtStart("CUSTOMER: " + printReceiptModel[0].CustomerName, Offset);

            Offset = Offset + mediuminc;
            DrawAtStart("TYPE#: " + printKOTItemModels[0].OrderType, Offset);

            if (printKOTItemModels[0].TableName != "")
            {
                DrawAtStart("".ToString().PadRight(43) + "TABLE#: " + printKOTItemModels[0].TableName, Offset);
            }

            underLine = "---------------------------------";
            DrawLine(underLine, largefont, Offset, 0);

            Offset = Offset + largeinc;

//            InsertHeaderStyleItem("ITEM".PadRight(intItemHeader) + "              QTY", "", Offset);
            InsertHeaderStyleItem("QTY" + "           ITEM", "", Offset);

            Offset = Offset + mediuminc;

            foreach (var item in printKOTItemModels)
            {
                InsertItemList(item.FoodMenuQty.ToString("F").PadRight(15) + item.FoodMenuName.ToString(), "", Offset, intItemFoodMenuName);
                Offset = Offset + smallinc;
            }
            Offset = Offset - smallinc;

            underLine = "---------------------------------";
            DrawLine(underLine, largefont, Offset, 0);
            Offset = Offset + largeinc;

            InsertItem(LoginDetail.Lastname + " " + LoginDetail.Firstname, "", Offset);
            Offset = Offset + smallinc;

            if (LoginDetail.Powerby.Length > 0)
            {
                DrawAtStartCenter(LoginDetail.Powerby, Offset, intPowerBy);
            }
        }
Esempio n. 6
0
        private void FormatPage(object sender, PrintPageEventArgs e)
        {
            graphics = e.Graphics;
            Font minifont   = new Font("Arial", 5);
            Font itemfont   = new Font("Arial", 6);
            Font smallfont  = new Font("Arial", 12);
            Font mediumfont = new Font("Arial", 14);
            Font largefont  = new Font("Arial", 16);

            int Offset = 10;
            int smallinc = 10, mediuminc = 12, largeinc = 17;

            //Getting Receipt data
            List <PrintReceiptModel>     printReceiptModel = new List <PrintReceiptModel>();
            List <PrintReceiptItemModel> printReceiptItemModel = new List <PrintReceiptItemModel>();

            //Parameter pass global Customer Order Id
            PrintReceiptViewModel printReceiptViewModel = new PrintReceiptViewModel();

            List <ReportOffsetModel> reportOffsetModels = new List <ReportOffsetModel>();

            printReceiptModel     = printReceiptViewModel.GetPrintReceiptByBillId(billId);
            printReceiptItemModel = printReceiptViewModel.GetPrintReceiptItemByBillId(billId);
            reportOffsetModels    = printReceiptViewModel.GetReportOffsetByReportName("R1");

            int intClientName       = reportOffsetModels.Find(x => x.ReportColumn.Contains("ClientName")).ColumnOffset;
            int intHeader           = reportOffsetModels.Find(x => x.ReportColumn.Contains("Header")).ColumnOffset;
            int intAddress1         = reportOffsetModels.Find(x => x.ReportColumn.Contains("Address1")).ColumnOffset;
            int intAddress2         = reportOffsetModels.Find(x => x.ReportColumn.Contains("Address2")).ColumnOffset;
            int intEmail            = reportOffsetModels.Find(x => x.ReportColumn.Contains("Email")).ColumnOffset;
            int intPhone            = reportOffsetModels.Find(x => x.ReportColumn.Contains("Phone")).ColumnOffset;
            int intDate             = reportOffsetModels.Find(x => x.ReportColumn.Contains("Date")).ColumnOffset;
            int intItemHeader       = reportOffsetModels.Find(x => x.ReportColumn.Contains("Item-header")).ColumnOffset;
            int intItemFoodMenuName = reportOffsetModels.Find(x => x.ReportColumn.Contains("Item-FoodMenuName")).ColumnOffset;
            int intItemFoodMenuRate = reportOffsetModels.Find(x => x.ReportColumn.Contains("Item-FoodMenuRate")).ColumnOffset;
            int intItemFoodMenuQty  = reportOffsetModels.Find(x => x.ReportColumn.Contains("Item-FoodMenuQty")).ColumnOffset;
            int intItemPrice        = reportOffsetModels.Find(x => x.ReportColumn.Contains("Item-Price")).ColumnOffset;
            int intGROSSTotal       = reportOffsetModels.Find(x => x.ReportColumn.Contains("GROSSTotal")).ColumnOffset;
            int intVATABLE          = reportOffsetModels.Find(x => x.ReportColumn.Contains("VATABLE")).ColumnOffset;
            int intDISCOUNT         = reportOffsetModels.Find(x => x.ReportColumn.Contains("DISCOUNT")).ColumnOffset;
            int intDELIVERYCharge   = reportOffsetModels.Find(x => x.ReportColumn.Contains("DELIVERYCharge")).ColumnOffset;
            int intTOTAL            = reportOffsetModels.Find(x => x.ReportColumn.Contains("TOTAL")).ColumnOffset;
            int intPaid             = reportOffsetModels.Find(x => x.ReportColumn.Contains("Paid")).ColumnOffset;
            int intFooter           = reportOffsetModels.Find(x => x.ReportColumn.Contains("Footer")).ColumnOffset;
            int intFooter1          = reportOffsetModels.Find(x => x.ReportColumn.Contains("Footer1")).ColumnOffset;
            int intFooter2          = reportOffsetModels.Find(x => x.ReportColumn.Contains("Footer2")).ColumnOffset;
            int intFooter3          = reportOffsetModels.Find(x => x.ReportColumn.Contains("Footer3")).ColumnOffset;
            int intFooter4          = reportOffsetModels.Find(x => x.ReportColumn.Contains("Footer4")).ColumnOffset;
            int intPowerBy          = reportOffsetModels.Find(x => x.ReportColumn.Contains("PowerBy")).ColumnOffset;



            //Image image = Image.FromFile("d:\\2.jpg");

            //e.Graphics.DrawImage(image, startX + 50, startY + Offset, 100, 30);
            // e.Graphics.DrawImage(image, 50, 10 + Offset, 100, 30);

            Offset = Offset + Offset;

            graphics.DrawString(LoginDetail.ClientName, smallfont, new SolidBrush(Color.Black), intClientName, Offset);//50 + 22
            //graphics.DrawString(LoginDetail.ClientName, smallfont, new SolidBrush(Color.Black), ((LoginDetail.ClientName.Length)*2), Offset);//50 + 22

            Offset = Offset + mediuminc;
            DrawAtStartCenter(LoginDetail.Header, Offset, intHeader);

            Offset = Offset + mediuminc;
            DrawAtStartCenter(LoginDetail.Address1, Offset, intAddress1);

            Offset = Offset + mediuminc;
            DrawAtStartCenter(LoginDetail.Address2, Offset, intAddress2);

            Offset = Offset + mediuminc;
            DrawAtStartCenter("EMAIL: " + LoginDetail.Email, Offset, intEmail);

            Offset = Offset + mediuminc;
            DrawAtStartCenter("PHONE : " + LoginDetail.Phone, Offset, intPhone);

            String underLine = "---------------------------------";

            DrawLine(underLine, largefont, Offset, 0);

            Offset = Offset + mediuminc + 6;
            DrawAtStart("RECEIPT NO: " + printReceiptModel[0].SalesInvoiceNumber.ToString().PadRight((intDate - printReceiptModel[0].SalesInvoiceNumber.ToString().Length) + 8) + "DATE: " + printReceiptModel[0].BillDateTime.ToString("dd/MM/yyyy HH:mm"), Offset);;

            Offset = Offset + mediuminc;
            DrawAtStart("CUSTOMER: " + printReceiptModel[0].CustomerName, Offset);

            underLine = "---------------------------------";
            DrawLine(underLine, largefont, Offset, 0);

            Offset = Offset + largeinc;

            InsertHeaderStyleItem("ITEM".PadRight(intItemHeader) + "RATE          AMOUNT ", "", Offset);

            Offset = Offset + mediuminc;

            foreach (var item in printReceiptItemModel)
            {
                InsertItemList(item.FoodMenuName.ToString(), "", Offset, intItemFoodMenuName);
                Offset = Offset + smallinc;
                InsertItemList(item.FoodMenuQty.ToString("F") + " " + item.Unitname, "", Offset, intItemFoodMenuQty + (50 - (item.FoodMenuQty.ToString().Length * 4)));
                InsertItemList(item.FoodMenuRate.ToString("F"), "", Offset, intItemFoodMenuRate + (50 - (item.FoodMenuRate.ToString().Length * 4)));
                InsertItemList(item.Price.ToString("F") + " " + item.FoodVat.ToString(), "", Offset, intItemPrice + (50 - (item.Price.ToString().Length * 4)));
                Offset = Offset + smallinc;
            }
            Offset = Offset - smallinc;

            underLine = "---------------------------------";
            DrawLine(underLine, largefont, Offset, 0);

            Offset = Offset + largeinc;
            InsertItem("GROSS TOTAL: ", "", Offset);
            InsertItem(printReceiptModel[0].GrossAmount.ToString("F").PadLeft(intGROSSTotal - printReceiptModel[0].GrossAmount.ToString("F").Length), "", Offset);

            Offset = Offset + smallinc;
            InsertItem("VATABLE: ", "", Offset);
            InsertItem(printReceiptModel[0].VatableAmount.ToString("F").PadLeft(intVATABLE - printReceiptModel[0].VatableAmount.ToString("F").Length), "", Offset);

            Offset = Offset + smallinc;
            InsertItem("VAT: ", "", Offset);
            InsertItem(printReceiptModel[0].TaxAmount.ToString("F").PadLeft(intVATABLE - printReceiptModel[0].TaxAmount.ToString("F").Length), "", Offset);

            Offset = Offset + smallinc;
            InsertItem("Non VAT: ", "", Offset);
            InsertItem(printReceiptModel[0].NonVatableAmount.ToString("F").PadLeft(intVATABLE - printReceiptModel[0].NonVatableAmount.ToString("F").Length), "", Offset);

            if (printReceiptModel[0].Discount.ToString("F") != "0.00")
            {
                Offset = Offset + smallinc;
                InsertItem("DISCOUNT/REDEEM: ", "", Offset);
                InsertItem(printReceiptModel[0].Discount.ToString("F").PadLeft(intVATABLE - printReceiptModel[0].Discount.ToString("F").Length), "", Offset);
            }

            if (printReceiptModel[0].ServiceCharge.ToString("F") != "0.00")
            {
                Offset = Offset + smallinc;
                InsertItem("DELIVERY CHARGE: ", printReceiptModel[0].ServiceCharge.ToString("F").PadLeft(intDELIVERYCharge - printReceiptModel[0].ServiceCharge.ToString("F").Length), Offset);
            }

            Offset = Offset + smallinc;
            InsertItem("TOTAL: ", "", Offset);
            InsertItem(printReceiptModel[0].TotalAmount.ToString("F").PadLeft(intTOTAL - printReceiptModel[0].TotalAmount.ToString("F").Length), "", Offset);

            underLine = "---------------------------------";
            DrawLine(underLine, largefont, Offset, 0);


            decimal dcLevy;

            dcLevy = ((Convert.ToDecimal(printReceiptModel[0].VatableAmount) + Convert.ToDecimal(printReceiptModel[0].NonVatableAmount)) * 2) / 100;

            Offset = Offset + largeinc;
            InsertItem("CATERING LEVY: ", "", Offset);
            InsertItem(dcLevy.ToString("F").PadLeft(intTOTAL - dcLevy.ToString("F").Length), "", Offset);

            underLine = "---------------------------------";
            DrawLine(underLine, largefont, Offset, 0);

            Offset = Offset + largeinc;

            InsertItem(LoginDetail.Lastname + " " + LoginDetail.Firstname, "", Offset);
            Offset = Offset + smallinc;

            InsertItem("PAID BY: ", "", Offset);
            Offset = Offset + smallinc;

            foreach (PrintReceiptModel payment in printReceiptModel)
            {
                InsertItem(payment.PaymentMethodName, payment.BillAmount.ToString("F").PadLeft(intPaid - payment.BillAmount.ToString("F").Length), Offset);
                Offset = Offset + smallinc;
            }

            if (printReceiptModel[0].RewardAmount != 0)
            {
                underLine = "---------------------------------";
                DrawLine(underLine, largefont, Offset, 0);

                Offset = Offset + largeinc;

                InsertItem("YOU EARN " + printReceiptModel[0].RewardAmount + " POINTS", "", Offset);
                Offset = Offset + smallinc;
            }

            Offset = Offset + largeinc;
            Offset = Offset + largeinc;

            // graphics.DrawString(LoginDetail.Footer, smallfont, new SolidBrush(Color.Black), intFooter, Offset);//50 + 22
            DrawAtStartCenter(LoginDetail.Footer, Offset, intFooter);

            Offset = Offset + largeinc;

            DrawAtStartCenter(LoginDetail.Footer1, Offset, intFooter1);
            Offset = Offset + mediuminc;

            DrawAtStartCenter(LoginDetail.Footer2, Offset, intFooter2);
            Offset = Offset + mediuminc;

            DrawAtStartCenter(LoginDetail.Footer3, Offset, intFooter3);
            Offset = Offset + mediuminc;

            DrawAtStartCenter(LoginDetail.Footer4, Offset, intFooter4);
            Offset = Offset + mediuminc;
            Offset = Offset + mediuminc;

            if (LoginDetail.Powerby.Length > 0)
            {
                DrawAtStartCenter(LoginDetail.Powerby, Offset, intPowerBy);
            }
        }
Esempio n. 7
0
        public void LoadData()
        {
            int billId = ReportDetail.BillId;
            //Getting Receipt data
            List <PrintReceiptA4Model>   printReceiptA4Models  = new List <PrintReceiptA4Model>();
            List <PrintReceiptItemModel> printReceiptItemModel = new List <PrintReceiptItemModel>();

            //Parameter pass global Customer Order Id
            PrintReceiptViewModel printReceiptViewModel = new PrintReceiptViewModel();

            if (billId > 0)
            {
                printReceiptA4Models  = printReceiptViewModel.GetPrintReceiptA4ByBillId(billId);
                printReceiptItemModel = printReceiptViewModel.GetPrintReceiptItemA4ByBillId(billId);

                dgItemList.ItemsSource = printReceiptItemModel;

                if (printReceiptA4Models.Count > 0)
                {
                    txtClientName.Text = printReceiptA4Models[0].ClientName;
                    //= printReceiptA4Models[0].ClientAddress1;
                    // = printReceiptA4Models[0].ClientAddress2;
                    txtClientEmail.Text = printReceiptA4Models[0].ClientEmail;
                    txtClientPIN.Text   = printReceiptA4Models[0].ClientPhone;
                    txtAddress1.Text    = printReceiptA4Models[0].ClientAddress1;
                    TxtAddress2.Text    = printReceiptA4Models[0].ClientAddress2;

                    txtSupplierName.Text     = printReceiptA4Models[0].CustomerName;
                    txtSupplierAddress1.Text = printReceiptA4Models[0].CustomerAddress1;
                    txtSupplierAddres2.Text  = printReceiptA4Models[0].CustomerAddress2;
                    txtSupplierEmail.Text    = printReceiptA4Models[0].CustomerEmail;
                    txtSupplierPhone.Text    = printReceiptA4Models[0].CustomerPhone;

                    //= printReceiptA4Models.CustomerPhone;
                    txtInvoiceDate.Text = printReceiptA4Models[0].BillDateTime.ToString("dd/MM/yyyy");
                    txtInvoiceNo.Text   = printReceiptA4Models[0].SalesInvoiceNumber;
                    txtVatable.Text     = printReceiptA4Models[0].VatableAmount.ToString("0.00");
                    txtNonVatable.Text  = printReceiptA4Models[0].NonVatableAmount.ToString("0.00");
                    txtVat.Text         = printReceiptA4Models[0].TaxAmount.ToString("0.00");;
                    //  txtAmountinWords.Text = commonMethods.ConvertNumbertoWords((long) printReceiptA4Models[0].TotalAmount) + " ONLY";
                    txtTotalAmount.Text = printReceiptA4Models[0].TotalAmount.ToString("0.00");
                    txtUserName.Text    = LoginDetail.Firstname + ' ' + LoginDetail.Lastname;
                    txtPrintedDate.Text = DateTime.Now.ToString("dd-MMMM-yyyy HH:mm");
                    txtHeader.Text      = "INVOICE";
                    if (printReceiptA4Models[0].SalesInvoiceNumber == "" || printReceiptA4Models[0].SalesInvoiceNumber == null)
                    {
                        txtHeader.Text = "PROFORMA INVOICE";
                    }

                    string strInvoiceTerms = LoginDetail.InvoiceTerms;

                    string[] strSplit = strInvoiceTerms.Split("\r\n");
                    strInvoiceTerms = "";

                    for (int i = 0; i < strSplit.Length; i++)
                    {
                        strInvoiceTerms = strInvoiceTerms + strSplit[i] + Environment.NewLine;
                    }
                    txtTerms.Text = strInvoiceTerms;

                    AppSettings appSettings = new AppSettings();

                    string rootPath = appSettings.GetAppPath();

                    string directory = System.IO.Path.GetDirectoryName(rootPath + @"\Images\");
                    string filePath  = System.IO.Path.Combine(directory, "CompanyLogo.jpg");

                    BitmapImage bitmap = new BitmapImage();
                    bitmap.BeginInit();
                    bitmap.UriSource = new Uri(filePath);
                    bitmap.EndInit();

                    imgLogo.Source = bitmap;
                }
            }
        }
        public ActionResult PrintReceipt()
        {
            PrintReceiptViewModel viewModel = PrintReceiptViewModel.Create();

            return(View(viewModel));
        }
        private FlowDocument PrintA4(int billId)
        {
            //Getting Receipt data
            List <PrintReceiptA4Model>   printReceiptModel     = new List <PrintReceiptA4Model>();
            List <PrintReceiptItemModel> printReceiptItemModel = new List <PrintReceiptItemModel>();

            //Parameter pass global Customer Order Id
            PrintReceiptViewModel printReceiptViewModel = new PrintReceiptViewModel();

            printReceiptModel     = printReceiptViewModel.GetPrintReceiptA4ByBillId(billId);
            printReceiptItemModel = printReceiptViewModel.GetPrintReceiptItemA4ByBillId(billId);

            var document = new FlowDocument();

            document.PagePadding = new Thickness(20, 20, 20, 20);
            document.PageWidth   = 210;
            document.PageHeight  = 297;
            document.ColumnWidth = 999999;
            var section = new Section();

            section.LineHeight = Double.NaN;

            var pReportTitle = new Paragraph();

            pReportTitle.Inlines.Add(new Run(ReportDetail.ReportTitle));
            pReportTitle.LineHeight = Double.NaN;
            pReportTitle.FontSize   = 24;
            document.Blocks.Add(pReportTitle);

            var pHeader = new Paragraph();

            pHeader.Inlines.Add(new Run(LoginDetail.ClientName + "\n" + LoginDetail.Address1 + "\n" + LoginDetail.Address2));
            pHeader.LineHeight = Double.NaN;
            document.Blocks.Add(pHeader);

            document.Blocks.Add(new BlockUIContainer(new Separator()));
            var pParameter = new Paragraph();

            pParameter.Inlines.Add(new Run("From Date: " + ReportDetail.ReportFromDate + "         fsdfsfsfsfsfsdfsdfsdsdf sfsd sdf sdfsdfsdfs 111sdfs fdsdfsdfsdf222s3d sdf sdfsdfsd       33           To Date: " + ReportDetail.ReportToDate));
            pParameter.LineHeight = Double.NaN;
            document.Blocks.Add(pParameter);

            document.ColumnGap = 0;

            //Table A
            var tableA = new Table();

            tableA.CellSpacing     = 0;
            tableA.BorderThickness = new Thickness(1);
            tableA.BorderBrush     = Brushes.Black;
            var supplierColumn = new TableColumn();

            supplierColumn.Width = new GridLength(375);
            var invoiceNoColumn = new TableColumn();

            invoiceNoColumn.Width = new GridLength(188);
            var invoiceDate = new TableColumn();

            invoiceDate.Width = new GridLength(188);


            tableA.Columns.Add(supplierColumn);
            tableA.Columns.Add(invoiceNoColumn);
            tableA.Columns.Add(invoiceDate);

            var rowGroupA = new TableRowGroup();
            var itemRowA  = new TableRow();
            var tcell     = new TableCell();
            var para      = new Paragraph();

            tcell.BorderThickness = new Thickness(2);

            para = new Paragraph();
            para.Inlines.Add(new Run(""));
            tcell.Blocks.Add(para);


            //Assuming your data item has Quantity, Price and Text
            itemRowA.Cells.Add(new TableCell(new Paragraph(new Run("FoodMenuQty"))));
            itemRowA.Cells.Add(new TableCell(new Paragraph(new Run("Rate"))));
            itemRowA.Cells.Add(new TableCell(new Paragraph(new Run("Total"))));

            // TableCell a =new

            //rowGroupA.Rows.Add(itemRowA);
            //  tableA.RowGroups.Add(rowGroupA);
            //  document.Blocks.Add(tableA);
            //End Table A

            //            var table = new Table();
            //            table.CellSpacing = 0;

            //            var quantityColumn = new TableColumn();
            //            quantityColumn.Width = new GridLength(80);
            //            var priceColumn = new TableColumn();
            //            priceColumn.Width = new GridLength(80);
            //            var textColumn = new TableColumn();
            //            textColumn.Width = new GridLength(597);

            //            table.Columns.Add(quantityColumn);
            //            table.Columns.Add(priceColumn);
            //            table.Columns.Add(textColumn);

            //             var rowGroup = new TableRowGroup();
            //            var itemRow1 = new TableRow();

            //            //Assuming your data item has Quantity, Price and Text
            //            itemRow1.Cells.Add(new TableCell(new Paragraph(new Run("FoodMenuQty"))));
            //            itemRow1.Cells.Add(new TableCell(new Paragraph(new Run("Rate"))));
            //            itemRow1.Cells.Add(new TableCell(new Paragraph(new Run("Total"))));

            //            rowGroup.Rows.Add(itemRow1);
            ////            document.Blocks.Add(table);

            //            foreach (var item in printReceiptItemModel)
            //            {
            //                //Add your data
            //                var itemRow = new TableRow();

            //                //Assuming your data item has Quantity, Price and Text
            //                itemRow.Cells.Add(new TableCell(new Paragraph(new Run(item.FoodMenuQty.ToString()))));
            //                itemRow.Cells.Add(new TableCell(new Paragraph(new Run(item.FoodMenuRate.ToString()))));
            //                itemRow.Cells.Add(new TableCell(new Paragraph(new Run(item.Price.ToString()))));

            //                rowGroup.Rows.Add(itemRow);
            //                //Etc.
            //            }

            //            table.RowGroups.Add(rowGroup);

            //            table.BorderThickness = new Thickness(1);
            //            table.BorderBrush = Brushes.Black;


            //            document.Blocks.Add(table);


            //FlowDocument flowDocument = new FlowDocument();


            return(document);
        }
Esempio n. 10
0
        private void FormatPage(object sender, PrintPageEventArgs e)
        {
            graphics = e.Graphics;
            Font minifont = new Font("Arial", 5);
            Font itemfont = new Font("Arial", 6);
            Font smallfont = new Font("Arial", 8);
            Font mediumfont = new Font("Arial", 10);
            Font largefont = new Font("Arial", 12);
            int  Offset = 10;
            int  smallinc = 10, mediuminc = 12, largeinc = 15;

            //Getting Receipt data
            List <PrintReceiptModel>     printReceiptModel     = new List <PrintReceiptModel>();
            List <PrintReceiptItemModel> printReceiptItemModel = new List <PrintReceiptItemModel>();

            //Parameter pass global Customer Order Id
            PrintReceiptViewModel printReceiptViewModel        = new PrintReceiptViewModel();

            printReceiptModel     = printReceiptViewModel.GetPrintReceiptByBillId(billId);
            printReceiptItemModel = printReceiptViewModel.GetPrintReceiptItemByBillId(billId);

            //Image image = Image.FromFile("d:\\2.jpg");

            //e.Graphics.DrawImage(image, startX + 50, startY + Offset, 100, 30);
            // e.Graphics.DrawImage(image, 50, 10 + Offset, 100, 30);

            Offset = Offset + Offset;

            //Name
            int intPadding = 10 + ((pageWidthHeader - LoginDetail.ClientName.Length) / 2) * 3;

            graphics.DrawString(LoginDetail.ClientName, smallfont, new SolidBrush(Color.Black), intPadding, Offset);//50 + 22

            Offset = Offset + mediuminc;
            DrawAtStartCenter(LoginDetail.Header, Offset);

            Offset = Offset + mediuminc;
            DrawAtStartCenter(LoginDetail.Address1, Offset);

            Offset = Offset + mediuminc;
            DrawAtStartCenter(LoginDetail.Address2, Offset);

            Offset = Offset + mediuminc;
            DrawAtStartCenter("Email : " + LoginDetail.Email, Offset);

            Offset = Offset + mediuminc;
            DrawAtStartCenter("Phone : " + LoginDetail.Phone, Offset);

            String underLine = "-------------------------------------";

            DrawLine(underLine, largefont, Offset, 0);

            Offset = Offset + mediuminc;
            DrawAtStart("Receipt Number: " + printReceiptModel[0].SalesInvoiceNumber.ToString().PadRight((20 - printReceiptModel[0].SalesInvoiceNumber.ToString().Length) + 10) + "Date: " + DateTime.Now.ToString("MM/dd/yyyy HH:mm"), Offset);;

            Offset = Offset + mediuminc;
            DrawAtStart("Customer: " + printReceiptModel[0].CustomerName, Offset);

            underLine = "-------------------------------------";
            DrawLine(underLine, largefont, Offset, 0);

            Offset = Offset + largeinc;

            InsertHeaderStyleItem("ITEM                                RATE     QTY    AMOUNT ", "", Offset);

            Offset = Offset + largeinc;

            foreach (var item in printReceiptItemModel)
            {
                InsertItemList(item.FoodMenuName.ToString(), "", Offset, 5);
                InsertItemList(item.FoodMenuRate.ToString("F"), "", Offset, 60 + (50 - (item.FoodMenuRate.ToString().Length * 4)));
                InsertItemList(item.FoodMenuQty.ToString("F"), "", Offset, 90 + (50 - (item.FoodMenuQty.ToString().Length * 4)));
                InsertItemList(item.Price.ToString("F"), "", Offset, 133 + (50 - (item.Price.ToString().Length * 4)));

                // InsertItem(item.FoodMenuName.ToString().PadRight((55- (item.FoodMenuName.ToString().Length)))  + "x " +   item.FoodMenuRate.ToString("F").PadRight((25 - (item.FoodMenuRate.ToString().Length))) + item.Price.ToString("F"), "", Offset);

                Offset = Offset + smallinc;
            }
            Offset = Offset - smallinc;

            underLine = "-------------------------------------";
            DrawLine(underLine, largefont, Offset, 0);

            Offset = Offset + largeinc;
            InsertItem("GROSS TOTAL: ", printReceiptModel[0].GrossAmount.ToString("F").PadLeft(30 - printReceiptModel[0].GrossAmount.ToString().Length), Offset);

            Offset = Offset + smallinc;
            InsertItem("DISCOUNT : ", printReceiptModel[0].Discount.ToString("F").PadLeft(30 - printReceiptModel[0].Discount.ToString().Length), Offset);

            Offset = Offset + smallinc;
            InsertItem("VATABLE: ", printReceiptModel[0].VatableAmount.ToString("F").PadLeft(30 - printReceiptModel[0].VatableAmount.ToString().Length), Offset);

            Offset = Offset + smallinc;
            InsertItem("SER CRH: ", printReceiptModel[0].ServiceCharge.ToString("F").PadLeft(30 - printReceiptModel[0].ServiceCharge.ToString().Length), Offset);

            Offset = Offset + smallinc;
            InsertItem("TOTAL: ", printReceiptModel[0].TotalAmount.ToString("F").PadLeft(30 - printReceiptModel[0].TotalAmount.ToString().Length), Offset);


            underLine = "-------------------------------------";
            DrawLine(underLine, largefont, Offset, 0);

            Offset = Offset + largeinc;
            InsertItem("TOTAL: ", printReceiptModel[0].PaymentMethodName.ToString().PadRight(10) + " " + printReceiptModel[0].BillAmount.ToString("F").PadLeft(10), Offset);

            Offset = Offset + largeinc;
            Offset = Offset + largeinc;

            intPadding = 10 + ((pageWidthHeader - LoginDetail.ClientName.Length) / 2) * 3;
            graphics.DrawString(LoginDetail.Footer, smallfont, new SolidBrush(Color.Black), intPadding, Offset);//50 + 22

            Offset = Offset + largeinc;

            DrawAtStartCenter(LoginDetail.Footer1, Offset);
            Offset = Offset + mediuminc;

            DrawAtStartCenter(LoginDetail.Footer2, Offset);
            Offset = Offset + mediuminc;

            DrawAtStartCenter(LoginDetail.Footer3, Offset);
            Offset = Offset + mediuminc;

            DrawAtStartCenter(LoginDetail.Footer4, Offset);
            Offset = Offset + mediuminc;


            //DrawAtStart(LoginDetail.Footer1, Offset);

            //Offset = Offset + mediuminc;
            //DrawAtStart(LoginDetail.Footer2, Offset);

            //Offset = Offset + mediuminc;
            //DrawAtStart(LoginDetail.Footer3, Offset);

            //Offset = Offset + mediuminc;
            //DrawAtStart(LoginDetail.Footer4, Offset);

            //Offset = Offset + 7;
            //underLine = "-------------------------------------";
            //DrawLine(underLine, largefont, Offset, 0);

            //Offset = Offset + mediuminc;
            //String greetings = "Thanks for visiting us.";
            //DrawSimpleString(greetings, mediumfont, Offset, 28);

            //Offset = Offset + mediuminc;
            //underLine = "-------------------------------------";
            //DrawLine(underLine, largefont, Offset, 0);

            //Offset += (2 * mediuminc);
            //string tip = "TIP: -----------------------------";
            //InsertItem(tip, "", Offset);

            //Offset = Offset + largeinc;
            //string DrawnBy = "Meganos Softwares: 0312-0459491 - OR - 0321-6228321";
            //DrawSimpleString(DrawnBy, minifont, Offset, 15);
        }