示例#1
0
        private void xongButton_Click(object sender, RoutedEventArgs e)
        {
            NguoiDung.NgaySinh = ngaysinhDatePicker.Date.ToString("dd/MM/yyyy");
            RadioButton selectedRadio = gioitinhPanel.Children.OfType <RadioButton>().FirstOrDefault(r => r.IsChecked == true);

            NguoiDung.GioiTinh = selectedRadio.Content.ToString();
            connection.Update(NguoiDung);

            // cap nhat lai file nguoi dung hien tai
            IsolatedStorageFile ISOFile = IsolatedStorageFile.GetUserStoreForApplication();

            if (ISOFile.FileExists("CurrentUser"))
            {
                ISOFile.DeleteFile("CurrentUser");
                using (IsolatedStorageFileStream fileStream = ISOFile.OpenFile("CurrentUser", FileMode.Create))
                {
                    DataContractSerializer serializer = new DataContractSerializer(typeof(NguoiDung));

                    serializer.WriteObject(fileStream, NguoiDung);
                }
            }

            Frame.Navigate(typeof(ThongTinCaNhan), NguoiDung);
            Frame.BackStack.RemoveAt(Frame.BackStackDepth - 1);
            Frame.BackStack.RemoveAt(Frame.BackStackDepth - 1);
        }
        private string GetJournalNumber(int type)
        {
            int         next_number = 0;
            JournalType jType       = (from jt in conn.Table <JournalType>()
                                       where jt.id == type
                                       select jt
                                       ).First <JournalType>();
            string prefix       = jType.prefix;
            bool   NGTableEntry = (from generator in conn.Table <NumberGenerator>()
                                   where generator.prefix == prefix
                                   select generator
                                   ).Any <NumberGenerator>();

            if (NGTableEntry)
            {
                NumberGenerator Gen = (from generator in conn.Table <NumberGenerator>()
                                       where generator.prefix == prefix
                                       select generator
                                       ).First <NumberGenerator>();
                next_number = Gen.value + 1;
                Gen.value  += 1;
                conn.Update(Gen);
            }
            else
            {
                next_number = int.Parse(jType.start_number);
                conn.Insert(new NumberGenerator()
                {
                    prefix = prefix,
                    value  = next_number
                });
            }

            return(prefix + " - " + next_number);
        }
        private async void themmuctieuButton_Click(object sender, RoutedEventArgs e)
        {
            
            if (await checkNumberTextBox() == true)
            {
                // xóa mục tiêu hiện tại
                var mtht = connection.Table<MucTieu>().Where(r => r.TenDangNhap == nguoidung.TenDangNhap && (r.TrangThai == "Đã bắt đầu" || r.TrangThai == "Chưa bắt đầu")).FirstOrDefault();
                if (mtht != null)
                {
                    mtht.TrangThai = "Hủy";
                    connection.Update(mtht);
                }

                // thêm mục tiêu mới vào db
                muctieu.SoCanMuonGiam = socanmuongiam;
                muctieu.SoNgay = thoigian;
                muctieu.TrangThai = "Chưa bắt đầu";
                // 1kg = 7700;
                muctieu.LuongKaloCanTieuHaoMoiNgay = Math.Round(socanmuongiam * 7700.0 / thoigian,2);
                connection.Insert(muctieu);

                MessageDialog msDialog = new MessageDialog("Tạo mục tiêu thành công");
                await msDialog.ShowAsync();
                
                Frame.Navigate(typeof(TrangChu), nguoidung);
            }
        }
示例#4
0
        public int save()
        {
            var path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");

            using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
            {
                var infoTable = conn.GetTableInfo("User");

                if (!infoTable.Any())
                {
                  //  conn.DropTable<User>();
                    conn.CreateTable<User>();

                }
                var info = conn.GetMapping(typeof(User));

                if (this._user.UserID == 0)
                { 
                    //var i = conn.InsertOrReplace(this._user);
                    var i = conn.Insert(this._user);
                    conn.Commit();
                   // this._user.UserID = i;
                    return i;
                }
                else
                {
                    var i = conn.Update(this._user);
                    return i;
                }
                

            }
        }
