public void loaddulieuchitiethoadondichvu()
 {
     dgvCTHDDV.Rows.Clear();
     foreach (CHITIETHOADON cthd in dsCTHDDV)
     {
         dgvCTHDDV.Rows.Add(cthd.getMahd(), DICHVUDAO.TenDV(QuanLyDichVu.dsDV, cthd.getMasp()), cthd.getSoluong(), cthd.thanhtien(DICHVUDAO.GiaMaDV(QuanLyDichVu.dsDV, cthd.getMasp())));
     }
 }
        private void cbboxMaHD_SelectedIndexChanged(object sender, EventArgs e)
        {
            dgvCTHDDV.Rows.Clear();
            dgvCTHDDV.Enabled   = true;
            btnThemCTHD.Enabled = true;
            btnIn.Enabled       = true;
            List <CHITIETHOADON> ds = CHITIETHOADONDVDAO.dsCTHDDVTheoMaHD(dsCTHDDV, cbboxMaHD.SelectedItem.ToString().Trim());

            foreach (CHITIETHOADON cthd in ds)
            {
                dgvCTHDDV.Rows.Add(cthd.getMahd(), DICHVUDAO.TenDV(QuanLyDichVu.dsDV, cthd.getMasp()), cthd.getSoluong(), cthd.thanhtien(DICHVUDAO.GiaMaDV(QuanLyDichVu.dsDV, cthd.getMasp())));
            }
            txtTongTien.Text = "" + tongtien();
        }
        private void btnIn_Click(object sender, EventArgs e)
        {
            List <CHITIETHOADON> ds = CHITIETHOADONDVDAO.dsCTHDDVTheoMaHD(dsCTHDDV, cbboxMaHD.SelectedItem.ToString().Trim());
            string line4            = "";
            string mahd             = "";

            foreach (CHITIETHOADON sp in ds)
            {
                int    lengthten     = DICHVUDAO.TenDV(QuanLyDichVu.dsDV, sp.getMasp()).Length;
                int    lengthsoluong = sp.getSoluong().ToString().Length;
                int    length        = 20 - lengthten;
                int    length2       = 16 - lengthsoluong;
                string khoangcach    = "";
                string khoangcach2   = "";
                for (int i = 0; i < length; i++)
                {
                    khoangcach += " ";
                }
                for (int i = 0; i < length2; i++)
                {
                    khoangcach2 += " ";
                }

                mahd   = sp.getMahd();
                line4 += DICHVUDAO.TenDV(QuanLyDichVu.dsDV, sp.getMasp()) + khoangcach + sp.getSoluong() + khoangcach2 + sp.thanhtien(SANPHAMDAO.GiaMaSP(QuanLyHangHoa.dsSP, sp.getMasp())) + "\n";
            }
            string[] lines = { "                                Hóa Đơn\n", "Tên khách hàng: " + HOADONDVDAO.TenKhachHang(dsHDDV, mahd) + "\n", "Mã hóa đơn: " + mahd + "\n", "Tên Sản Phẩm      Số lượng      Thành tiền", line4, "Tổng tiền: " + txtTongTien.Text };
            // WriteAllText creates a file, writes the specified string to the file,
            // and then closes the file.    You do NOT need to call Flush() or Close().
            System.IO.File.WriteAllLines(@"C:\DevPrograms\DoAnCongNghePhanMem (2)\Phan tich thiet ke HTTT\Phan tich thiet ke HTTT\BanIn\In.txt", lines);

            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.FileName = @"C:\DevPrograms\DoAnCongNghePhanMem (2)\Phan tich thiet ke HTTT\Phan tich thiet ke HTTT\BanIn\In.txt"; // Your absolute PATH

            Process.Start(startInfo);
        }