Beispiel #1
0
        public void drawPants(Product p)
        {
            Pants s = (Pants)p;

            drawSet(true, true, true, true, true, false, false, false);
            drawApparel(p);

            lblVar4.Text = "Inseam";
            txtVar4.Text = s.Inseam.ToString();

            lblVar5.Text = "Waist";
            txtVar5.Text = s.Waist.ToString();
        }
        public void writeToBinary()
        {
            BinaryWriter bOut = new BinaryWriter(new FileStream(@"Products.dat", FileMode.Create, FileAccess.Write));

            foreach (Product p in this)
            {
                bOut.Write(p.Desc);
                bOut.Write(p.ID);
                bOut.Write(p.Price);
                bOut.Write(p.Quantity);
                bOut.Write(p.Type);

                switch (p.Desc)
                {
                    case "DressShirt":
                        DressShirt d = (DressShirt)p;
                        bOut.Write(d.Color);
                        bOut.Write(d.Manufacturer);
                        bOut.Write(d.Material);
                        bOut.Write(d.Neck);
                        bOut.Write(d.Sleeve);
                        break;
                    case "Pants":
                        Pants x = (Pants)p;
                        bOut.Write(x.Color);
                        bOut.Write(x.Manufacturer);
                        bOut.Write(x.Material);
                        bOut.Write(x.Inseam);
                        bOut.Write(x.Waist);
                        break;
                    case "TShirt":
                        TShirt t = (TShirt)p;
                        bOut.Write(t.Color);
                        bOut.Write(t.Manufacturer);
                        bOut.Write(t.Material);
                        bOut.Write(t.Size);
                        break;
                    case "Software":
                        Software s = (Software)p;
                        bOut.Write(s.ReleaseDate.ToString());
                        bOut.Write(s.NumDisks);
                        bOut.Write(s.Size);
                        bOut.Write(s.TypeDisk);
                        bOut.Write(s.TypeSoft);
                        break;
                    case "Movie":
                        Movie m = (Movie)p;
                        bOut.Write(m.ReleaseDate.ToString());
                        bOut.Write(m.NumDisks);
                        bOut.Write(m.Size);
                        bOut.Write(m.TypeDisk);
                        bOut.Write(m.RunTime.ToString());
                        bOut.Write(m.Director);
                        bOut.Write(m.Producer);
                        break;
                    case "Music":
                        Music u = (Music)p;
                        bOut.Write(u.ReleaseDate.ToString());
                        bOut.Write(u.NumDisks);
                        bOut.Write(u.Size);
                        bOut.Write(u.TypeDisk);
                        bOut.Write(u.RunTime.ToString());
                        bOut.Write(u.Artist);
                        bOut.Write(u.Genre);
                        bOut.Write(u.Label);
                        break;
                }
            }
        }