public AddEditManufacturerDialog(CommonUtils.EquipmentTypeCode equipmentType)
 {
     InitializeComponent();
     Manufacturer = new Manufacturer();
     Manufacturer.EquipmentTypeId = (int) equipmentType;
     model = new AddEditManufacturerViewModel(Manufacturer, (int)equipmentType);
     model.View = this;
     Utils.ResetOriginalValues(this);
 }
        public AddEditManufacturerViewModel(Manufacturer manufacturer, int equipmentTypeId)
        {
            mEquipmentTypeId = manufacturer.EquipmentTypeId;
            mManufacturer = manufacturer;
            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
            cmsWebServiceClient.GetManufacturersCompleted += CmsWebServiceClientOnGetManufacturersCompleted;
            cmsWebServiceClient.GetManufacturersAsync(equipmentTypeId);

            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanModifyConfig);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true);
        }
        public AddEditManufacturerViewModel(int manufacturerId, int equipmentTypeId)
        {
            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

            cmsWebServiceClient.GetManufacturerCompleted +=
                (s1, e1) =>
                    {
                        mManufacturer = e1.Result;
                        OriginalName = mManufacturer.Name;
                        mEquipmentTypeId = mManufacturer.EquipmentTypeId;

                        cmsWebServiceClient.GetManufacturersCompleted += CmsWebServiceClientOnGetManufacturersCompleted;
                        cmsWebServiceClient.GetManufacturersAsync(equipmentTypeId);

                    };
            cmsWebServiceClient.GetManufacturerAsync(manufacturerId);

            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanModifyConfig);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true);
        }
