Esempio n. 1
0
        private IEnumerable <ShipmentkeyModel> GetShipmentKeys(int weekId)
        {
            var shipmentkeyModels = DB.ShipmentKeys(weekId);

            ShipmentKeys = shipmentkeyModels.ToList();
            return(shipmentkeyModels);
        }
Esempio n. 2
0
        private void LoadItems(int invoiceid)
        {
            var items = DB.InvoiceOrderDetailItemsForInvoice(invoiceid);

            InvoiceItems = items;
            BindData(ItemGrid, items);
        }
Esempio n. 3
0
        private void LoadBillToAndShipTo()
        {
            var addresses = DB.AllDistributorClientAddressNames().ToList();

            BindData(ShipToDropDownList, addresses);
            BindData(BillToDropDownList, addresses);
        }
Esempio n. 4
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);
        }
Esempio n. 5
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);
            }
        }
Esempio n. 6
0
        private void GetShipmentkey(int ShipTo, int ShipmentModeID, int Port, DateTime ShipmentDate, int PriceTerm, int WeeklyProductionCapacity)
        {
            List <ShipmentkeyModel> shipmentkeyModels = DB.ShipmentKeys(WeeklyProductionCapacity);
            var shipmentkey = shipmentkeyModels.Where(o => o.ShipTo == ShipTo && o.ShipmentModeID == ShipmentModeID && o.PortID == Port && o.ShipmentDate == ShipmentDate && o.PriceTermID == PriceTerm).FirstOrDefault();

            litShipToTable.Text          = shipmentkey.CompanyName;
            litDestinationPortTable.Text = shipmentkey.DestinationPort;
            litETDTable.Text             = shipmentkey.ShipmentDate.ToString("dd MMMM yyyy");
            litPriceTermTable.Text       = shipmentkey.PriceTerm;
            litQtyTable.Text             = shipmentkey.Qty.ToString();
        }
Esempio n. 7
0
        private void LoadInvoiceItems(int invoiceId)
        {
            List <InvoiceOrderDetailItemModel> invoiceItems = new List <InvoiceOrderDetailItemModel>();

            if (CurrentInvoiceType == InvoiceType.Factory)
            {
                invoiceItems = DB.InvoiceOrderDetailItemsForInvoice(invoiceId);
            }
            else if (CurrentInvoiceType == InvoiceType.Indiman)
            {
                invoiceItems = DB.InvoiceOrderDetailItemsForInvoice(invoiceId, true);
            }
            InvoiceItems = invoiceItems;
            RebindItemGrid();
        }
Esempio n. 8
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;
        }