示例#5
0
        public static bool setValueByKey(string key_, string value_)
        {
            bool res  = false;
            var  conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), FullPathSQLite);

            try
            {
                var row = conn.Query <Settings>("select * from Settings where Key=?", key_).FirstOrDefault();

                if (row != null)
                {
                    row.Value = value_;
                    conn.RunInTransaction(() =>
                    {
                        conn.Update(row);
                    });

                    res = true;
                }
                else
                {
                    Settings row_ = new Settings {
                        Key = key_, Value = value_, DefaultValue = value_
                    };

                    conn.Insert(row_);
                    res = true;
                }
            }
            catch (Exception ex)
            {
                res = false;
            }
            return(res);
        }
示例#6
0
        //hien thi dialog ve nhan xet luon kalo da an
        private async void XongBtn_Click(object sender, RoutedEventArgs e)
        {
            if (kaloSum == 0)
            {
                var ms = new MessageDialog("Bạn nên chọn lượng Kcal nhập vào \nđể thống kê chính xác nhất");
                await ms.ShowAsync();

                return;
            }

            var msKalo = new MessageDialog("Tổng lượng Kcal bạn đã ăn là: " + kaloSum);
            await msKalo.ShowAsync();

            if (muctieu != null && thongkengay != null)
            {
                connection.Execute("DELETE FROM ThucDon WHERE IdThongKeNgay =?", thongkengay.IdThongKeNgay);
                //add cac thuc an da chon vao database
                foreach (var item in monanChonList)
                {
                    connection.Insert(item);
                }

                thongkengay.LuongKaloDuaVao = connection.ExecuteScalar <double>("SELECT SUM(LuongKalo) FROM THUCDON WHERE IdThongKeNgay =?", thongkengay.IdThongKeNgay);
                connection.Update(thongkengay);
            }


            Frame.Navigate(typeof(TrangChu), nguoidung);
        }
示例#7
0
        public int save()
        {
            var path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");

            using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
            {
                var infoTable = conn.GetTableInfo("Eat");

                if (!infoTable.Any())
                {
                    //conn.DropTable<Eat>();
                    conn.CreateTable <Eat>();
                }
                var info = conn.GetMapping(typeof(Eat));

                if (this._eat.EatID == 0)
                {
                    var i = conn.Insert(this._eat);
                    conn.Commit();
                    return(i);
                }
                else
                {
                    var i = conn.Update(this._eat);
                    return(i);
                }
            }
        }
示例#8
0
 private async void AcknowledgeButton_Click(object sender, RoutedEventArgs e)
 {
     if (ProcessTimeTextBox.Text == string.Empty)
     {
         await new MessageDialog("Please provide processing time for this order.").ShowAsync();
     }
     else
     {
         Order order = (from O in conn.Table <Order>()
                        where O.Id == orderId
                        select O).ToList <Order>()[0];
         order.Acknowledged = 1;
         order.ProcessTime  = ProcessTimeTextBox.Text;
         conn.Update(order);
         LoadDetails();
     }
 }
示例#9
0
 //Update existing conatct
 public void UpdateRegular(RegularItem _RegularItem)
 {
     using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH))
     {
         conn.RunInTransaction(() =>
         {
             conn.Update(_RegularItem);
         });
     }
 }
