public static Boolean ExecuteSelectTableTaskMemo(string dbpath, TaskMemoViewModel tmv, string sql, Int64 id) { // return value true: More button visibie Boolean ret = false; SQLiteConnection con = new SQLiteConnection("Data Source=" + dbpath + ";"); con.Open(); SQLiteCommand com = new SQLiteCommand(sql, con); com.Parameters.Add(sqliteParamInt64(com, "@id", id)); try { SQLiteDataReader sdr = com.ExecuteReader(); int resultCount = 0; while (sdr.Read() == true) { resultCount++; if (resultCount <= TaskMemoMoreSize) { ListTaskMemo ltm = new ListTaskMemo(); ltm.Memo = (string)sdr["memo"]; DateTime utc = DateCalc.SQLiteStringToDateTime((string)sdr["date"]); ltm.Date = utc.ToLocalTime().ToString("G", System.Globalization.CultureInfo.CurrentCulture); tmv.Memos.Add(ltm); } else { TaskMemoMoreCount += TaskMemoMoreSize; ret = true; } } sdr.Close(); } catch (Exception ex) { MessageBox.Show("database table select taskmemo error!\n" + ex.Message); } finally { con.Close(); } return(ret); }
// /////////////////////////////////////////////////////////////////////////// // // Memo /// <summary> /// taskmemo in editpanel is selected /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ListTaskMemoSelectionChanged(object sender, SelectionChangedEventArgs e) { ListTaskMemo ltm = ((sender as ListView).SelectedItem as ListTaskMemo); if (ltm != null) { MemoWindow dlg = new MemoWindow(); dlg.memo = ltm.Memo; dlg.date = ltm.Date; dlg.Owner = this; dlg.WindowStartupLocation = WindowStartupLocation.CenterOwner; if (dlg.ShowDialog() == true) { // window is closed } listviewTaskMemo.UnselectAll(); } }