private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            string        a = dataGridView1.CurrentRow.Cells[0].Value.ToString();
            tbl_PHIEUTHUE b = conectdb.tbl_PHIEUTHUE.Single(p => p.MaPhieu.Equals(a));

            txtkt.Text = b.MaKH;
        }
 private void btnthem_Click(object sender, EventArgs e)
 {
     if (Int32.Parse(txtsnm.Text) > 10 && kiemtra(txtsoxe.Text) == "xe máy" || ((Int32.Parse(txtsnm.Text) > 7 || Int32.Parse(txtsnm.Text) < 1) && kiemtraoto(txtsoxe.Text) != null) || kiemtrabanglai(txtsoxe.Text) == null)
     {
         MessageBox.Show("Không thêm được!!!");
     }
     else
     {
         try
         {
             tbl_PHIEUTHUE hh = new tbl_PHIEUTHUE();
             hh.MaKH         = txtmkh.Text;
             hh.MaPhieu      = txtmaphieu.Text;
             hh.NgayLapPhieu = DateTime.Parse(txtnlp.Text);
             hh.SoNgayMuon   = Int32.Parse(txtsnm.Text);
             hh.SoXe         = txtsoxe.Text.ToString();
             connectdb.tbl_PHIEUTHUE.Add(hh);
             connectdb.SaveChanges();
             loaddb();
             MessageBox.Show("đã thêm");
         }
         catch (Exception)
         {
             MessageBox.Show("không thêm được");
         }
     }
 }
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            string        maphieu = dataGridView1.CurrentRow.Cells[0].Value.ToString();
            tbl_PHIEUTHUE hh      = connectdb.tbl_PHIEUTHUE.Single(p => p.MaPhieu.Equals(maphieu));

            txtmaphieu.Text = hh.MaPhieu;
            txtmkh.Text     = hh.MaKH;
            txtnlp.Text     = hh.NgayLapPhieu.ToString();
            txtsnm.Text     = hh.SoNgayMuon.ToString();
            txtsoxe.Text    = hh.SoXe;
        }
 void xoa()
 {
     try
     {
         string        maphieu = dataGridView1.CurrentRow.Cells[0].Value.ToString();
         tbl_PHIEUTHUE xe      = connectdb.tbl_PHIEUTHUE.Single(p => p.MaPhieu.Equals(maphieu));
         connectdb.tbl_PHIEUTHUE.Remove(xe);
         connectdb.SaveChanges();
         loaddb();
         MessageBox.Show("Da xoa");
     }
     catch (Exception)
     {
         MessageBox.Show("khong xóa được");
     }
 }