示例#10
0
 public bool UpdateProduct(Products product)
 {
     if (conn.Update(product) > 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#11
0
        private async Task FinishAsync()
        {
            _loggingService.WriteLine($"Editing tags for {Items.Count} items.");

            if (_previousTags == null)
            {
                foreach (var item in Items)
                {
                    foreach (var tag in Tags)
                    {
                        item.Tags.Add(tag);
                    }

                    _database.Update(item);

                    Messenger.Default.Send(new TagsEditedMessage(item));

                    await _offlineTaskService.AddAsync(item.Id, OfflineTask.OfflineTaskAction.EditTags, Tags.ToList());
                }
            }
            else
            {
                _loggingService.WriteLine($"Number of previous tags: {_previousTags.Count()}");

                var newTags     = Tags.Except(_previousTags).ToList();
                var deletedTags = _previousTags.Except(Tags).ToList();

                _loggingService.WriteLine($"Number of new tags: {newTags?.Count}");
                _loggingService.WriteLine($"Number of deleted tags: {deletedTags?.Count}");

                Items.First().Tags.Replace(Tags);
                _database.Update(Items.First());

                Messenger.Default.Send(new TagsEditedMessage(Items.First()));

                await _offlineTaskService.AddAsync(Items.First().Id, OfflineTask.OfflineTaskAction.EditTags, newTags, deletedTags);
            }

            // TODO: Find a workaround so that the ViewModel can navigate back without relying on the UI.
            //_navigationService.GoBack();
        }
示例#12
0
        private void XongBtn_Click(object sender, RoutedEventArgs e)
        {
            kaloRieng = double.Parse(kaloBox.Text);

            tkNgay.LuongKaloNgoaiDuKien = kaloRieng;
            if (muctieu != null && tkNgay != null)
            {
                connection.Update(tkNgay);
                MessageDialog msDialog = new MessageDialog("Thành công");
            }
            Frame.Navigate(typeof(TrangChu), nguoidung);
        }
示例#13
0
        private async void stopBtn_Click(object sender, RoutedEventArgs e)
        {
            tracking = false;
            timeThread.Cancel();
            double tocDo;

            dapXe.ThoiGianTap += timeCount;
            dapXe.QuangDuong  += Distance;
            double kaloTieuHao = 0;

            try
            {
                tocDo = dapXe.QuangDuong / dapXe.ThoiGianTap;
            }
            catch (DivideByZeroException)
            {
                tocDo = 0;
            }
            if (tocDo == 0)
            {
                kaloTieuHao = 0;
            }
            if (tocDo <= 5 && tocDo > 0)
            {
                kaloTieuHao = (115 / 30) * (timeCount / 60.0);
            }
            if (tocDo > 5 && tocDo < 10)
            {
                kaloTieuHao = (330 / 30) * (timeCount / 60.0);
            }
            if (tocDo >= 10)
            {
                kaloTieuHao = (400 / 30) * (timeCount / 60.0);
            }
            kaloTieuHao             = Math.Round(kaloTieuHao, 2);
            dapXe.LuongKaloTieuHao += kaloTieuHao;

            // nếu mục tiêu và thống kê ngày != null mới đưa vào database
            if (muctieu != null && thongkengay != null)
            {
                connection.Update(dapXe);
            }

            var ketQua = new MessageDialog("Thời gian: " + timeBlock.Text + "\nQuãng đường: " + distanceBlock.Text +
                                           "\nLượng kalo tiêu hao: " + kaloTieuHao + "kalo");
            await ketQua.ShowAsync();

            if (Frame.CanGoBack)
            {
                Frame.GoBack();
            }
        }
示例#14
0
        private void EditCategoryButton_Click(object sender, RoutedEventArgs e)
        {
            string categoryName = CategoryComboBox.SelectedValue.ToString();
            string newCategory  = EditCategoryTextBox.Text;

            if (newCategory == string.Empty)
            {
                WarningTextBlock.Text       = "Please provide a category name.";
                WarningTextBlock.Foreground = new SolidColorBrush(Windows.UI.Colors.Red);
            }
            else
            {
                WarningTextBlock.Text = "";

                // Cahecking duplicate value.
                bool same          = false;
                var  queryCategory = conn.Table <Category>();
                foreach (var category in queryCategory)
                {
                    if (category.Name == newCategory && category.Name != categoryName)
                    {
                        same = true;
                        break;
                    }
                }

                // If duplicate value prompt user else enter in database.
                if (!same)
                {
                    var cat = (from c in conn.Table <Category>()
                               where c.Name == categoryName
                               select c).ToList <Category>();

                    var add = conn.Update(new Category()
                    {
                        Id      = cat[0].Id,
                        Name    = newCategory,
                        Deleted = 0
                    });
                    Debug.WriteLine(path);
                    EditCategoryTextBox.Text = string.Empty;

                    WarningTextBlock.Text       = "Category edited successfully.";
                    WarningTextBlock.Foreground = new SolidColorBrush(Windows.UI.Colors.Green);
                }
                else
                {
                    WarningTextBlock.Text       = "This category name is already in used.";
                    WarningTextBlock.Foreground = new SolidColorBrush(Windows.UI.Colors.Red);
                }
            }
        }
        //Update existing conatct
        public void UpdateUniqueExpense(UniqueExpenseItem _Item)
        {
            using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH))
            {
                conn.RunInTransaction(() =>
                {
                    conn.Update(_Item);
                });

                // after insert - update total
                UpdateTotal(conn);
            }
        }
