예제 #1
0
 private bool SaveDiary()
 {
     Current.RowVersion = DateTime.Now;
     if (Current.ID > 0)
     {
         return(DapperExHelper <Diary> .Update(Current));
     }
     else
     {
         return(DapperExHelper <Diary> .Insert(Current) > 0);
     }
 }
예제 #2
0
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            Diary  selectedRow = (Diary)_lvwDiarys.SelectedItem;
            string title       = selectedRow.Title;
            string message     = $"确认要删除该日记 “{title}” 吗?";

            if (MessageBox.Show(message, "删除日记", MessageBoxButton.YesNoCancel, MessageBoxImage.Exclamation) == MessageBoxResult.Yes)
            {
                //selectedRow.IsDeleted = true;
                //DapperExHelper<Diary>.Update(selectedRow);
                if (DapperExHelper <Diary> .Delete(selectedRow))
                {
                    LoadDiarys(new DateTime(_year, _month, _day));
                }
                else
                {
                    MessageBox.Show("删除日记失败!");
                }
            }
        }
예제 #3
0
 public IList <Diary> GetDiaries(string sql)
 {
     return(DapperExHelper <Diary> .Query(sql).ToList());
 }
예제 #4
0
 public Diary GetDiary(int id)
 {
     return(DapperExHelper <Diary> .Get(id));
 }
예제 #5
0
 public IList <Diary> GetDiaries()
 {
     return(DapperExHelper <Diary> .GetAll().ToList());
 }