void calculateTotal() { float totalCoef = 1; for (int i = 0; i < lbTickets.Items.Count; ++i) { TicketItem ti = lbTickets.Items[i] as TicketItem; totalCoef *= ti.Game.Coefitients[ti.Tip]; } tbTotalCoef.Text = string.Format("{0:0.000}", totalCoef); tbProfit.Text = string.Format("{0:0.0}", totalCoef * (float)nudPayment.Value); }
bool containsTicketItem(TicketItem ti) { foreach (object obj in lbTickets.Items) { TicketItem ticketItem = obj as TicketItem; if (ti.Game.Code.Equals(ticketItem.Game.Code)) { return(true); } } return(false); }
private void btnAddGame_Click(object sender, EventArgs e) { if (lbGames.SelectedIndex != -1 && cbTip.SelectedIndex != -1) { Game game = (Game)lbGames.SelectedItem; TicketItem ti = new TicketItem(); ti.Game = game; ti.Tip = cbTip.SelectedIndex; if (!containsTicketItem(ti)) { lbTickets.Items.Add(ti); lbGames.ClearSelected(); calculateTotal(); } else { MessageBox.Show("Овој наптревар е веќе типуван!"); } } }
bool containsTicketItem(TicketItem ti) { foreach (object obj in lbTickets.Items) { TicketItem ticketItem = obj as TicketItem; if (ti.Game.Code.Equals(ticketItem.Game.Code)) { return true; } } return false; }