示例#16
0
        private void dungButton_Click(object sender, RoutedEventArgs e)
        {
            if ("Dừng".Equals(dungButton.Content))
            {
                startButton.IsEnabled  = false;
                startButton.Visibility = Visibility.Collapsed;
                gapbungImg.Visibility  = Visibility.Collapsed;
                dungButton.Content     = "Trở Về";
                flag = false;
                bipMedia.Stop();
                tongCalo = Math.Round(tinhTongCalo(count), 2);
                // thống kê
                thongKeText.Visibility = Visibility;

                // update so lần
                tongText.Text       = "Số lần tập: " + count.ToString();
                tongText.Visibility = Visibility;
                // update tong calo
                caloText.Text                    = "Tổng lượng calo: " + tongCalo.ToString();
                caloText.Visibility              = Visibility;
                thongKeTapBung.SoLan            += count;
                thongKeTapBung.LuongKaloTieuHao += tongCalo;
                thongKeNgay.LuongKaloTieuHao    += tongCalo;

                if (muctieu != null && thongKeNgay != null)
                {
                    connection.Update(thongKeTapBung);
                    connection.Update(thongKeNgay);
                }

                count = 0;
                startButton.Content = "Bắt Đầu";
            }
            else if ("Trở Về".Equals(dungButton.Content))
            {
                startButton.IsEnabled = false;
                Frame.Navigate(typeof(DanhSachBaiTap), nguoidung);
            }
        }
示例#17
0
        //Update existing conatct
        public void UpdateDetails(ExpenseItem ObjContact)
        {
            using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH))
            {
                conn.RunInTransaction(() =>
                {
                    conn.Update(ObjContact);
                });

                // update average
                UpdateStatistics(conn);
            }
        }
示例#18
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     nguoidung = TrangChu.nguoidung;
     muctieu   = TrangChu.muctieu;
     if (muctieu != null)
     {
         if (muctieu.ThoiGianBatDau == null || muctieu.TrangThai == "Chưa bắt đầu")
         {
             muctieu.TrangThai      = "Đã bắt đầu";
             muctieu.ThoiGianBatDau = DateTime.Today.ToString("dd/MM/yyyy");
             connection.Update(muctieu);
         }
     }
 }
示例#19
0
 //Update existing conatct
 public void UpdateDetails(Contacts ObjContact)
 {
     using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH))
     {
         var existingconact = conn.Query <Contacts>("select * from Contacts where Id =" + ObjContact.Id).FirstOrDefault();
         if (existingconact != null)
         {
             conn.RunInTransaction(() =>
             {
                 conn.Update(ObjContact);
             });
         }
     }
 }
示例#20
0
 //Update existing Picture
 public void UpdateDetails(Picture ObjPicture)
 {
     using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH))
     {
         var existingPicture = conn.Query <Picture>("select * from Picture where Id =" + ObjPicture.Id).FirstOrDefault();
         if (existingPicture != null)
         {
             conn.RunInTransaction(() =>
             {
                 conn.Update(ObjPicture);
             });
         }
     }
 }
 /// <summary>
 /// Reorders saved cards pivot page cards after delete. 
 /// </summary>
 /// <param name="pack">The pack number where a card was removed</param>
 /// <param name="cardPosition">Position number of the card where card was removed</param>
 public void ReOrderSavedCards(int pack, int cardPosition)
 {
     int newCardPosition = cardPosition;
     using (SQLite.Net.SQLiteConnection db = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.path))
     {
         IEnumerable<SavedCards> reOrderQuery = db.Table<SavedCards>()
         .Where(card => card.PackNumber == pack && card.CardNumber > cardPosition);
         foreach (SavedCards savedCard in reOrderQuery)
         {
             savedCard.CardNumber = newCardPosition;
             db.Update(savedCard);
             newCardPosition++;
         }
     }
 }
