Ejemplo n.º 1
0
        private void PopulatePreview(ItemCounts counts)
        {
            if (this.previewDGV.Rows.Count != 0)
            {
                this.previewDGV.Rows.Clear();
            }

            var metals   = counts.Metal;
            var walls    = counts.Walls;
            var covers   = counts.Covers;
            var tiedowns = counts.TieDowns;

            if (covers != null)
            {
                metals   = metals.OrderBy(o => o.Type).ToList();
                walls    = walls.OrderBy(o => o.Type).ToList();
                covers   = covers.OrderBy(o => o.Type).ToList();
                tiedowns = tiedowns.OrderBy(o => o.Type).ToList();

                int i = 0;


                // Loop through all items in metal list
                foreach (var metal in metals)
                {
                    this.previewDGV.Rows.Add();
                    this.previewDGV.Rows[i].Cells[0].Value = metal.Type;
                    this.previewDGV.Rows[i].Cells[1].Value = metal.Qty.ToString();
                    i++;
                }

                // Loop through all items in covers list
                foreach (var cover in covers)
                {
                    this.previewDGV.Rows.Add();
                    this.previewDGV.Rows[i].Cells[0].Value = cover.Type;
                    this.previewDGV.Rows[i].Cells[1].Value = cover.Qty.ToString();
                    i++;
                }

                // Loop through all items in wall list
                foreach (var wall in walls)
                {
                    this.previewDGV.Rows.Add();
                    this.previewDGV.Rows[i].Cells[0].Value = wall.Type;
                    this.previewDGV.Rows[i].Cells[1].Value = wall.Qty.ToString();
                    i++;
                }

                // Loop through all items in tie down list
                foreach (var tiedown in tiedowns)
                {
                    this.previewDGV.Rows.Add();
                    this.previewDGV.Rows[i].Cells[0].Value = tiedown.Type;
                    this.previewDGV.Rows[i].Cells[1].Value = tiedown.Qty.ToString();
                    i++;
                }
            }
        }
Ejemplo n.º 2
0
 public Createpdf(string truck, string trailer, string driver, ItemCounts counts, string installDate)
 {
     this.Truck       = truck;
     this.Trailer     = trailer;
     this.Driver      = driver;
     this.Counts      = counts;
     this.InstallDate = installDate;
 }
Ejemplo n.º 3
0
 public Createpdf(string truck, string trailer, string driver, ItemCounts counts, List <Accessory> acc, string installDate)
 {
     this.Truck       = truck;
     this.Trailer     = trailer;
     this.Driver      = driver;
     this.Counts      = counts;
     this.Acc         = acc;
     this.InstallDate = installDate;
 }
Ejemplo n.º 4
0
        private ItemCounts UpdateList()
        {
            // Declare lists
            List <Tent>   tentTypes      = new List <Tent>();
            List <string> tentSizes      = new List <string>();
            List <int>    tentQties      = new List <int>();
            List <string> tentCoverTypes = new List <string>();
            List <string> tentHoldDowns  = new List <string>();
            List <string> tentWalls      = new List <string>();
            List <string> tentLegs       = new List <string>();

            ItemCounts counts = new ItemCounts();

            // Loop through tentDGV and store data in lists
            if (tentDGV.Rows.Count != 0)
            {
                foreach (DataGridViewRow row in tentDGV.Rows)
                {
                    tentTypes.Add((Tent)row.Cells[0].Value);
                    tentSizes.Add(row.Cells[1].Value.ToString());
                    tentQties.Add(Convert.ToInt32(row.Cells[2].Value));
                    tentCoverTypes.Add(row.Cells[3].Value.ToString());
                    tentHoldDowns.Add(row.Cells[4].Value.ToString());
                    tentWalls.Add(row.Cells[5].Value.ToString());
                    tentLegs.Add(row.Cells[6].Value.ToString());
                }

                // Create object with the lists and send for processing
                var         ListOfLists = new ListNames(tentTypes, tentSizes, tentQties, tentCoverTypes, tentHoldDowns, tentWalls, tentLegs);
                DataHandler handler     = new DataHandler();
                counts = handler.CountTents(ref ListOfLists);
            }

            if (counts != null)
            {
                PopulatePreview(counts);
            }

            return(counts);
        }
