コード例 #1
0
        /// <summary>
        /// Updates the form.
        /// </summary>
        /// <param name="patient">The patient.</param>
        private void UpdateForm(Patient patient)
        {
            Patient ptn = _patientRepo.GetById(patient.Id);

            this.bdsPatient.DataSource = ptn;
            _lastPrescription          = _prescriptionRepo.GetLastByPatient(ptn.Id);

            if (_lastPrescription != null)
            {
                this.bdsPrescription.DataSource = _lastPrescription;
                var detailList = _prescriptionDetailRepo.GetByPrescription(_lastPrescription.Id);
                foreach (var detailItem in detailList)
                {
                    detailItem.MedicineName = detailItem.Medicine.Name;
                    detailItem.TradeName    = detailItem.Medicine.TradeName;
                    detailItem.UnitName     = detailItem.Medicine.Define.Name;
                }

                //this.bdsPrescription.DataSource = this.bdsPrescription;
                this.bdsPrescriptionDetail.DataSource = detailList;
                this.bdsPrescriptionDetail.ResetBindings(false);
                this.dataGridViewX1.Refresh();
            }
            else
            {
                this.bdsPrescription.Clear();
                this.bdsPrescriptionDetail.Clear();
            }
        }
コード例 #2
0
        /// <summary>
        /// Updates the form.
        /// </summary>
        /// <param name="patient">The patient.</param>
        private void UpdateForm(Patient patient)
        {
            this.bdsPrescription.Clear();
            this.bdsPrescriptionDetail.Clear();
            this.bdsPatient.DataSource = patient;
            this.selectedPatient       = patient;

            if (patient == null)
            {
                this.btnCheck.Enabled = false;
                return;
            }

            this.btnCheck.Enabled = true;
            lastPrescription      = prescriptionRepo.GetLastByPatient(patient.Id);

            if (lastPrescription == null)
            {
                return;
            }
            this.bdsPrescription.DataSource = lastPrescription;

            List <PrescriptionDetail> detailList = prescriptionDetailRepo.GetByPrescription(lastPrescription.Id);

            if (detailList != null)
            {
                for (int i = 0; i < detailList.Count; i++)
                {
                    detailList[i].No = i + 1;
                }
                this.bdsPrescriptionDetail.DataSource = detailList;
            }
        }
