public List <Product> GetLSShirts(int id) { List <Product> list = new List <Product>(); var conn = GetConnection(); string sql = String.Format("SELECT LSShirt.* FROM LSShirt where ProductId = {0};", id); OleDbCommand command = new OleDbCommand(sql, connection); try { conn.Open(); using (OleDbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Product p = new LSShirt(Convert.ToDouble(reader["Neck"]), Convert.ToInt16(reader["Sleeve"])); p.Quantity = Convert.ToInt16(reader["Quantity"]); p.Dbquantity = Convert.ToInt16(reader["Quantity"]); Console.WriteLine(p.ToString()); list.Add(p); } } conn.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(list); }
private void buttonOrder_Click(object sender, EventArgs e) { if (list.products.Count > 0) { bool flag = db.InsertLineItem(invoice); bool flag1 = db.InsertInvoice(invoice); foreach (var p in list.products) { if (p.Type == "TeeShirt") { TeeShirt t = (TeeShirt)p; int newQuantity = t.Dbquantity - t.Quantity; db.UpdateTeeShirtQty(newQuantity, t.Size, t.Id); } if (p.Type == "Pants") { Pants t = (Pants)p; int newQuantity = t.Dbquantity - t.Quantity; db.UpdatePantsQty(newQuantity, t.Inseam, t.Waist, t.Id); } if (p.Type == "LSShirts") { LSShirt t = (LSShirt)p; int newQuantity = t.Dbquantity - t.Quantity; db.UpdateLSSQty(newQuantity, t.Neck, t.Sleeve, t.Id); } if (p.Type == "Shorts") { Shorts t = (Shorts)p; int newQuantity = t.Dbquantity - t.Quantity; db.UpdateShortsQty(newQuantity, t.Waist, t.Id); } if (p.Type == "SSShirt") { SSShirt t = (SSShirt)p; int newQuantity = t.Dbquantity - t.Quantity; db.UpdateSSShirtQty(newQuantity, t.Neck, t.Id); } } if (flag && flag1) { detailsBox.Text = "Thanks for your order."; list.products.Clear(); } else { MessageBox.Show("Error in saving to file!"); } invoice = new Invoice(list); } }
public void Copy(LSShirt toCopy) { base.Copy(toCopy); this.neck = toCopy.neck; this.sleeve = toCopy.sleeve; }
public LSShirt(LSShirt toCopy) : base(toCopy) { this.Copy(toCopy); }