private void btnSubmit_Click(object sender, EventArgs e) { var checkedButton = this.Controls.OfType <RadioButton>().Where(rb => rb.Checked).SingleOrDefault(); if (txtNoiDung.Text.Length == 0) { MessageBox.Show("Phải nhập nội dung câu hỏi", "Thông báo"); return; } else if (txtCauA.Text.Length == 0) { MessageBox.Show("Phải nhập nội dung câu A", "Thông báo"); return; } else if (txtCauB.Text.Length == 0) { MessageBox.Show("Phải nhập nội dung câu B", "Thông báo"); return; } else if (txtCauC.Text.Length == 0) { MessageBox.Show("Phải nhập nội dung câu C", "Thông báo"); return; } else if (txtCauD.Text.Length == 0) { MessageBox.Show("Phải nhập nội dung câu D", "Thông báo"); return; } else if (checkedButton == null) { MessageBox.Show("Chưa chọn đáp án đúng", "Thông báo"); return; } var requestQuest = new CauHoi() { NoiDung = txtNoiDung.Text, CauA = txtCauA.Text, CauB = txtCauB.Text, CauC = txtCauC.Text, CauD = txtCauD.Text, CauTLDung = checkedButton.Text.ToLower().ToCharArray().FirstOrDefault(), LoaiCauHoi = 2, DaDuyet = 0 }; Question.AddRequest(requestQuest); MessageBox.Show("Bạn đã thêm thành công"); ResetInput(checkedButton); }