private void tsslma_KeyUp(object sender, KeyEventArgs e)
 {
     try
     {
         if (e.KeyCode == Keys.F4)
         {
             if (cbbdoituong.SelectedIndex == 0)
             {
                 frmTimKH a = new frmTimKH("PhieuTTCuaKH");
                 a.ShowDialog();
                 if (frmTimKH.drvr != null)
                 {
                     tsslma.Text     = frmTimKH.drvr.Cells["MaKH"].Value.ToString();
                     tsslten.Text    = frmTimKH.drvr.Cells["Ten"].Value.ToString();
                     tssldiachi.Text = frmTimKH.drvr.Cells["DiaChi"].Value.ToString();
                     sono            = Convert.ToDouble(frmTimKH.drvr.Cells["DuNo"].Value.ToString());
                     tsslsodudauky.Focus();
                     frmTimKH.drvr = null;
                 }
             }
             else
             {
                 frmTimNCC tkh = new frmTimNCC("PhieuTTNCC");
                 tkh.ShowDialog();
                 if (frmTimNCC.drvr != null)
                 {
                     tsslma.Text     = frmTimNCC.drvr.Cells["MaNhaCungCap"].Value.ToString();
                     tsslten.Text    = frmTimNCC.drvr.Cells["TenNhaCungCap"].Value.ToString();
                     tssldiachi.Text = frmTimNCC.drvr.Cells["DiaChi"].Value.ToString();
                     sono            = Convert.ToDouble(frmTimKH.drvr.Cells["DuNo"].Value.ToString());
                     tsslsodudauky.Focus();
                     frmTimNCC.drvr = null;
                 }
             }
         }
     }
     catch
     {
     }
 }
 /// <summary>
 /// tìm nhà cung cấp
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btntimkh_Click_1(object sender, EventArgs e)
 {
     try
     {
         frmTimNCC tkh = new frmTimNCC("PhieuTTNCC");
         tkh.ShowDialog();
         if (frmTimNCC.drvr != null)
         {
             txtmancc.Text = frmTimNCC.drvr.Cells["MaNhaCungCap"].Value.ToString();
             lbncc.Text = frmTimNCC.drvr.Cells["TenNhaCungCap"].Value.ToString();
             txtnohienthoi.Text = String.Format("{0:0}", float.Parse(frmTimNCC.drvr.Cells["DuNo"].Value.ToString()));
             frmTimNCC.drvr = null;
             dtgvNCC.DataSource = new Entities.HDThanhToanKH[0];
             fix();
         }
     }
     catch (Exception ex)
     {
     }
 }
 /// <summary>
 /// tìm khách hàng
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btntimkh_Click(object sender, EventArgs e)
 {
     frmTimNCC tncc = new frmTimNCC();
     tncc.ShowDialog();
 }
 private void tsslma_KeyUp(object sender, KeyEventArgs e)
 {
     try
     {
         if (e.KeyCode == Keys.F4)
         {
             if (cbbdoituong.SelectedIndex == 0)
             {
                 frmTimKH a = new frmTimKH("PhieuTTCuaKH");
                 a.ShowDialog();
                 if (frmTimKH.drvr != null)
                 {
                     tsslma.Text = frmTimKH.drvr.Cells["MaKH"].Value.ToString();
                     tsslten.Text = frmTimKH.drvr.Cells["Ten"].Value.ToString();
                     tssldiachi.Text = frmTimKH.drvr.Cells["DiaChi"].Value.ToString();
                     sono = Convert.ToDouble(frmTimKH.drvr.Cells["DuNo"].Value.ToString());
                     tsslsodudauky.Focus();
                     frmTimKH.drvr = null;
                 }
             }
             else
             {
                 frmTimNCC tkh = new frmTimNCC("PhieuTTNCC");
                 tkh.ShowDialog();
                 if (frmTimNCC.drvr != null)
                 {
                     tsslma.Text = frmTimNCC.drvr.Cells["MaNhaCungCap"].Value.ToString();
                     tsslten.Text = frmTimNCC.drvr.Cells["TenNhaCungCap"].Value.ToString();
                     tssldiachi.Text = frmTimNCC.drvr.Cells["DiaChi"].Value.ToString();
                     sono = Convert.ToDouble(frmTimKH.drvr.Cells["DuNo"].Value.ToString());
                     tsslsodudauky.Focus();
                     frmTimNCC.drvr = null;
                 }
             }
         }
     }
     catch
     {
     }
 }
        /// <summary>
        /// xử lý tìm kiếm
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btntimkiem_Click(object sender, EventArgs e)
        {
            try
            {
                if (cbbdoituong.Text == "Khach Hang")
                {
                    frmTimKH kh = new frmTimKH("PhieuTTCuaKH");
                    kh.ShowDialog();
                    if (frmTimKH.drvr != null)
                    {
                        string dt = txtdoituong.Text;
                        txtdoituong.Text = frmTimKH.drvr.Cells["MaKH"].Value.ToString();
                        if (!dt.ToUpper().Equals(txtdoituong.Text.ToUpper()))
                        {
                            checkBox1.Checked = false;
                        }
                        lbhienthima.Text = frmTimKH.drvr.Cells["MaKH"].Value.ToString();
                        lbhienthiten.Text = frmTimKH.drvr.Cells["Ten"].Value.ToString();
                        lbhienthidiachi.Text = frmTimKH.drvr.Cells["DiaChi"].Value.ToString();
                        duno = frmTimKH.drvr.Cells["DuNo"].Value.ToString();
                        frmTimKH.drvr = null;
                    }
                }
                if (cbbdoituong.Text == "Nha Cung Cap")
                {
                    frmTimNCC tkh = new frmTimNCC("PhieuTTNCC");
                    tkh.ShowDialog();
                    if (frmTimNCC.drvr != null)
                    {
                        txtdoituong.Text = frmTimNCC.drvr.Cells["MaNhaCungCap"].Value.ToString();
                        lbhienthima.Text = frmTimNCC.drvr.Cells["MaNhaCungCap"].Value.ToString();
                        lbhienthiten.Text = frmTimNCC.drvr.Cells["TenNhaCungCap"].Value.ToString();
                        lbhienthidiachi.Text = frmTimNCC.drvr.Cells["DiaChi"].Value.ToString();
                        duno = frmTimNCC.drvr.Cells["DuNo"].Value.ToString();
                        frmTimNCC.drvr = null;
                    }
                }
                if (cbbdoituong.Text == "Nhan Vien")
                {
                    frmTimNhanVien tnv = new frmTimNhanVien();
                    tnv.ShowDialog();
                    if (frmTimNhanVien.drvr != null)
                    {
                        txtdoituong.Text = frmTimNhanVien.drvr.Cells["MaNhanVien"].Value.ToString();
                        lbhienthima.Text = frmTimNhanVien.drvr.Cells["MaNhanVien"].Value.ToString();
                        lbhienthiten.Text = frmTimNhanVien.drvr.Cells["TenNhanVien"].Value.ToString();
                        lbhienthidiachi.Text = frmTimNhanVien.drvr.Cells["Email"].Value.ToString();
                        frmTimNhanVien.drvr = null;
                    }
                }
                if (cbbdoituong.Text == "")
                {
                    MessageBox.Show("Bạn phải chọn Khoản mục");
                }
            }
            catch (Exception ex)
            {

            }
        }