public SpeciesAvailableName GetSpeciesAvailableName(int taxonId)
        {
            var mapper = new GenericMapperBuilder <SpeciesAvailableName>().build();
            SpeciesAvailableName result = null;

            StoredProcReaderFirst("spSANGet", (reader) => {
                result = mapper.Map(reader);
            }, _P("intBiotaID", taxonId));
            return(result);
        }
 public void InsertOrUpdateSpeciesAvailableName(SpeciesAvailableName name)
 {
     StoredProcUpdate("spSANInsertUpdate",
                      _P("intBiotaID", name.BiotaID),
                      _P("intRefID", name.RefID),
                      _P("vchrRefPage", name.RefPage),
                      _P("vchrAvailableNameStatus", name.AvailableNameStatus),
                      _P("txtRefQual", name.RefQual),
                      _P("vchrPrimaryType", name.PrimaryType),
                      _P("vchrSecondaryType", name.SecondaryType),
                      _P("bitPrimaryTypeProbable", name.PrimaryTypeProbable),
                      _P("bitSecondaryTypeProbable", name.SecondaryTypeProbable));
 }
示例#3
0
        public SpeciesAvailableNameControl(TaxonViewModel taxon, User user) : base(taxon, user, "SpeciesAvailabeNames::")
        {
            InitializeComponent();

            txtReference.BindUser(user, LookupType.Reference);
            txtNameStatus.BindUser(user, PickListType.Phrase, "SAN Name Status", TraitCategoryType.Taxon);
            txtInstitution.BindUser(user, PickListType.Phrase, "Institution", TraitCategoryType.Taxon);
            txtSpecimen.BindUser(user, LookupType.Material);


            int taxaId = taxon.TaxaID.GetValueOrDefault(-1);
            SpeciesAvailableName data = Service.GetSpeciesAvailableName(taxaId) ?? new SpeciesAvailableName {
                BiotaID = taxaId
            };

            _model = new SpeciesAvailableNameViewModel(data);

            _model.DataChanged += changed => RegisterUniquePendingChange(new UpdateSanDatabaseCommand(_model.Model));

            cmbPrimaryType.SelectionChanged += (source, e) => {
                var tstr = cmbPrimaryType.SelectedItem as string;
                if (tstr != null && _SANTypeDataTypes.ContainsKey(tstr))
                {
                    var typedata = _SANTypeDataTypes[tstr];
                    cmbSecondaryType.ItemsSource = typedata.SecondaryTypes;
                }
            };

            if (taxon.TaxaID != null)
            {
                List <SANTypeDataType> santypes = Service.GetSANTypeDataTypes(taxon.TaxaID.Value);
                foreach (SANTypeDataType type in santypes)
                {
                    _SANTypeDataTypes[type.PrimaryType] = type;
                }

                cmbPrimaryType.ItemsSource = santypes.ConvertAll(st => st.PrimaryType);
            }

            var tdlist = Service.GetSANTypeData(taxaId);

            _typeData = new ObservableCollection <SANTypeDataViewModel>(tdlist.ConvertAll(d => {
                var viewmodel          = new SANTypeDataViewModel(d);
                viewmodel.DataChanged += changed => {
                    if (viewmodel.SANTypeDataID >= 0)
                    {
                        RegisterUniquePendingChange(new UpdateSANTypeDataCommand(viewmodel.Model));
                    }
                };
                return(viewmodel);
            }));
            lstTypeData.ItemsSource = _typeData;

            lstTypeData.SelectionChanged += (source, e) => {
                gridTypeData.IsEnabled = lstTypeData.SelectedItem != null;

                var availableTypes = new List <string> {
                    cmbPrimaryType.Text
                };
                var secondaries = cmbSecondaryType.ItemsSource as IEnumerable <string>;

                if (secondaries != null)
                {
                    availableTypes.AddRange(secondaries);
                }

                cmbType.ItemsSource      = availableTypes;
                gridTypeData.DataContext = lstTypeData.SelectedItem;
            };

            DataContext = _model;

            gridTypeData.IsEnabled = false;


            this.BackgroundInvoke(() => {
                if (_typeData.Count > 0)
                {
                    lstTypeData.SelectedIndex = 0;
                }
            });
        }