Пример #1
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            // lấy dữ liệu đang nhập lưu vào database
            if (c == true)
            {
                ModDocGia add = new ModDocGia();
                dtpNamSinh.CustomFormat = "yyyy/MM/dd";// cài đặt ngày giờ của datetimepicker theo dạng của sql

                string hoten    = txtHoTen.Text;
                string gioitinh = cbGioiTinh.Text;
                string namsinh  = dtpNamSinh.Value.ToString();
                bool   kq       = add.ThemDocGia(hoten, gioitinh, namsinh);
                if (kq == true)
                {
                    MessageBox.Show("Thêm Thành Công!", "Thông Báo");
                }
                setNut(true);
                Load();//load lại dư liêệu vào dgv
            }
            else
            {
                ModDocGia Sua = new ModDocGia();
                dtpNamSinh.CustomFormat = "yyyy/MM/dd";
                int    madocgia = int.Parse(txtDocGia.Text);
                string hoten    = txtHoTen.Text;
                string gioitinh = cbGioiTinh.Text;
                string namsinh  = dtpNamSinh.Value.ToString();
                bool   kq1      = Sua.SuaDocGia(madocgia, hoten, gioitinh, namsinh);
                setNut(true);
                Load();
            }
        }
Пример #2
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            //sau khi chọn dòng cần xoá bấm xoá thì ẩn nút sửa và thêm
            setNut(false);
            //hiện lên message hỏi có muốn xoá hay khôn
            if (MessageBox.Show("Bạn Có Muốn Xoá Đọc Giả Này", "Cảnh Báo", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                //nếu ok thì thực hiện lệnh xoá theo mã đọc giả
                ModDocGia Xoa = new ModDocGia();
                string    Ma  = txtDocGia.Text;
                bool      kq  = Xoa.XoaDocGia(Ma);
                if (kq == true)
                {
                    MessageBox.Show("Xoá Thành Công!");
                }
                // load lại dữ liệu set lại nút xoá dữ liện trên textbox
                Load();
                setNut(true);
                txtHoTen.Clear();
                cbGioiTinh.Text  = "";
                dtpNamSinh.Value = DateTime.Now;
            }
            else
            {
                // chọn cancel thì bật tất cả nút, xoá dữ liệu trên textbox
                setNut(true);

                txtHoTen.Clear();
                cbGioiTinh.Text  = "";
                dtpNamSinh.Value = DateTime.Now;
            }
        }
Пример #3
0
        private void btnTim_Click(object sender, EventArgs e)
        {
            ModDocGia tim = new ModDocGia();
            DataTable dt  = tim.timtheoten(txtTim.Text);

            if (dt.Rows.Count > 0)
            {
                dgvDocgia.DataSource = null;
                dgvDocgia.DataSource = dt;
            }
            else
            {
                dgvDocgia.DataSource = null;
                MessageBox.Show("Không tìm thấy đọc giả !", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning) == DialogResult.OK
                Load();
            }
        }