private void buttonX1_Click(object sender, EventArgs e) { if (comboBoxEx5.SelectedValue != null && comboBoxEx4.SelectedValue != null && comboBoxEx3.SelectedValue != null) { Patient obj = new Patient(); obj.Name = textBoxX1.Text; obj.PhoneNo = textBoxX4.Text; obj.Address = textBoxX3.Text; obj.Age = (int)numericUpDown1.Value; obj.Gender = radioButton1.Checked ? true : false; obj.DoctorId = (int)comboBoxEx5.SelectedValue; obj.ReceptionistId = (int)comboBoxEx3.SelectedValue; obj.RoomId = (int)comboBoxEx4.SelectedValue; try { BL.Create(obj); refresh(); textBoxX1.Text = ""; textBoxX3.Text = ""; textBoxX4.Text = ""; numericUpDown1.Value = 0; } catch (Exception ex) { MessageBox.Show(ex.Message, "خطا"); } } else { MessageBox.Show("همه فیلد ها را تکمیل کنید", "خطا"); } }