示例#1
0
        public StateEditor(ISession session, Individual individual, T _state, string stateSelectQuery, bool currentTroopVisitsOnly = true)
        {
            InitializeComponent();

            this.individual = individual;
            if (currentTroopVisitsOnly)
            {
                this.tvs = new TroopVisitSelector(individual.CurrentTroop());
            }
            else
            {
                this.tvs = new TroopVisitSelector();
            }

            // Get the list of states
            this.comboBoxState.DataSource = session
                                            .CreateQuery(stateSelectQuery)
                                            .List <S>();

            if (_state != null)
            {
                this.state = _state;
                //this.individualReproductiveStateBindingSource.DataSource = state;
                this.troopVisit                 = state.TroopVisit;
                this.labelTroopVisit.Text       = state.TroopVisit.ToString();
                this.comboBoxState.SelectedItem = state.State;

                this.textBoxComments.Text = state.Comments;
            }
            else
            {
                // Set some defaults values
                this.state            = new T();
                this.state.Individual = individual;
                //this.timeDateTimePicker.Value = DateTime.Today;

                // We cannot set all the values so do not let
                // user hit ok for now
                this.buttonOk.Enabled = false;
            }

            if (comboBoxState.Items.Count <= 0)
            {
                MessageBox.Show("There are no States in the database to select from!");
                this.DialogResult = System.Windows.Forms.DialogResult.Abort;
                this.Close();
                return;
            }

            this.labelStateDescription.Text = ((S)comboBoxState.SelectedValue).Description;

            // hook up cotrol validation
            this.comboBoxState.SelectedValueChanged += new EventHandler(StateChangedEventHandler);

            ValidEntry();
        }
示例#2
0
        public TroopCompositionEditor(TroopComposition troopComposition)
            : base(troopComposition)
        {
            this.Text = "Troop Composition Editor";
            this.individualSelector             = new IndividualSelector(this.persistentObject.Individual);
            this.troopVisitSelector             = new TroopVisitSelector(troopComposition.TroopVisit);
            this.troopCompositionStatusSelector = new TroopCompositionStatusSelector(troopComposition.Status);
            this.timeControl    = new TimeControl(troopComposition.Time);
            this.commentControl = new CommentControl(troopComposition.Comments);

            this.propertyPanel.Controls.Add(individualSelector);
            this.propertyPanel.Controls.Add(troopVisitSelector);
            this.propertyPanel.Controls.Add(troopCompositionStatusSelector);
            this.propertyPanel.Controls.Add(timeControl);
            this.propertyPanel.Controls.Add(commentControl);
        }