示例#22
0
        protected void Save()
        {
            using (SQLite.Net.SQLiteConnection db = new SQLite.Net.SQLiteConnection(m_Initialize.Platform, m_Initialize.DBPath))
            {
                db.CreateTable <TTable>();
                if (0 == db.Table <TTable>().Count())
                {
                    Load();
                }

                var table = db.Table <TTable>().First();
                Save(table);
                db.Update(table);
            }
        }
        public override Task DeactivateAsync(IDictionary <string, object> pageState)
        {
            Settings.Appereance.FontSize      = FontSize;
            Settings.Appereance.FontFamily    = FontFamily;
            Settings.Appereance.ColorScheme   = ColorScheme;
            Settings.Appereance.TextAlignment = TextAlignment;

            pageState.Add(nameof(Item.Model.Id), Item.Model.Id);
            pageState.Add(nameof(ErrorDuringInitialization), ErrorDuringInitialization);
            pageState.Add(nameof(ErrorDescription), ErrorDescription);

            _loggingService.WriteLine("Updating item in database.");
            _database.Update(Item.Model);

            return(Task.FromResult(true));
        }
示例#24
0
        private void UpdateContact(object sender, RoutedEventArgs e)
        {
            string NameValue        = Name.Text;
            string PhoneNumberValue = Phone.Text;
            var    updateContact    = connect.Table <Contact>().Where(x => x.name == NameValue).FirstOrDefault();

            if (updateContact != null)
            {
                updateContact.name        = NameValue;
                updateContact.phonenumber = PhoneNumberValue;
                connect.RunInTransaction(() =>
                {
                    connect.Update(updateContact);
                });
            }
        }
        private void ScenarioDisable(object sender, RoutedEventArgs e)
        {
            if ("Trở về".Equals(ScenarioDisableButton.Content))
            {
                Frame.Navigate(typeof(DanhSachBaiTap));
                return;
            }
            Window.Current.VisibilityChanged -= new WindowVisibilityChangedEventHandler(VisibilityChanged);
            _accelerometer.ReadingChanged    -= new TypedEventHandler <Accelerometer, AccelerometerReadingChangedEventArgs>(ReadingChanged);

            // Restore the default report interval to release resources while the sensor is not in use
            _accelerometer.ReportInterval = 0;
            isPause = true;
            ScenarioEnableButton.IsEnabled = true;



            int    buoc        = counter;
            double kaloTieuHao = 0;

            kaloTieuHao                = buoc * 0.015;
            dungngoi.SoBuoc           += buoc;
            dungngoi.LuongKaloTieuHao += kaloTieuHao;
            dungngoi.ThoiGianTap      += (double)timeCount;

            // nếu chưa có mục tiêu và thống kê ngày thì không đưa vào database
            if (muctieu != null && thongkengay != null)
            {
                connection.Update(dungngoi);
            }

            tabataImg.Visibility            = Visibility.Collapsed;
            huongdanTextBlock.Visibility    = Visibility.Collapsed;
            ScenarioEnableButton.Visibility = Visibility.Collapsed;
            ScenarioPauseButton.Visibility  = Visibility.Collapsed;
            ketquaStackPanel.Visibility     = Visibility.Visible;
            solanthuchienTextBlock.Text     = "Số lần thực hiện: " + Lan.Text;
            thoigiantapTextBlock.Text       = "Thời gian tập: " + timetime.Text;
            luongkcalTextBlock.Text         = "Lượng kcal tiêu hao: " + kaloTieuHao + "kcal";
            ScenarioDisableButton.Content   = "Trở về";
            //var ketQua = new MessageDialog("Số lần thực hiện: " + Lan.Text + "\nThời gian tập là:" + timetime.Text +
            //    "Lần \nLượng kalo tiêu hao: " + kaloTieuHao + "kalo");
            //await ketQua.ShowAsync();
            //if (Frame.CanGoBack) { Frame.GoBack(); }
        }
