예제 #1
0
 protected override DataGridViewRow FillRow(Freight entity, DataGridViewRow rowToAdd)
 {
     rowToAdd.Cells.Add(new DataGridViewTextBoxCell { Value = entity.Id });
     rowToAdd.Cells.Add(new DataGridViewTextBoxCell { Value = entity.Name });
     rowToAdd.Cells.Add(new DataGridViewTextBoxCell { Value = entity.SuggestedMoney.ToString("C0") });
     if (!entity.ActiveState) rowToAdd.DefaultCellStyle.BackColor = _inactiveColor;
     return rowToAdd;
 }
예제 #2
0
        public async Task<AddUpdateFreightStatus> UpdateAsync(Freight freight)
        {
            var old = await FindByNameAsync(freight.Name);
            if (old?.Id != freight.Id)
                return AddUpdateFreightStatus.DuplicateName;

            return AddUpdateFreightStatus.Success;
        }
예제 #3
0
        public async Task<AddUpdateFreightStatus> AddAsync(Freight freight)
        {
            if (await IsExistByNameAsync(freight.Name))
                return AddUpdateFreightStatus.DuplicateName;

            _freights.Add(freight);
            return AddUpdateFreightStatus.Success;
        }
예제 #4
0
        protected override void OnSaveButtonClicked()
        {
            var entity = new Freight
            {
                Name = nameBox.Text.Trim(),
                SuggestedMoney = taxNum.Value,
                ActiveState = true
            };
            if (!Validation(entity)) return;

            var old = _repository.FirstOrDefault(x => x.Id == _result.Id);
            if (old == null)
            {
                entity.ActiveState = true;
                _repository.Add(entity);
            }
            else
            {
                old.Name = entity.Name;
                old.SuggestedMoney = entity.SuggestedMoney;
            }
            SaveAndExit();
        }
예제 #5
0
 public void Active(Freight freight)
     => freight.ActiveState = true;
예제 #6
0
 public void Inactive(Freight freight)
     => freight.ActiveState = false;