Esempio n. 9
0
        private void Save()
        {
            var invoice = InvoiceItems.First().InvoiceID;

            switch (CurrentInvoiceType)
            {
            case InvoiceType.Factory:
                DB.UpdateInvoice(invoice, LoggedUser.ID, txtInvoiceNo.Text, txtAwbNo.Text, Convert.ToInt32(StatusDropDownList.SelectedItem.Value), Convert.ToInt32(BillToDropDownList.SelectedItem.Value), Convert.ToInt32(BankDropDownList.SelectedItem.Value), Convert.ToDateTime(txtInvoiceDate.Text).GetSQLDateString());
                break;

            case InvoiceType.Indiman:
                DB.UpdateInvoice(invoice, LoggedUser.ID, null, txtAwbNo.Text, Convert.ToInt32(StatusDropDownList.SelectedItem.Value), Convert.ToInt32(BillToDropDownList.SelectedItem.Value), Convert.ToInt32(BankDropDownList.SelectedItem.Value), Convert.ToDateTime(txtInvoiceDate.Text).GetSQLDateString(), txtIndimanInvoiceNo.Text, txtIndimanInvoiceDate.Text);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            DB.UpdateChangedInvoiceOrderDetailItemPrices(InvoiceItems);
        }
Esempio n. 10
0
        private static string CreateJkInvoiceDetailHtml(InvoiceModel invoice)
        {
            var     jkinvoicedetailhtmlstring = new StringBuilder(JkInvoiceDetail);
            var     recordcount   = 0;
            var     finalrecord   = string.Empty;
            var     masterqty     = 0;
            decimal masteramount  = 0;
            var     rowIndex      = 1;
            var     rowIndexCount = 20;


            var address = DB.DistributorClientAddress(invoice.ShipTo.GetValueOrDefault());

            var billTo              = DB.DistributorClientAddress(invoice.BillTo.GetValueOrDefault());
            var billtoCountry       = DB.Country(billTo.Country);
            var invoiceShipmentMode = DB.ShipmentMode(invoice.ShipmentMode);
            var billtoPort          = DB.DestinationPort(billTo.Port.GetValueOrDefault());

            jkinvoicedetailhtmlstring
            .Replace("<$invoiceno$>", invoice.InvoiceNo)
            .Replace("<$shipmentdate$>", invoice.InvoiceDate.ToString("dd MMMM yyyy"))
            .Replace("<$shipcompanyname$>", address.CompanyName)
            .Replace("<$shipcompanyaddress$>", address.Address + "  " + address.State)
            .Replace("<$shipcompanypostalcode$>", address.PostCode + "  " + billtoCountry.ShortName)
            .Replace("<$shipcompanycontact$>", address.ContactName + "  " + address.ContactPhone)
            .Replace("<$shipmentmode$>", invoiceShipmentMode.Name)
            .Replace("<$awbno$>", invoice.AWBNo)
            .Replace("<$port$>", (billTo.Port != null && billTo.Port > 0) ? billtoPort.Name : string.Empty)
            .Replace("<$billtocompanyname$>", billTo.CompanyName)
            .Replace("<$billtocompanyname$>", billTo.Address)
            .Replace("<$billtocompanystate$>", billTo.Suburb + "  " + billTo.State + "  " + billTo.PostCode)
            .Replace("<$billtocompanycountry$>", billtoCountry.ShortName);


            var invoicedetail = "<table cellpadding=\"1\" cellspacing=\"0\" style=\"font-size: 7px\" width=\"100%\"><tr>" +
                                "<th border=\"0\" width=\"9%\"><b>Type</b></th>" +          //13
                                "<th border=\"0\" width=\"10%\"><b>Qty</b></th>" +          //5
                                "<th border=\"0\" width=\"20%\"><b>Sizes</b></th>" +        //25
                                "<th border=\"0\"  width=\"34%\"><b>Description</b></th>" + //35
                                "<th border=\"0\" width=\"6%\"><b>Price</b></th>" +
                                "<th border=\"0\" width=\"7%\"><b>Other/Ch</b></th>" +
                                "<th border=\"0\" width=\"6%\"><b>Total</b></th>" +
                                "<th border=\"0\" width=\"8%\"><b>AMOUNT</b></th></tr>";

            var invoiceItems = DB.InvoiceOrderDetailItemsForInvoice(invoice.ID).GroupBy(i => i.Distributor).ToList();

            foreach (var distributor in invoiceItems)
            {
                var     totoalqty   = 0;
                decimal totalamount = 0;
                invoicedetail += "<tr style=\"height:-2px;\" border=\"0.5\"><td style=\"line-height:10px;\" colspan=\"8\"><h6 style=\"padding-left:5px\"><b>" + distributor.Key /*address.CompanyName*/ + "</b></h6></td></tr>";
                rowIndex++;

                var lstOrderDetailsGroup = distributor.ToList();

                foreach (var item in lstOrderDetailsGroup)
                {
                    var orderdetailqty = string.Empty;
                    orderdetailqty += item.SizeQuantities;
                    var total = (decimal)(item.Amount);
                    totalamount  = totalamount + total;
                    masteramount = masteramount + total;
                    totoalqty    = totoalqty + item.Qty.GetValueOrDefault();

                    invoicedetail += "<tr style=\"height:-2px;\">" +
                                     "<td style=\"line-height:10px;\" width=\"9%\">" + item.OrderType + "<br>" + item.PurchaseOrder + "</td>" +                                                                    //13
                                     "<td style=\"line-height:10px;\" width=\"10%\">" + item.Qty + "  " + item.ItemName + "</td>" +                                                                                //5
                                     "<td style=\"line-height:10px;\" width=\"20%\">" + item.VisualLayout + " " + item.Client + "<br>" + orderdetailqty.Trim().Substring(0, orderdetailqty.Length - 2) + "</td>" + //item.client(ic) //25
                                     "<td style=\"line-height:10px;\" width=\"34%\">" + item.Fabric + " " + item.Material + "</td>" +
                                     "<td style=\"line-height:10px;\" width=\"6%\">" + item.FactoryPrice.GetValueOrDefault().ToString("0.00") + "</td>" +                                                          //35
                                     "<td style=\"line-height:10px;\" width=\"7%\" >" + item.OtherCharges.GetValueOrDefault().ToString("0.00") + "</td>" +
                                     "<td style=\"line-height:10px;\" width=\"6%\" >" + ((decimal)item.Amount).ToString("0.00") + "</td>" +
                                     "<td style=\"line-height:10px;\" width=\"6%\" >" + total.ToString("0.00") + "</td></tr>" +
                                     "<tr><td style=\"line-height:0px;\" colspan=\"8\" border=\"0.5\"></td></tr>";

                    rowIndex++;

                    if (rowIndex >= rowIndexCount) //16
                    {
                        invoicedetail += "<tr style=\"height:5px;\"><td border=\"0\" style=\"line-height:50px;color: #FFFFFF;\" colspan=\"8\"><h6>INDICO</h6></td></tr>";
                        rowIndex       = 0;
                        rowIndexCount  = 27;
                    }
                }
                //}
                invoicedetail += "<tr style=\"height:2px;\"><td  style=\"line-height:-2px;color: #F0FFFF;\" colspan=\"8\"></td>"; //9colspan
                invoicedetail += "<tr>" +
                                 "<td  style=\"line-height:8px;\" border=\"0\" width=\"9%\">&nbsp;</td>" +                        //13
                                 "<td  style=\"line-height:8px;\" border=\"0\" width=\"10%\"><b>" + totoalqty + "</b></td>" +     //5
                                 "<td  style=\"line-height:8px;\" border=\"0\" width=\"20%\">&nbsp;</td>" +                       //25
                                 "<td style=\"line-height:8px;\" border=\"0\" width=\"34%\">&nbsp;</td>" +                        //35
                                 "<td style=\"line-height:8px;\" border=\"0\" width=\"6%\">&nbsp;</td>" +
                                 "<td style=\"line-height:8px;\" border=\"0\" width=\"7%\">&nbsp;</td>" +                         //IC
                                 "<td style=\"line-height:8px;\" border=\"0\" width=\"6%\">&nbsp;</td>" +                         //IC
                                 "<td  style=\"line-height:8px;\" border=\"0\" width=\"8%\">" + totalamount.ToString("0.00") + "</td>" +
                                 "</tr>";

                recordcount = recordcount + 1;
                masterqty   = masterqty + totoalqty;

                if (invoiceItems.Count != recordcount)
                {
                    invoicedetail += "<tr style=\"height:5px;\"><td border=\"0\" style=\"line-height:2px;color: #FFFFFF;\" colspan=\"8\"><h6>INDICO</h6></td>"; //7 colspan
                    rowIndex++;

                    if (rowIndex >= rowIndexCount)
                    {
                        invoicedetail += "<tr style=\"height:5px;\"><td border=\"0\" style=\"line-height:50px;color: #FFFFFF;\" colspan=\"8\"><h6>INDICO</h6></td></tr>"; //7 colspan
                        rowIndex       = 0;
                        rowIndexCount  = 27;
                    }
                }
            }

            invoicedetail += "</table>";

            if (invoiceItems.Count == recordcount)
            {
                finalrecord = "<table border=\"0.5\">" +
                              "<tr>" +
                              "<td width=\"9%\" style=\"line-height:0px;\">&nbsp;</td>" +  //13
                              "<td width=\"10%\" style=\"line-height:0px;\">&nbsp;</td>" + //5
                              "<td width=\"20%\" style=\"line-height:0px;\">&nbsp;</td>" + //25
                              "<td width=\"34%\" style=\"line-height:0px;\">&nbsp;</td>" + //35
                              "<td width=\"6%\" style=\"line-height:0px;\">&nbsp;</td>" +
                              "<td width=\"7%\" style=\"line-height:0px;\">&nbsp;</td>" +  //IC
                              "<td width=\"6%\" style=\"line-height:0px;\">&nbsp;</td>" +  //IC
                              "<td width=\"8%\" style=\"line-height:0px;\">&nbsp;</td>" +
                              "</tr>";
                finalrecord += "<tr>" +
                               "<td width=\"9%\" style=\"line-height:10px;\" border=\"0\">&nbsp;</td>" +             //13
                               "<td width=\"10%\" style=\"line-height:10px;\" border=\"0\">" + masterqty + "</td>" + //5
                               "<td width=\"20%\" style=\"line-height:10px;\" border=\"0\">&nbsp;</td>" +            //25
                               "<td width=\"34%\" style=\"line-height:10px;\" border=\"0\">&nbsp;</td>" +            //35
                               "<td width=\"6%\" style=\"line-height:10px;\" border=\"0\">&nbsp;</td>" +
                               "<td width=\"7%\" style=\"line-height:10px;\" border=\"0\">&nbsp;</td>" +             //IC
                               "<td width=\"6%\" style=\"line-height:10px;\" border=\"0\">&nbsp;</td>" +             //IC
                               "<td width=\"8%\" style=\"line-height:10px;\" border=\"0\">" + masteramount.ToString("0.00") + "</td>" +
                               "</tr>" +
                               "</table>";
            }

            jkinvoicedetailhtmlstring = jkinvoicedetailhtmlstring.Replace("<$pricedetails$>", invoicedetail);
            jkinvoicedetailhtmlstring = jkinvoicedetailhtmlstring.Replace("<$finalrecord$>", finalrecord);

            var invoiceBank = DB.Bank(invoice.Bank.GetValueOrDefault());
            var bankCountry = DB.Country(invoiceBank.Country.GetValueOrDefault());

            jkinvoicedetailhtmlstring = jkinvoicedetailhtmlstring.Replace("<$bankname$>", invoiceBank.Name);

            string country = (invoiceBank.Country != null || invoiceBank.Country > 0) ? bankCountry.ShortName : string.Empty;

            jkinvoicedetailhtmlstring = jkinvoicedetailhtmlstring.Replace("<$bankaddress$>", invoiceBank.Address + "  " + invoiceBank.City + "  " + invoiceBank.State + "  " + invoiceBank.Postcode + "  " + country);

            jkinvoicedetailhtmlstring = jkinvoicedetailhtmlstring.Replace("<$accountnumber$>", invoiceBank.AccountNo);

            jkinvoicedetailhtmlstring = jkinvoicedetailhtmlstring.Replace("<$swiftcode$>", invoiceBank.SwiftCode);

            return(jkinvoicedetailhtmlstring.ToString());
        }
Esempio n. 11
0
        public static string CreateIndimanInvoiceHtml(InvoiceModel invoice)
        {
            var     indimaninvoicehtmlstring = new StringBuilder(IndimanInvoice);
            var     recordcount  = 0;
            var     finalrecord  = string.Empty;
            var     masterqty    = 0;
            decimal masteramount = 0;

            var invNo = invoice.IndimanInvoiceNo ?? "0";
            var date  = (invoice.IndimanInvoiceDate != null) ? Convert.ToDateTime(invoice.IndimanInvoiceDate.Value).ToString("dd MMMM yyyy") : DateTime.Now.ToString("dd MMMM yyyy");

            //  IndicoPackingEntities context = new IndicoPackingEntities();

            var address = DB.DistributorClientAddress(invoice.ShipTo.GetValueOrDefault());

            // var billTo = DB.DistributorClientAddress(invoice.BillTo.GetValueOrDefault());
            var addressCountry      = DB.Country(address.Country);
            var invoiceShipmentMode = DB.ShipmentMode(invoice.ShipmentMode);

            indimaninvoicehtmlstring
            .Replace("<$invoiceno$>", invNo)
            .Replace("<$invoicedate$>", date)
            .Replace("<$shipcompanyname$>", address.CompanyName)
            .Replace("<$shipcompanyaddress$>", address.Address + "  " + address.State)
            .Replace("<$shipcompanypostalcode$>", address.PostCode + "  " + addressCountry.ShortName)
            .Replace("<$shipcompanycontact$>", address.ContactName + "  " + address.ContactPhone)
            .Replace("<$shipmentmode$>", invoiceShipmentMode.Name)
            .Replace("<$awbno$>", invoice.AWBNo);

            var invoicedetail = "<table cellpadding=\"1\" cellspacing=\"0\" style=\"font-size: 6px\" border=\"0.5\" width=\"100%\"><tr>" +
                                "<th style=\"line-height:7px;\" width=\"10%\" align=\"center\"><b>Order</b></th>" +
                                "<th style=\"line-height:7px;\" width=\"5%\" align=\"center\"><b>Total</b></th>" +
                                "<th style=\"line-height:7px;\" width=\"18%\" align=\"center\"><b>Description</b></th>" +
                                "<th style=\"line-height:7px;\" width=\"32%\" align=\"center\"><b>Particulars</b></th>" +
                                "<th style=\"line-height:7px;\" width=\"6%\" align=\"center\"><b>Type</b></th>" +
                                "<th style=\"line-height:7px;\" width=\"6%\" align=\"center\"><b>Price</b></th>" +
                                "<th style=\"line-height:7px;\" width=\"6%\" align=\"center\"><b>Other/Ch</b></th>" +
                                "<th style=\"line-height:7px;\" width=\"6%\" align=\"center\"><b>Total Price</b></th>" +
                                "<th style=\"line-height:7px;\" width=\"6%\" align=\"center\"><b>Amount</b></th>" +
                                "<th style=\"line-height:7px;\" width=\"5%\" align=\"center\"><b>Notes</b></th></tr>";


            var       invoiceItems    = DB.InvoiceOrderDetailItemsForInvoice(invoice.ID).GroupBy(i => i.Distributor).ToList();
            double    rowCount        = 0;
            var       pageCount       = 0;
            const int firstPageCount  = 28;
            const int otherPagesCount = 35;

            foreach (var distributor in invoiceItems)
            {
                var totoalqty = 0;
                invoicedetail += "<tr style=\"height:-2px;\"><td style=\"line-height:10px;\" colspan=\"10\"><h6 style=\"padding-left:5px\"><b>" + distributor.Key + "</b></h6></td></tr>";
                rowCount++;

                var lstOrderDetailsGroup = distributor.ToList();

                foreach (var item in lstOrderDetailsGroup)
                {
                    var orderdetailqty = string.Empty;
                    orderdetailqty += item.SizeQuantities;
                    var total = (decimal)(item.Amount);
                    masteramount = masteramount + total;
                    totoalqty    = totoalqty + item.Qty.GetValueOrDefault();
                    var patternNo  = item.Pattern.Substring(0, item.Pattern.LastIndexOf('-')).Trim();
                    var fabricName = item.Fabric.Substring(item.Fabric.IndexOf('-') + 1).Trim();
                    var nickName   = item.Pattern.Substring(item.Pattern.IndexOf('-') + 1).Trim();

                    if (((item.VisualLayout + " " + item.Client).Count() > 27) || ((patternNo + " " + fabricName).Count() > 46)) //32
                    {
                        rowCount = rowCount + 0.5;
                    }
                    if (((orderdetailqty.Trim().Substring(0, orderdetailqty.Length - 2)).Count() > 27) || (nickName.Count() > 46))
                    {
                        rowCount = rowCount + 0.5;
                    }

                    invoicedetail += "<tr><td style=\"line-height:10px;\" border=\"0\" width=\"10%\">" + item.PurchaseOrder + "</td>" +
                                     "<td style=\"line-height:10px;\" border=\"0\" width=\"5%\">" + item.Qty + "</td>" +
                                     "<td style=\"line-height:10px;\" border=\"0\"  width=\"18%\">" + item.VisualLayout + " " + item.Client + "<br/>" + orderdetailqty.Trim().Substring(0, orderdetailqty.Length - 2) + "</td>" +
                                     "<td style=\"line-height:10px;\" border=\"0\" width=\"32%\">" + patternNo + " " + fabricName + "<br/>" + nickName + "</td>" +
                                     "<td style=\"line-height:10px;\" border=\"0\"  width=\"6%\">" + item.OrderType + "</td>" +
                                     "<td style=\"line-height:10px;\" border=\"0\"  width=\"6%\">" + item.IndimanPrice + "</td>" +
                                     "<td style=\"line-height:10px;\" border=\"0\" width=\"6%\">" + item.OtherCharges + "</td>" +
                                     "<td style=\"line-height:10px;\" border=\"0\" width=\"6%\">" + item.Amount + "</td>" +
                                     "<td style=\"line-height:10px;\" border=\"0\" width=\"6%\">" + total.ToString("0.00") + "</td>" +
                                     "<td style=\"line-height:10px;\" border=\"0\"  width=\"5%\">" + item.IndimanNotes + " </td></tr>";

                    rowCount++;


                    if ((pageCount == 0 && rowCount >= firstPageCount) || (pageCount != 0 && rowCount >= otherPagesCount))
                    {
                        invoicedetail += "<tr style=\"height:5px;\"><td border=\"0\" style=\"line-height:60px;color: #FFFFFF;\" colspan=\"10\"><h6>INDICO</h6></td></tr>";
                        rowCount       = 0;
                        pageCount++;
                    }
                }

                recordcount = recordcount + 1;
                masterqty   = masterqty + totoalqty;
            }

            invoicedetail += "</table>";

            if (invoiceItems.Count == recordcount)
            {
                finalrecord += "<table border=\"0.5\"><tr><td style=\"line-height:10px;\" border=\"0\">Total:</td><td style=\"line-height:10px;\" border=\"0\">" + masterqty + "</td><td style=\"line-height:10px;\" border=\"0\">&nbsp;</td>" +
                               "<td style=\"line-height:10px;\" border=\"0\">&nbsp;</td><td style=\"line-height:10px;\" border=\"0\">&nbsp;</td><td style=\"line-height:10px;\" border=\"0\">&nbsp;</td><td style=\"line-height:10px;\" border=\"0\">&nbsp;</td>" +
                               "<td style=\"line-height:10px;\" border=\"0\"></td></tr></table>";
            }

            indimaninvoicehtmlstring
            .Replace("<$pricedetails$>", invoicedetail)
            .Replace("<$finalrecord$>", finalrecord);

            var gst      = ((masteramount * 10) / 100);
            var totalgst = gst + masteramount;

            indimaninvoicehtmlstring
            .Replace("<$subtotal$>", masteramount.ToString("0.00"))
            .Replace("<$gst$>", gst.ToString("0.00"))
            .Replace("<$totgst$>", totalgst.ToString("0.00"));

            return(indimaninvoicehtmlstring.ToString());
        }
Esempio n. 12
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);
        }