示例#26
0
        private void ScenarioDisable(object sender, RoutedEventArgs e)
        {
            if ("Trở về".Equals(ScenarioDisableButton.Content))
            {
                Frame.Navigate(typeof(DanhSachBaiTap));
            }
            Window.Current.VisibilityChanged -= new WindowVisibilityChangedEventHandler(VisibilityChanged);
            _accelerometer.ReadingChanged    -= new TypedEventHandler <Accelerometer, AccelerometerReadingChangedEventArgs>(ReadingChanged);

            // Restore the default report interval to release resources while the sensor is not in use
            _accelerometer.ReportInterval = 0;
            isPause = true;
            ScenarioEnableButton.IsEnabled = true;



            int    buoc        = counter;
            double kaloTieuHao = 0;

            kaloTieuHao               = buoc * 0.017;
            nhayday.SoBuoc           += buoc;
            nhayday.LuongKaloTieuHao += kaloTieuHao;
            nhayday.ThoiGianTap      += (double)timeCount;

            // nếu chưa có mục tiêu và thống kê ngày thì không đưa vào database
            if (muctieu != null && thongkengay != null)
            {
                connection.Update(nhayday);
            }

            tabataImg.Visibility            = Visibility.Collapsed;
            ScenarioPauseButton.Visibility  = Visibility.Collapsed;
            ScenarioEnableButton.Visibility = Visibility.Collapsed;
            ScenarioDisableButton.Content   = "Trở về";
            huongdanTextBlock.Visibility    = Visibility.Collapsed;

            ketquaStackPanel.Visibility = Visibility.Visible;
            solanthuchienTextBlock.Text = "Số bước nhảy: " + Lan.Text;
            thoigiantapTextBlock.Text   = "Thời gian tập: " + timetime.Text;
            luongkcalTextBlock.Text     = "Lượng kcal tiêu hao: " + kaloTieuHao + "kcal";
        }
示例#27
0
        private void checkBoxIstenmeyenGunler_Checkeds(object sender, RoutedEventArgs e)
        {
            string a = (listViewNobMudYrd.SelectedItem as SentinelDirectorAssistant).FullName;//(((sender as CheckBox).Content) as TextBlock).Text;
            SentinelDirectorAssistant seçilinöb = SentinelDirectorAssistantManager.AdaGöreBul(a);

            int  x         = Convert.ToInt32((sender as CheckBox).Tag);
            bool ischecked = (sender as CheckBox).IsChecked ?? false;

            seçilinöb.UnwantedDays[x] = ischecked;

            var conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), FileUtils.FullDataPath);

            string FullName = (listViewNobMudYrd.SelectedItem as SentinelDirectorAssistant).FullName;
            var    row      = conn.Query <SentinelDirectorAssistantDataset>("select * from SentinelDirectorAssistantDataset where FullName=?", FullName).FirstOrDefault();

            if (row != null)
            {
                if (x == 0)
                {
                    row.NotMonday = ischecked;
                }
                if (x == 1)
                {
                    row.NotTuesday = ischecked;
                }
                if (x == 2)
                {
                    row.NotWednesday = ischecked;
                }
                if (x == 3)
                {
                    row.NotThursday = ischecked;
                }
                if (x == 4)
                {
                    row.NotFriday = ischecked;
                }
            }
            conn.Update(row);
        }
示例#28
0
        private void stopBtn_Click(object sender, RoutedEventArgs e)
        {
            if ("Trở về".Equals(stopBtn.Content))
            {
                Frame.Navigate(typeof(DanhSachBaiTap));
                return;
            }
            threadImg.Cancel();
            double kaloTieuHao;

            if (Percent == 100)
            {
                kaloTieuHao = 33.7;
            }
            else
            {
                timer.Stop();
                saveTime = Time;
                saveTime++;
                timer.Tick -= OnTimerTick;
                kaloTieuHao = Math.Round((200.0 / (30 * 60)) * saveTime, 2);
            }

            lacVong.ThoiGianTap      += saveTime;
            lacVong.LuongKaloTieuHao += kaloTieuHao;

            // nếu mục tiêu và thống kê ngày != null mới đưa vào database
            if (muctieu != null && thongkengay != null)
            {
                connection.Update(lacVong);
            }

            stopBtn.Content = "Trở về";
            huongdanStackPanel.Visibility = Visibility.Collapsed;
            lacVongImg.Visibility         = Visibility.Collapsed;

            ketquaStackPanel.Visibility = Visibility.Visible;
            thoigiantapTextBlock.Text   = "Thời gian tập: " + TimeStr;
            luongkcalTextBlock.Text     = "Lượng Kcal tiêu hao: " + kaloTieuHao;
        }
示例#29
0
        private async void UpdateData(object data)
        {
            DetailSViewModel ObjContact = ((DetailSViewModel)data);

            using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH))
            {
                var existingconact = conn.Query <ContactList>("select * from ContactList where Id =" + Id).FirstOrDefault();
                if (existingconact != null)
                {
                    existingconact.Name       = Name;
                    existingconact.Number     = Number;
                    existingconact.UpdateDate = DateTime.Now.ToString();
                    conn.RunInTransaction(() =>
                    {
                        conn.Update(existingconact);
                    });
                }
            }

            MessageDialog messageDialog = new MessageDialog("Updated Successes fully");
            await messageDialog.ShowAsync();

            _navigationService.GoBack();
        }
        private async void ScenarioDisable(object sender, RoutedEventArgs e)
        {
            Window.Current.VisibilityChanged -= new WindowVisibilityChangedEventHandler(VisibilityChanged);
            _accelerometer.ReadingChanged    -= new TypedEventHandler <Accelerometer, AccelerometerReadingChangedEventArgs>(ReadingChanged);

            // Restore the default report interval to release resources while the sensor is not in use
            _accelerometer.ReportInterval = 0;
            isPause = true;
            ScenarioEnableButton.IsEnabled = true;



            int    buoc        = counter;
            double kaloTieuHao = 0;

            kaloTieuHao              = buoc * 3;
            chaybo.SoBuoc           += buoc;
            chaybo.QuangDuong       += Math.Round(counter * 54.0 / 10000, 2);
            chaybo.LuongKaloTieuHao += Math.Round(kaloTieuHao, 2);
            chaybo.ThoiGianTap      += (double)timeCount;

            // nếu chưa có mục tiêu và thống kê ngày thì không đưa vào database
            if (muctieu != null && thongkengay != null)
            {
                connection.Update(chaybo);
            }

            var ketQua = new MessageDialog("Số bước: " + Steps.Text + "\nQuãng đường bạn đã đi được là: " + Distance.Text +
                                           "Km \nLượng kalo tiêu hao: " + kaloTieuHao + "kalo");
            await ketQua.ShowAsync();

            if (Frame.CanGoBack)
            {
                Frame.GoBack();
            }
        }
示例#31
0
 public int UpdateUser(Lugars i)
 {
     return(db.Update(i));
 }
