Ejemplo n.º 1
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            DialogResult dialog = MessageBox.Show("Có chắc chắn xóa thẻ này ?", "Thông báo", MessageBoxButtons.YesNo);

            if (dialog == DialogResult.Yes)
            {
                if (Bus_TimTV.XoaTV(mathe))
                {
                    txtMaThe.Text  = "null";
                    txtHoTen.Text  = "null";
                    txtLoaiDG.Text = "null";
                    txtEmail.Text  = "null";
                    txtDiaChi.Text = "null";


                    MessageBox.Show("Xóa thành công", "Thông báo");

                    //cap nhat bang dtDachSach
                    dataSrc = Bus_TimTV.TimTV(txtDocGia.Text);
                    dtDanhsach.DataSource = dataSrc;

                    txtDocGia.Focus();
                }

                else
                {
                    MessageBox.Show("Không thể xóa thẻ này", "Thông báo");
                }
            }
        }
Ejemplo n.º 2
0
        private void dtDanhsach_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            hangDuocChon = e.RowIndex;
            if (hangDuocChon >= dataSrc.Rows.Count || hangDuocChon < 0)
            {
                return;
            }

            string    theDuocChon = dtDanhsach[0, hangDuocChon].Value.ToString();
            DataTable dt          = Bus_TimTV.TraCuuTV(theDuocChon);

            btnSua.Visible = true;
            btnXoa.Visible = true;

            mathe      = dt.Rows[0][0].ToString();
            hoten      = dt.Rows[0][1].ToString();
            loaidg     = dt.Rows[0][2].ToString();
            ngaysinh   = dt.Rows[0][3].ToString();
            diachi     = dt.Rows[0][4].ToString();
            email      = dt.Rows[0][5].ToString();
            ngaylapthe = dt.Rows[0][6].ToString();
            taikhoanno = dt.Rows[0][7].ToString();


            txtMaThe.Text     = mathe;
            txtHoTen.Text     = hoten;
            txtLoaiDG.Text    = loaidg;
            txtEmail.Text     = email;
            txtDiaChi.Text    = diachi;
            dtNgayLapThe.Text = ngaylapthe;
            dtNgaySinh.Text   = ngaysinh;
        }
Ejemplo n.º 3
0
        internal void open()
        {
            this.Focus();
            //datatable mac dinh se hien thi tat ca cac DG thu vien hien co
            dataSrc = Bus_TimTV.TimTV("");
            dtDanhsach.DataSource = dataSrc;

            txtDocGia.Focus();
        }
Ejemplo n.º 4
0
        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            string _mathe      = txtMaThe.Text;
            string _hoten      = txtHoTen.Text;
            string _email      = txtEmail.Text;
            string _diachi     = txtDiaChi.Text;
            string _ngaylapthe = dtNgayLapThe.Text;
            string _ngaysinh   = dtNgaySinh.Text;
            string _loaidg     = txtLoaiDG.Text;

            if (_mathe == "" || _hoten == "" || _email == "" || _diachi == "" || _ngaylapthe == "" ||
                _ngaysinh == "" || _loaidg == "")
            {
                MessageBox.Show("Vui lòng nhập đầy dủ thông tin", "Thông báo");
            }

            else
            {
                DialogResult dialog = MessageBox.Show("Có chắc chắn cập nhật thông tin của thẻ này ?", "Thông báo", MessageBoxButtons.YesNo);
                if (dialog == DialogResult.Yes)
                {
                    En_LapThe dg = new En_LapThe(_mathe, _hoten, DateTime.Parse(_ngaysinh), DateTime.Parse(_ngaylapthe), _email, _diachi, _loaidg, int.Parse(taikhoanno));
                    Bus_TimTV.CapNhatTV(dg);
                    MessageBox.Show("Cập nhật thành công");

                    //cap nhat bang dtDachSach
                    dataSrc = Bus_TimTV.TimTV(txtDocGia.Text);
                    dtDanhsach.DataSource = dataSrc;

                    dtDanhsach.Rows[0].Selected            = false;
                    dtDanhsach.Rows[hangDuocChon].Selected = true;
                    // hien thi button
                    btnSua.Visible     = true;
                    btnXoa.Visible     = true;
                    dtDanhsach.Enabled = true;
                    btnCapNhat.Visible = false;
                    btnHuy.Visible     = false;

                    setTextBoxEnabled(false);

                    txtDocGia.Enabled = true;
                }
                else
                {
                    btnHuy_Click(sender, e);
                }
            }
        }
Ejemplo n.º 5
0
 private void txtDocGia_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         dataSrc = Bus_TimTV.TimTV(txtDocGia.Text);
         if (dataSrc.Rows.Count <= 0)
         {
             btnSua.Visible        = false;
             dtDanhsach.DataSource = null;
         }
         else
         {
             dtDanhsach.DataSource = dataSrc;
         }
     }
 }