Ejemplo n.º 5
0
        private string GenerateReport()
        {
            // Get information about the truck, trailer, driver
            string truck    = tb_truck.Text;
            string trailer  = tb_trailer.Text;
            string driver   = tb_driver.Text;
            string filename = String.Empty;

            // Test for null or empty strings
            if (String.IsNullOrEmpty(truck))
            {
                truck = "not assigned";
            }
            if (String.IsNullOrEmpty(trailer))
            {
                trailer = "not assigned";
            }
            if (String.IsNullOrEmpty(driver))
            {
                driver = "_______________";
            }

            // Get today's date
            string date = InstallDate.ToString("yyyy-MM-dd");

            // Get the My Documents path
            string MyDocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            // Check if output folder already exists
            string OutputPath = @MyDocumentsPath + @"\Truck Loads\" + @"\" + date.Substring(0, 7) + @"\";

            Console.WriteLine(OutputPath);
            if (!File.Exists(OutputPath))
            {
                Directory.CreateDirectory(OutputPath);
            }

            // Get the final count of items
            ItemCounts counts = UpdateList();

            // If the counts list is null, show a warning to the user and do not generate a PDF
            if (counts.Covers != null)
            {
                // Get items from accessory list
                List <Accessory> AccList = new List <Accessory>();
                int    qty  = 0;
                string item = "";

                // Call default constructor
                Createpdf pdf = new Createpdf();

                if (accDGV.Rows.Count != 0)
                {
                    foreach (DataGridViewRow row in accDGV.Rows)
                    {
                        item = row.Cells[0].Value.ToString();
                        qty  = Convert.ToInt32(row.Cells[1].Value);
                        Accessory acc = new Accessory(item, qty);
                        AccList.Add(acc);
                    }
                    // Generate the PDF
                    pdf = new Createpdf(truck, trailer, driver, counts, AccList, date);
                }
                else
                {
                    // Generate the PDF
                    pdf = new Createpdf(truck, trailer, driver, counts, date);
                }

                // Create a MigraDoc document
                Document document = pdf.CreateDocument();
                document.UseCmykColor = true;

                // Create a renderer for PDF that uses Unicode font encoding
                PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true)
                {
                    // Set the MigraDoc document
                    Document = document
                };

                // Create the PDF document
                pdfRenderer.RenderDocument();

                // Save the PDF document...
                // TODO: Check if file already exists
                filename = string.Format(@"{0}MaterialList_{2}_truck{1}.pdf", OutputPath, truck, date);

                pdfRenderer.Save(filename);

                // ...and start a viewer if desired
                if (ShowPDF == true)
                {
                    Process.Start(filename);
                }
            }
            else
            {
                MessageBox.Show("You can not generate a list at this point, because you have no tents listed. Please add tents to this load.",
                                "Empty List", MessageBoxButtons.OK, MessageBoxIcon.Error);
                filename = string.Empty;
            }

            return(filename);
        }