Esempio n. 13
0
        private void LoadShipmentModes()
        {
            var shipmentModes = DB.AllShipmentModeNames();

            BindData(ShipmentModeDropDownList, shipmentModes);
        }
Esempio n. 14
0
        private void LoadBanks()
        {
            var banks = DB.AllBankNames();

            BindData(BankDropDownList, banks);
        }
Esempio n. 15
0
 private void InitializeUserInterfaceForNewInvoice()
 {
     DisableControl(RadComboShipmentKey);
     EnableOrDisableInvoiceInformationControls(false);
     BindData(WeekComboBox, DB.GetWeekNames(DateTime.Now.Year));
 }
Esempio n. 16
0
        private static string CreateJKInvoiceSummaryHTML(InvoiceModel objInvoice)
        {
            var     jkinvoicesummaryhtmlstring = JkInvoiceSummary;
            var     masterqty    = 0;
            decimal masteramount = 0;
            var     rowIndex     = 1;

            // IndicoPackingEntities context = new IndicoPackingEntities();
            var address = DB.DistributorClientAddress(objInvoice.ShipTo.GetValueOrDefault());

            var billTo              = DB.DistributorClientAddress(objInvoice.BillTo.GetValueOrDefault());
            var billtoCountry       = DB.Country(billTo.Country);
            var invoiceShipmentMode = DB.ShipmentMode(objInvoice.ShipmentMode);
            var billtoPort          = DB.DestinationPort(billTo.Port.GetValueOrDefault());
            var addressCountry      = DB.Country(address.Country);


            jkinvoicesummaryhtmlstring = jkinvoicesummaryhtmlstring.Replace("<$invoicenumber$>", objInvoice.InvoiceNo);
            jkinvoicesummaryhtmlstring = jkinvoicesummaryhtmlstring.Replace("<$shipmentdate$>", objInvoice.InvoiceDate.ToString("dd MMMM yyyy"));
            jkinvoicesummaryhtmlstring = jkinvoicesummaryhtmlstring.Replace("<$mode$>", invoiceShipmentMode.Name);
            jkinvoicesummaryhtmlstring = jkinvoicesummaryhtmlstring.Replace("<$awbno$>", objInvoice.AWBNo);
            jkinvoicesummaryhtmlstring = jkinvoicesummaryhtmlstring.Replace("<$companyname$>", address.CompanyName);
            jkinvoicesummaryhtmlstring = jkinvoicesummaryhtmlstring.Replace("<$companyaddress$>", address.Address + "  " + address.State);
            jkinvoicesummaryhtmlstring = jkinvoicesummaryhtmlstring.Replace("<$companypostalcodecountry$>", address.PostCode + "  " + addressCountry.ShortName);
            jkinvoicesummaryhtmlstring = jkinvoicesummaryhtmlstring.Replace("<$companycontact$>", address.ContactName + "  " + address.ContactPhone);
            jkinvoicesummaryhtmlstring = jkinvoicesummaryhtmlstring.Replace("<$port$>", (billTo.Port != null && billTo.Port > 0) ? billtoPort.Name : string.Empty);

            jkinvoicesummaryhtmlstring = jkinvoicesummaryhtmlstring.Replace("<$billtocompanyname$>", billTo.CompanyName);
            jkinvoicesummaryhtmlstring = jkinvoicesummaryhtmlstring.Replace("<$billtocompanyname$>", billTo.Address);
            jkinvoicesummaryhtmlstring = jkinvoicesummaryhtmlstring.Replace("<$billtocompanystate$>", billTo.Suburb + "  " + billTo.State + "  " + billTo.PostCode);
            jkinvoicesummaryhtmlstring = jkinvoicesummaryhtmlstring.Replace("<$billtocompanycountry$>", billtoCountry.ShortName);

            var invoicesummary = "<table width=\"100%\" style=\"font-size:6px;\" cellpadding=\"1\" cellspacing=\"0\"><tr>" +
                                 "<th width=\"35%\">Filaments</th>" +
                                 "<th width=\"20%\">Item Name</th>" +
                                 "<th width=\"10%\">Gender</th>" +
                                 "<th width=\"15%\">Item Sub Cat</th>" +
                                 "<th width=\"10%\">Qty</th>" +
                                 "<th width=\"10%\">Amount</th></tr>" +
                                 "<tr><td style=\"line-height:0px;\" colspan=\"6\" border=\"0.5\"></td></tr>";

            var invoiceItems = DB.InvoiceOrderDetailItemsForInvoice(objInvoice.ID).GroupBy(i => i.HSCode).ToList();

            foreach (var hscode in invoiceItems)
            {
                var     hscodetext = (!string.IsNullOrEmpty(hscode.Key)) ? hscode.Key : string.Empty;
                var     qty        = 0;
                decimal amount     = 0;
                decimal total      = 0;
                rowIndex++;

                invoicesummary += "<tr><td colspan=\"6\"><b>" + hscodetext + "</b></td></tr>";

                var lstOrderDetailsGroup = hscode.ToList();

                foreach (var item in lstOrderDetailsGroup)
                {
                    qty    = qty + item.Qty.GetValueOrDefault();
                    total  = (decimal)item.Amount;
                    amount = amount + total;

                    invoicesummary += "<tr><td style=\"line-height:12px;\" width=\"35%\">" + item.Material + "</td>" +
                                      "<td style=\"line-height:12px;\" width=\"20%\">" + item.ItemName + "</td>" +
                                      "<td style=\"line-height:12px;\" width=\"10%\">" + item.Gender + "</td>" +
                                      "<td style=\"line-height:12px;\" width=\"15%\">" + item.ItemSubGroup + "</td>" +
                                      "<td style=\"line-height:12px;\" width=\"10%\">" + item.Qty + "</td>" +
                                      "<td style=\"line-height:12px;\" width=\"10%\">" + ((decimal)item.Amount).ToString("0.00") + "</td></tr>";

                    rowIndex++;

                    if (rowIndex >= 37)
                    {
                        invoicesummary += "<tr style=\"height:5px;\"><td border=\"0\" style=\"line-height:50px;color: #FFFFFF;\" colspan=\"6\"><h6>INDICO</h6></td></tr>";
                        rowIndex        = 0;
                    }
                }

                masterqty       = masterqty + qty;
                masteramount    = masteramount + amount;
                invoicesummary += "<tr><td style=\"line-height:12px;\" width=\"35%\"></td>" +
                                  "<td width=\"20%\"></td>" +
                                  "<td style=\"line-height:12px;\" width=\"10%\"></td>" +
                                  "<td style=\"line-height:12px;\" width=\"15%\"></td>" +
                                  "<td style=\"line-height:12px;\" width=\"10%\"><b>" + qty.ToString() + "</b></td>" +
                                  "<td style=\"line-height:12px;\" width=\"10%\"><b>" + amount.ToString("0.00") + "</b></td></tr>";

                invoicesummary += "<tr><td width=\"35%\"></td>" +
                                  "<td width=\"20%\"></td>" +
                                  "<td width=\"10%\"></td>" +
                                  "<td width=\"15%\"></td>" +
                                  "<td width=\"10%\" style=\"line-height:0px;\" border=\"0.5\"></td>" +
                                  "<td width=\"10%\" style=\"line-height:0px;\" border=\"0.5\"></td></tr>";

                if (rowIndex >= 37)
                {
                    invoicesummary += "<tr style=\"height:5px;\"><td border=\"0\" style=\"line-height:50px;color: #FFFFFF;\" colspan=\"6\"><h6>INDICO</h6></td></tr>";
                    rowIndex        = 0;
                }
            }

            invoicesummary += "<tr><td style=\"line-height:12px;\" width=\"35%\"></td>" +
                              "<td style=\"line-height:12px;\" width=\"20%\"></td>" +
                              "<td style=\"line-height:12px;\" width=\"10%\"></td>" +
                              "<td style=\"line-height:12px;\" width=\"15%\"></td>" +
                              "<td style=\"line-height:12px;\" width=\"10%\"><b>" + masterqty.ToString() + "</b></td>" +
                              "<td style=\"line-height:12px;\" width=\"10%\"><b>" + masteramount.ToString("0.00") + "</b></td></tr>";
            invoicesummary += "<tr><td width=\"35%\"></td>" +
                              "<td width=\"20%\"></td>" +
                              "<td width=\"10%\"></td>" +
                              "<td width=\"15%\"></td>" +
                              "<td width=\"10%\" style=\"line-height:0px;\" border=\"0.5\"></td><td width=\"10%\" style=\"line-height:0px;\" border=\"0.5\"></td></tr>";
            invoicesummary += "</table>";

            jkinvoicesummaryhtmlstring = jkinvoicesummaryhtmlstring.Replace("<$invoicesummary$>", invoicesummary);

            //string textFilePath = IndicoConfiguration.AppConfiguration.PathToDataFolder + @"\Temp\invoice_" + objInvoice.ID.ToString() + ".html";
            //System.IO.StreamWriter file = new System.IO.StreamWriter(textFilePath, false);
            //file.WriteLine(jkinvoicesummaryhtmlstring);
            //file.Close();

            return(jkinvoicesummaryhtmlstring);
        }
