Example #1
0
        private void MenuItemDelPerson_Click(object sender, RoutedEventArgs e)
        {
            var p = VM.SelectedPerson;

            PersonEditWnd wnd = new PersonEditWnd();

            wnd.Owner      = this;
            wnd.Person     = (Person)p.Copy();
            wnd.IsReadOnly = true;
            if (wnd.ShowDialog() ?? false)
            {
                //点击了确认
                VM.PersonList.Remove(p);


                if (DbHelper.PersonBLL.Delete(p.ID))
                {
                    MessageBox.Show("删除成功");
                }
                else
                {
                    MessageBox.Show("删除失败");
                }
            }
            else
            {
                //点击了取消
            }
        }
Example #2
0
        private void MenuItemAddPerson_Click(object sender, RoutedEventArgs e)
        {
            //var list = SQLiteHelper.GetTableBySQL("select * from Persons");

            PersonEditWnd wnd = new PersonEditWnd();

            wnd.Owner = this;
            if (wnd.ShowDialog() ?? false)
            {
                //点击了确认
                var      p  = wnd.Person;
                DBPerson db = ModelConvertHelper.ModelToDB(p);
                DbHelper.PersonBLL.Add(db);
                VM.PersonList.Add(p);
            }
            else
            {
                //点击了取消
            }
        }
Example #3
0
        private void MenuItemEditPerson_Click(object sender, RoutedEventArgs e)
        {
            var p = VM.SelectedPerson;

            PersonEditWnd wnd = new PersonEditWnd();

            wnd.Owner  = this;
            wnd.Person = (Person)p.Copy();
            if (wnd.ShowDialog() ?? false)
            {
                //点击了确认

                int index = VM.PersonList.IndexOf(p);
                VM.PersonList[index] = p = wnd.Person;
                DBPerson db = ModelConvertHelper.ModelToDB(p);
                DbHelper.PersonBLL.Update(db);
            }
            else
            {
                //点击了取消
            }
        }