private bool CheckTonTai(string strMa)
 {
     bool kq = false;
     clsDM_DichVu obj = new clsDM_DichVu();
     kq = obj.CheckTonTai(strMa);
     return kq;
 }
 private int Delete(string strMaDM)
 {
     int kq = 0;
     clsDM_DichVu obj = new clsDM_DichVu();
     if (MessageBox.Show("Bạn muốn xóa?", "Thông báo", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         kq = obj.Delete(strMaDM);
     }
     return kq;
 }
        private int Delete()
        {
            int kq = 0;
            clsDM_DichVu obj = new clsDM_DichVu();
            if (MessageBox.Show("Bạn muốn xóa?", "Thông báo", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                if (grdMaster.SelectedRows.Count != 0)
                {
                    DataGridViewRow row = this.grdMaster.SelectedRows[0];
                    string MaDichVu = row.Cells["MaDichVu"].Value.ToString();
                    kq = obj.Delete(MaDichVu);
                    if (kq > 0)
                    {
                        LoadGridView();
                    }
                }

            }
            return kq;
        }
        private void FillData()
        {
            lblCapNhat.Text = "Thêm";
            if (MaDM != "")
            {
                txtMaDichVu.Enabled = false;
                lblCapNhat.Text = "Cập nhật";

                clsDM_DichVu obj = new clsDM_DichVu();
                obj.GetByKey(MaDM);
                txtMaDichVu.Text = obj.MaDichVu;
                txtTenDichVu.Text = obj.TenDichVu;
                txtDVT.Text = obj.DonViTinh;
                decDonGiaCSKCB.Value = obj.DonGiaCSKCB ?? 0;
                decDonGiaBHYT.Value = obj.DonGiaBHYT ?? 0;
                txtMaLoaiDichVu.Text = obj.MaLoaiDichVu.ToString();
                txtMaNhom1.Text = obj.MaNhom1;

                txtMaNhom2.Text = obj.MaNhom2.ToString();
                cbTrongDanhBaBHYT.Checked = obj.TrongDanhMucBHYT ?? false;
                cbActive.Checked = obj.Active ?? false;
                cbDichVuKTC.Checked = obj.DichVuKTC ?? false;
                txtThongTu.Text = obj.ThongTu;

                txtSoBHYT.Text = obj.STTBYT;
                txtMaKhac.Text = obj.MaKhac;
                txtMaLoaiChiPhi.Text = obj.MaLoaiChiPhi;
                txtMaDichVuBHYT.Text = obj.MaDichVuBYT;
                txtGhiChu.Text = obj.GhiChu;
            }
        }
        private int Update(string strMa)
        {
            int kq = 0;
            clsDM_DichVu obj = new clsDM_DichVu();
            obj.MaDichVu = strMa;
            obj.GetByKey(strMa);
            obj.TenDichVu = txtTenDichVu.Text;
            obj.DonViTinh = txtDVT.Text;
            obj.DonGiaCSKCB = decDonGiaCSKCB.Value;
            obj.DonGiaBHYT = decDonGiaBHYT.Value;
            obj.GhiChu = txtGhiChu.Text;
            obj.MaLoaiDichVu = txtMaLoaiDichVu.Text;
            obj.MaNhom1 = txtMaNhom1.Text;
            obj.MaNhom2 = txtMaNhom2.Text;

            obj.Active = cbActive.Checked;
            obj.TrongDanhMucBHYT = cbTrongDanhBaBHYT.Checked;
            obj.DichVuKTC = cbDichVuKTC.Checked;

            obj.ThongTu = txtThongTu.Text;
            obj.STTBYT = txtSoBHYT.Text;
            obj.MaDichVuBYT = txtMaDichVuBHYT.Text;
            obj.MaKhac = txtMaKhac.Text;
            obj.MaLoaiChiPhi = txtMaLoaiChiPhi.Text;

            kq = obj.Update();
            return kq;
        }
        private int Insert()
        {
            if (CheckTonTai(txtMaDichVu.Text))
            {
                MessageBox.Show("Mã dịch vụ đã tồn tại.");
                txtMaDichVu.Focus();
                return 0;
            }

            int kq = 0;
            clsDM_DichVu obj = new clsDM_DichVu();
            obj.MaDichVu = txtMaDichVu.Text;
            obj.TenDichVu = txtTenDichVu.Text;
            obj.DonViTinh = txtDVT.Text;
            obj.DonGiaCSKCB = decDonGiaCSKCB.Value;
            obj.DonGiaBHYT = decDonGiaBHYT.Value;
            obj.GhiChu = txtGhiChu.Text;
            obj.MaLoaiDichVu = txtMaLoaiDichVu.Text;
            obj.MaNhom1 = txtMaNhom1.Text;
            obj.MaNhom2 = txtMaNhom2.Text;

            obj.Active = cbActive.Checked;
            obj.TrongDanhMucBHYT = cbTrongDanhBaBHYT.Checked;
            obj.DichVuKTC = cbDichVuKTC.Checked;

            obj.ThongTu = txtThongTu.Text;
            obj.STTBYT = txtSoBHYT.Text;
            obj.MaDichVuBYT = txtMaDichVuBHYT.Text;
            obj.MaKhac = txtMaKhac.Text;
            obj.MaLoaiChiPhi = txtMaLoaiChiPhi.Text;

            kq = obj.Insert();
            return kq;
        }
        private void LoadGridView()
        {
            int index = 0;
            if (grdMaster.RowCount > 0)
            {
                index = grdMaster.CurrentCell.RowIndex;
            }
            clsDM_DichVu obj = new clsDM_DichVu();
            DMDICHVU = obj.GetAll();
            grdMaster.DataSource = DMDICHVU;

            if (grdMaster.RowCount > 0)
            {
                grdMaster.Rows[index].Selected = true;
                grdMaster.FirstDisplayedScrollingRowIndex = index;
            }
        }
Exemplo n.º 8
0
        private void ThemVaCapNhatChiPhi()
        {
            if (txtSoTheBHYT.Text.Replace("-", "").Length < 15)
            {
                MessageBox.Show("Vui lòng nhập số thẻ BHYT trước khi thêm chi phí.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                //lblThongBao.Text = "Vui lòng nhập số thẻ BHYT trước khi thêm chi phí!";
                //timerThongBao.Enabled = true;

                txtThuoc.Focus();
                return;
            }
            string MaChiPhi = txtThuoc.SelectedValues["MaChiPhi"].ToString();
            string LoaiChiPhi = txtThuoc.SelectedValues["LoaiChiPhi"].ToString();

            bool isUpdateChiTiet = false;

            isCapNhat = false;

            if (m_MaChiPhi.Trim().Length > 0 && m_LoaiChiPhi.Trim().Length > 0)
            {
                MaChiPhi = m_MaChiPhi;
                LoaiChiPhi = m_LoaiChiPhi;
                isUpdateChiTiet = true;
                isCapNhat = true;
            }

            DataRow[] existsRows = TableChiPhiThuoc.Select("MaChiPhi ='" + MaChiPhi + "'");

            if (LoaiChiPhi == "T")
            {
                clsDM_Thuoc t = new clsDM_Thuoc();
                t.GetByKey(MaChiPhi);

                if (existsRows.Length > 0)
                {
                    if (!isUpdateChiTiet && MessageBox.Show("Mã " + MaChiPhi + " chi phí này tồn tại? Bạn có muốn cập nhật số lượng?", "Thông báo", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        existsRows[0]["SoLuong"] = (decimal)existsRows[0]["SoLuong"] + txtSoLuongThuoc.Value;

                    }
                    else
                    {
                        existsRows[0]["SoLuong"] = txtSoLuongThuoc.Value;
                    }

                    existsRows[0]["PhanTramDuocHuong"] = txtPhanTramHuong.Text;

                    decimal ThanhTienBHYT = Math.Round((decimal)existsRows[0]["SoLuong"] * t.DonGiaThau.Value);
                    decimal BHYTThanhToan = Math.Round(((decimal)existsRows[0]["SoLuong"] * t.DonGiaThau.Value) * (txtPhanTramHuong.Value / 100) * (t.TyLeThanhToan.Value / 100));
                    decimal NguoiBenhTra = ThanhTienBHYT - txtNguonKhacThuoc.Value - BHYTThanhToan;

                    existsRows[0]["ThanhTienBHYT"] = ThanhTienBHYT;
                    existsRows[0]["BHYTThanhToan"] = BHYTThanhToan;
                    existsRows[0]["NguoiBenhTra"] = NguoiBenhTra; ;
                    existsRows[0]["NguonKhac"] = txtNguonKhacThuoc.Value;
                    existsRows[0]["ChiPhiNgoaiDinhSuat"] = 0;
                    existsRows[0]["TyLeThanhToan"] = t.TyLeThanhToan.Value;
                    TableChiPhiThuoc.AcceptChanges();
                }
                else
                {

                    DataRow dr = TableChiPhiThuoc.NewRow();
                    dr["MaChiPhi"] = t.MaThuoc;
                    //dr["MaPhu"] = t.MaPhu ;
                    dr["TenChiPhi"] = t.TenThuoc;
                    dr["DonViTinh"] = t.DonViTinh;
                    dr["SoLuong"] = txtSoLuongThuoc.Value;
                    dr["DonGiaBHYT"] = t.DonGiaThau;
                    dr["PhanTramDuocHuong"] = txtPhanTramHuong.Text;

                    decimal ThanhTienBHYT = Math.Round(txtSoLuongThuoc.Value * t.DonGiaThau.Value);
                    decimal BHYTThanhToan = Math.Round((txtSoLuongThuoc.Value * t.DonGiaThau.Value) * (txtPhanTramHuong.Value / 100) * (t.TyLeThanhToan.Value / 100));
                    decimal NguoiBenhTra = ThanhTienBHYT - txtNguonKhacThuoc.Value - BHYTThanhToan;

                    dr["ThanhTienBHYT"] = ThanhTienBHYT;
                    dr["BHYTThanhToan"] = BHYTThanhToan;
                    dr["NguoiBenhTra"] = NguoiBenhTra;
                    dr["NguonKhac"] = txtNguonKhacThuoc.Value;
                    dr["ChiPhiNgoaiDinhSuat"] = 0;
                    dr["MaNhom1"] = t.MaNhom1;
                    dr["MaNhom2"] = t.MaNhom2;
                    dr["MaLoaiChiPhi"] = LoaiChiPhi;
                    //dr["VTYTDichVuKTC"] = t.VTYTDichVuKTC ;
                    //dr["DichVuKTC"] = t.DichVuKTC ;
                    dr["GhiChu"] = t.GhiChu;

                    dr["TyLeThanhToan"] = t.TyLeThanhToan.Value;

                    dr["GroupName"] = "Thuốc";

                    TableChiPhiThuoc.Rows.Add(dr);
                }
            }

            else if (LoaiChiPhi == "D")
            {
                clsDM_DichVu dv = new clsDM_DichVu();
                dv.GetByKey(MaChiPhi);

                if (existsRows.Length > 0)
                {
                    if (!isUpdateChiTiet && MessageBox.Show("Mã " + MaChiPhi + " chi phí này tồn tại? Bạn có muốn cập nhật số lượng?", "Thông báo", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        existsRows[0]["SoLuong"] = (decimal)existsRows[0]["SoLuong"] + txtSoLuongThuoc.Value;
                    }
                    else
                    {
                        existsRows[0]["SoLuong"] = txtSoLuongThuoc.Value;
                    }
                    existsRows[0]["PhanTramDuocHuong"] = txtPhanTramHuong.Text;

                    decimal ThanhTienBHYT = Math.Round((decimal)existsRows[0]["SoLuong"] * dv.DonGiaBHYT.Value);
                    decimal BHYTThanhToan = Math.Round(((decimal)existsRows[0]["SoLuong"] * dv.DonGiaBHYT.Value) * (txtPhanTramHuong.Value / 100));
                    decimal NguoiBenhTra = ThanhTienBHYT - txtNguonKhacThuoc.Value - BHYTThanhToan;

                    existsRows[0]["ThanhTienBHYT"] = ThanhTienBHYT;
                    existsRows[0]["BHYTThanhToan"] = BHYTThanhToan;
                    existsRows[0]["NguoiBenhTra"] = NguoiBenhTra; ;
                    existsRows[0]["NguonKhac"] = txtNguonKhacThuoc.Value;
                    existsRows[0]["ChiPhiNgoaiDinhSuat"] = 0;
                    TableChiPhiThuoc.AcceptChanges();
                }
                else
                {

                    DataRow dr = TableChiPhiThuoc.NewRow();
                    dr["MaChiPhi"] = dv.MaDichVu;
                    dr["MaPhu"] = dv.MaKhac;
                    dr["TenChiPhi"] = dv.TenDichVu;
                    dr["DonViTinh"] = dv.DonViTinh;
                    dr["SoLuong"] = txtSoLuongThuoc.Value;
                    dr["DonGiaBHYT"] = dv.DonGiaBHYT;
                    dr["PhanTramDuocHuong"] = txtPhanTramHuong.Text;

                    decimal ThanhTienBHYT = Math.Round(txtSoLuongThuoc.Value * dv.DonGiaBHYT.Value);
                    decimal BHYTThanhToan = Math.Round((txtSoLuongThuoc.Value * dv.DonGiaBHYT.Value) * (txtPhanTramHuong.Value / 100));
                    decimal NguoiBenhTra = ThanhTienBHYT - txtNguonKhacThuoc.Value - BHYTThanhToan;

                    dr["ThanhTienBHYT"] = ThanhTienBHYT;
                    dr["BHYTThanhToan"] = BHYTThanhToan;
                    dr["NguoiBenhTra"] = NguoiBenhTra;
                    dr["NguonKhac"] = txtNguonKhacThuoc.Value;
                    dr["ChiPhiNgoaiDinhSuat"] = 0;
                    dr["MaNhom1"] = dv.MaNhom1;
                    dr["MaNhom2"] = dv.MaNhom2;
                    dr["MaLoaiChiPhi"] = LoaiChiPhi;
                    //dr["VTYTDichVuKTC"] = t.VTYTDichVuKTC ;
                    dr["DichVuKTC"] = dv.DichVuKTC.Value;
                    dr["GhiChu"] = dv.GhiChu;

                    dr["GroupName"] = "Dịch vụ";

                    TableChiPhiThuoc.Rows.Add(dr);
                }
            }
            else if (LoaiChiPhi == "V")
            {
                clsDM_VTYT vtyt = new clsDM_VTYT();
                vtyt.GetByKey(MaChiPhi);

                if (existsRows.Length > 0)
                {
                    if (!isUpdateChiTiet && MessageBox.Show("Mã " + MaChiPhi + " chi phí này tồn tại? Bạn có muốn cập nhật số lượng?", "Thông báo", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        existsRows[0]["SoLuong"] = (decimal)existsRows[0]["SoLuong"] + txtSoLuongThuoc.Value;

                    }
                    else
                    {
                        existsRows[0]["SoLuong"] = txtSoLuongThuoc.Value;
                    }
                    existsRows[0]["PhanTramDuocHuong"] = txtPhanTramHuong.Text;
                    decimal ThanhTienBHYT = Math.Round((decimal)existsRows[0]["SoLuong"] * vtyt.DonGiaThau.Value);
                    decimal BHYTThanhToan = Math.Round(((decimal)existsRows[0]["SoLuong"] * vtyt.DonGiaThau.Value) * (txtPhanTramHuong.Value / 100));
                    decimal NguoiBenhTra = ThanhTienBHYT - txtNguonKhacThuoc.Value - BHYTThanhToan;

                    existsRows[0]["ThanhTienBHYT"] = ThanhTienBHYT;
                    existsRows[0]["BHYTThanhToan"] = BHYTThanhToan;
                    existsRows[0]["NguoiBenhTra"] = NguoiBenhTra; ;
                    existsRows[0]["NguonKhac"] = txtNguonKhacThuoc.Value;
                    existsRows[0]["ChiPhiNgoaiDinhSuat"] = 0;
                    TableChiPhiThuoc.AcceptChanges();
                }
                else
                {

                    DataRow dr = TableChiPhiThuoc.NewRow();
                    dr["MaChiPhi"] = vtyt.MaVTYT;
                    // dr["MaPhu"] = vtyt.;
                    dr["TenChiPhi"] = vtyt.TenVTYT;
                    dr["DonViTinh"] = vtyt.DonViTinh;
                    dr["SoLuong"] = txtSoLuongThuoc.Value;
                    dr["DonGiaBHYT"] = vtyt.DonGiaThau;
                    dr["PhanTramDuocHuong"] = txtPhanTramHuong.Text;

                    decimal ThanhTienBHYT = Math.Round(txtSoLuongThuoc.Value * vtyt.DonGiaThau.Value);
                    decimal BHYTThanhToan = Math.Round((txtSoLuongThuoc.Value * vtyt.DonGiaThau.Value) * (txtPhanTramHuong.Value / 100));
                    decimal NguoiBenhTra = ThanhTienBHYT - txtNguonKhacThuoc.Value - BHYTThanhToan;
                    dr["ThanhTienBHYT"] = ThanhTienBHYT;
                    dr["BHYTThanhToan"] = BHYTThanhToan;
                    dr["NguoiBenhTra"] = NguoiBenhTra;
                    dr["NguonKhac"] = txtNguonKhacThuoc.Value;

                    dr["ChiPhiNgoaiDinhSuat"] = 0;
                    dr["MaNhom1"] = vtyt.MaNhom1;
                    dr["MaNhom2"] = vtyt.MaNhom2;
                    dr["MaLoaiChiPhi"] = LoaiChiPhi;
                    dr["VTYTDichVuKTC"] = vtyt.VTYTDichVuKTC.Value;
                    //dr["DichVuKTC"] = t.DichVuKTC ;
                    dr["GhiChu"] = vtyt.GhiChu;
                    dr["GroupName"] = "Vật tư y tế";
                    TableChiPhiThuoc.Rows.Add(dr);
                }
            }
            else if (LoaiChiPhi == "M")
            {
                clsDM_Mau m = new clsDM_Mau();
                m.GetByKey(MaChiPhi);

                if (existsRows.Length > 0)
                {
                    if (MessageBox.Show("Mã " + MaChiPhi + " chi phí này tồn tại? Bạn có muốn cập nhật số lượng?", "Thông báo", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        existsRows[0]["SoLuong"] = (decimal)existsRows[0]["SoLuong"] + txtSoLuongThuoc.Value;

                    }
                    else
                    {
                        existsRows[0]["SoLuong"] = txtSoLuongThuoc.Value;
                    }
                    existsRows[0]["PhanTramDuocHuong"] = txtPhanTramHuong.Text;

                    decimal ThanhTienBHYT = Math.Round((decimal)existsRows[0]["SoLuong"] * m.DonGiaBHYT.Value);
                    decimal BHYTThanhToan = Math.Round(((decimal)existsRows[0]["SoLuong"] * m.DonGiaBHYT.Value) * (txtPhanTramHuong.Value / 100));
                    decimal NguoiBenhTra = ThanhTienBHYT - txtNguonKhacThuoc.Value - BHYTThanhToan;

                    existsRows[0]["ThanhTienBHYT"] = ThanhTienBHYT;
                    existsRows[0]["BHYTThanhToan"] = BHYTThanhToan;
                    existsRows[0]["NguoiBenhTra"] = NguoiBenhTra; ;
                    existsRows[0]["NguonKhac"] = txtNguonKhacThuoc.Value;

                    existsRows[0]["ChiPhiNgoaiDinhSuat"] = 0;
                    TableChiPhiThuoc.AcceptChanges();
                }
                else
                {

                    DataRow dr = TableChiPhiThuoc.NewRow();
                    dr["MaChiPhi"] = m.MaMauVaChePhamMau;
                    // dr["MaPhu"] = vtyt.;
                    dr["TenChiPhi"] = m.TenMauVaChePhamMau;
                    dr["DonViTinh"] = m.DonViTinh;
                    dr["SoLuong"] = txtSoLuongThuoc.Value;
                    dr["DonGiaBHYT"] = m.DonGiaBHYT;
                    dr["PhanTramDuocHuong"] = txtPhanTramHuong.Text;

                    decimal ThanhTienBHYT = Math.Round(txtSoLuongThuoc.Value * m.DonGiaBHYT.Value);
                    decimal BHYTThanhToan = Math.Round((txtSoLuongThuoc.Value * m.DonGiaBHYT.Value) * (txtPhanTramHuong.Value / 100));
                    decimal NguoiBenhTra = ThanhTienBHYT - txtNguonKhacThuoc.Value - BHYTThanhToan;
                    dr["ThanhTienBHYT"] = ThanhTienBHYT;
                    dr["BHYTThanhToan"] = BHYTThanhToan;
                    dr["NguoiBenhTra"] = NguoiBenhTra;
                    dr["NguonKhac"] = txtNguonKhacThuoc.Value;

                    dr["ChiPhiNgoaiDinhSuat"] = 0;
                    dr["MaNhom1"] = m.MaNhom1;
                    dr["MaNhom2"] = m.MaNhom2;
                    dr["MaLoaiChiPhi"] = LoaiChiPhi;
                    //dr["VTYTDichVuKTC"] = vtyt.VTYTDichVuKTC;
                    //dr["DichVuKTC"] = t.DichVuKTC ;
                    dr["GhiChu"] = m.GhiChu;
                    dr["GroupName"] = "Máu và chế phẩm";
                    TableChiPhiThuoc.Rows.Add(dr);
                }
            }
            m_MaChiPhi = "";
            m_LoaiChiPhi = "";
            txtThuoc.ClearSelection();
            TinhTongGridView();
            txtThuoc.Focus();
        }