private void btnLuu_Click(object sender, EventArgs e) { if (txtMatran.Text == "") { MessageBox.Show("Bạn chưa nhập mã trận đấu"); txtMatran.Focus(); return; } if (txtMacauthu.Text == "") { MessageBox.Show("Bạn chưa nhập mã cầu thủ"); txtMacauthu.Focus(); return; } if (cmbMadoi.Text == "") { MessageBox.Show("Bạn chưa nhập mã đội"); cmbMadoi.Focus(); return; } if (txtVitri.Text == "") { MessageBox.Show("Bạn chưa nhập vị trí"); txtVitri.Focus(); return; } string sqlCheckKey = "select * from trandau_cauthu where matrandau='" + txtMatran.Text.Trim() + "'"; DAO.OpenConnection(); if (DAO.checkKeyExit(sqlCheckKey)) { MessageBox.Show("Mã trận đấu đã tồn tại"); DAO.CloseConnetion(); txtMatran.Focus(); return; } string sql = "insert into trandau_cauthu values ('" + txtMatran.Text.Trim() + "','" + cmbMadoi.SelectedValue.ToString() + "', '" + txtMacauthu.Text.Trim() + "',N'" + txtVitri.Text.Trim() + "')"; DAO.RunSqlDel(sql); //Thực hiện câu lệnh sql LoadDataToGridView(); //Nạp lại DataGridView }