public static TShirt SelectTShirt(string id) { TShirt t = (TShirt)null; OleDbConnection conn = GetConnection(); string selectStatement = "SELECT Product.Type, Product.ID, Product.Desc, Product.Price, Product.Qty, Apparel.Material, Apparel.Color, Apparel.Manufacturer, TShirt.[SizeT] " + "FROM (Product INNER JOIN Apparel ON Product.ID = Apparel.ID) INNER JOIN TShirt ON Apparel.ID = TShirt.ID " + "WHERE Product.ID = '" + id + "';"; OleDbCommand selectCommand = new OleDbCommand(selectStatement, conn); try { conn.Open(); OleDbDataReader dataReader = selectCommand.ExecuteReader(); if (dataReader.Read()) { t = new TShirt(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.GetString(8)); } } catch (OleDbException ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); } finally { conn.Close(); } return(t); }
private void drawTShirt(Product p) { TShirt tshirt = (TShirt)p; drawSet(true, true, true, true, false, false, false, false); drawApparel(p); lblVar4.Text = "Size"; txtVar4.Text = tshirt.Size.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; } } }