Exemplo n.º 1
0
 public UnitAccount()
 {
     ModelInfo = new ModelInfo();
     Inventory = "";
     Card = -1;
     _properties = new List<UnitFeature>();
     Comments = "";
     LastUpdate = DateTime.Now;
 }
Exemplo n.º 2
0
 public UnitAccount(int id, ModelInfo model, string inventory, int card, 
     IList<UnitFeature> properties, string comments, DateTime lastUpdate)
 {
     Id = id;
     ModelInfo = model;
     Inventory = inventory;
     Card = card;
     _properties = (List<UnitFeature>) properties;
     Comments = comments;
     LastUpdate = lastUpdate;
 }
Exemplo n.º 3
0
        private void OkButClick(object sender, RoutedEventArgs e)
        {
            string unitType = UnitType.SelectedItem.ToString();
            string unitMaker = Maker.SelectedValue.ToString();
            string name = Model.Text;

            var type = _types.Find(modelType => modelType.Name == unitType);
            var maker = _makers.Find(modelMaker => modelMaker.Name == unitMaker);
            var param = _modelParamMapper.FindByType(type);
            var accParam = _unitParamMapper.FindByType(type);

            _model = _modelInfoMapper.Find(type, maker, name);
            if (_model.IsNew())
            {
                _model.ModelType = type;
                _model.ModelMaker = maker;
                _model.Name = name;

                for (int i = 0; i < param.Count; i++)
                    _model.AddProperty(param[0], _mainParams[i].Value.Text);

                _modelInfoMapper.Save(_model);
                _model = _modelInfoMapper.Find(type, maker, name); //TODO: Убрать дублирование поиска. Id назначать.
            }

            for (int i = 0; i < accParam.Count; i++)
                _account.AddProperty(accParam[i], _addParams[i].Value.Text);

            _account.ModelInfo = _model;
            _account.Inventory = Inventory.Text;
            _account.Card = Convert.ToInt32(Card.Text);
            _account.Comments = Comments.Document.ToString();

            _accountMapper.Save(_account);
            Close();
        }
Exemplo n.º 4
0
        private void FillExistModelParams(string unitType, string unitMaker, string name)
        {
            var type = _types.Find(modelType => modelType.Name == unitType);
            var maker = _makers.Find(modelMaker => modelMaker.Name == unitMaker);

            if (type != null && maker != null)
            {
                _model = _modelInfoMapper.Find(type, maker, name);

                if (!_model.IsNew())
                {
                    for (int i = 0; i < _model.Features.Count; i++)
                        _mainParams[i].Value.Text = _model.Features[i].Value;
                }
                else
                {
                    foreach (var element in _mainParams)
                        element.Value.Text = "";
                }
            }
        }