private void button1_Click(object sender, EventArgs e) { if (IdTextBox.Text.Length > 0 || !Regex.IsMatch(IdTextBox.Text, @"^\d+$")) { int index = KuponListBox.FindString(IdTextBox.Text); if (index != -1) { KuponListBox.SetSelected(index, true); string[] separators = { " " }; string[] words = KuponListBox.SelectedItem.ToString().Split(separators, StringSplitOptions.RemoveEmptyEntries); kurs = kurs / double.Parse(words[2]); Kurs_wypis.Text = kurs.ToString(); if (BetValueLabel.Text.Length > 0) { Kwota_wypis.Text = (double.Parse(BetValueLabel.Text) * kurs).ToString(); } KuponListBox.Items.Remove(KuponListBox.SelectedItem); KuponListBox.Refresh(); } } }
private void SaveBetButton_Click(object sender, EventArgs e) { Dane_Error.Text = ""; if (IdTextBox.Text.Length > 0 && !Regex.IsMatch(IdTextBox.Text, @"^\d+$")) { } var result = from p in dataBase.Matches where p.ID.ToString() == IdTextBox.Text select p; if (result.Any()) { if ((EnvironmentVariableTargetx = KuponListBox.FindString(IdTextBox.Text)) == -1) { if (TeamTextBox.Text == "1") { KuponListBox.Items.Add(result.First().ID.ToString() + " " + result.First().Team1 + " " + result.First()._1); kurs = kurs * result.First()._1; Kurs_wypis.Text = kurs.ToString(); IdTextBox.Text = ""; TeamTextBox.Text = ""; } else if (TeamTextBox.Text == "2") { KuponListBox.Items.Add(result.First().ID.ToString() + " " + result.First().Team2 + " " + result.First()._2); kurs = kurs * result.First()._2; Kurs_wypis.Text = kurs.ToString(); IdTextBox.Text = ""; TeamTextBox.Text = ""; } else if (TeamTextBox.Text == "X" || TeamTextBox.Text == "x") { KuponListBox.Items.Add(result.First().ID.ToString() + " Remis " + result.First().X); kurs = kurs * result.First().X; Kurs_wypis.Text = kurs.ToString(); } else { Dane_Error.Text = "Nieprawidłowa drużyna, wpisz 1, X lub 2."; } } } else { Dane_Error.Text = "Nieprawidłowe ID"; } if (BetValueLabel.Text.Length > 0) { if (double.Parse(BetValueLabel.Text) >= 2) { Kwota_wypis.Text = (double.Parse(BetValueLabel.Text) * kurs).ToString(); kwota_error.Text = ""; } else { kwota_error.Text = "Minimalna kwota zakładu to 2 zł."; } } else { kwota_error.Text = "Podaj kwotę by zobaczyć przewidywaną wygraną i naciśnij ponownie 'Dodaj'!"; } }