示例#1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            string name = txtTalent.Text.Trim();

            if (string.IsNullOrEmpty(name))
            {
                MessageBox.Show("请取一个带感的名称!");
                return;
            }
            var check = LocalHelper.TalentList.Talents.Exists(d => d.Name == name && d.Id != _talentEntity.Id);

            if (check)
            {
                MessageBox.Show("该名称已经存在,请换一个.");
                return;
            }
            _talentEntity.Talentdatas.Clear();
            foreach (var item in DataGridTalent.ItemsSource)
            {
                var entity = item as LocalTalentEntity;

                if (entity.IsSelect)
                {
                    var data = new LocalTransferTalentDataEntity();
                    data.Id = entity.Id;
                    _talentEntity.Talentdatas.Add(data);
                }
            }
            _talentEntity.Name = name;
            if (_isNew)
            {
                LocalHelper.TalentList.Talents.Add(_talentEntity);
            }
            LocalHelper.SaveLocalTransferTalent();
            this.DialogResult = true;
            this.Close();
        }