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

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

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

                if (entity.IsSelect)
                {
                    var data = new LocalTransferWillDataEntity();
                    data.Id = entity.Id;
                    _willEntity.Willdatas.Add(data);
                }
            }
            _willEntity.Name = name;
            if (_isNew)
            {
                LocalHelper.WillList.Wills.Add(_willEntity);
            }
            LocalHelper.SaveLocalTransferWill();
            this.DialogResult = true;
            this.Close();
        }