public FreeRentEquipmentDlg(OrmParentReference parentReference, FreeRentEquipment sub)
 {
     this.Build ();
     ParentReference = parentReference;
     subject = sub;
     loadFromPackage = subject.IsNew;
     if (subject.Equipment != null && subject.FreeRentPackage != null)
         TabName = subject.EquipmentName + " " + subject.PackageName;
     subjectCopy = ObjectCloner.Clone<FreeRentEquipment> (sub);
     ConfigureDlg ();
 }
Пример #2
0
 public FreeRentEquipmentDlg(OrmParentReference parentReference, FreeRentEquipment sub)
 {
     this.Build();
     ParentReference = parentReference;
     subject         = sub;
     loadFromPackage = subject.IsNew;
     if (subject.Equipment != null && subject.FreeRentPackage != null)
     {
         TabName = subject.EquipmentName + " " + subject.PackageName;
     }
     subjectCopy = ObjectCloner.Clone <FreeRentEquipment> (sub);
     ConfigureDlg();
 }
        void EquipmentSelected(object sender, OrmReferenceObjectSectedEventArgs e)
        {
            var selectedEquipment = (Equipment)e.Subject;

            var rentPackage = RentPackageRepository.GetFreeRentPackage(AgreementUoW, selectedEquipment.Nomenclature.Type);
            if (rentPackage == null)
            {
                MessageDialogWorks.RunErrorDialog("Для выбранного типа оборудования нет пакета бесплатной аренды.");
                return;
            }

            FreeRentEquipment eq = new FreeRentEquipment ();
            eq.Equipment = selectedEquipment;
            eq.Deposit = rentPackage.Deposit;
            eq.FreeRentPackage = rentPackage;
            eq.WaterAmount = rentPackage.MinWaterAmount;
            equipments.Add (eq);
            UpdateTotalLabels ();
        }
        void EquipmentByTypeSelected(object sender, ReferenceRepresentationSelectedEventArgs args)
        {
            var equipmentType = AgreementUoW.GetById<EquipmentType>(args.ObjectId);

            var rentPackage = Repository.RentPackageRepository.GetFreeRentPackage(AgreementUoW, equipmentType);
            if (rentPackage == null)
            {
                MessageDialogWorks.RunErrorDialog("Для выбранного типа оборудования нет пакета бесплатной аренды.");
                return;
            }

            var exclude = equipments.Select(e => e.Equipment.Id).ToArray();

            var selectedEquipment = EquipmentRepository.GetAvailableEquipmentForRent(AgreementUoW, equipmentType, exclude);
            if(selectedEquipment == null)
            {
                MessageDialogWorks.RunErrorDialog("Не найдено свободного оборудования выбранного типа.");
                return;
            }

            FreeRentEquipment eq = new FreeRentEquipment ();
            eq.Equipment = selectedEquipment;
            eq.Deposit = rentPackage.Deposit;
            eq.FreeRentPackage = rentPackage;
            eq.WaterAmount = rentPackage.MinWaterAmount;
            equipments.Add (eq);
            UpdateTotalLabels ();
        }