private bool CheckTonTai(string strMa)
 {
     bool kq = false;
     clsDM_VTYT obj = new clsDM_VTYT();
     kq = obj.CheckTonTai(strMa);
     return kq;
 }
 private int Delete(string strMaDM)
 {
     int kq = 0;
     clsDM_VTYT obj = new clsDM_VTYT();
     if (MessageBox.Show("Bạn muốn xóa?", "Thông báo", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         kq = obj.Delete(strMaDM);
     }
     return kq;
 }
Ejemplo n.º 3
0
        public bool CheckTonTai(string strMaVTYT)
        {
            m_dbConnection.Open();
            DataTable dt = new DataTable();
            string sql = "SELECT MaVTYT FROM DM_VTYT WHERE MaVTYT=@MaVTYT";
            SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
            command.Parameters.Add(new SQLiteParameter("@MaVTYT", strMaVTYT));
            SQLiteDataAdapter da = new SQLiteDataAdapter(command);
            da.Fill(dt);
            m_dbConnection.Close();

            clsDM_VTYT obj = new clsDM_VTYT();

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

            }

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

                clsDM_VTYT obj = new clsDM_VTYT();
                obj.GetByKey(MaDM);
                txtMaVTYT.Text = obj.MaVTYT;
                txtTenVTYT.Text = obj.TenVTYT;
                txtDVT.Text = obj.DonViTinh;
                txtTenHoatChat.Text = obj.TenHoatChat;
                txtQuyCach.Text = obj.QuyCach;
                txtNhaSanXuat.Text = obj.NhaSanXuat;
                txtNuocSanXuat.Text = obj.NuocSanXuat;
                txtSoDK.Text = obj.SoDangKy;

                decDonGiaMua.Value = obj.DonGiaMua??0;
                decDonGiaCSKCB.Value = obj.DonGiaCSKCB??0;
                decDonGiaBHYT.Value = obj.DonGiaThau??0;
                chkVTYT_TT.Checked = obj.VTYTThayThe??false;
                chkKTC.Checked = obj.VTYTDichVuKTC??false;
                chkConDung.Checked = obj.Active??false;
                chkBHYT.Checked = obj.TrongDanhMucBHYT??false;
                txtNhom1.Text = obj.MaNhom1;
                txtNhom2.Text = obj.MaNhom2;

                txtHanSuDung.Text = (obj.HanSuDung != null) ? string.Format("{0:dd/MM/yyyy}", obj.HanSuDung) : "";

                chkKTC.Checked = obj.VTYTDichVuKTC??false;
                txtMaVTYTBYT.Text = obj.MaVTYTBYT;

                txtGhiChu.Text = obj.GhiChu;
                intSTTBYT.Text = obj.STTBYT;
                txtMaVTYTBYT.Text = obj.MaVTYTBYT;
                txtTenVTYTBYT.Text = obj.TenVTYTBYT;
            }
        }
        private int Update(string strMa)
        {
            int kq = 0;
            clsDM_VTYT obj = new clsDM_VTYT();
            obj.MaVTYT = strMa;
            obj.TenVTYT = txtTenVTYT.Text;
            obj.DonViTinh = txtDVT.Text;
            obj.TenHoatChat = txtTenHoatChat.Text;
            obj.QuyCach = txtQuyCach.Text;
            obj.NhaSanXuat = txtNhaSanXuat.Text;
            obj.NuocSanXuat = txtNuocSanXuat.Text;
            obj.SoDangKy = txtSoDK.Text;

            obj.DonGiaMua = decDonGiaMua.Value;
            obj.DonGiaCSKCB = decDonGiaCSKCB.Value;
            obj.DonGiaThau = decDonGiaBHYT.Value;
            obj.VTYTThayThe = chkVTYT_TT.Checked;
            obj.VTYTDichVuKTC = chkKTC.Checked;
            obj.Active = chkConDung.Checked;
            obj.TrongDanhMucBHYT = chkBHYT.Checked;
            obj.MaNhom1 = txtNhom1.Text;
            obj.MaNhom2 = txtNhom2.Text;

            if (txtHanSuDung.Text.Length > 0)
            {
                DateTime dt = DateTime.ParseExact(txtHanSuDung.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                obj.HanSuDung = dt;
            }
            else
            {
                obj.HanSuDung = null;
            }

            obj.VTYTDichVuKTC = chkKTC.Checked;
            obj.Active = chkConDung.Checked;
            obj.MaVTYTBYT = txtMaVTYTBYT.Text;

            obj.GhiChu = txtGhiChu.Text;
            obj.STTBYT = intSTTBYT.Text;
            obj.MaVTYTBYT = txtMaVTYTBYT.Text;
            obj.TenVTYTBYT = txtTenVTYTBYT.Text;
            kq = obj.Update();
            return kq;
        }
        private int Insert()
        {
            if (CheckTonTai(txtMaVTYT.Text))
            {
                MessageBox.Show("Mã VTYT này đã được sử dụng. Xin nhập mã VTYT khác", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtMaVTYT.Focus();
                return 0;
            }

            int kq = 0;
            clsDM_VTYT obj = new clsDM_VTYT();
            obj.MaVTYT = txtMaVTYT.Text;
            obj.TenVTYT = txtTenVTYT.Text;
            obj.DonViTinh = txtDVT.Text;
            obj.TenHoatChat = txtTenHoatChat.Text;
            obj.QuyCach = txtQuyCach.Text;
            obj.NhaSanXuat = txtNhaSanXuat.Text;
            obj.NuocSanXuat = txtNuocSanXuat.Text;
            obj.SoDangKy = txtSoDK.Text;

            obj.DonGiaMua = decDonGiaMua.Value;
            obj.DonGiaCSKCB = decDonGiaCSKCB.Value;
            obj.DonGiaThau = decDonGiaBHYT.Value;
            obj.VTYTThayThe = chkVTYT_TT.Checked;
            obj.VTYTDichVuKTC = chkKTC.Checked;
            obj.Active = chkConDung.Checked;
            obj.TrongDanhMucBHYT = chkBHYT.Checked;
            obj.MaNhom1 = txtNhom1.Text;
            obj.MaNhom2 = txtNhom2.Text;

            if (txtHanSuDung.Text.Length > 0)
            {
                DateTime dt = DateTime.ParseExact(txtHanSuDung.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                obj.HanSuDung = dt;
            }
            else
            {
                obj.HanSuDung = null;
            }

            obj.VTYTDichVuKTC = chkKTC.Checked;
            obj.Active = chkConDung.Checked;
            obj.MaVTYTBYT = txtMaVTYTBYT.Text;

            obj.GhiChu = txtGhiChu.Text;
            obj.STTBYT = intSTTBYT.Text;
            obj.MaVTYTBYT = txtMaVTYTBYT.Text;
            obj.TenVTYTBYT = txtTenVTYTBYT.Text;
            kq = obj.Insert();
            return kq;
        }
        private void LoadGridView()
        {
            int index = 0;
            if (gridMaster.RowCount > 0)
            {
                index = gridMaster.CurrentCell.RowIndex;
            }
            clsDM_VTYT obj = new clsDM_VTYT();
            dTableDanhMucVTYT = obj.GetAll();
            gridMaster.DataSource = dTableDanhMucVTYT;

            if (gridMaster.RowCount > 0)
            {
                gridMaster.Rows[index].Selected = true;
                gridMaster.FirstDisplayedScrollingRowIndex = index;
            }
        }
Ejemplo n.º 9
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();
        }