Exemplo n.º 4
0
        private void SetControlValuesFromSearchFilterList(SearchFilterList searchFilterList)
        {
            mSearchFilterControl.SetFilterIsOn(true);
            ClearControls();

            //1. Manufacturer
            SearchFilter manufactuerFilter = (from x in searchFilterList.SearchFilters where x.Name.Equals(CommonUtils.PipeSearchFilterNames.Manufacturer.ToString(), StringComparison.CurrentCultureIgnoreCase) select x).FirstOrDefault();
            if (manufactuerFilter != null)
            {
                int result;
                if (int.TryParse(manufactuerFilter.Value, out result))
                {
                    Manufacturer match = (from x in Manufacturers where x.Id == result select x).FirstOrDefault();
                    mSelectedManufacturer = match;
                    RaisePropertyChanged("SelectedManufacturer");
                }
            }

            //2. Model
            SearchFilter modelFilter = (from x in searchFilterList.SearchFilters where x.Name.Equals(CommonUtils.PipeSearchFilterNames.Model.ToString(), StringComparison.CurrentCultureIgnoreCase) select x).FirstOrDefault();
            if (modelFilter != null)
            {
                int result;
                if (int.TryParse(modelFilter.Value, out result))
                {
                    Model match = (from x in mModelsCache where x.Id == result select x).FirstOrDefault();
                    mSelectedModel = match;
                    RaisePropertyChanged("SelectedModel");
                }
            }

            //1. Area
            SearchFilter areaFilter = (from x in searchFilterList.SearchFilters where x.Name.Equals(CommonUtils.PipeSearchFilterNames.Area.ToString(), StringComparison.CurrentCultureIgnoreCase) select x).FirstOrDefault();
            if (areaFilter != null)
            {
                int result;
                if (int.TryParse(areaFilter.Value, out result))
                {
                    Area match = (from x in Areas where x.Id == result select x).FirstOrDefault();
                    mSelectedArea = match;
                    RaisePropertyChanged("SelectedArea");
                }
            }

            //2. SubArea
            SearchFilter subareaFilter = (from x in searchFilterList.SearchFilters where x.Name.Equals(CommonUtils.PipeSearchFilterNames.SubArea.ToString(), StringComparison.CurrentCultureIgnoreCase) select x).FirstOrDefault();
            if (subareaFilter != null)
            {
                int result;
                if (int.TryParse(subareaFilter.Value, out result))
                {
                    Cell match = (from x in SubAreas where x.Id == result select x).FirstOrDefault();
                    mSelectedSubArea = match;
                    RaisePropertyChanged("SelectedSubArea");
                }
            }

            foreach (SearchFilter filter in searchFilterList.SearchFilters)
            {
                if (!string.IsNullOrEmpty(filter.Value))
                {
                    //KeyWords
                    if (filter.Name.Equals(CommonUtils.PipeSearchFilterNames.KeyWord.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        mKeyword = filter.Value;
                        RaisePropertyChanged("Keyword");
                    }

                    //PipeClass
                    if (filter.Name.Equals(CommonUtils.PipeSearchFilterNames.Class.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            var match = (from x in PipeClasses where x.Id == result select x).FirstOrDefault();
                            mSelectedPipeClass = match;
                            RaisePropertyChanged("SelectedPipeClass");
                        }
                    }

                    //PipeSize
                    if (filter.Name.Equals(CommonUtils.PipeSearchFilterNames.Size.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            var match = (from x in PipeSizes where x.Id == result select x).FirstOrDefault();
                            mSelectedPipeSize = match;
                            RaisePropertyChanged("SelectedPipeSize");
                        }
                    }

                    //PipeFluidCode
                    if (filter.Name.Equals(CommonUtils.PipeSearchFilterNames.FluidCode.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            var match = (from x in PipeFluidCodes where x.Id == result select x).FirstOrDefault();
                            mSelectedPipeFluidCode = match;
                            RaisePropertyChanged("SelectedPipeFluidCode");
                        }
                    }

                    //PipeSpecialFeature
                    if (filter.Name.Equals(CommonUtils.PipeSearchFilterNames.SpecialFeature.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            var match = (from x in PipeSpecialFeatures where x.Id == result select x).FirstOrDefault();
                            mSelectedPipeSpecialFeature = match;
                            RaisePropertyChanged("SelectedPipeSpecialFeature");
                        }
                    }

                    //PidDocument
                    if (filter.Name.Equals(CommonUtils.PipeSearchFilterNames.PidDocument.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            QuickDocument match = (from x in PandIDDocuments where x.Id == result select x).FirstOrDefault();
                            mSelectedPAndIdDocument = match;
                            RaisePropertyChanged("SelectedPAndIdDocument");
                        }
                    }

                    //ComponentType
                    if (filter.Name.Equals(CommonUtils.PipeSearchFilterNames.ComponentType.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            PipeComponentType match = (from x in ComponentTypes where x.Id == result select x).FirstOrDefault();
                            mSelectedComponentType = match;
                            RaisePropertyChanged("SelectedComponentType");
                        }
                    }

                    //IsActive
                    if (filter.Name.Equals(CommonUtils.PipeSearchFilterNames.IsActive.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        //For compatibility as previously it was saved as Id
                        if (filter.Value == "-1") filter.Value = All;
                        if (filter.Value == "-2") filter.Value = Yes;
                        if (filter.Value == "-3") filter.Value = No;

                        var match = (from x in IsActiveChoices where x == filter.Value select x).FirstOrDefault();
                        mSelectedIsActive = match;
                        RaisePropertyChanged("SelectedIsActive");

                    }

                }
            }

            ProcessSearchFilter();
        }
Exemplo n.º 5
0
        private void ClearControls()
        {
            mKeyword = string.Empty;
            RaisePropertyChanged("Keyword");

            mSelectedArea = Areas[0];
            RaisePropertyChanged("SelectedArea");

            mSelectedSubArea = SubAreas[0];
            RaisePropertyChanged("SelectedSubArea");

            mSelectedPipeClass = PipeClasses[0];
            RaisePropertyChanged("SelectedPipeClass");

            mSelectedPipeSize = PipeSizes[0];
            RaisePropertyChanged("SelectedPipeSize");

            mSelectedPipeFluidCode = PipeFluidCodes[0];
            RaisePropertyChanged("SelectedPipeFluidCode");

            mSelectedPipeSpecialFeature = PipeSpecialFeatures[0];
            RaisePropertyChanged("SelectedPipeSpecialFeature");

            mSelectedPAndIdDocument = PandIDDocuments[0];
            RaisePropertyChanged("SelectedPAndIdDocument");

            mSelectedComponentType = ComponentTypes[0];
            RaisePropertyChanged("SelectedComponentType");

            mSelectedManufacturer = Manufacturers[0];
            RaisePropertyChanged("SelectedManufacturer");

            mSelectedModel = Models[0];
            RaisePropertyChanged("SelectedModel");

            mSelectedIsActive = IsActiveChoices[0];
            RaisePropertyChanged("SelectedIsActive");
        }
        private void ClearControls()
        {
            mKeyword = string.Empty;
            RaisePropertyChanged("Keyword");

            mSelectedArea = Areas[0];
            RaisePropertyChanged("SelectedArea");

            mMainSystId = string.Empty;
            RaisePropertyChanged("MainSystId");

            mSelectedEquipmentType = EquipmentTypes[0];
            RaisePropertyChanged("SelectedEquipmentType");

            mSelectedSubArea = SubAreas[0];
            RaisePropertyChanged("SelectedSubArea");

            mSelectedPAndIdDocument = PandIDDocuments[0];
            RaisePropertyChanged("SelectedPAndIdDocument");

            mSelectedComponentType = ComponentTypes[0];
            RaisePropertyChanged("SelectedComponentType");

            mSelectedSpecificationDocument = SpecificationDocuments[0];
            RaisePropertyChanged("SelectedSpecificationDocument");

            mSelectedClassified = Classifieds[0];
            RaisePropertyChanged("Classified");

            mSelectedIsActive = IsActiveChoices[0];
            RaisePropertyChanged("SelectedIsActive");

            mSelectedManufacturer = Manufacturers[0];
            RaisePropertyChanged("SelectedManufacturer");

            mSelectedModel = Models[0];
            RaisePropertyChanged("SelectedModel");

            mSelectedPAndIdDocument = PandIDDocuments[0];
            RaisePropertyChanged("SelectedPAndIDDocument");

            mSelectedClassified = Classifieds[0];
            RaisePropertyChanged("SelectedClassified");
        }
        private void SetControlValuesFromSearchFilterList(SearchFilterList searchFilterList)
        {
            mSearchFilterControl.SetFilterIsOn(true);
            ClearControls();

            //1. Manufacturer
            SearchFilter manufactuerFilter = (from x in searchFilterList.SearchFilters where x.Name.Equals(CommonUtils.MobilePlantSearchFilterNames.Manufacturer.ToString(), StringComparison.CurrentCultureIgnoreCase) select x).FirstOrDefault();
            if (manufactuerFilter != null)
            {
                int result;
                if (int.TryParse(manufactuerFilter.Value, out result))
                {
                    Manufacturer match = (from x in Manufacturers where x.Id == result select x).FirstOrDefault();
                    mSelectedManufacturer = match;
                    RaisePropertyChanged("SelectedManufacturer");
                }
            }

            //2. Model
            SearchFilter modelFilter = (from x in searchFilterList.SearchFilters where x.Name.Equals(CommonUtils.MobilePlantSearchFilterNames.Model.ToString(), StringComparison.CurrentCultureIgnoreCase) select x).FirstOrDefault();
            if (modelFilter != null)
            {
                int result;
                if (int.TryParse(modelFilter.Value, out result))
                {
                    Model match = (from x in mModelsCache where x.Id == result select x).FirstOrDefault();
                    mSelectedModel = match;
                    RaisePropertyChanged("SelectedModel");
                }
            }

            //1. Area
            SearchFilter areaFilter = (from x in searchFilterList.SearchFilters where x.Name.Equals(CommonUtils.MobilePlantSearchFilterNames.Area.ToString(), StringComparison.CurrentCultureIgnoreCase) select x).FirstOrDefault();
            if (areaFilter != null)
            {
                int result;
                if (int.TryParse(areaFilter.Value, out result))
                {
                    Area match = (from x in Areas where x.Id == result select x).FirstOrDefault();
                    mSelectedArea = match;
                    RaisePropertyChanged("SelectedArea");
                }
            }

            //2. SubArea
            SearchFilter subareaFilter = (from x in searchFilterList.SearchFilters where x.Name.Equals(CommonUtils.MobilePlantSearchFilterNames.SubArea.ToString(), StringComparison.CurrentCultureIgnoreCase) select x).FirstOrDefault();
            if (subareaFilter != null)
            {
                int result;
                if (int.TryParse(subareaFilter.Value, out result))
                {
                    Cell match = (from x in SubAreas where x.Id == result select x).FirstOrDefault();
                    mSelectedSubArea = match;
                    RaisePropertyChanged("SelectedSubArea");
                }
            }

            foreach (SearchFilter filter in searchFilterList.SearchFilters)
            {
                if (!string.IsNullOrEmpty(filter.Value))
                {
                    //KeyWords
                    if (filter.Name.Equals(CommonUtils.MobilePlantSearchFilterNames.KeyWord.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        mKeyword = filter.Value;
                        RaisePropertyChanged("Keyword");
                    }

                    //MainSystId
                    if (filter.Name.Equals(CommonUtils.MobilePlantSearchFilterNames.MaintSystemId.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        mMainSystId = filter.Value;
                        RaisePropertyChanged("MainSystId");
                    }

                    //Owner
                    if (filter.Name.Equals(CommonUtils.MobilePlantSearchFilterNames.Owner.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            mSelectedMobileOwner = (from x in MobileOwners where x.Id == result select x).FirstOrDefault();
                            RaisePropertyChanged("SelectedMobileOwner");
                        }
                    }

                    //Hirer
                    if (filter.Name.Equals(CommonUtils.MobilePlantSearchFilterNames.Hirer.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            mSelectedMobileHirer = (from x in MobileHirers where x.Id == result select x).FirstOrDefault();
                            RaisePropertyChanged("SelectedMobileHirer");
                        }
                    }

                    //Classified
                    if (filter.Name.Equals(CommonUtils.MobilePlantSearchFilterNames.Classified.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        //For compatibility as previously it was saved as Id
                        if (filter.Value == "-1") filter.Value = All;
                        if (filter.Value == "-2") filter.Value = Yes;
                        if (filter.Value == "-3") filter.Value = No;

                        var match = (from x in Classifieds where x == filter.Value select x).FirstOrDefault();
                        mSelectedClassified = match;
                        RaisePropertyChanged("Classified");
                    }

                    //Type
                    if (filter.Name.Equals(CommonUtils.MobilePlantSearchFilterNames.MobilePlantType.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            MobilePlantType match = (from x in EquipmentTypes where x.Id == result select x).FirstOrDefault();
                            mSelectedEquipmentType = match;
                            RaisePropertyChanged("SelectedEquipmentType");
                        }
                    }

                    //ComponentType
                    if (filter.Name.Equals(CommonUtils.MobilePlantSearchFilterNames.ComponentType.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            MobilePlantComponentType match = (from x in ComponentTypes where x.Id == result select x).FirstOrDefault();
                            mSelectedComponentType = match;
                            RaisePropertyChanged("SelectedComponentType");
                        }
                    }

                    //IsActive
                    if (filter.Name.Equals(CommonUtils.MobilePlantSearchFilterNames.IsActive.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        //For compatibility as previously it was saved as Id
                        if (filter.Value == "-1") filter.Value = All;
                        if (filter.Value == "-2") filter.Value = Yes;
                        if (filter.Value == "-3") filter.Value = No;

                        var match = (from x in IsActiveChoices where x == filter.Value select x).FirstOrDefault();
                        mSelectedIsActive = match;
                        RaisePropertyChanged("SelectedIsActive");

                    }

                }
            }

            ProcessSearchFilter();
        }
        private void SetManufacturersCache()
        {
            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

            cmsWebServiceClient.GetAllManufacturersCompleted += (sender, e) =>
            {
                if (e.Result.Any())
                {
                    Manufacturer all = new Manufacturer { Id = -1,Name = ALL };
                    e.Result.Insert(0, all);

                    mCachedManufacturers = new ObservableCollection<Manufacturer>(e.Result);

                    Manufacturers = mCachedManufacturers;
                    SelectedManufacturer = all;

                }
            };
            cmsWebServiceClient.GetAllManufacturersAsync();
        }