private void btn_Luu_Click(object sender, EventArgs e)
        {
            bool flag = CheckValue();

            if (flag)
            {
                foreach (DataRow dataRow in ((DataTable)gridDSDichVuKe.DataSource).Rows)
                {
                    DichVu_LanKham_Info dichVu_LanKham_Info = new DichVu_LanKham_Info(0, Convert.ToInt32(dataRow["DichVuID"].ToString()), lk.Ma, Convert.ToInt32(dataRow["BacSiGuiID"].ToString()), Convert.ToInt32(dataRow["SoLuong"].ToString()), Convert.ToDecimal(dataRow["DonGia"].ToString()), 0, Convert.ToDateTime(txt_Ngay_Gio_vaovien.Value), DateTime.Now, 0);
                    dichVu_LanKham_Info.Insert();
                }

                TienNop_LanKham_Info tn = new TienNop_LanKham_Info(0, lk.LanKhamID, Convert.ToDecimal(txtTongChiPhi.Value), "");
                tn.Insert();
                MessageBox.Show("Cập nhật thành công!", "Thông báo", MessageBoxButtons.OK);
                txtSoKham.Focus();
                // In biên lai

                DataTable ds = dsDichVuKe;
                foreach (DataRow r in ds.Rows)
                {
                    DataView v = ds.DefaultView;
                    v.RowFilter = "DichVuID=" + r["DichVuID"].ToString();
                    decimal       t          = Convert.ToDecimal(r["SoLuong"].ToString()) * Convert.ToDecimal(r["DonGia"].ToString());
                    string[]      ParamName  = { "@NgayThu", "@HoVaTen", "@Tuoi", "@DiaChi", "@TenDoiTuong", "@SoTien", "@BangChu", "@SoKham", "@Phong" };
                    object[]      ParamValue = { DateTime.Now,                             txtHoTenBenhNhan.Text, txtNamSinh.Value.ToString()
                                                 ,                                              txtDiaChi.Text,        txtTenDoiTuong.Text,t,
                                                 Util.FormHandler.txtVND(Convert.ToDecimal(t)), txtSoKham.Text,        r["TenPhong"].ToString() };
                    frmReportMain report = new frmReportMain(11, v.ToTable(), ParamName, ParamValue);
                    report.Show();
                }
                dsDichVuKe.Rows.Clear();
                this.Close();
            }
        }
        private void btn_Luu_Click(object sender, EventArgs e)
        {
            bool flag = CheckValue();

            if (flag)
            {
                BenhNhan_Info benhNhan_Info = new BenhNhan_Info(0, txtHoTenBenhNhan.Text, txtDiaChi.Text, txtSoDienThoai.Text, Convert.ToInt32(txtNamSinh.Value), Convert.ToDateTime(new DateTime(DateTime.Now.Year - Convert.ToInt32(txtNamSinh.Value), DateTime.Now.Month, DateTime.Now.Day, 1, 0, 0)), Convert.ToBoolean(cbx_GioiTinh.Text));
                benhNhan_Info.Insert();
                LanKham_Info lanKham_Info = new LanKham_Info(0, benhNhan_Info.Ma, Convert.ToInt32(cbx_BacSiGui.Value), Convert.ToInt32(cbx_MaDoiTuong.Text), txtMaTheBHYT.Text, txtChuanDoan.Text, Convert.ToDateTime(cdt_Ngayvaovien.Value), "", Convert.ToInt32(txtSoKham.Text));
                lanKham_Info.Insert();
                IEnumerator ienumerator = ((DataTable)gridDSDichVuKe.DataSource).Rows.GetEnumerator();
                foreach (DataRow dataRow in ((DataTable)gridDSDichVuKe.DataSource).Rows)
                {
                    DichVu_LanKham_Info dichVu_LanKham_Info = new DichVu_LanKham_Info(0, Convert.ToInt32(dataRow["DichVuID"].ToString()), lanKham_Info.Ma, Convert.ToInt32(dataRow["BacSiGuiID"].ToString()), Convert.ToInt32(dataRow["SoLuong"].ToString()), Convert.ToDecimal(dataRow["DonGia"].ToString()), 0, Convert.ToDateTime(cdt_Ngayvaovien.Value), DateTime.Now, 0);
                    dichVu_LanKham_Info.Insert();
                }

                TienNop_LanKham_Info tn = new TienNop_LanKham_Info(0, lanKham_Info.LanKhamID, Convert.ToDecimal(txtTongChiPhi.Value), "");
                tn.Insert();


                DataTable dataTable = DB_SQL.EXECUTE_SQL("select max(SoKham) as SoKham from LanKham");
                flag = dataTable.Rows[0]["SoKham"].ToString() != "";
                if (!flag)
                {
                    txtSoKham.Text = "1";
                }
                else
                {
                    int i = Convert.ToInt32(dataTable.Rows[0]["SoKham"].ToString()) + 1;
                    txtSoKham.Text = i.ToString();
                }
                MessageBox.Show("Cập nhật thành công!", "Thông báo", MessageBoxButtons.OK);
                txtSoKham.Focus();
                // In biên lai

                DataTable ds = dsDichVuKe, temp;
                temp = dsDichVuKe.Copy();
                temp.Clear();
                foreach (DataRow r in ds.Rows)
                {
                    if (check_as(temp, "PhongID", r["PhongID"].ToString()))
                    {
                        DataRow rt = temp.NewRow();
                        rt["PhongID"] = r["PhongID"].ToString();
                        temp.Rows.Add(rt);
                        DataView v = ds.DefaultView;
                        v.RowFilter = "TenPhong='" + r["TenPhong"].ToString() + "'";
                        DataTable ds1 = v.ToTable();
                        decimal   t   = 0;
                        foreach (DataRow k in ds1.Rows)
                        {
                            t += Convert.ToDecimal(k["SoLuong"].ToString()) * Convert.ToDecimal(k["DonGia"].ToString());
                        }

                        string[]      ParamName  = { "@NgayThu", "@HoVaTen", "@Tuoi", "@DiaChi", "@TenDoiTuong", "@SoTien", "@BangChu", "@SoKham", "@Phong" };
                        object[]      ParamValue = { Convert.ToDateTime(cdt_Ngayvaovien.Value), txtHoTenBenhNhan.Text,          txtNamSinh.Value.ToString()
                                                     ,                                               txtDiaChi.Text,                 txtTenDoiTuong.Text,t,
                                                     Util.FormHandler.txtVND(Convert.ToDecimal(t)),  lanKham_Info.SoKham.ToString(), r["TenPhong"].ToString() };
                        frmReportMain report = new frmReportMain(11, v.ToTable(), ParamName, ParamValue);
                        report.Show();
                    }
                }
                txtTongChiPhi.Value = 0;

                clear();
                load();
            }
        }