コード例 #3
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        private void Initialize()
        {
            this._vWareHouseDetailList      = new List <VWareHouseDetail>();
            this.bdsMedicine.DataSource     = _medicineRepo.GetAll();
            this._medDeliveryAllocationList = new List <MedicineDeliveryAllocationEntity>();
            this._prescription = _prescriptionRepo.Get(this._prescriptionId);
            this.bdsPrescription.DataSource = this._prescription;
            this._prescriptionDetailList    = _prescriptionDetailRepo.GetByPrescription(this._prescriptionId);
            if (_prescription == null || this._prescriptionDetailList == null)
            {
                throw new Exception("Data done not existed");
            }

            this._medicineDelivery = this._medicineDeliveryRepo.GetByPrescriptionId(this._prescriptionId);
            this._formMode         = this._medicineDelivery == null ? ViewModes.Add : ViewModes.View;

            if (this._formMode == ViewModes.Add)
            {
                // Createe MachineDelivery
                // Create MachineDeliveryDetail
                // Craete MedicindeDeliveryDetailAllocate
                // Get WareHouseDetail
                // Get WareHouse;
                // this._warehouseDetailList  = this._warehouseDetailRepo
                var medincineIdList = this._prescriptionDetailList.Select(item => item.MedicineId).ToList();
                this._warehouseList              = this._warehouseRepo.GetByMedicineId(medincineIdList, AppContext.CurrentClinic.Id);
                this._vWareHouseDetailList       = this._vWareHouseDetailRepo.GetByMedicine(medincineIdList);
                this._medicineDelivery           = CreatePrescription(this._prescription);
                this._medicineDeliveryDetailList = CreateMedicineDeliveryDetail(this._prescriptionDetailList);
                this.AutoAllocate(this._medicineDeliveryDetailList, this._vWareHouseDetailList);
                // this._warehouseDetailList = this._warehouseDetailRepo.GetByMedicine(medincineIdList, AppContext.CurrentClinic.Id);)
                // this._mdecidineDeliveryDetailAllocate = AutoAllocate(this._medicineDeliveryDetailList, this._warehouseDetailList);
                // var item = this._warehouseDetailList.Select(x => new { x.MedicineId, x.LotNo, x.ExpiredDate}).GroupBy(x => new { x.MedicineId, x.LotNo, x.ExpiredDate }).ToList();

                var no = 1;
                foreach (var deliveryItem in this._medicineDeliveryDetailList)
                {
                    // var allocatedList = this._mdecidineDeliveryDetailAllocate.Where(x => x.MedicineDeliveryDetailId == deliveryItem.Id).ToList();
                    var warehouse = this._warehouseList.FirstOrDefault(x => x.MedicineId == deliveryItem.MedicineId);
                    var item      = new MedicineDeliveryAllocationEntity(no++, deliveryItem, warehouse);
                    this._medDeliveryAllocationList.Add(item);

                    var subNo = 1;
                    foreach (var itm in deliveryItem.AllocatedWareHouseDetail)
                    {
                        var subItem = new MedicineDeliveryAllocationEntity(subNo++, itm);
                        _medDeliveryAllocationList.Add(subItem);
                    }
                }
                this.bindingSource1.DataSource = this._medDeliveryAllocationList;
            }
            else
            {
                var medincineIdList = this._prescriptionDetailList.Select(item => item.MedicineId).ToList();
                this._warehouseList        = this._warehouseRepo.GetByMedicineId(medincineIdList, AppContext.CurrentClinic.Id);
                this._vWareHouseDetailList = this._vWareHouseDetailRepo.GetByMedicine(medincineIdList);

                this._medicineDelivery           = this._medicineDeliveryRepo.GetByPrescriptionId(this._prescription.Id);
                this._medicineDeliveryDetailList = this._medicineDeliveryDetailRepo.GetByDelivery(this._medicineDelivery.Id);
                var deliveryDetailList = this._medicineDeliveryDetailList.Select(x => x.Id).ToList();
                this._vMedicineDeliveryDetailAllocateds = this._medicineDeliveryDetailRepo.GetDeliveryDetailAllocateds(deliveryDetailList);
                // this._mdecidineDeliveryDetailAllocate = AutoAllocate(this._medicineDeliveryDetailList, this._warehouseDetailList);
                // var item = this._warehouseDetailList.Select(x => new { x.MedicineId, x.LotNo, x.ExpiredDate}).GroupBy(x => new { x.MedicineId, x.LotNo, x.ExpiredDate }).ToList();
                // this._warehouseDetailList = this._warehouseDetailRepo.GetByMedicine(medincineIdList, AppContext.CurrentClinic.Id);)

                var no = 1;
                foreach (var deliveryItem in this._medicineDeliveryDetailList)
                {
                    // var allocatedList = this._mdecidineDeliveryDetailAllocate.Where(x => x.MedicineDeliveryDetailId == deliveryItem.Id).ToList();
                    var warehouse = this._warehouseList.FirstOrDefault(x => x.MedicineId == deliveryItem.MedicineId);
                    var item      = new MedicineDeliveryAllocationEntity(no++, deliveryItem, warehouse);
                    this._medDeliveryAllocationList.Add(item);

                    List <VMedicineDeliveryDetailAllocated> allocatedWareHouseDetailList =
                        this._vMedicineDeliveryDetailAllocateds.Where(x => x.MedicineDeliveryDetailId == deliveryItem.Id)
                        .ToList();
                    var subNo = 1;
                    foreach (var itm in allocatedWareHouseDetailList)
                    {
                        var subItem = new MedicineDeliveryAllocationEntity(subNo++, itm);
                        _medDeliveryAllocationList.Add(subItem);
                    }
                }
                this.dataGridViewX1.Columns[6].Visible = false;
                this.dataGridViewX1.Columns[8].Visible = false;
                this.bindingSource1.DataSource         = this._medDeliveryAllocationList;
            }
        }