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";
                    }
                }
            }
        }
Esempio n. 2
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;
                }
            }
        }
        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);
        }