Пример #1
0
        public static string CombinedInvoice(int invoice, string dataFolder)
        {
            var objInvoice           = DB.Invoice(invoice);
            var jkinvoicesummarypath = string.Empty;

            jkinvoicesummarypath = dataFolder + @"Data\Invoices\" + "JKCombineInvoice_" + objInvoice.ID.ToString() + "_" + ".pdf";
            try
            {
                if (File.Exists(jkinvoicesummarypath))
                {
                    File.Delete(jkinvoicesummarypath);
                }

                var lstfilespath = new List <string>();

                var invoicedetailpath = GenerateJKInvoiceDetail(invoice, dataFolder);
                lstfilespath.Add(invoicedetailpath);
                var invoicesummarypath = GenerateJKInvoiceSummary(invoice, dataFolder);
                lstfilespath.Add(invoicesummarypath);
                CombineAndSavePdf(jkinvoicesummarypath, lstfilespath);
            }
            catch (Exception)
            {
                //IndicoLogging.log.Error("Error occured while creating combined invoice from GenerateOdsPdf", ex);
            }
            return(jkinvoicesummarypath);
        }
Пример #2
0
        protected void OnShipmentKeyComboBoxSelectionChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            var index = RadComboShipmentKey.SelectedIndex;

            if (index < 0)
            {
                return;
            }

            var selectedModel = ShipmentKeys[index];

            if (selectedModel == null)
            {
                return;
            }
            var selectedItem = RadComboShipmentKey.SelectedItem;

            if (selectedItem == null)
            {
                return;
            }

            EnableOrDisableInvoiceInformationControls(true);
            LoadBillToAndShipTo();
            LoadBanks();
            LoadShipmentModes();
            LoadStatus();
            LoadPorts();

            var weeklyCapacityId = int.Parse(WeekComboBox.SelectedItem.Value);
            var obj = new WeeklyProductionCapacityBO {
                ID = weeklyCapacityId
            };

            obj.GetObject();

            int invoiceId;
            var invoices = DB.Invoice(weeklyCapacityId, selectedModel.ShipToID, selectedModel.ShipmentDate.GetSQLDateString());

            if (invoices.Count == 0)
            {
                invoiceId = DB.CreateInvoice(weeklyCapacityId, selectedModel.ShipToID, selectedModel.PortID, obj.WeekendDate.Year + obj.WeekendDate.Month.ToString().PadLeft(2, '0') + obj.WeekendDate.Day.ToString().PadLeft(2, '0'),
                                             selectedModel.ShipmentDate.GetSQLDateString(), selectedModel.PriceTermID, selectedModel.ShipmentModeID, LoggedUser.ID);
            }
            else
            {
                invoiceId = invoices[0].ID;
            }
            if (invoiceId != 0)
            {
                btnCreateInvoice.Visible = true;
                dvNewContent.Visible     = true;
                CostSheetButton.Visible  = true;
                ItemsPanel.Visible       = true;
                LoadInvoiceItems(invoiceId);
            }
        }
Пример #3
0
        private void InitializeUserInterfaceForExistingInvoice()
        {
            var invoice = DB.Invoice(CurrentInvoiceId);

            WeekComboBox.Enabled = false;
            txtShipmentDate.Text = invoice.ShipmentDate.ToString("dd MMMM yyyy");
            DisableControl(RadComboShipmentKey);
            txtInvoiceNo.Text   = invoice.InvoiceNo;
            txtInvoiceDate.Text = invoice.InvoiceDate.ToString("dd MMMM yyyy");
            txtAwbNo.Text       = invoice.AWBNo;
            ShipmentKeyDropDownPannel.Visible = false;
            ShipmentKeyDropDownPannel.Visible = false;
            ShipmentKeyPannel.Visible         = true;

            if (CurrentInvoiceType == InvoiceType.Indiman)
            {
                txtIndimanInvoiceNo.Text   = invoice.IndimanInvoiceNo;
                txtInvoiceNo.Enabled       = false;
                txtIndimanInvoiceDate.Text = DateTime.Now.ToString("dd MMMM yyyy");
                txtInvoiceDate.Enabled     = false;
            }

            LoadBillToAndShipTo();
            LoadBanks();
            LoadShipmentModes();
            GetShipmentkey(invoice.ShipTo.Value, invoice.ShipmentMode, invoice.Port, invoice.ShipmentDate, invoice.PriceTerm, invoice.WeeklyProductionCapacity);
            GetWeek(invoice.WeeklyProductionCapacity, DateTime.Now.Year);
            LoadStatus();
            LoadPorts();
            //*SDS LoadItems(invoice.ID);

            btnCreateInvoice.Visible = true;
            dvNewContent.Visible     = true;
            CostSheetButton.Visible  = true;
            ItemsPanel.Visible       = true;
            LoadInvoiceItems(invoice.ID);


            //RadComboShipmentKey.Items.FindItemByValue(DB.ShipmentKeys).Selected = true;
            ShipToDropDownList.Items.FindByValue(invoice.ShipTo.ToString()).Selected             = true;
            BillToDropDownList.Items.FindByValue(invoice.BillTo.ToString()).Selected             = true;
            BankDropDownList.Items.FindByValue(invoice.Bank.ToString()).Selected                 = true;
            ShipmentModeDropDownList.Items.FindByValue(invoice.ShipmentMode.ToString()).Selected = true;
            StatusDropDownList.Items.FindByValue(invoice.Status.ToString()).Selected             = true;
        }
