public void AddUpdateUserAddress(AddressInfo addressObj,AspxCommonInfo aspxCommonObj)
 {
     List<KeyValuePair<string, object>> parameter = new List<KeyValuePair<string, object>>();
     parameter.Add(new KeyValuePair<string, object>("@AddressID", addressObj.AddressID));
     parameter.Add(new KeyValuePair<string, object>("@CustomerID", aspxCommonObj.CustomerID));
     parameter.Add(new KeyValuePair<string, object>("@FirstName", addressObj.FirstName));
     parameter.Add(new KeyValuePair<string, object>("@LastName", addressObj.LastName));
     parameter.Add(new KeyValuePair<string, object>("@Email", addressObj.Email));
     parameter.Add(new KeyValuePair<string, object>("@Company", addressObj.Company));
     parameter.Add(new KeyValuePair<string, object>("@Address1", addressObj.Address1));
     parameter.Add(new KeyValuePair<string,object>("@Address2",addressObj.Address2));
     parameter.Add(new KeyValuePair<string, object>("@City", addressObj.City));
     parameter.Add(new KeyValuePair<string, object>("@State", addressObj.State));
     parameter.Add(new KeyValuePair<string, object>("@Zip", addressObj.Zip));
     parameter.Add(new KeyValuePair<string, object>("@Phone", addressObj.Phone));
     parameter.Add(new KeyValuePair<string, object>("@Mobile", addressObj.Mobile));
     parameter.Add(new KeyValuePair<string, object>("@Fax", addressObj.Fax));
     parameter.Add(new KeyValuePair<string, object>("@WebSite", addressObj.Website));
     parameter.Add(new KeyValuePair<string, object>("@Country", addressObj.Country));
     parameter.Add(new KeyValuePair<string, object>("@IsDefaultShipping", addressObj.DefaultShipping));
     parameter.Add(new KeyValuePair<string, object>("@IsDefaultBilling", addressObj.DefaultBilling));
     parameter.Add(new KeyValuePair<string, object>("@StoreID", aspxCommonObj.StoreID));
     parameter.Add(new KeyValuePair<string, object>("@PortalID", aspxCommonObj.PortalID));
     parameter.Add(new KeyValuePair<string, object>("@UserName", aspxCommonObj.UserName));
     parameter.Add(new KeyValuePair<string, object>("@CultureName", aspxCommonObj.CultureName));
     SQLHandler sqlH = new SQLHandler();
     sqlH.ExecuteNonQuery("usp_Aspx_AddUpdateUserAddress", parameter);
 }
 public void AddUpdateUserAddress(AddressInfo addressObj, AspxCommonInfo aspxCommonObj)
 {
     try
     {
         AspxUserDashController.AddUpdateUserAddress(addressObj, aspxCommonObj);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public void CreateShipmentLabel(AddressInfo destinationAddress, WareHouseAddress wareHouseAddress, AspxCommonInfo aspxCommonObj, BasicPackageInfo basicPackageInfo)
        {
            HttpContext.Current.Response.ContentType = "application/pdf";
            HttpContext.Current.Response.AddHeader("content-disposition",
                                                   "attachment;filename=" + "ShipmentLabel_" +
                                                   DateTime.Now.ToString("M_dd_yyyy_H_M_s") + ".pdf");

            Document doc = new Document(iTextSharp.text.PageSize.A4, 0, 0, 20, 20);
            PdfWriter writer = PdfWriter.GetInstance(doc, HttpContext.Current.Response.OutputStream);

            writer.PageEvent = new MyPageEventHandler(basicPackageInfo.CautionMessage);
            doc.Open();
            var textFont = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 9, Font.NORMAL, new BaseColor(0, 0, 255));

            PdfPTable shipmentTalbe = new PdfPTable(2);
            shipmentTalbe.SetWidths(new int[2] {5, 15});
             
            //string cautionMessage = basicPackageInfo.CautionMessage;
            //PdfPCell verticalC = new PdfPCell(); //new PdfPCell(new Paragraph(cautionMessage, textFont));
            //verticalC.Rotation = 90;
            //// verticalC.VerticalAlignment = Element.ALIGN_CENTER;
            //verticalC.PaddingTop = 30f;
            //verticalC.PaddingBottom = 50f;
            //verticalC.Border = Rectangle.NO_BORDER;
            ////  shipmentTalbe.AddCell("");
            //shipmentTalbe.AddCell(verticalC);


            PdfPTable headerTbl = new PdfPTable(2);
            headerTbl.SetWidths(new int[2] {10, 15});
            float[] widths = new float[] { 200f,300f };
            // headerTbl.TotalWidth = doc.PageSize.Width;
            headerTbl.WidthPercentage = 100;

            Paragraph pa = new Paragraph("From",
                                         FontFactory.GetFont(FontFactory.TIMES_ROMAN, 16, Font.BOLD,
                                                             new BaseColor(0, 0, 255)));

            PdfPCell cell = new PdfPCell(pa);
            cell.PaddingLeft = 15f;
            //   pa.Alignment = Element.ALIGN_BOTTOM;
            cell.Border = Rectangle.NO_BORDER + Rectangle.RIGHT_BORDER;
            cell.AddElement(pa);

            PdfPTable fromTable = new PdfPTable(1);
            fromTable.WidthPercentage = 100;

            string fromAdd = string.Empty;
            if (!string.IsNullOrEmpty(wareHouseAddress.Name))
                fromAdd += wareHouseAddress.Name.Trim() + Environment.NewLine;
            if (!string.IsNullOrEmpty(wareHouseAddress.Address))
                fromAdd += wareHouseAddress.Address.Trim() + Environment.NewLine;
            if (!string.IsNullOrEmpty(wareHouseAddress.StreetAddress1))
                fromAdd += wareHouseAddress.StreetAddress1.Trim() + Environment.NewLine;
            if (!string.IsNullOrEmpty(wareHouseAddress.StreetAddress2))
                fromAdd += wareHouseAddress.StreetAddress2.Trim() + Environment.NewLine;
            if (!string.IsNullOrEmpty(wareHouseAddress.City))
                fromAdd += wareHouseAddress.City.Trim();
            if (!string.IsNullOrEmpty(wareHouseAddress.State))
                fromAdd += ", " + wareHouseAddress.State.Trim();
            if (!string.IsNullOrEmpty(wareHouseAddress.PostalCode))
                fromAdd += ", " + wareHouseAddress.PostalCode.Trim() + Environment.NewLine;
            if (!string.IsNullOrEmpty(wareHouseAddress.Country))
                fromAdd += wareHouseAddress.Country.Trim() + Environment.NewLine;
            if (!string.IsNullOrEmpty(wareHouseAddress.Phone))
                fromAdd += wareHouseAddress.Phone.Trim() + Environment.NewLine;
            if (!string.IsNullOrEmpty(wareHouseAddress.Fax))
                fromAdd += wareHouseAddress.Fax.Trim() + Environment.NewLine;
            if (!string.IsNullOrEmpty(wareHouseAddress.Email))
                fromAdd += wareHouseAddress.Email.Trim() + Environment.NewLine;

            PdfPCell fromAddcell = new PdfPCell(new Paragraph(fromAdd, textFont));
            fromAddcell.Border = Rectangle.NO_BORDER;
            fromAddcell.PaddingLeft = 30f;
            fromTable.AddCell(fromAddcell);
            cell.AddElement(fromTable);
            headerTbl.AddCell(cell);


            Paragraph to = new Paragraph("To",
                                         FontFactory.GetFont(FontFactory.TIMES_ROMAN, 16, Font.BOLD,
                                                             new BaseColor(0, 0, 255)));
            PdfPCell cellTo = new PdfPCell(to);
            cellTo.PaddingLeft = 15f;
            cellTo.Border = Rectangle.NO_BORDER;
            cellTo.AddElement(to);
            PdfPTable toTable = new PdfPTable(1);
            toTable.WidthPercentage = 100;
            string toAddress = string.Empty;
            if (!string.IsNullOrEmpty(destinationAddress.FirstName))
                toAddress += destinationAddress.FirstName.Trim() + " ";
            if (!string.IsNullOrEmpty(destinationAddress.LastName))
                toAddress += destinationAddress.LastName.Trim() + Environment.NewLine;
            if (!string.IsNullOrEmpty(destinationAddress.Company))
                toAddress += destinationAddress.Company.Trim() + Environment.NewLine;
            if (!string.IsNullOrEmpty(destinationAddress.Address1))
                toAddress += destinationAddress.Address1.Trim() + Environment.NewLine;
            if (!string.IsNullOrEmpty(destinationAddress.Address2))
                toAddress += destinationAddress.Address2.Trim() + Environment.NewLine;
            if (!string.IsNullOrEmpty(destinationAddress.City))
                toAddress += destinationAddress.City.Trim();
            if (!string.IsNullOrEmpty(destinationAddress.State))
                toAddress += ", " + destinationAddress.State.Trim();
            if (!string.IsNullOrEmpty(destinationAddress.Zip))
                toAddress += ", " + destinationAddress.Zip.Trim() + Environment.NewLine;
            if (!string.IsNullOrEmpty(destinationAddress.Country))
                toAddress += destinationAddress.Country.Trim() + Environment.NewLine;
            if (!string.IsNullOrEmpty(destinationAddress.Email))
                toAddress += destinationAddress.Email.Trim() + Environment.NewLine;
            if (!string.IsNullOrEmpty(destinationAddress.Phone))
                toAddress += destinationAddress.Phone.Trim();
            if (!string.IsNullOrEmpty(destinationAddress.Mobile))
                toAddress += ", " + destinationAddress.Mobile.Trim() + Environment.NewLine;
            if (!string.IsNullOrEmpty(destinationAddress.Fax))
                toAddress += destinationAddress.Fax.Trim() + Environment.NewLine;
            if (!string.IsNullOrEmpty(destinationAddress.Website))
                toAddress += destinationAddress.Website.Trim();
            PdfPCell toAddresscell = new PdfPCell(new Paragraph(toAddress, textFont));
            toAddresscell.Border = Rectangle.NO_BORDER;
            toAddresscell.PaddingLeft = 30f;
            toTable.AddCell(toAddresscell);
            cellTo.AddElement(toTable);
            headerTbl.AddCell(cellTo);

            var cellBackColor = new BaseColor(System.Drawing.ColorTranslator.FromHtml("#F4F8FC"));

            // for one line spacing
            PdfPCell blankCell1 = new PdfPCell();
            blankCell1.Colspan = 2;
            blankCell1.Border = Rectangle.NO_BORDER;
            // blankCell1.BackgroundColor = cellBackColor;
            headerTbl.AddCell(blankCell1);

            // For Tracking Number
            //PdfPCell trackingCell = new PdfPCell();
            //trackingCell.Colspan = 2;
            //trackingCell.Border = Rectangle.NO_BORDER;
            //Paragraph tracingPa = new Paragraph("Tracking No: " + basicPackageInfo.TrackingNo + "",
            //                                    FontFactory.GetFont(FontFactory.TIMES_ROMAN, 16, Font.BOLD,
            //                                                        new BaseColor(0, 0, 255)));
            //trackingCell.AddElement(tracingPa);
            //headerTbl.AddCell(trackingCell);

            // For one line spacing after tracking no.

            PdfPCell blankCell2 = new PdfPCell();
            blankCell2.Colspan = 2;
            blankCell2.Border = Rectangle.NO_BORDER;
            // blankCell2.BackgroundColor = cellBackColor;
            headerTbl.AddCell(blankCell2);

            // for total weight

            PdfPCell blankMiddleCell = new PdfPCell();
            blankMiddleCell.Border = Rectangle.NO_BORDER;
            headerTbl.AddCell(blankMiddleCell);
            string dimension = basicPackageInfo.Length + "*" + basicPackageInfo.Width + "*" + basicPackageInfo.Height +
                               " " + basicPackageInfo.DimensionUnit;
            Paragraph wtPa = new Paragraph("Total Weight: " + basicPackageInfo.TotalWeight + "" + Environment.NewLine
                                           + "Weight Unit: " + basicPackageInfo.WeightUnit + "" + Environment.NewLine
                                           + "Dimension(L*W*H): " + dimension, textFont);
            PdfPCell wtCell = new PdfPCell();
            wtCell.AddElement(wtPa);
            wtCell.Border = Rectangle.NO_BORDER;
            wtCell.PaddingLeft = 30f;
            headerTbl.AddCell(wtCell);

            // for one line space after total weight

            PdfPCell blankCell3 = new PdfPCell();
            blankCell3.Colspan = 2;
            blankCell3.Border = Rectangle.NO_BORDER;
            // blankCell3.BackgroundColor = cellBackColor;
            headerTbl.AddCell(blankCell3);

            // for last row with logo

            Paragraph senderPa = new Paragraph("Sender Name: " + basicPackageInfo.SenderName + "" + Environment.NewLine
             + "Servce Type: " + basicPackageInfo.ServiceType, textFont);
            PdfPCell senderCell = new PdfPCell(senderPa);
            senderCell.Border = Rectangle.NO_BORDER + Rectangle.RIGHT_BORDER;
            headerTbl.AddCell(senderCell);

            StoreSettingConfig ssc = new StoreSettingConfig();
            string storeLogoUrl = ssc.GetStoreSettingsByKey(StoreSetting.StoreLogoURL, aspxCommonObj.StoreID,
                                                            aspxCommonObj.PortalID, aspxCommonObj.CultureName);
            string logoPath = HttpContext.Current.Request.MapPath("~/" + storeLogoUrl);
            PdfPTable logoTable = new PdfPTable(1);
            if (File.Exists(logoPath))
            {
                iTextSharp.text.Image logo =
                                   iTextSharp.text.Image.GetInstance(logoPath.Replace("uploads", "uploads/Small").Replace("\\", @"//"));
                logo.ScalePercent(50f);
                PdfPCell logoImage = new PdfPCell(logo);
                logoImage.Border = Rectangle.NO_BORDER;
                logoImage.PaddingLeft = 30f;
                logoImage.AddElement(logo);
                //PdfPTable logoTable = new PdfPTable(1);
                logoTable.WidthPercentage = 100;
                logoTable.AddCell(logoImage);
            }
            var storeName = ssc.GetStoreSettingsByKey(StoreSetting.StoreName, aspxCommonObj.StoreID,
                                                      aspxCommonObj.PortalID, aspxCommonObj.CultureName);
            PdfPCell storeNameCell = new PdfPCell(new Paragraph(storeName, textFont));
            storeNameCell.Border = Rectangle.NO_BORDER;
            storeNameCell.PaddingLeft = 30f;
            logoTable.AddCell(storeNameCell);

            PdfPCell logoCell = new PdfPCell();
            logoCell.AddElement(logoTable);
            logoCell.HorizontalAlignment = Element.ALIGN_CENTER;
            logoCell.Border = Rectangle.NO_BORDER;
            headerTbl.AddCell(logoCell);

            headerTbl.DefaultCell.Border = Rectangle.NO_BORDER;
            PdfPCell detailCell = new PdfPCell();
            detailCell.Colspan = 2;
            detailCell.AddElement(headerTbl);
            shipmentTalbe.AddCell(detailCell);
            doc.Add(shipmentTalbe);
            doc.Close();

        }
 public static void AddUpdateUserAddress(AddressInfo addressObj, AspxCommonInfo aspxCommonObj)
 {
     AspxUserDashProvider.AddUpdateUserAddress(addressObj, aspxCommonObj);
 }