/// <summary> /// Search customer by id /// and checking the correctness of the input /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonSearch_Click(object sender, EventArgs e) { int parsedValue; if (!int.TryParse(textBoxId.Text, out parsedValue)) // check if id number not contain a characters { MessageBox.Show("Id number have to be digits only", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxId.Text = ""; } if (textBoxId.Text == "") { MessageBox.Show("Enter Customer id"); } else { CurrentCustomer = obj.getCusomerById(Convert.ToInt32(textBoxId.Text)); if (CurrentCustomer != null) { buttonSearch.Enabled = false; panelClasses.Visible = true; customerClasses = CurrentCustomer.getListGymClass(); } else { MessageBox.Show("No user with this id number"); textBoxId.Text = ""; } } }
private void button1_Click(object sender, EventArgs e) { int parsedValue; if (!int.TryParse(textBoxID.Text, out parsedValue)) // check if id number not contain a characters { MessageBox.Show("Id number have to be digits only", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxID.Text = ""; } if (textBoxID.Text == "") { MessageBox.Show("Enter Customer id"); } else { CurrentCustomer = obj.getCusomerById(Convert.ToInt32(textBoxID.Text)); if (CurrentCustomer != null) { if (CurrentCustomer.getListGymClass().Count() != 0) { button1.Enabled = false; foreach (GymClass ClassName in CurrentCustomer.getListGymClass()) { // empEdit classes name to combobox comboBox1.Items.Add(ClassName.getClassName()); } panel1.Visible = true; } else { MessageBox.Show("This user have no classes"); } } else { MessageBox.Show("No user with this id number"); textBoxID.Text = ""; } } }