コード例 #1
0
ファイル: MainApp.cs プロジェクト: DianaElena99/University
        private void button1_Click(object sender, EventArgs e)
        {
            string nume  = textBox1.Text;
            int    seats = 0;

            if (dataGridView1.SelectedRows.Count == 0)
            {
                MessageBox.Show("La ce concert sa fie biletul?");
                return;
            }
            int idConcert      = int.Parse(dataGridView1.SelectedRows[0].Cells[0].Value.ToString());
            int nrLocuriLibere = int.Parse(dataGridView1.SelectedRows[0].Cells[6].Value.ToString());

            try
            {
                seats = int.Parse(textBox2.Text);
                if (seats > nrLocuriLibere)
                {
                    MessageBox.Show("Nu sunt destule locuri");
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Not a number, sorry not sorry :/ ");
                return;
            }
            if (seats != 0 && nume != "")
            {
                Bilet b = new Bilet(nume, idConcert, seats);
                server.sellTicket(b);
            }
        }