private void btn_luu_Click(object sender, EventArgs e) { try { if (txt_mssv.Text.Trim() != "" && txt_hoTen.Text.Trim() != "" && cbb_tenLop.SelectedIndex != -1) { string sql = "insert into SinhVien values('" + txt_mssv.Text.Trim() + "',N'" + txt_hoTen.Text.Trim() + "','" + cbb_tenLop.SelectedValue.ToString() + "')"; conn.CapnhatCSDL(sql); reloadDGV(); refresh(); } else { MessageBox.Show("Vui lòng nhập dữ liệu", "Thông báo"); } } catch { } }
private void btn_luu_Click(object sender, EventArgs e) { try { if (txt_maLop.Text.Trim() != "" && txt_tenLop.Text.Trim() != "") { string sql = "insert into Lop values('" + txt_maLop.Text.Trim() + "',N'" + txt_tenLop.Text.Trim() + "')"; conn.CapnhatCSDL(sql); reloadDGV(); refresh(); } else { if (txt_maLop.Text.Trim() == "" && txt_tenLop.Text.Trim() == "") { MessageBox.Show("Vui lòng nhập dữ liệu vào ô Mã Lớp và ô Tên Lớp", "Thông báo"); } else { if (txt_maLop.Text.Trim() == "") { MessageBox.Show("Vui lòng nhập dữ liệu vào ô Mã Lớp", "Thông báo"); } if (txt_tenLop.Text.Trim() == "") { MessageBox.Show("Vui lòng nhập dữ liệu vào ô Tên Lớp", "Thông báo"); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }