Пример #1
0
 public bool deleteRecord(ReadingRecord record)
 {
     if (record.Id.Equals(""))
     {
         return false;
     }
     Debug.WriteLine("delete from readingrecord where Id = " + record.Id);
     SQLiteCommand command = dbConn.CreateCommand("delete from readingrecord where Id = " + record.Id);
     command.ExecuteQuery<ReadingRecord>();
     return true;
 }
Пример #2
0
        public bool deleteRecord(ReadingRecord record)
        {
            if (record.Id.Equals(""))
            {
                return(false);
            }
            Debug.WriteLine("delete from readingrecord where Id = " + record.Id);
            SQLiteCommand command = dbConn.CreateCommand("delete from readingrecord where Id = " + record.Id);

            command.ExecuteQuery <ReadingRecord>();
            return(true);
        }
Пример #3
0
        // 读书记录的数据库操作

        public bool insertRecord(ReadingRecord record)
        {
            if (record.UserId == null || record.ISBN == null || record.Timestamp == null || record.UserId.Equals("") || record.ISBN.Equals("") || record.Timestamp.Equals(""))
            {
                return(false);
            }

            if (dbConn.Insert(record) > 0)
            {
                return(true);
            }

            return(false);
        }
        private string ForecastDays2Finish(List <ReadingRecord> records)
        {
            if (records.Count == 0)
            {
                return("\u221E");
            }

            ReadingRecord record = records.First();

            TimeSpan ts = DateTime.Now - DateTime.Parse(record.Timestamp);

            int days = (ts.Days + 1) * (book.PageNo - book.HaveReadPage) / book.HaveReadPage + 1;

            return(days.ToString());
        }
        private void ConfirmRecord_Click(object sender, RoutedEventArgs e)
        {
            Button t = (Button)sender;

            record = t.DataContext as ReadingRecord;

            int StartPageNo;
            int EndPageNo;

            if (int.TryParse(StartPage.Text, out StartPageNo) && int.TryParse(EndPage.Text, out EndPageNo))
            {
                Debug.WriteLine("[DEBUG]SartPageNo is : " + StartPageNo);
                Debug.WriteLine("[DEBUG]EndPageNo is : " + EndPageNo);
                if (StartPageNo <= EndPageNo && StartPageNo > 0 && EndPageNo <= book.PageNo)
                {
                    record.StartPageNo = StartPageNo;
                    record.EndPageNo   = EndPageNo;

                    record.ISBN      = currentISBN;
                    record.UserId    = phoneAppServeice.State["username"].ToString();
                    record.Timestamp = DateTime.Now.ToString();
                    bookService.insertRecord(record);
                    record = null;
                }
                else if (StartPageNo > EndPageNo)
                {
                    MessageBox.Show("书读反了!请重新输入!");
                }
                else
                {
                    MessageBox.Show("页码的范围有误,请重新输入!");
                }
            }
            else
            {
                MessageBox.Show("请输入有效的页码!");
            }
            StartPage.Text = "";
            EndPage.Text   = "";
            RefreshReadingRecord();
            NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
        }
        private void ConfirmRecord_Click(object sender, RoutedEventArgs e)
        {
            Button t = (Button)sender;
            record = t.DataContext as ReadingRecord;

            int StartPageNo;
            int EndPageNo;
            if (int.TryParse(StartPage.Text, out StartPageNo) && int.TryParse(EndPage.Text, out EndPageNo))
            {
                Debug.WriteLine("[DEBUG]SartPageNo is : " + StartPageNo);
                Debug.WriteLine("[DEBUG]EndPageNo is : " + EndPageNo);
                if (StartPageNo <= EndPageNo && StartPageNo > 0 && EndPageNo <= book.PageNo)
                {
                    record.StartPageNo = StartPageNo;
                    record.EndPageNo = EndPageNo;

                    record.ISBN = currentISBN;
                    record.UserId = phoneAppServeice.State["username"].ToString();
                    record.Timestamp = DateTime.Now.ToString();
                    bookService.insertRecord(record);
                    record = null;
                }
                else if (StartPageNo > EndPageNo)
                {
                    MessageBox.Show("书读反了!请重新输入!");
                }
                else
                {
                    MessageBox.Show("页码的范围有误,请重新输入!");
                }

            }
            else
            {
                MessageBox.Show("请输入有效的页码!");
            }
            StartPage.Text = "";
            EndPage.Text = "";
            RefreshReadingRecord();
            NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
        }
Пример #7
0
        // 读书记录的数据库操作
        public bool insertRecord(ReadingRecord record)
        {
            if (record.UserId == null || record.ISBN == null || record.Timestamp == null || record.UserId.Equals("") || record.ISBN.Equals("") || record.Timestamp.Equals(""))
            {
                return false;
            }

            if (dbConn.Insert(record) > 0)
            {
                return true;
            }

            return false;
        }