Esempio n. 1
0
        public static DressShirt SelectDressShirt(string id)
        {
            DressShirt d = (DressShirt)null;

            OleDbConnection conn            = GetConnection();
            string          selectStatement = "SELECT Product.Type, Product.ID, Product.Desc, Product.Price, Product.Qty, Apparel.Material, Apparel.Color, Apparel.Manufacturer, DressShirt.Neck, DressShirt.Sleeve " +
                                              "FROM (Product INNER JOIN Apparel ON Product.ID = Apparel.ID) INNER JOIN DressShirt ON Apparel.ID = DressShirt.ID " +
                                              "WHERE Product.ID = '" + id + "';";
            OleDbCommand selectCommand = new OleDbCommand(selectStatement, conn);

            try
            {
                conn.Open();
                OleDbDataReader dataReader = selectCommand.ExecuteReader();

                if (dataReader.Read())
                {
                    d = new DressShirt(dataReader.GetString(0), dataReader.GetString(1), dataReader.GetString(2), dataReader.GetDouble(3), dataReader.GetInt32(4), dataReader.GetString(5), dataReader.GetString(6), dataReader.GetString(7), dataReader.GetInt32(8), dataReader.GetInt32(9));
                }
            }
            catch (OleDbException ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
            }
            finally
            {
                conn.Close();
            }

            return(d);
        }
Esempio n. 2
0
        private void drawDressShirt(Product p)
        {
            DressShirt dressShirt = (DressShirt)p;

            drawSet(true, true, true, true, true, false, false, false);
            drawApparel(p);
            lblVar4.Text = "Neck";
            txtVar4.Text = dressShirt.Neck.ToString();
            lblVar5.Text = "Sleeve";
            txtVar5.Text = dressShirt.Sleeve.ToString();
        }
Esempio n. 3
0
        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;
                }
            }
        }