Esempio n. 17
0
        private void LoadStatus()
        {
            var statuses = DB.AllInvoiceStatusNames();

            BindData(StatusDropDownList, statuses);
        }
Esempio n. 18
0
        private void LoadPorts()
        {
            var ports = DB.AllDestinationPortNames();

            BindData(PortDropDownList, ports);
        }
Esempio n. 19
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);
        }
        /*protected void btnCombineInvoice_Click(object sender, EventArgs e)
         * {
         *  int id = int.Parse(((System.Web.UI.WebControls.WebControl)(sender)).Attributes["qid"].ToString());
         *  //int id = int.Parse(this.hdnSelectedID.Value);
         *
         *  if (id > 0)
         *  {
         *      try
         *      {
         *          string pdfFilePath = Common.GenerateOdsPdf.CombinedInvoice(id);
         *
         *          this.DownloadPDFFile(pdfFilePath);
         *      }
         *      catch (Exception ex)
         *      {
         *          IndicoLogging.log.Error("Error occured while printing JKCombineInvoice from ViewInvoices.aspx", ex);
         *      }
         *  }
         * }*/

        //protected void btnIndimanInvoice_Click(object sender, EventArgs e)
        //{
        //    int id = int.Parse(((System.Web.UI.WebControls.WebControl)(sender)).Attributes["qid"].ToString());
        //    //int id = int.Parse(this.hdnSelectedID.Value);

        //    if (id > 0)
        //    {
        //        try
        //        {
        //            string pdfFilePath = Common.GenerateOdsPdf.GenerateIndimanInvoice(id);

        //            this.DownloadPDFFile(pdfFilePath);
        //        }
        //        catch (Exception ex)
        //        {
        //            IndicoLogging.log.Error("Error occured while printing Indiman Invoice from ViewInvoices.aspx", ex);
        //        }
        //    }
        //}

        protected void btnIndimanInvoice_Click(object sender, EventArgs e)
        {
            int id = int.Parse(((System.Web.UI.WebControls.WebControl)(sender)).Attributes["qid"].ToString());

            using (ReportViewer rpt = new ReportViewer())
            {
                bool   IsFileOpen = false;
                string reportName = "Indiman_Detail_Summary" + DateTime.Now.Ticks.ToString();
                //string dataFolder = @"~\IndicoData\Temp";
                //string rdlFileName = "Sales Report";

                //rpt.ProcessingMode = ProcessingMode.Local;
                //rpt.LocalReport.ReportPath = Server.MapPath("~/Reports/JK_Detail_Invoice.rdl");

                //DateTime? selecteddate1 = null;
                //DateTime? selecteddate2 = null;

                //if (!string.IsNullOrEmpty(this.txtCheckin.Value) && !string.IsNullOrEmpty(this.txtCheckout.Value))
                //{
                //    selecteddate1 = Convert.ToDateTime(this.txtCheckin.Value);
                //    selecteddate2 = Convert.ToDateTime(this.txtCheckout.Value);
                //}

                rpt.ShowToolBar            = false;
                rpt.SizeToReportContent    = true;
                rpt.ProcessingMode         = Microsoft.Reporting.WebForms.ProcessingMode.Local;
                rpt.LocalReport.ReportPath = Server.MapPath("~/Reports/Indiman_Invoice.rdl");
                rpt.Visible = true;

                List <ReportParameter> parameters = new List <ReportParameter>();
                ReportParameter        parameter  = new ReportParameter();
                parameter.Name = "P_InvoiceId";
                parameter.Values.Add(id.ToString());
                parameters.Add(parameter);
                rpt.LocalReport.SetParameters(parameters);

                ReportDataSource dataSource = new ReportDataSource("DataSet1", DB.GetIndimanDetailInvoiceInfo(id));

                rpt.LocalReport.DataSources.Clear();
                rpt.LocalReport.DataSources.Add(dataSource);
                rpt.LocalReport.Refresh();

                string    mimeType, encoding, extension, deviceInfo;
                string[]  streamids;
                Warning[] warnings;
                string    format = "PDF";

                deviceInfo = "<DeviceInfo>" + "<SimplePageHeaders>True</SimplePageHeaders>" + "</DeviceInfo>";

                byte[] bytes = rpt.LocalReport.Render(format, deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings);

                string temppath = IndicoConfiguration.AppConfiguration.PathToDataFolder + @"\Temp\" + reportName + ".pdf";

                FileStream stream = null;

                if (File.Exists(temppath))
                {
                    try
                    {
                        stream = File.Open(temppath, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
                    }
                    catch (IOException)
                    {
                        IsFileOpen = true;
                    }
                    finally
                    {
                        if (stream != null)
                        {
                            stream.Close();
                        }
                    }
                }

                if (File.Exists(temppath) && !IsFileOpen)
                {
                    File.Delete(temppath);
                }

                if (!IsFileOpen)
                {
                    using (FileStream fs = new FileStream(temppath, FileMode.Create))
                    {
                        fs.Write(bytes, 0, bytes.Length);
                    }
                }

                while (File.Exists(temppath))
                {
                    Thread.Sleep(1000);
                    System.Diagnostics.Process.Start(temppath);
                    break;
                }

                if (File.Exists(temppath))
                {
                    try
                    {
                        this.DownloadPDFFile(temppath);
                    }
                    catch (Exception ex)
                    {
                        IndicoLogging.log.Error("Error occured while printing JKInvoiceOrderDetail from AddEditInvoice.aspx", ex);
                    }
                }
            }
        }