Exemple #1
0
        private void OnDisplayServicesHistory()
        {
            Result result = ServiceHistoryBus.GetServiceHistory(_patientGUID, _isAll, _fromDate, _toDate);

            if (result.IsOK)
            {
                MethodInvoker method = delegate
                {
                    ClearData();
                    dgServiceHistory.DataSource = result.QueryResult;

                    if (!_isChuyenBenhAn)
                    {
                        HighlightPaidServices();
                        CalculateTotalPrice();
                    }
                };

                if (InvokeRequired)
                {
                    BeginInvoke(method);
                }
                else
                {
                    method.Invoke();
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("ServiceHistoryBus.GetServiceHistory"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ServiceHistoryBus.GetServiceHistory"));
            }
        }
        private void OnDisplayServicesHistory()
        {
            Result result = ServiceHistoryBus.GetDSDichVuChuaXuatPhieu(_fromDate, _toDate);

            if (result.IsOK)
            {
                MethodInvoker method = delegate
                {
                    dgServiceHistory.DataSource = result.QueryResult;
                };

                if (InvokeRequired)
                {
                    BeginInvoke(method);
                }
                else
                {
                    method.Invoke();
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("ServiceHistoryBus.GetDSDichVuChuaXuatPhieu"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ServiceHistoryBus.GetDSDichVuChuaXuatPhieu"));
            }
        }
        private bool CheckInfo()
        {
            if (cboService.SelectedValue == null || cboService.Text == null || cboService.Text == string.Empty)
            {
                MsgBox.Show(this.Text, "Vui lòng chọn dịch vụ.", IconType.Information);
                cboService.Focus();
                return false;
            }

            string serviceHistoryGUID = _isNew ? string.Empty : _serviceHistory.ServiceHistoryGUID.ToString();
            string serviceGUID = cboService.SelectedValue.ToString();
            DateTime ngayKham = dtpkActiveDate.Value;
            Result result = ServiceHistoryBus.CheckDichVuExist(serviceHistoryGUID, _patientGUID, serviceGUID, ngayKham);
            if (result.Error.Code == ErrorCode.EXIST || result.Error.Code == ErrorCode.NOT_EXIST)
            {
                if (result.Error.Code == ErrorCode.EXIST && _hopDongGUID == string.Empty)
                {
                    MsgBox.Show(this.Text, "Dịch vụ này hôm nay đã có. Vui lòng chọn dịch vụ khác.", IconType.Information);
                    cboService.Focus();
                    return false;
                }
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("ServiceHistoryBus.CheckDichVuExist"), IconType.Error);
                return false;
            }

            if (chkBSCD.Checked && (cboBacSiChiDinh.SelectedValue == null || cboBacSiChiDinh.Text == string.Empty))
            {
                MsgBox.Show(this.Text, "Vui lòng chọn bác sĩ chỉ định", IconType.Information);
                cboBacSiChiDinh.Focus();
                return false;
            }

            if (raKhamTheoHopDong.Checked && !CheckDichVuTheoHopDongValid(_patientGUID)) return false;

            if (chkChuyenNhuong.Checked && txtChuyenNhuong.Text == string.Empty)
            {
                MsgBox.Show(this.Text, "Vui lòng chọn người chuyển nhượng.", IconType.Information);
                btnChonBenhNhan.Focus();
                return false;
            }

            if (chkChuyenNhuong.Checked && !CheckDichVuChuyenNhuongValid(txtChuyenNhuong.Tag.ToString())) return false;

            return true;
        }
Exemple #4
0
        private void OnDisplayDichVuLamThem(string patientGUID)
        {
            ClearDichVuLamThem();
            chkChecked2.Checked = false;
            Result result = ServiceHistoryBus.GetDichVuLamThemList(patientGUID, _hopDongGUID);

            if (result.IsOK)
            {
                dgDichVuLamThem.DataSource = result.QueryResult;
                HighlightPaidServices();
                OnTinhTongTienDichVuLamThem();
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("ServiceHistoryBus.GetDichVuLamThemList"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ServiceHistoryBus.GetDichVuLamThemList"));
            }
        }
        private void OnCapNhatAllChecklist(List <string> checkedPatientList)
        {
            foreach (string patientGUID in checkedPatientList)
            {
                Result result = CompanyContractBus.GetCheckList(_hopDongGUID, patientGUID);
                if (!result.IsOK)
                {
                    MsgBox.Show(this.Text, result.GetErrorAsString("CompanyContractBus.GetCheckList"), IconType.Error);
                    Utility.WriteToTraceLog(result.GetErrorAsString("CompanyContractBus.GetCheckList"));
                    return;
                }

                DataTable      dtChecklist   = result.QueryResult as DataTable;
                List <DataRow> checkListRows = new List <DataRow>();
                foreach (DataRow row in dtChecklist.Rows)
                {
                    bool isUsing = Convert.ToBoolean(row["Using"]);
                    if (isUsing)
                    {
                        continue;
                    }
                    row["Using"] = true;
                    checkListRows.Add(row);
                }

                if (checkListRows.Count <= 0)
                {
                    continue;
                }
                result = ServiceHistoryBus.UpdateChecklist(patientGUID, _hopDongGUID, _beginDate, _endDate, checkListRows);
                if (!result.IsOK)
                {
                    MsgBox.Show(this.Text, result.GetErrorAsString("ServiceHistoryBus.UpdateChecklist"), IconType.Error);
                    Utility.WriteToTraceLog(result.GetErrorAsString("ServiceHistoryBus.UpdateChecklist"));
                    return;
                }
            }

            MsgBox.Show(this.Text, "Đã cập nhật thành công.", IconType.Information);
        }
Exemple #6
0
        private void OnChuyenKetQuaKham()
        {
            if (!_isChuyenBenhAn)
            {
                return;
            }

            if (dgServiceHistory.RowCount <= 0 ||
                CheckedServiceRows == null || CheckedServiceRows.Count <= 0)
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu ít nhất 1 dịch vụ cần chuyển.", IconType.Information);
                return;
            }

            if (_patientRow2 == null)
            {
                MsgBox.Show(Application.ProductName, "Vui lòng chọn bệnh nhân nhận dịch vụ chuyển đến.", IconType.Information);
                return;
            }

            string fileNum = _patientRow2["FileNum"].ToString();

            if (MsgBox.Question(Application.ProductName, string.Format("Bạn có muốn chuyển những dịch vụ đã chọn đến bệnh nhân: '{0}'?", fileNum)) == DialogResult.No)
            {
                return;
            }

            Result result = ServiceHistoryBus.ChuyenBenhAn(_patientRow2["PatientGUID"].ToString(), CheckedServiceRows);

            if (result.IsOK)
            {
                DisplayAsThread();
            }
            else
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("ServiceHistoryBus.ChuyenBenhAn"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ServiceHistoryBus.ChuyenBenhAn"));
            }
        }
Exemple #7
0
        private void SaveCheckList()
        {
            List <DataRow> checkListRows = new List <DataRow>();

            foreach (DataGridViewRow row in dgService.Rows)
            {
                DataGridViewDisableCheckBoxCell cell = row.Cells["Using"] as DataGridViewDisableCheckBoxCell;
                if (!cell.Enabled)
                {
                    continue;
                }

                DataRow drRow = (row.DataBoundItem as DataRowView).Row;
                checkListRows.Add(drRow);
            }

            if (checkListRows.Count <= 0)
            {
                return;
            }

            Result result = ServiceHistoryBus.UpdateChecklist(_patientGUID, _hopDongGUID, _beginDate, _endDate, checkListRows);

            if (!result.IsOK)
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("ServiceHistoryBus.UpdateChecklist"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ServiceHistoryBus.UpdateChecklist"));
            }
            else
            {
                MsgBox.Show(this.Text, "Đã lưu thành công.", IconType.Information);
                _isSaved = true;
                OnTinhTongTienChecklist(_patientRow);
                txtSearchPatient.Focus();
            }
        }
Exemple #8
0
        private void OnDelete()
        {
            List <string>  deletedServiceHistoryList = new List <string>();
            List <DataRow> deletedRows = new List <DataRow>();
            DataTable      dt          = dgServiceHistory.DataSource as DataTable;

            foreach (DataRow row in dt.Rows)
            {
                if (Boolean.Parse(row["Checked"].ToString()))
                {
                    bool isExported = Convert.ToBoolean(row["IsExported"]);

                    if (!isExported)
                    {
                        deletedServiceHistoryList.Add(row["ServiceHistoryGUID"].ToString());
                        deletedRows.Add(row);
                    }
                    else
                    {
                        string srvHistoryGUID = row["ServiceHistoryGUID"].ToString();
                        Result r = ServiceHistoryBus.GetPhieuThuByServiceHistoryGUID(srvHistoryGUID);
                        if (r.IsOK)
                        {
                            string soPhieuThu = string.Empty;
                            if (r.QueryResult != null)
                            {
                                Receipt receipt = r.QueryResult as Receipt;
                                soPhieuThu = receipt.ReceiptCode;
                            }

                            string srvName = row["Name"].ToString();
                            MsgBox.Show(Application.ProductName, string.Format("Dịch vụ: '{0}' không thể xóa vì đã xuất phiếu thu ({1}). Vui lòng chọn lại.", srvName, soPhieuThu),
                                        IconType.Information);
                            return;
                        }
                        else
                        {
                            MsgBox.Show(Application.ProductName, r.GetErrorAsString("ServiceHistoryBus.GetPhieuThuByServiceHistoryGUID"), IconType.Error);
                            Utility.WriteToTraceLog(r.GetErrorAsString("ServiceHistoryBus.GetPhieuThuByServiceHistoryGUID"));
                            return;
                        }
                    }
                }
            }

            if (deletedServiceHistoryList.Count > 0)
            {
                if (MsgBox.Question(Application.ProductName, "Bạn có muốn xóa những dịch vụ mà bạn đã đánh dấu ?") == DialogResult.Yes)
                {
                    Result result = ServiceHistoryBus.DeleteServiceHistory(deletedServiceHistoryList);
                    if (result.IsOK)
                    {
                        base.RaiseServiceHistoryChanged();
                    }
                    else
                    {
                        MsgBox.Show(Application.ProductName, result.GetErrorAsString("ServiceHistoryBus.DeleteServiceHistory"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("ServiceHistoryBus.DeleteServiceHistory"));
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những dịch vụ cần xóa.", IconType.Information);
            }
        }
        private void OnSaveInfo()
        {
            try
            {
                if (_isNew)
                {
                    _serviceHistory.CreatedDate = DateTime.Now;
                    _serviceHistory.CreatedBy = Guid.Parse(Global.UserGUID);
                }
                else
                {
                    _serviceHistory.UpdatedDate = DateTime.Now;
                    _serviceHistory.UpdatedBy = Guid.Parse(Global.UserGUID);
                }

                _serviceHistory.PatientGUID = Guid.Parse(_patientGUID);
                _serviceHistory.Note = txtDescription.Text;

                MethodInvoker method = delegate
                {
                    _serviceHistory.ActivedDate = dtpkActiveDate.Value;
                    _serviceHistory.KhamTuTuc = raKhamTuTuc.Checked;

                    if (cboDocStaff.SelectedValue != null && cboDocStaff.Text.Trim() != string.Empty)
                        _serviceHistory.DocStaffGUID = Guid.Parse(cboDocStaff.SelectedValue.ToString());
                    else
                        _serviceHistory.DocStaffGUID = null;

                    if (chkChuyenNhuong.Checked)
                        _serviceHistory.RootPatientGUID = Guid.Parse(txtChuyenNhuong.Tag.ToString());
                    else
                        _serviceHistory.RootPatientGUID = null;

                    _serviceHistory.ServiceGUID = Guid.Parse(cboService.SelectedValue.ToString());

                    _serviceHistory.Price = (double)numPrice.Value;
                    _serviceHistory.Discount = (double)numDiscount.Value;
                    _serviceHistory.SoLuong = Convert.ToInt32(numSoLuong.Value);

                    _serviceHistory.IsNormalOrNegative = raNormal.Checked;
                    if (raNormal.Checked)
                    {
                        _serviceHistory.Normal = chkNormal.Checked;
                        _serviceHistory.Abnormal = chkAbnormal.Checked;
                        _serviceHistory.Negative = false;
                        _serviceHistory.Positive = false;
                    }
                    else
                    {
                        _serviceHistory.Normal = false;
                        _serviceHistory.Abnormal = false;
                        _serviceHistory.Negative = chkNegative.Checked;
                        _serviceHistory.Positive = chkPositive.Checked;
                    }

                    if (_hopDongGUID != string.Empty)
                        _serviceHistory.HopDongGUID = Guid.Parse(_hopDongGUID);

                    Result result = GiaVonDichVuBus.GetGiaVonDichVuMoiNhat(_serviceHistory.ServiceGUID.ToString(), _serviceHistory.ActivedDate.Value);
                    if (!result.IsOK)
                    {
                        MsgBox.Show(this.Text, result.GetErrorAsString("GiaVonDichVuBus.GetGiaVonDichVuMoiNhat"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("GiaVonDichVuBus.GetGiaVonDichVuMoiNhat"));
                        this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                        return;
                    }

                    DataTable dt = result.QueryResult as DataTable;
                    if (dt != null && dt.Rows.Count > 0)
                        _serviceHistory.GiaVon = Convert.ToDouble(dt.Rows[0]["GiaVon"]);

                    result = ServiceHistoryBus.InsertServiceHistory(_serviceHistory);
                    if (!result.IsOK)
                    {
                        MsgBox.Show(this.Text, result.GetErrorAsString("ServiceHistoryBus.InsertServiceHistory"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("ServiceHistoryBus.InsertServiceHistory"));
                        this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                    }
                    else if (_serviceGUID == string.Empty)
                    {
                        if (chkBSCD.Checked)
                        {
                            if (_chiDinh == null)
                            {
                                _chiDinh = new ChiDinh();
                                string maChiDinh = GenerateCode();
                                if (maChiDinh == string.Empty) return;

                                //Insert chỉ định
                                _chiDinh.CreatedDate = DateTime.Now;
                                _chiDinh.CreatedBy = Guid.Parse(Global.UserGUID);
                                _chiDinh.MaChiDinh = maChiDinh;
                                _chiDinh.BenhNhanGUID = Guid.Parse(_patientGUID);
                                _chiDinh.BacSiChiDinhGUID = Guid.Parse(cboBacSiChiDinh.SelectedValue.ToString());
                                _chiDinh.NgayChiDinh = DateTime.Now;
                                _chiDinh.Status = (byte)Status.Actived;

                                List<ChiTietChiDinh> addedList = new List<ChiTietChiDinh>();
                                List<string> deletedKeys = new List<string>();
                                ChiTietChiDinh ctcd = new ChiTietChiDinh();
                                ctcd.CreatedDate = DateTime.Now;
                                ctcd.CreatedBy = Guid.Parse(Global.UserGUID);
                                ctcd.ServiceGUID = _serviceHistory.ServiceGUID.Value;
                                addedList.Add(ctcd);

                                result = ChiDinhBus.InsertChiDinh(_chiDinh, addedList, deletedKeys);
                                if (!result.IsOK)
                                {
                                    MsgBox.Show(Application.ProductName, result.GetErrorAsString("ChiDinhBus.InsertChiDinh"), IconType.Error);
                                    Utility.WriteToTraceLog(result.GetErrorAsString("ChiDinhBus.InsertChiDinh"));
                                    this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                                }
                                else
                                {
                                    DichVuChiDinh dichVuChiDinh = new DichVuChiDinh();
                                    dichVuChiDinh.ServiceHistoryGUID = _serviceHistory.ServiceHistoryGUID;
                                    dichVuChiDinh.ChiTietChiDinhGUID = ctcd.ChiTietChiDinhGUID;
                                    dichVuChiDinh.CreatedDate = DateTime.Now;
                                    dichVuChiDinh.CraetedBy = Guid.Parse(Global.UserGUID);
                                    dichVuChiDinh.Status = (byte)Status.Actived;

                                    result = ChiDinhBus.InsertDichVuChiDinh(dichVuChiDinh);
                                    if (!result.IsOK)
                                    {
                                        MsgBox.Show(Application.ProductName, result.GetErrorAsString("ChiDinhBus.InsertDichVuChiDinh"), IconType.Error);
                                        Utility.WriteToTraceLog(result.GetErrorAsString("ChiDinhBus.InsertDichVuChiDinh"));
                                        this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                                    }
                                }
                            }
                            else
                            {
                                _chiDinh.UpdatedDate = DateTime.Now;
                                _chiDinh.UpdatedBy = Guid.Parse(Global.UserGUID);
                                _chiDinh.Status = (byte)Status.Actived;

                                _chiDinh.BacSiChiDinhGUID = Guid.Parse(cboBacSiChiDinh.SelectedValue.ToString());
                                result = ChiDinhBus.UpdateChiDinh(_chiDinh, cboService.SelectedValue.ToString());
                                if (!result.IsOK)
                                {
                                    MsgBox.Show(Application.ProductName, result.GetErrorAsString("ChiDinhBus.UpdateChiDinh"), IconType.Error);
                                    Utility.WriteToTraceLog(result.GetErrorAsString("ChiDinhBus.UpdateChiDinh"));
                                    this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                                }
                            }
                        }
                        else if (_chiDinh != null)
                        {
                            List<string> keys = new List<string>();
                            keys.Add(_chiDinh.ChiDinhGUID.ToString());
                            result = ChiDinhBus.DeleteChiDinhs(keys);
                            if (!result.IsOK)
                            {
                                MsgBox.Show(Application.ProductName, result.GetErrorAsString("ChiDinhBus.DeleteChiDinhs"), IconType.Error);
                                Utility.WriteToTraceLog(result.GetErrorAsString("ChiDinhBus.DeleteChiDinhs"));
                                this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                            }
                        }
                    }
                };

                if (InvokeRequired) BeginInvoke(method);
                else method.Invoke();
            }
            catch (Exception e)
            {
                MsgBox.Show(this.Text, e.Message, IconType.Error);
                Utility.WriteToTraceLog(e.Message);
            }
        }