private void btnLuu_Click(object sender, EventArgs e) { if (dgvDSDiemHocVien.Rows.Count > 0) { for (int i = 0; i < dgvDSDiemHocVien.Rows.Count; i++) { string makt, mahv; float diem; makt = cbbKyThi.SelectedValue.ToString(); mahv = dgvDSDiemHocVien.Rows[i].Cells[1].Value.ToString(); diem = float.Parse(dgvDSDiemHocVien.Rows[i].Cells[3].Value.ToString()); _objdanhsachthi = new DanhSachThi(makt, mahv, diem); if (_objdanhsachthibus.AddDanhSachThi(_objdanhsachthi)) { dgvDSDiemHocVien.Rows.Remove(dgvDSDiemHocVien.Rows[i]); i--; LoadData(); } else { string a = dgvDSDiemHocVien.Rows[i].Cells[0].Value.ToString(); MessageBox.Show("Lưu dòng " + a + " thất bại"); } } if (dgvDSDiemHocVien.Rows.Count == 0) { MessageBox.Show("Lưu thành công"); } resetbox(); } else { MessageBox.Show("Không có dữ liệu để lưu ! ", "Thống báo ", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public bool EditDanhSachThi(DanhSachThi dst) { try { if (conn.State != ConnectionState.Open) { conn.Open(); } SqlCommand cmd = new SqlCommand("DanhSachThi_Edit", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@MaKyThi", SqlDbType.VarChar).Value = dst._makithi; cmd.Parameters.Add("@MaHV", SqlDbType.VarChar).Value = dst._mahv; cmd.Parameters.Add("@Diem", SqlDbType.Float).Value = dst._ketquathi; cmd.ExecuteNonQuery(); conn.Close(); return(true); } catch { conn.Close(); return(false); } }
public bool EditDanhSachThi(DanhSachThi dst) { return(objDanhSachThi.EditDanhSachThi(dst)); }