コード例 #1
0
        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);
                }
            }
        }
コード例 #2
0
        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);
                }
            }
        }
コード例 #3
0
        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);
                }
            }
        }
コード例 #4
0
        private void btnChiuThua_Click(object sender, EventArgs e)
        {
            soCauDaTraLoi++;
            CSDL.SuaTu(listCauHoi[thuTuCauHoi].DapAn, tenBo[thuTuCauHoi], false, conn); //Update false

            xem[thuTuCauHoi]      = 2;                                                  //Trả lời sai
            txtCauTraLoi.ReadOnly = true;
            HieuUng(false);


            NextScene();
        }
コード例 #5
0
        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();
            }
        }
コード例 #6
0
        private void btnCauD_Click(object sender, EventArgs e)
        {
            listCauHoi[thuTuCauHoi].LuaChonCuaBan = 3;

            if (listCauHoi[thuTuCauHoi].KiemTraDung()) //Cập nhật ở trong này
            {
                xem[thuTuCauHoi] = 1;                  //Trả lời đúng
                soCauDung++;
                HieuUng(true);
                CSDL.SuaTu(listCauHoi[thuTuCauHoi].DapAn, tenBo[thuTuCauHoi], true, conn);
            }
            else
            {
                xem[thuTuCauHoi] = 2;   //Trả lời sai
                HieuUng(false);
                CSDL.SuaTu(listCauHoi[thuTuCauHoi].DapAn, tenBo[thuTuCauHoi], false, conn);
            }
            soCauDaTraLoi++;
        }
コード例 #7
0
        private void txtCauTraLoi_TextChanged(object sender, EventArgs e)
        {
            listCauHoi[thuTuCauHoi].CauTraLoi = txtCauTraLoi.Text;

            if (xem[thuTuCauHoi] == 0)
            {
                if (listCauHoi[thuTuCauHoi].KiemTraDung())
                {
                    HieuUng(true);
                    soCauDung++;
                    soCauDaTraLoi++;

                    CSDL.SuaTu(listCauHoi[thuTuCauHoi].DapAn, tenBo[thuTuCauHoi], true, conn);

                    xem[thuTuCauHoi]      = 1; //Trả lời đúng
                    txtCauTraLoi.ReadOnly = true;

                    xem[thuTuCauHoi] = 1;   //Đã trả lời
                    NextScene();
                }
            }
        }