示例#32
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            // neu muctieu == null ---> tuc nguoidung chua co muc tieu nao hien tai
            if (muctieu == null)
            {
                // an header dau tien
                calsGiamGrid.Visibility = Visibility.Collapsed;
            }
            else
            {
                string today = DateTime.Today.ToString("dd/MM/yyyy");
                // neu nguoi dung chua bat dau muc tieu hien tai
                if (muctieu.ThoiGianBatDau == null || muctieu.TrangThai == "Chưa bắt đầu")
                {
                    calsGiamGrid.Visibility = Visibility.Collapsed;
                    MessageDialog msDialog = new MessageDialog("Bạn vẫn chưa bắt đầu tập luyện!\n");
                    msDialog.Commands.Add(new UICommand("Ok, đến trang tập luyện"));
                    msDialog.Commands.Add(new UICommand("Để sau"));
                    var result = await msDialog.ShowAsync();

                    if (result.Label.Equals("Để sau"))
                    {
                        return;
                    }
                    else
                    {
                        // dat thoi gian bat dau la ngay hom nay
                        muctieu.ThoiGianBatDau = today;
                        muctieu.TrangThai      = "Đã bắt đầu";
                        connection.Update(muctieu);
                        Frame.Navigate(typeof(DanhSachBaiTap), nguoidung);
                    }
                }

                // kiem tra thoigianketthuc cua muc tieu

                //DateTime ngayketthuc = DateTime.Parse(muctieu.ThoiGianBatDau).AddDays((int)muctieu.SoNgay); <--- nho dung ParseExact de theo chuan dd/MM/yyyy
                DateTime ngayketthuc = DateTime.ParseExact(muctieu.ThoiGianBatDau, "dd/MM/yyyy", new CultureInfo("vi-vn")).AddDays(muctieu.SoNgay);
                // neu da vuot qua so ngay
                if (DateTime.Today > ngayketthuc)
                {
                    muctieu.TrangThai = "Hoàn thành";
                    connection.Update(muctieu);
                    MessageDialog msDialog = new MessageDialog("Chúc mừng, bạn đã tập hết số ngày của mục tiêu đề ra\nHãy xem lại quá trình luyện tập của bạn!");
                    msDialog.Commands.Add(new UICommand("Xem thống kê"));
                    msDialog.Commands.Add(new UICommand("Mục tiêu mới"));
                    var result = await msDialog.ShowAsync();

                    if (result.Label.Equals("Mục tiêu mới"))
                    {
                        // chuyển tới trang mục tiêu mới
                        denTaoMucTieuMoiPage();
                    }
                    else
                    {
                        // chuyển đến trang thống kê
                        Frame.Navigate(typeof(ThongKePage), nguoidung);
                    }
                }
                // neu van con trong thoi han cua muc tieu
                else
                {
                    thongkengay = connection.Table <ThongKeNgay>().Where(r => r.IdMucTieu == muctieu.IdMucTieu && r.Ngay == today).FirstOrDefault();
                    if (thongkengay == null)
                    {
                        thongkengay           = new ThongKeNgay();
                        thongkengay.IdMucTieu = muctieu.IdMucTieu;
                        thongkengay.Ngay      = today;
                        // mặc định = chỉ số bmr
                        thongkengay.LuongKaloDuaVao = muctieu.ChiSoBMR;
                        connection.Insert(thongkengay);
                    }
                }
                // LuongKaloCanGiamHomNay = KaloCanTieuHaoMoiNgay (để giảm cân) - LuongKaloTieuHao (chohoatdongbaitap) - chisobmr (luongkalo chohoatdonghangngay) + tongluongkaloduavao
                if (muctieu != null && thongkengay != null)
                {
                    double calsCanGiam = muctieu.LuongKaloCanTieuHaoMoiNgay;
                    calsCanGiamTextBlock.Text = calsCanGiam.ToString();

                    // luong cals giam tu bai tap
                    double calsGiamBaiTap = thongkengay.LuongKaloTieuHao;
                    calsBaiTapTextBlock.Text = calsGiamBaiTap.ToString();

                    // luong Cals giam tu thuc don
                    double calsGiamThucDon = muctieu.ChiSoBMR - thongkengay.LuongKaloDuaVao - thongkengay.LuongKaloNgoaiDuKien;
                    calsThucDonTextBlock.Text = calsGiamThucDon.ToString();

                    double calsConThieu = calsCanGiam - calsGiamBaiTap - calsGiamThucDon;
                    calsConThieuTextBlock.Text = calsConThieu.ToString();
                }
            }
        }
示例#33
0
 /// <summary>
 /// Used to save a card, when user is browsing generated cards.
 /// </summary>
 /// <param name="overWrite">If we are overwriting existing genererated card then overWrite should be true, else false</param>
 /// <param name="index">Generated card index which we are overwriting</param>
 public void SaveGeneratedCard(bool overWrite, int index)
 {
     using (SQLite.Net.SQLiteConnection db = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.path))
     {
         if (overWrite == false)
         {
             GeneratedCards generatedCards = new GeneratedCards() { VerbWord = currentModel.Verb, AdjectiveWord = currentModel.Adjective, NounWord = currentModel.Noun, Image = currentModel.Image };
             try
             {
                 db.Insert(generatedCards);
             }
             catch (Exception e)
             {
                 Debug.WriteLine(e.Message);
             }
         }
         else
         {
             try
             {
                 GeneratedCards generatedCard = db.Table<GeneratedCards>().Skip(index).First();
                 generatedCard.Image = currentModel.Image;
                 generatedCard.VerbWord = currentModel.Verb;
                 generatedCard.AdjectiveWord = currentModel.Adjective;
                 generatedCard.NounWord = currentModel.Noun;
                 db.Update(generatedCard);
             }
             catch (Exception e)
             {
                 Debug.WriteLine(e.Message);
             }
         }
     }
 }