private void btnXacNhan_Click(object sender, EventArgs e) { if (txtTenBoMoi.Text == "") { MessageBox.Show("Tên bộ từ không được bỏ trống", "Lỗi thông tin", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { int kq = CSDL.Change("Update BoTuVung set TenBoTuVung = N'" + txtTenBoMoi.Text + "', GhiChu = N'" + XuLyDuLieu.ChuyenVeDataBase(txtMoTaMoi.Text) + "' where TenBoTuVung = N'" + cmbBoTuSua.Text + "'"); if (kq == 0) { MessageBox.Show("Tên bộ từ vựng này đã bị trùng hoặc chưa sửa, vui lòng kiểm tra lại!", "Lỗi thông tin", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Sửa thành công!", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information); checkSua = true; boMoi = txtTenBoMoi.Text; boCu = cmbBoTuSua.Text; moTaMoi = txtMoTaMoi.Text; this.Close(); } } catch (SqlException a) { MessageBox.Show("Tên bộ từ vựng này đã bị trùng hoặc chưa sửa, vui lòng kiểm tra lại!", "Lỗi thông tin", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnXacNhan_Click(object sender, EventArgs e) { if (txtTenBo.Text == "") { MessageBox.Show("Vui lòng nhập tên bộ từ", "Lỗi thông tin", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { string query = @"INSERT Into BoTuVung(TenBoTuVung, GhiChu) values (N'" + XuLyDuLieu.ChuyenVeDataBase(txtTenBo.Text) + "', N'" + XuLyDuLieu.ChuyenVeDataBase(txtMoTa.Text) + "')"; try { if (CSDL.Change(query) != 1) { MessageBox.Show("Bộ từ đã bị trùng, xin vui lòng đổi tên hoặc xóa bộ đã có" + txtTenBo.Text, "Lỗi trùng lặp", MessageBoxButtons.OK, MessageBoxIcon.Error); xacNhan = false; } else { xacNhan = true; ten = txtTenBo.Text; moTa = txtMoTa.Text; this.Close(); } } catch (SqlException) { MessageBox.Show("Bộ từ vựng đã bị trùng tên, xin vui lòng đổi tên hoặc xóa bộ đã có" + txtTenBo.Text, "Lỗi trùng lặp", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnXacNhan_Click(object sender, EventArgs e) { if (txtTuCanThem.Text == "") { MessageBox.Show("Tên từ vựng thêm vào không được bỏ trống.", "Lỗi thông tin", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { int kq = CSDL.Change(@"Insert into TuVung (TenTuVung, NghiaTuVung, TenBoTuVung, SoLanLuyenTap, SoLanTraLoiSai, TiLeTraLoiSai) values ('" + txtTuCanThem.Text + "', N'" + XuLyDuLieu.ChuyenVeDataBase(txtNghiaCuaTu.Text) + "', N'" + cmbBoThem.Text + "', 0, 0, 1006)"); //thêm vào class và listview, để form kia lo! if (kq != 0) { //MessageBox.Show("Thêm thành công!", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information); checkThem = true; tuCanThem = txtTuCanThem.Text; nghiaTuCanThem = txtNghiaCuaTu.Text; this.Close(); //Đóng form lại } else { MessageBox.Show("Từ mới đã bị trùng, xin kiểm tra lại!", "Lỗi trùng lặp", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (SqlException) { MessageBox.Show("Từ mới đã bị trùng, xin kiểm tra lại!", "Lỗi trùng lặp", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnXacNhan_Click(object sender, EventArgs e) { //Cập nhật trên class trước if (txtNghiaTuMoi.Text == "") { MessageBox.Show("Nghĩa của từ không được bỏ trống. Xin kiểm tra lại", "Lỗi thông tin", MessageBoxButtons.OK, MessageBoxIcon.Error); txtNghiaTuMoi.Select(); } else { //Sửa trên database trước, thành công rồi mới sửa trên listview int kq = CSDL.Change(@"Update TuVung set NghiaTuVung = N'" + XuLyDuLieu.ChuyenVeDataBase(txtNghiaTuMoi.Text) + "' where TenBoTuVung = N'" + ptbChe.suaTrongBo + "' and TenTuVung = '" + txtTuCanSua.Text + "'"); checkSua = true; nghiaTuMoi = txtNghiaTuMoi.Text; MessageBox.Show("Sửa thành công!", "Thành công!", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } }