Exemple #1
0
        public void SendCopyToManager(User pUser, string message)
        {
            try
            {
                BusinessLogic.lnPerson _LNP = new BusinessLogic.lnPerson();
                Person PersonInfo           = _LNP.GetPersonById(pUser.Person.Id);

                MailMessage mail       = new MailMessage();
                SmtpClient  SmtpServer = new SmtpClient("smtp.ionos.com");
                mail.From = new MailAddress("*****@*****.**", "A new order has been received");
                mail.Bcc.Add(new MailAddress("*****@*****.**"));
                string subject = "New order by " + PersonInfo.Name + " " + PersonInfo.Lastname;
                mail.Subject           = subject;
                mail.Body              = "<!DOCTYPE html><html><body style=' margin: 0;'><section style='width: 100%; display: flex; justify-content: center; height: 100%;'><div id='DivContent' style='width: 100%; height: 100%;'><div id='DivHeader' style='height: 20%;'><div id='HeaderImg' style='justify - content: center; display: flex; align-items: center;'><img style='width: 200px; padding: 3px; height: 56px;' src='http://app.venuscabinetdoors.com/Content/img/Venus_Doors11.png'></div><div id='HeaderTittle' style='display: flex;justify-content: center;'><h1 style='margin: 0;width: 100%;text-align: center;background: #014d41;padding: 15px;color: #fff;'>" + subject + "</h1></div></div><div id='DivBody' style='height: 65%;'><div style='display: flex;justify-content: center;text-align: justify;height: 75%;'><div id='DivOrderInfo' style='width:100%'>" + message + "</div></div><div style='text-align: center;height: 25%;'><div style='display:flex; justify-content:center'><p style='width: 100%;'>Stay connected with us.</p></div><div style='display:flex; justify-content:center; align-items:center'><span style='width:100%'><a href='https://www.facebook.com/Venus-Cabinet-Doors-171950720354840/' target='_blank' title='Venus Cabinet Doors on FB'><img style='width:40px; height:40px' src='http://app.venuscabinetdoors.com/Content/img/fbICO.png'></a><a href='http://venuscabinetdoors.com/' target='_blank' style='margin-left: 8px;margin-right: 8px;'><img style='width:40px; height:40px' title='Venus Cabinet Doors Homepage' src='http://app.venuscabinetdoors.com/Content/img/Venus_Doors11.ico'></a><a href='https://www.instagram.com/venusdoors/' target='_blank' title='@venusdoors'><img style='width:40px; height:40px' src='http://app.venuscabinetdoors.com/Content/img/igICO.png'></a></span></div></div></div><div id='DivFooter' style='height: 15%;display: flex;text-align: center;justify-content: center; align-items:center'><p style='width: 90%;'><span>Venus Doors</span> - Copyright © 2019 | <a target='_blank' href='http://venuscabinetdoors.com/' style='color:#014d41'>Venuscabinetdoors.com</a> - All rights reserved. | Privacy policy | About.</p></div></div></section></body></html>";
                mail.IsBodyHtml        = true;
                SmtpServer.Port        = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "venusCBD2019*");
                SmtpServer.EnableSsl   = true;
                SmtpServer.Send(mail);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemple #2
0
        public string DescargarPDF(int IdOrder, string mapPach)
        {
            try
            {
                string path = mapPach + "/Content/PDF";
                foreach (var item in Directory.GetFiles(path, "*.*"))
                {
                    File.SetAttributes(item, FileAttributes.Normal);
                    File.Delete(item);
                }

                BusinessLogic.lnOrder      LNOrder     = new BusinessLogic.lnOrder();
                BusinessLogic.lnUser       LNUser      = new BusinessLogic.lnUser();
                BusinessLogic.lnCompany    LNCOmpany   = new BusinessLogic.lnCompany();
                BusinessLogic.lnDoorsxUser LNDoorUser  = new BusinessLogic.lnDoorsxUser();
                BusinessLogic.lnDoorxOrder LNDoorOrder = new BusinessLogic.lnDoorxOrder();
                BusinessLogic.lnPerson     LNPerson    = new BusinessLogic.lnPerson();
                Order             order      = LNOrder.GetOrderById(IdOrder);
                User              user       = LNUser.GetUserById(order.User.Id);
                Person            person     = LNPerson.GetPersonById(user.Person.Id);
                Company           company    = LNCOmpany.GetCompanyById(user.Company.Id);
                DoorsxUser        doorsxUser = LNDoorUser.GetAllDoorsxUser().Where(x => x.Order.Id == IdOrder).FirstOrDefault();
                List <DoorxOrder> DO         = LNDoorOrder.GetAllDoorxOrderByDoorxUser(doorsxUser.Id);

                var doc1 = new Document();
                //use a variable to let my code fit across the page...


                string ruta = "/Content/PDF" + "/" + IdOrder + ".pdf";
                PdfWriter.GetInstance(doc1, new FileStream(path + "/" + IdOrder + ".pdf", FileMode.Create));

                doc1.Open();

                string rutaImagen = mapPach + company.Logo;
                Image  image      = Image.GetInstance(rutaImagen);
                Chunk  c          = new Chunk("Order #" + IdOrder + " \n",
                                              FontFactory.GetFont("Arial", 18));

                PdfPTable table = new PdfPTable(4);

                //PdfPCell cell = new PdfPCell(new Phrase("Header spanning 3 columns"));
                //cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                //cell.Border = 0;
                //table.AddCell(cell);

                table.TotalWidth = 526f;

                //fix the absolute width of the table

                table.LockedWidth = true;

                //relative col widths in proportions - 1/3 and 2/3

                float[] widths = new float[] { 1f, 1f, 1f, 1f };

                table.SetWidths(widths);

                table.HorizontalAlignment = 0;

                //leave a gap before and after the table

                //table.SpacingBefore = 20f;

                //table.SpacingAfter = 30f;

                PdfPCell cell = new PdfPCell(new Phrase("General Configuration", FontFactory.GetFont("Arial", 12)));
                cell.Colspan             = 4;
                cell.HorizontalAlignment = 1;
                cell.Border        = 0;
                cell.PaddingBottom = 10f;
                table.AddCell(cell);


                cell = new PdfPCell(new Phrase("Wood Species: " + doorsxUser.Material.Description, FontFactory.GetFont("Arial", 9)));
                cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                cell.Border        = 0;
                cell.PaddingBottom = 5f;
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase("Door Style: " + doorsxUser.DoorStyle.Description, FontFactory.GetFont("Arial", 9)));
                cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                cell.Border        = 0;
                cell.PaddingBottom = 5f;
                table.AddCell(cell);

                string overlay = (doorsxUser.isOverlay == true) ? "Overlay Door Type" : "Inset Door Type";
                cell = new PdfPCell(new Phrase("Door Place: " + overlay, FontFactory.GetFont("Arial", 9)));
                cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                cell.Border        = 0;
                cell.PaddingBottom = 5f;
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase("Stile Width: " + doorsxUser.TopRail.Description, FontFactory.GetFont("Arial", 9)));
                cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                cell.Border        = 0;
                cell.PaddingBottom = 5f;
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase("Rail Width: " + doorsxUser.BottomRail.Description, FontFactory.GetFont("Arial", 9)));
                cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                cell.Border        = 0;
                cell.PaddingBottom = 5f;
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase("Inside Profile: " + doorsxUser.InsideEdgeProfile.Description, FontFactory.GetFont("Arial", 9)));
                cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                cell.Border        = 0;
                cell.PaddingBottom = 5f;
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase("Outside Profile: " + doorsxUser.OutsideEdgeProfile.Description, FontFactory.GetFont("Arial", 9)));
                cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                cell.Border        = 0;
                cell.PaddingBottom = 5f;
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase("Door Assembly: " + doorsxUser.Join.Description, FontFactory.GetFont("Arial", 9)));
                cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                cell.Border        = 0;
                cell.PaddingBottom = 5f;
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase("Panel Material: " + doorsxUser.PanelMaterial.Description, FontFactory.GetFont("Arial", 9)));
                cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                cell.Border        = 0;
                cell.PaddingBottom = 5f;
                table.AddCell(cell);

                string OpeningMeasurement = (doorsxUser.IsOpeningMeasurement == true) ? "Yes" : "No";
                cell = new PdfPCell(new Phrase("Opening Measurement: " + OpeningMeasurement, FontFactory.GetFont("Arial", 9)));
                cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                cell.Border        = 0;
                cell.PaddingBottom = 5f;
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase("Vertical Divisions: " + doorsxUser.VerticalDivisions.Quantity.ToString(), FontFactory.GetFont("Arial", 9)));
                cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                cell.Border        = 0;
                cell.PaddingBottom = 5f;
                table.AddCell(cell);


                cell = new PdfPCell(new Phrase("Horizontal Divisions: " + doorsxUser.HorizontalDivisions.Quantity.ToString(), FontFactory.GetFont("Arial", 9)));
                cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                cell.Border        = 0;
                cell.PaddingBottom = 5f;
                table.AddCell(cell);

                string Drill = (doorsxUser.isDrill == true) ? "Yes (" + doorsxUser.HingeDirection.Direction + ")" : "No";
                cell = new PdfPCell(new Phrase("Drill: " + Drill, FontFactory.GetFont("Arial", 9)));
                cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                cell.Border        = 0;
                cell.PaddingBottom = 5f;
                table.AddCell(cell);

                string FingerPull = (doorsxUser.isFingerPull == true) ? "Yes" : "No";
                cell = new PdfPCell(new Phrase("Finger Pull: " + FingerPull, FontFactory.GetFont("Arial", 9)));
                cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                cell.Border        = 0;
                cell.PaddingBottom = 5f;
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(" ", FontFactory.GetFont("Arial", 9)));
                cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                cell.Border        = 0;
                cell.PaddingBottom = 5f;
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase(" ", FontFactory.GetFont("Arial", 9)));
                cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                cell.Border        = 0;
                cell.PaddingBottom = 5f;
                table.AddCell(cell);

                image.ScaleAbsoluteWidth(150);
                image.ScaleAbsoluteHeight(42);

                Paragraph p     = new Paragraph();
                int       descu = 9;
                if (DO.Sum(x => x.Descuento) > 0)
                {
                    doorsxUser.DescuentoActivos = true;
                    descu = 10;
                }
                PdfPTable TableDoor = new PdfPTable(descu);
                TableDoor.TotalWidth          = 526f;
                TableDoor.LockedWidth         = true;
                TableDoor.HorizontalAlignment = 0;
                TableDoor.SpacingBefore       = 20f;
                TableDoor.SpacingAfter        = 30f;
                cell                     = new PdfPCell(new Phrase("Door List", FontFactory.GetFont("Arial", 12)));
                cell.Colspan             = descu;
                cell.HorizontalAlignment = 1;
                cell.Border              = 0;
                cell.PaddingBottom       = 10f;
                TableDoor.AddCell(cell);
                cell = new PdfPCell(new Phrase("Door", FontFactory.GetFont("Arial", 10)));
                TableDoor.AddCell(cell);
                cell = new PdfPCell(new Phrase("Quantity", FontFactory.GetFont("Arial", 10)));
                TableDoor.AddCell(cell);
                cell = new PdfPCell(new Phrase("Width", FontFactory.GetFont("Arial", 10)));
                TableDoor.AddCell(cell);
                cell = new PdfPCell(new Phrase("Height", FontFactory.GetFont("Arial", 10)));
                TableDoor.AddCell(cell);
                cell = new PdfPCell(new Phrase("Panel", FontFactory.GetFont("Arial", 10)));
                TableDoor.AddCell(cell);
                cell = new PdfPCell(new Phrase("Door Type", FontFactory.GetFont("Arial", 10)));
                TableDoor.AddCell(cell);
                cell = new PdfPCell(new Phrase("Door Option", FontFactory.GetFont("Arial", 10)));
                TableDoor.AddCell(cell);
                cell = new PdfPCell(new Phrase("Item Cost", FontFactory.GetFont("Arial", 10)));
                TableDoor.AddCell(cell);
                if (doorsxUser.DescuentoActivos)
                {
                    cell = new PdfPCell(new Phrase("Discount", FontFactory.GetFont("Arial", 10)));
                    TableDoor.AddCell(cell);
                }
                cell = new PdfPCell(new Phrase("Sub Total", FontFactory.GetFont("Arial", 10)));
                TableDoor.AddCell(cell);

                foreach (DoorxOrder item in DO)
                {
                    string rutaImagenDoor = mapPach + item.Picture;
                    Image  imagen         = Image.GetInstance(rutaImagenDoor);
                    TableDoor.AddCell(imagen);
                    cell = new PdfPCell(new Phrase(item.Quantity.ToString().Replace(',', '.'), FontFactory.GetFont("Arial", 10)));
                    TableDoor.AddCell(cell);
                    string dw  = (item.DecimalsWidth.Id == 2) ? "" : item.DecimalsWidth.Description;
                    string wit = item.Width.ToString().Split(',')[0] + " " + dw;
                    cell = new PdfPCell(new Phrase(wit, FontFactory.GetFont("Arial", 10)));
                    TableDoor.AddCell(cell);

                    string dh  = (item.DecimalsHeight.Id == 2) ? "" : item.DecimalsHeight.Description;
                    string hei = item.Height.ToString().Split(',')[0] + " " + dh;
                    cell = new PdfPCell(new Phrase(hei, FontFactory.GetFont("Arial", 10)));
                    TableDoor.AddCell(cell);
                    cell = new PdfPCell(new Phrase(item.Panel.Description, FontFactory.GetFont("Arial", 10)));
                    TableDoor.AddCell(cell);
                    cell = new PdfPCell(new Phrase(item.DoorType.Description, FontFactory.GetFont("Arial", 10)));
                    TableDoor.AddCell(cell);
                    cell = new PdfPCell(new Phrase(item.DoorOption.Description, FontFactory.GetFont("Arial", 10)));
                    TableDoor.AddCell(cell);
                    cell = new PdfPCell(new Phrase("$" + item.ItemCost.ToString().Replace(',', '.'), FontFactory.GetFont("Arial", 10)));
                    TableDoor.AddCell(cell);
                    if (doorsxUser.DescuentoActivos)
                    {
                        cell = new PdfPCell(new Phrase(item.Descuento.ToString() + "%", FontFactory.GetFont("Arial", 10)));
                        TableDoor.AddCell(cell);
                    }
                    cell = new PdfPCell(new Phrase("$" + item.SubTotal.ToString().Replace(',', '.'), FontFactory.GetFont("Arial", 10)));
                    TableDoor.AddCell(cell);
                }
                Chunk sub = new Chunk("Sub-Total: $" + order.SubTotal.ToString().Replace(',', '.') + " \n",
                                      FontFactory.GetFont("Arial", 14));
                Chunk tax = new Chunk("Tax: $" + order.Tax.ToString().Replace(',', '.') + " \n",
                                      FontFactory.GetFont("Arial", 14));
                Chunk total = new Chunk("Total Price: $" + order.Total.ToString().Replace(',', '.') + " \n",
                                        FontFactory.GetFont("Arial", 16));
                Paragraph footer = new Paragraph();
                footer.Add(sub);
                footer.Add(tax);
                footer.Add(total);
                footer.Alignment = 2;

                PdfPTable TableUser = new PdfPTable(1);
                TableUser.TotalWidth          = 526f;
                TableUser.LockedWidth         = true;
                TableUser.HorizontalAlignment = 0;
                TableUser.SpacingBefore       = 20f;
                TableUser.SpacingAfter        = 30f;
                cell = new PdfPCell(new Phrase("Name: " + person.Name + " " + person.Lastname + " \n",
                                               FontFactory.GetFont("Arial", 10)));
                cell.Border = 0;
                TableUser.AddCell(cell);
                cell = new PdfPCell(new Phrase("Email: " + user.Email + " \n",
                                               FontFactory.GetFont("Arial", 10)));
                cell.Border = 0;
                TableUser.AddCell(cell);
                cell = new PdfPCell(new Phrase("Telephone: " + person.Telephone + " \n",
                                               FontFactory.GetFont("Arial", 10)));
                cell.Border = 0;
                TableUser.AddCell(cell);


                PdfPTable TableHeader = new PdfPTable(2);
                TableHeader.TotalWidth          = 526f;
                TableHeader.LockedWidth         = true;
                TableHeader.HorizontalAlignment = 0;
                TableHeader.SpacingBefore       = 20f;
                TableHeader.SpacingAfter        = 30f;
                cell = new PdfPCell(image);
                cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                cell.Border = 0;
                TableHeader.AddCell(cell);
                p.Add(c);
                p.Add(order.CreationDate.ToString("MM/dd/yyyy") + " \n");


                p.Alignment = 2;
                cell        = new PdfPCell(new Phrase(p));
                cell.HorizontalAlignment = 2; //0=Left, 1=Centre, 2=Right
                cell.Border = 0;
                TableHeader.AddCell(cell);



                //  doc1.Add(p);
                // doc1.Add(image);
                doc1.Add(TableHeader);
                doc1.Add(TableUser);
                doc1.Add(table);
                doc1.Add(TableDoor);
                doc1.Add(footer);
                doc1.Close();
                //-------------------------------
                return(ruta);
                //  return Json(true);
            }
            catch (Exception ex)
            {
                return("");
                // return Json(false);
            }
        }