Пример #4
0
        public static string GenerateIndimanInvoice(int invoice, string dataFolder)
        {
            //InvoiceBO objInvoice = new InvoiceBO();
            //objInvoice.ID = invoice;
            //objInvoice.GetObject();

            var temppath = string.Empty;


            var objInvoice = DB.Invoice(invoice);

            var document = new Document();

            try
            {
                temppath = dataFolder + @"Data\Invoices\" + "IndimanInvoiceDetail_" + objInvoice.ID + "_" + ".pdf";

                if (File.Exists(temppath))
                {
                    File.Delete(temppath);
                }

                var writer = PdfWriter.GetInstance(document, new FileStream(temppath, FileMode.Create));
                document.AddKeywords("paper airplanes");

                //float marginBottom = 12;
                //float lineHeight = 14;
                //float pageMargin = 20;
                var pageHeight = PageSize.A4.Height;
                var pageWidth  = PageSize.A4.Width;

                document.SetPageSize(new Rectangle(pageWidth, pageHeight));
                document.SetMargins(0, 0, 0, 0);

                writer.PageEvent = new PDFFooter("Indico Manufacturing Pty Ltd", true);

                // Open the document for writing content
                document.Open();
                // Get the top layer and write some text
                //contentByte = writer.DirectContent;

                //contentByte.BeginText();
                //string content = string.Empty;
                //string content_1 = string.Empty;
                //////string page = "Page " + writer.GetPageReference();

                //////Header
                //contentByte.SetFontAndSize(PDFFont, 12);
                //content = "Indico Manufacturing Pty Ltd";
                //contentByte.ShowTextAligned(PdfContentByte.ALIGN_LEFT, content, pageMargin, (pageHeight - pageMargin - lineHeight), 0);

                //contentByte.SetFontAndSize(PDFFont, 6);
                //content_1 = "Suit 43,125 Highbury Road, Burwood, VIC 3125";
                //contentByte.ShowTextAligned(PdfContentByte.ALIGN_LEFT, content_1, pageMargin, (pageHeight - pageMargin - 22), 0);

                //contentByte.EndText();
                //// Top Line
                //contentByte.SetLineWidth(0.5f);
                //contentByte.SetColorStroke(BaseColor.BLACK);
                //contentByte.MoveTo(pageMargin, (pageHeight - pageMargin - lineHeight - marginBottom - 4));
                //contentByte.LineTo((pageWidth - pageMargin), (pageHeight - pageMargin - lineHeight - marginBottom - 4));
                //contentByte.Stroke();

                var htmlText   = CreateIndimanInvoiceHtml(objInvoice);
                var htmlWorker = new HTMLWorker(document);
                htmlWorker.Parse(new StringReader(htmlText));

                writer.Close();
            }
            catch (Exception)
            {
                //IndicoLogging.log.Error("Error occured while Generate Pdf indimaninvoicepath in GenerateOdsPdf Class", ex);
            }
            finally
            {
                document.Close();
            }

            return(temppath);
        }
Пример #5
0
        public static string GenerateJKInvoiceDetail(int invoice, string dataFolder)
        {
            string jkinvoicedetailpath = string.Empty;

            //IndicoPackingEntities context = new IndicoPackingEntities();

            var objInvoice = DB.Invoice(invoice);

            try
            {
                jkinvoicedetailpath = dataFolder + @"Data\Invoices\" + "JKInvoiceDetail_" + objInvoice.ID.ToString() + "_" + ".pdf";

                if (File.Exists(jkinvoicedetailpath))
                {
                    File.Delete(jkinvoicedetailpath);
                }

                Document  document = new Document();
                PdfWriter writer   = PdfWriter.GetInstance(document, new FileStream(jkinvoicedetailpath, FileMode.Create));
                document.AddKeywords("paper airplanes");

                //float marginBottom = 12;
                //float lineHeight = 14;
                //float pageMargin = 20;
                float pageHeight = iTextSharp.text.PageSize.A4.Height;
                float pageWidth  = iTextSharp.text.PageSize.A4.Width;

                document.SetPageSize(new iTextSharp.text.Rectangle(pageWidth, pageHeight));
                document.SetMargins(0, 0, 0, 0);

                // Open the document for writing content
                writer.PageEvent = new PDFFooter("COMMERCIAL INVOICE", false);

                document.Open();

                // Get the top layer and write some text
                //contentByte = writer.DirectContent;

                //contentByte.BeginText();
                //string content = string.Empty;
                //string pageNo = string.Empty;
                ////string page = "Page " + writer.getpa();


                ////Header
                //contentByte.SetFontAndSize(PDFFontBold, 10);
                //content = "COMMERCIAL INVOICE";
                //contentByte.ShowTextAligned(PdfContentByte.ALIGN_LEFT, content, pageMargin, (pageHeight - pageMargin - lineHeight), 0);

                //// set Page Number
                //contentByte.SetFontAndSize(PDFFont, 8);
                //pageNo = "Page " + writer.PageNumber.ToString();
                //contentByte.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, pageNo, (pageWidth - 30), (pageHeight - pageMargin - lineHeight), 0);

                //contentByte.EndText();

                //// Top Line
                //contentByte.SetLineWidth(0.5f);
                //contentByte.SetColorStroke(BaseColor.BLACK);
                //contentByte.MoveTo(pageMargin, (pageHeight - pageMargin - lineHeight - marginBottom - 4));
                //contentByte.LineTo((pageWidth - pageMargin), (pageHeight - pageMargin - lineHeight - marginBottom - 4));
                //contentByte.Stroke();

                string     htmlText   = CreateJkInvoiceDetailHtml(objInvoice);
                HTMLWorker htmlWorker = new HTMLWorker(document);
                htmlWorker.Parse(new StringReader(htmlText));

                document.Close();
            }
            catch (Exception ex)
            {
                //IndicoLogging.log.Error("Error occured while Generate Pdf JKInvoiceOrderDetail in GenerateOdsPdf Class", ex);
            }

            return(jkinvoicedetailpath);
        }