Ejemplo n.º 6
0
        public ItemCounts CountTents(ref ListNames ListOfLists)
        {
            // Declare lists of TentItems
            List <TentItems> MetalItemList = new List <TentItems>();
            List <TentItems> WallList      = new List <TentItems>();
            List <TentItems> CoverList     = new List <TentItems>();
            List <TentItems> HoldDownList  = new List <TentItems>();

            // Declare object of ItemCounts class
            ItemCounts counts = new ItemCounts();

            // Declare variables.
            Legs      leg         = Legs.none;
            string    legTentType = null;
            IDatabase db          = new SmallTentDB();

            IEnumerable <SmallTentDB> SmallDB     = ReadTentDatabase <SmallTentDB>(UserInterface.Tent.Small);
            List <SmallTentDB>        Small       = SmallDB.ToList();
            IEnumerable <LargeTentDB> LargeDB     = ReadTentDatabase <LargeTentDB>(UserInterface.Tent.Large);
            List <LargeTentDB>        Large       = LargeDB.ToList();
            IEnumerable <FrameDB>     FrameDB     = ReadTentDatabase <FrameDB>(UserInterface.Tent.Frame);
            List <FrameDB>            Frame       = FrameDB.ToList();
            IEnumerable <ClearSpanDB> ClearSpanDB = ReadTentDatabase <ClearSpanDB>(UserInterface.Tent.ClearSpan);
            List <ClearSpanDB>        ClearSpan   = ClearSpanDB.ToList();

            // Loop through all tents
            for (int i = 0; i < ListOfLists.tentType.Count; ++i)
            {
                // Get the quantity of that particular tent
                int qty = ListOfLists.tentQties[i];

                // Get the cover size, type of cover and type of tent
                string             size       = ListOfLists.tentSizes[i];
                UserInterface.Tent typeOfTent = ListOfLists.tentType[i];
                string             coverType  = ListOfLists.tentCoverTypes[i];

                // Depending on the type and size of tent, get the appropriate row in the database.
                switch (ListOfLists.tentType[i])
                {
                case UserInterface.Tent.Small:
                {
                    legTentType = "ST";

                    // Get the appropriate row from the small tent database, depending on the size of the tent.
                    SmallTentDB SmallRow = Small.Find(b => b.Size == size);
                    db = SmallRow;

                    if (SmallRow != null)
                    {
                        // Metal list
                        // TODO: string builder for legs, cable, poteau de milieu
                        HandleList("Pipe", SmallRow.Pipe * qty, MetalItemList);
                        HandleList("Pipe 5ft", SmallRow.Pipe5 * qty, MetalItemList);
                        HandleList("T - 20", SmallRow.SmallTee * qty, MetalItemList);
                        HandleList("T - 30", SmallRow.LargeTee * qty, MetalItemList);
                        HandleList("Entures", SmallRow.Enture * qty, MetalItemList);
                        if (size == "Hexagon")
                        {
                            HandleList("Coins Hex", SmallRow.Corner * qty, MetalItemList);
                            HandleList("Hexagone", qty, CoverList);
                        }
                        else
                        {
                            HandleList("Coins", SmallRow.Corner * qty, MetalItemList);
                            HandleList(SmallRow.Size + " " + coverType, qty, CoverList);
                        }
                        HandleList("Brace - 30", SmallRow.Brace * qty, MetalItemList);
                        HandleList(string.Format("PM {0}", size), SmallRow.MiddlePost * qty, MetalItemList);
                        HandleList(string.Format("Cables {0}", size), SmallRow.Cable * qty, WallList);
                    }
                }
                break;

                case UserInterface.Tent.Large:
                    legTentType = "BT";

                    // Get the appropriate row from the large tent database, depending on the size of the tent.
                    LargeTentDB LargeRow = Large.Find(b => b.Size == size);
                    db = LargeRow;

                    if (LargeRow != null)
                    {
                        HandleList(string.Format("PM {0}", size.Substring(0, 2)), LargeRow.MiddlePost * qty, MetalItemList);
                        HandleList("Plates", LargeRow.Plates * qty, MetalItemList);
                        HandleList(string.Format("Mid {0}' x 20' {1}", size.Substring(0, 2), coverType), LargeRow.Mid20 * qty, CoverList);
                        HandleList(string.Format("Mid {0}' x 30' {1}", size.Substring(0, 2), coverType), LargeRow.Mid30 * qty, CoverList);
                        HandleList(string.Format("End {0}' {1}", size.Substring(0, 2), coverType), 2 * qty, CoverList);
                    }
                    break;

                case UserInterface.Tent.Frame:
                    // Get the appropriate row from the frame database, depending on the size of the tent.
                    FrameDB FrameRow = Frame.Find(b => b.Size == size);
                    db = FrameRow;

                    if (FrameRow != null)
                    {
                        // TODO: Handle mids and ends after database is fixed
                        HandleList("Mid 10' " + coverType, FrameRow.Cover10 * qty, CoverList);
                        HandleList("Mid 15' " + coverType, FrameRow.Cover15 * qty, CoverList);
                        HandleList("End Frame " + coverType, qty, CoverList);
                    }

                    break;

                case UserInterface.Tent.ClearSpan:
                    // Get the appropriate row from the ClearSpan database, depending on the size of the tent.
                    ClearSpanDB ClearSpanRow = ClearSpan.Find(b => b.Size == size);
                    db = ClearSpanRow;

                    // Get the width of the ClearSpan
                    int ClearSpanWidth = Convert.ToInt32(size.Substring(0, 2));

                    if (ClearSpanRow != null)
                    {
                        HandleList(string.Format("ClearSpan {0}' x 10' {1}", ClearSpanWidth.ToString(), coverType), ClearSpanRow.Cover10 * qty, CoverList);
                        HandleList(string.Format("ClearSpan {0}' x 15' {1}", ClearSpanWidth.ToString(), coverType), ClearSpanRow.Cover15 * qty, CoverList);

                        switch (ClearSpanWidth)
                        {
                        case 30:
                            HandleList("Triangle 30'", ClearSpanRow.Triangle * qty, CoverList);
                            break;

                        case 40:
                            HandleList("Triangle 40'", ClearSpanRow.Triangle * qty, CoverList);
                            break;

                        case 50:
                            HandleList("Triangle 50'", ClearSpanRow.Triangle * qty, CoverList);
                            break;
                        }

                        if (ListOfLists.tentWalls[i] != "None")
                        {
                            switch (ListOfLists.tentWalls[i])
                            {
                            case "Full Plain":
                                HandleList("Mur CSP 10'", ClearSpanRow.CSPWalls10 * qty, WallList);
                                HandleList("Mur CSP 15'", ClearSpanRow.CSPWalls15 * qty, WallList);
                                HandleList("Mur CSP 20'", ClearSpanRow.CSPWalls20 * qty, WallList);
                                break;

                            case "Full Bay Window":
                                HandleList("Mur CSP 10' Bay", ClearSpanRow.CSPWalls10 * qty, WallList);
                                HandleList("Mur CSP 15' Bay", ClearSpanRow.CSPWalls15 * qty, WallList);
                                HandleList("Mur CSP 20' Bay", ClearSpanRow.CSPWalls20 * qty, WallList);
                                break;

                            case "Full French Window":
                                HandleList("Mur CSP 10' FW", ClearSpanRow.CSPWalls10 * qty, WallList);
                                HandleList("Mur CSP 15' FW", ClearSpanRow.CSPWalls15 * qty, WallList);
                                HandleList("Mur CSP 20' FW", ClearSpanRow.CSPWalls20 * qty, WallList);
                                break;

                            case "Half Plain Half Bay Window":
                                HandleList("Mur CSP 10'", (int)System.Math.Ceiling((double)ClearSpanRow.CSPWalls10 / 2) * qty, WallList);
                                HandleList("Mur CSP 15'", (int)System.Math.Ceiling((double)ClearSpanRow.CSPWalls15 / 2) * qty, WallList);
                                HandleList("Mur CSP 20'", (int)System.Math.Ceiling((double)ClearSpanRow.CSPWalls20 / 2) * qty, WallList);
                                HandleList("Mur CSP 10' Bay", (int)System.Math.Ceiling((double)ClearSpanRow.CSPWalls10 / 2) * qty, WallList);
                                HandleList("Mur CSP 15' Bay", (int)System.Math.Ceiling((double)ClearSpanRow.CSPWalls15 / 2) * qty, WallList);
                                HandleList("Mur CSP 20' Bay", (int)System.Math.Ceiling((double)ClearSpanRow.CSPWalls20 / 2) * qty, WallList);
                                break;
                            }
                        }
                    }
                    break;
                }

                // Hold Down list
                switch (ListOfLists.tentHoldDowns[i])
                {
                case "Pins":
                    HandleList("White Pins", db.PinsW * qty, HoldDownList);
                    HandleList("Red Pins", db.PinsR * qty, HoldDownList);
                    break;

                case "Water Barrels":
                    HandleList("Water Barrels", db.Barrels * qty, HoldDownList);
                    break;

                case "250 lb Concrete Block":
                    HandleList("250 lb Block", db.Concrete250 * qty, HoldDownList);
                    break;

                case "400 lb Concrete Block":
                    HandleList("400 lb Block", db.Concrete400 * qty, HoldDownList);
                    break;

                case "600 lb Concrete Block":
                    HandleList("600 lb Block", db.Concrete600 * qty, HoldDownList);
                    break;

                case "1/2 ton Concrete Block":
                    HandleList("1/2 ton Block", db.ConcreteHalfTon * qty, HoldDownList);
                    break;

                case "1 ton Concrete Block":
                    HandleList("1 ton Block", db.ConcreteTon * qty, HoldDownList);
                    break;
                }

                //Comealongs
                HandleList("Come Along", db.ComeAlong * qty, HoldDownList);

                // If the tent is not hexagon, build the string for type of legs and handle it
                string tentLegs = ListOfLists.tentLegs[i];

                if (tentLegs != "Hexagon")
                {
                    string LegsForList = string.Format("Pattes {0} {1}", tentLegs, legTentType);
                    HandleList(LegsForList, db.Legs * qty, MetalItemList);

                    // Assign enum depending on leg type
                    if (tentLegs == "8 ft" || tentLegs == "8 ft Adjustable")
                    {
                        leg = Legs.shortLegs;
                    }
                    else if (tentLegs == "10 ft" || tentLegs == "10 ft Adjustable")
                    {
                        leg = Legs.longLegs;
                    }
                }
                else
                {
                    // If the size of the cover selected is not hexagon, throw an error.
                    if (ListOfLists.tentSizes[i] != "Hexagon")
                    {
                        throw new Exception("Hexagon legs were chosen, but the cover type for this tent is not Hexagon.");
                    }
                    else
                    {
                        // Assign shortLegs enum to leg variable because hex tents have 8' high walls...
                        leg = Legs.shortLegs;
                        HandleList("Pattes Hex", db.Legs * qty, MetalItemList);
                    }
                }

                // This can definitely be optimized but it works...
                // Insert walls in list.
                if (leg != Legs.none && ListOfLists.tentWalls[i] != "None")
                {
                    string leg_length = null;
                    if (leg == Legs.longLegs)
                    {
                        leg_length = ", 10'";
                    }

                    switch (ListOfLists.tentWalls[i])
                    {
                    case "Full Plain":
                        HandleList(string.Format("Murs 10' P{0}", leg_length), db.Walls10 * qty, WallList);
                        HandleList(string.Format("Murs 15' P{0}", leg_length), db.Walls15 * qty, WallList);
                        HandleList(string.Format("Murs 20' P{0}", leg_length), db.Walls20 * qty, WallList);
                        break;

                    case "Full Window":
                        HandleList(string.Format("Murs 10' W{0}", leg_length), db.Walls10 * qty, WallList);
                        HandleList(string.Format("Murs 15' W{0}", leg_length), db.Walls15 * qty, WallList);
                        HandleList(string.Format("Murs 20' W{0}", leg_length), db.Walls20 * qty, WallList);
                        break;

                    case "Half Plain Half Window":
                        HandleList(string.Format("Murs 10' P{0}", leg_length), (int)System.Math.Ceiling((double)db.Walls10 / 2) * qty, WallList);
                        HandleList(string.Format("Murs 15' P{0}", leg_length), (int)System.Math.Ceiling((double)db.Walls15 / 2) * qty, WallList);
                        HandleList(string.Format("Murs 20' P{0}", leg_length), (int)System.Math.Ceiling((double)db.Walls20 / 2) * qty, WallList);
                        HandleList(string.Format("Murs 10' W{0}", leg_length), (int)System.Math.Ceiling((double)db.Walls10 / 2) * qty, WallList);
                        HandleList(string.Format("Murs 15' W{0}", leg_length), (int)System.Math.Ceiling((double)db.Walls15 / 2) * qty, WallList);
                        HandleList(string.Format("Murs 20' W{0}", leg_length), (int)System.Math.Ceiling((double)db.Walls20 / 2) * qty, WallList);
                        break;

                    case "Full Plain Fiesta":
                        HandleList(string.Format("Murs 10' PF, {0}", leg_length), db.Walls10 * qty, WallList);
                        HandleList(string.Format("Murs 15' PF, {0}", leg_length), db.Walls15 * qty, WallList);
                        HandleList(string.Format("Murs 20' PF, {0}", leg_length), db.Walls20 * qty, WallList);
                        break;

                    case "Full Window Fiesta":
                        HandleList(string.Format("Murs 10' WF, {0}", leg_length), db.Walls10 * qty, WallList);
                        HandleList(string.Format("Murs 15' WF, {0}", leg_length), db.Walls15 * qty, WallList);
                        HandleList(string.Format("Murs 20' WF, {0}", leg_length), db.Walls20 * qty, WallList);
                        break;

                    case "Half Plain Half Window Fiesta":
                        HandleList(string.Format("Murs 10' PF, {0}", leg_length), (int)System.Math.Ceiling((double)db.Walls10 / 2) * qty, WallList);
                        HandleList(string.Format("Murs 15' PF, {0}", leg_length), (int)System.Math.Ceiling((double)db.Walls15 / 2) * qty, WallList);
                        HandleList(string.Format("Murs 20' PF, {0}", leg_length), (int)System.Math.Ceiling((double)db.Walls20 / 2) * qty, WallList);
                        HandleList(string.Format("Murs 10' WF, {0}", leg_length), (int)System.Math.Ceiling((double)db.Walls10 / 2) * qty, WallList);
                        HandleList(string.Format("Murs 15' WF, {0}", leg_length), (int)System.Math.Ceiling((double)db.Walls15 / 2) * qty, WallList);
                        HandleList(string.Format("Murs 20' WF, {0}", leg_length), (int)System.Math.Ceiling((double)db.Walls20 / 2) * qty, WallList);
                        break;
                    }
                }
            }

            // Collect all the lists into the "counts" object to be returned.
            counts.Covers   = CoverList;
            counts.Metal    = MetalItemList;
            counts.TieDowns = HoldDownList;
            counts.Walls    = WallList;

            return(counts);
        }