/// <summary> /// Add a a product to the ticket and insert it in the database /// </summary> /// <param name="ticketID">ID of the ticket</param> /// <param name="bde">BDE of the ticket</param> /// <param name="p">Product</param> /// <param name="quantity">Quantity of the product added</param> /// <returns></returns> public void AddTicket(Ticket t) { var bdeID = t.BDESale.ID; foreach (var basketitem in t.ProductItems) { var productID = basketitem.ItemProduct.ID; db.ExecuteCommand($"INSERT INTO ligneTicket values('{t.IDTicket}','{productID}','{bdeID}',{basketitem.Quantity},datetime('now'),{t.SellerUser.ID},{t.Account.ID},{t.Reduction.ToString("F", CultureInfo.InvariantCulture)})"); db.ExecuteCommand($"UPDATE products SET stock={basketitem.itemProduct.Stock - basketitem.quantity} where idProduct={basketitem.itemProduct.ID}"); } }