public static Pants SelectPants(string id) { Pants p = (Pants)null; OleDbConnection conn = GetConnection(); string selectStatement = "SELECT Product.Type, Product.ID, Product.Desc, Product.Price, Product.Qty, Apparel.Material, Apparel.Color, Apparel.Manufacturer, Pants.Inseam, Pants.Waist " + "FROM (Product INNER JOIN Apparel ON Product.ID = Apparel.ID) INNER JOIN Pants ON Apparel.ID = Pants.ID " + "WHERE Product.ID = '" + id + "';"; OleDbCommand selectCommand = new OleDbCommand(selectStatement, conn); try { conn.Open(); OleDbDataReader dataReader = selectCommand.ExecuteReader(); if (dataReader.Read()) { p = new Pants(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(p); }
private void drawPants(Product p) { Pants pants = (Pants)p; drawSet(true, true, true, true, true, false, false, false); drawApparel(p); lblVar4.Text = "Waist"; txtVar4.Text = pants.Waist.ToString(); lblVar5.Text = "Inseam"; txtVar5.Text = pants.Inseam.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; } } }