Example #1
0
        private async void SubmitButton_Click(object sender, RoutedEventArgs e)
        {
            DateTime d     = DateTime.Now;
            string   day   = d.Day < 10 ? "0" + d.Day.ToString() : d.Day.ToString();
            string   month = d.Month < 10 ? "0" + d.Month.ToString() : d.Month.ToString();
            string   year  = d.Year.ToString();
            string   date  = day + "-" + month + "-" + year;

            string hour   = d.Hour < 10 ? "0" + d.Hour.ToString() : d.Hour.ToString();
            string minute = d.Minute < 10 ? "0" + d.Minute.ToString() : d.Minute.ToString();
            string second = d.Second < 10 ? "0" + d.Minute.ToString() : d.Minute.ToString();
            string time   = hour + ":" + minute + ":" + second;

            string orderNo = "Order - " + (rowCount + 1000).ToString();

            if (orderDict.Count > 0)
            {
                // insert in order table
                conn.CreateTable <Order>();
                conn.Insert(new Order()
                {
                    Id           = rowCount,
                    UserId       = Login.userId,
                    OrderDate    = date,
                    OrderTime    = time,
                    TotalAmount  = total,
                    Acknowledged = 0,
                    Deliveried   = 0,
                    ProcessTime  = "",
                    Canceled     = 0,
                    OrderNo      = orderNo
                });

                // insert in order item table
                foreach (var order in orderDict)
                {
                    string[] itemId_Price = order.Key.Split(' ');
                    int      itemId       = Convert.ToInt32(itemId_Price[0]);
                    double   price        = Convert.ToDouble(itemId_Price[1]);
                    int      quantity     = Convert.ToInt32(order.Value);

                    conn.CreateTable <OrderItem>();
                    conn.Insert(new OrderItem()
                    {
                        OrderId  = rowCount,
                        UserId   = Login.userId,
                        Date     = date,
                        Time     = time,
                        ItemId   = itemId,
                        Price    = price,
                        Quantity = quantity,
                        Total    = price * quantity
                    });
                }
                await new MessageDialog("Order is submitted successfully.\nTotal Amount: " + total).ShowAsync();
                SubmittedOrder.showOrderDict = orderDict;
                SubmittedOrder.title         = orderNo;
                this.Frame.Navigate(typeof(SubmittedOrder));
            }
        }
Example #2
0
        ///Add new account methods
        public void AddPWAcc()
        {
            NewPassword.Add(new Passwords
            {
                Account   = accountTextbox.Text,
                Username  = usernameTextbox.Text,
                Password  = passwordTextbox.Text,
                SQ1       = sq1_Textbox.Text,
                SQA1      = sqa1_Textbox.Text,
                SQ2       = sq2_Textbox.Text,
                SQA2      = sqa2_Textbox.Text,
                Code      = codeTextbox.Text,
                Accnumber = accNoTextbox.Text,
            });



            //Add curr text in texboxes to new row in SQL db
            conn.Insert(new Passwords()
            {
                Account   = accountTextbox.Text,
                Username  = usernameTextbox.Text,
                Password  = passwordTextbox.Text,
                SQ1       = sq1_Textbox.Text,
                SQA1      = sqa1_Textbox.Text,
                SQ2       = sq2_Textbox.Text,
                SQA2      = sqa2_Textbox.Text,
                Code      = codeTextbox.Text,
                Accnumber = accNoTextbox.Text
            });
        }
        public int Add(string journalDate, string typeString, string partyString, string referenceString, string note,
                       Dictionary <int, double> accountInfo, double totalDebit, double totalCredit)
        {
            int add = -1;

            if (accountInfo.Count < 2)
            {
                return(-2);
            }
            if (totalDebit != totalCredit)
            {
                return(-3);
            }
            try
            {
                int type = int.Parse(typeString), party_id = int.Parse(partyString),
                    ref_journal_id = int.Parse(referenceString);

                string number = GetJournalNumber(type);
                string json   = JsonConvert.SerializeObject(accountInfo, Formatting.Indented).ToString()
                                .Replace("\r", "").Replace("\n", "").Replace(" ", "");
                Journal journal = new Journal()
                {
                    number         = number,
                    journal_date   = DateTime.Parse(journalDate),
                    amount         = totalDebit,
                    type           = type,
                    party_id       = party_id,
                    ref_journal_id = ref_journal_id,
                    description    = note,
                    account_info   = json.Trim(),
                    deleted        = 0
                };
                conn.Insert(journal);
                add = journal.id;
                if (add > 0)
                {
                    foreach (KeyValuePair <int, double> pair in accountInfo)
                    {
                        conn.Insert(new Ledger()
                        {
                            journal_id     = journal.id,
                            account_id     = pair.Key,
                            amount         = pair.Value,
                            party_id       = party_id,
                            entry_date     = DateTime.Parse(journalDate),
                            description    = note,
                            other_accounts = json
                        });
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
                add = -1;
            }
            return(add);
        }
Example #4
0
 private void button_Click(object sender, RoutedEventArgs e)
 {
     var s = conn.Insert(new Userdata()
     {
         Username     = us,
         Site         = textBox.Text,
         SiteUsername = textBox1.Text,
         Password     = passwordBox.Password
     });
 }
Example #5
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);
                }
            }
        }
        private void enter_Click(object sender, RoutedEventArgs e)
        {
            String t = "";

            if (sexfemale != null)
            {
                t = sexfemale.Content.ToString();
            }
            var s = conn.Insert(new GuestTable()
            {
                Name    = username.Text,
                Age     = userage.Text,
                sex     = t,
                country = usercountry.PlaceholderText.ToString(),
            });

            if (((username.Text != "") && (userage.Text != "")) && (((ComboBoxItem)usercountry.SelectedItem).Content.ToString() != ""))
            {
                Frame.Navigate(typeof(PostPage));
            }
            else
            {
                MyMessageBox("Enter Required Details");
            }
        }
Example #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("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;
                }
                

            }
        }
Example #8
0
        //ADD
        //create SQLite DB connection
        //create variable "addProduct" that holds SQLite insert statement
        //set each instance variable in the Item class with values from each TextBox
        //Call Show_tapped func to asynchronously update page
        //close db conn
        //clear textboxes after adding
        private async void Add_Tapped(object sender, TappedRoutedEventArgs e)
        {
            dbConnection();
            try
            {
                if (!IsDecimal(quantityTextBox) || !IsDecimal(priceTextBox))
                {
                    MessageDialog decimalMsg = new MessageDialog("Quantity + Price must be a number.");
                    await decimalMsg.ShowAsync();
                }
                else
                {
                    var addProduct = conn.Insert(new Product()
                    {
                        productName  = productTextBox.Text,
                        productQTY   = Convert.ToInt32(quantityTextBox.Text),
                        productPrice = Convert.ToDouble(priceTextBox.Text)
                    });
                }
            }
            catch (Exception)
            {
                MessageDialog message = new MessageDialog("Nothing to Add.");
                await message.ShowAsync();
            }

            //ShowAllError_Tapped(sender, e);   for showing all data when using Add_Tapped
            closeDBconnection();
            //clearTextBoxes();
            Show_Tapped(sender, e);
            SetBalance();
        } // End Add_Tapped
Example #9
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);
        }
        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);
            }
        }
Example #11
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            var query = conn.Table <Logindata>();
            var dummy = 0;

            textBlock3.Text = "";
            foreach (var message in query)
            {
                if (textBox.Text == message.Username)
                {
                    dummy           = 1;
                    textBlock3.Text = "Username already taken";
                    break;
                }
            }
            if (dummy == 0)
            {
                textBlock3.Text = "Registered, click on Login";
                var s = conn.Insert(new Logindata()
                {
                    Username = textBox.Text,
                    Password = textBox1.Password
                });
            }
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            ScenarioEnableButton.IsEnabled  = true;
            ScenarioDisableButton.IsEnabled = false;
            ScenarioPauseButton.IsEnabled   = false;

            nguoidung = TrangChu.nguoidung;
            muctieu   = TrangChu.muctieu;
            if (muctieu != null)
            {
                thongkengay = TrangChu.getThongKeNgayHienTai(muctieu);
                chaybo      = connection.Table <ThongKeBaiTap>().Where(r => r.IdThongKeNgay == thongkengay.IdThongKeNgay && r.IdBaiTap == 1).FirstOrDefault();
                if (chaybo == null)
                {
                    chaybo = new ThongKeBaiTap()
                    {
                        IdBaiTap         = 1,
                        IdThongKeNgay    = thongkengay.IdThongKeNgay,
                        QuangDuong       = 0,
                        SoBuoc           = 0,
                        LuongKaloTieuHao = 0,
                        ThoiGianTap      = 0
                    };
                    connection.Insert(chaybo);
                }
            }

            // mục tiêu == null || thống kê ngày == null -> tập nhưng không đưa vào database
            else
            {
                chaybo = new ThongKeBaiTap();
            }
        }
Example #13
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);
        }
Example #14
0
        CreateGameViewModel.CreateGameResult IStorage.Upload(Core.Model.Game game, FileInfo dbFile, FileInfo savedGame)
        {
            CreateGameAtGoogle cgg = new CreateGameAtGoogle();

            GoogleDrive.GoogleStorageResult googleResult = cgg.Execute(m_User, game, dbFile, savedGame);

            m_DB.CreateTable <MasterTableGoogle>();

            MasterTableGoogle googleMasterTable = new MasterTableGoogle();

            googleMasterTable.GameID     = game.ID;
            googleMasterTable.DBFileID   = googleResult.DatabaseFileID;
            googleMasterTable.GameFileID = googleResult.GameFileID;
            m_DB.Insert(googleMasterTable);

            var result = new CreateGameViewModel.CreateGameResult();

            result.GameID      = game.ID;
            result.GameType    = game.GameType;
            result.StorageType = this.Type;
            result.IDList.Add(googleResult.DatabaseFileID);
            result.IDList.Add(googleResult.GameFileID);

            return(result);
        }
Example #15
0
        public int Add(string name, string code, string typeString, string subtypeString,
                       string parentString, string openingBalance, string openingDate, string note)
        {
            int add = -1;

            try
            {
                int     type = int.Parse(typeString), subtype = int.Parse(subtypeString), parent_id = int.Parse(parentString);
                Account account = new Account()
                {
                    name            = name,
                    code            = code,
                    type            = type,
                    subtype         = subtype,
                    parent_id       = parent_id,
                    depth           = 0,
                    entry_date      = DateTime.Parse(openingDate),
                    note            = note,
                    opening_balance = Double.Parse(openingBalance),
                    deleted         = 0
                };
                conn.Insert(account);
                add = account.id;
                if (Double.Parse(openingBalance) > 0.0)
                {
                    int flag = CreateJournal(account.id, openingDate, openingBalance, note);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
                add = -1;
            }
            return(add);
        }
        public int Add(string name, string prefix, string start_number,
                       string debit_account_id_str, string credit_account_id_str)
        {
            int add = -1;

            try
            {
                int debit_account_id  = int.Parse(debit_account_id_str),
                    credit_account_id = int.Parse(credit_account_id_str);
                JournalType type      = new JournalType()
                {
                    name              = name,
                    prefix            = prefix,
                    start_number      = start_number,
                    debit_account_id  = debit_account_id,
                    credit_account_id = credit_account_id,
                    deleted           = 0
                };
                conn.Insert(type);
                add = type.id;
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
                add = -1;
            }
            return(add);
        }
Example #17
0
 private void AddData_Click(object sender, RoutedEventArgs e)
 {
     var customer = conn.Insert(new Customer()
     {
         Name        = textBox.Text,
         PhoneNumber = textBox1.Text
     });
 }
Example #18
0
 private void Add_Click(object sender, RoutedEventArgs e)
 {
     var s = conn.Insert(new Customer()
     {
         Name = textBox.Text,
         Age  = textBox1.Text
     });
 }
Example #19
0
 private void Add_Click(object sender, RoutedEventArgs e)
 {
     var s = conn.Insert(new Contact()
     {
         email = textBox.Text,
         phone = textBox1.Text
     });
 }
 private void Add_OnClick(object sender, RoutedEventArgs e)
 {
     var s = conn.Insert(new ToDoList()
     {
         Title     = Title.Text,
         StartDate = DateTimeOffset.Now,
         //Description = Description.Text
     });
 }
Example #21
0
 public void AddRegister(Registre registre)
 {
     using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
     {
         conn.Insert(new Registre {
             RegistreDate = registre.RegistreDate
         });
     }
 }
Example #22
0
        private void btl1_Click(object sender, RoutedEventArgs e)
        {
            var a = conn.Insert(new logdata()
            {
                Name = TT1.Text, Email = TT3.Text, Password = TT0.Password, Number = TT7.Text
            });

            Frame.Navigate(typeof(MainPage));
        }
Example #23
0
        private void btnExit_Click(object sender, RoutedEventArgs e)
        {
            if (txtBoxNickName.Text.Length < 3 || txtBoxNickName.Text.Length > 8)
            {
                ShowDialog();
            }
            else
            {
                var insert = conn.Insert(new Game()
                {
                    Name   = txtBoxNickName.Text.ToString(),
                    Move   = moves,
                    Result = result
                });

                this.Frame.Navigate(typeof(MainPage));
            }
        }
Example #24
0
 private void AddTaskButton_Click(object sender, RoutedEventArgs e)
 {
     if (TaskNameTextBox.Text.Equals(""))
     {
         PopupNotice popupNotice = new PopupNotice("计划名称不能为空~");
         popupNotice.ShowAPopup();
     }
     else
     {
         List <ToDoTasks> tempList = conn.Query <ToDoTasks>("select * from ToDoTasks where Name = ?", TaskNameTextBox.Text);
         if (tempList.Count != 0)
         {
             if (tempList[0].IsDelete.Equals("1"))
             {
                 conn.Execute("update ToDoTasks set Name = ?, Date = ?, Star = ?, Remark = ?, Done = ?, UpdateTime = ?, IsDelete = ?  where TaskId = ?",
                              TaskNameTextBox.Text, "", "0", "", "0", DateTime.Now.ToString(), "0", tempList[0].TaskId);
                 ToDoTaskViewModel1.ToDoDatas.Add(new ToDoTasks()
                 {
                     TaskId = tempList[0].TaskId, Name = TaskNameTextBox.Text, Date = "", Remark = "", UpdateTime = DateTime.Now.ToString(), StarVisibility = Visibility.Collapsed, DateVisibility = Visibility.Collapsed, RemarkVisibility = Visibility.Collapsed
                 });
             }
             else
             {
                 PopupNotice popupNotice0 = new PopupNotice("请勿重复添加计划");
                 popupNotice0.ShowAPopup();
             }
         }
         else
         {
             string uuid = Guid.NewGuid().ToString();
             conn.Insert(new ToDoTasks()
             {
                 TaskId = uuid, Name = TaskNameTextBox.Text, Date = "", Star = "0", Remark = "", Done = "0", UpdateTime = DateTime.Now.ToString(), IsDelete = "0"
             });
             ToDoTaskViewModel1.ToDoDatas.Add(new ToDoTasks()
             {
                 TaskId = uuid, Name = TaskNameTextBox.Text, Date = "", Remark = "", UpdateTime = DateTime.Now.ToString(), StarVisibility = Visibility.Collapsed, DateVisibility = Visibility.Collapsed, RemarkVisibility = Visibility.Collapsed
             });
         }
         PopupNotice popupNotice = new PopupNotice("添加成功");
         popupNotice.ShowAPopup();
         TaskNameTextBox.Text = "";
     }
 }
Example #25
0
        private async void dangkyButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (tendangnhapTextBox.Text.Trim() == "" || matkhauPasswordBox.Password.Trim() == "")
                {
                    // neu khong nhap tendangnhap, matkhau thi se hien len thong bao
                    var msDialog = new MessageDialog("TÊN ĐĂNG NHẬP và MẬT KHẨU không được để trống");
                    await msDialog.ShowAsync();

                    return;
                }
                // kiem tra ngay sinh (ngay sinh khong duoc la ngay o tuong lai)
                if (ngaysinhDatePicker.Date > DateTime.Today)
                {
                    var msDialog = new MessageDialog("NGÀY SINH không chính xác");
                    await msDialog.ShowAsync();

                    return;
                }

                // kiem tra tendangnhap da co nguoidung su dung chua
                var nguoidungCollection = connection.Table <NguoiDung>();
                foreach (var nd in nguoidungCollection)
                {
                    if (nd.TenDangNhap == tendangnhapTextBox.Text)
                    {
                        var msDialog = new MessageDialog("TÊN ĐĂNG NHẬP đã tồn tại.\nVui lòng chọn tên đăng nhập khác.");
                        await msDialog.ShowAsync();

                        return;
                    }
                }

                //dua nguoidung vao database
                //lay ngaysinh, dua ve dang dd-MM-yyyy
                string ngaysinh = ngaysinhDatePicker.Date.ToString("dd/MM/yyyy");
                //lay gioitinh
                RadioButton selectedRadio = gioitinhPanel.Children.OfType <RadioButton>().FirstOrDefault(r => r.IsChecked == true);
                // tao moi nguoidung
                NguoiDung nguoidung = new NguoiDung(tendangnhapTextBox.Text, matkhauPasswordBox.Password, ngaysinh, selectedRadio.Content.ToString());
                //insert nguoidung
                connection.Insert(nguoidung);

                //hien thi thong bao thanh cong
                var msDialog1 = new MessageDialog("Đăng ký thành công!");
                await msDialog1.ShowAsync();

                //tro ve trang MainPage de dang nhap
                Frame.Navigate(typeof(MainPage));
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #26
0
 // Insert the new contact in the Contacts table.
 public void InsertRegular(RegularItem _RegularItem)
 {
     using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH))
     {
         conn.RunInTransaction(() =>
         {
             conn.Insert(_RegularItem);
         });
     }
 }
Example #27
0
 public async void Button_Click(object sender, RoutedEventArgs e)
 {
     var page = conn.Insert(new BookMark()
     {
         date        = DateResult.Text,
         title       = TitleResult.Text,
         image       = ImageResult.Source.ToString(),
         description = ContentResult.Text,
     });
 }
Example #28
0
 // Insert the new contact in the Contacts table.
 public void Insert(Contacts objContact)
 {
     using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH))
     {
         conn.RunInTransaction(() =>
         {
             conn.Insert(objContact);
         });
     }
 }
Example #29
0
        private void submit_Click(object sender, RoutedEventArgs e)
        {
            double totheight = 0, totneck = 0, totwaist = 0, tothip = 0, totbust = 0, totweight = 0;
            double h1, n1, w1, hi1, b1;

            h1 = double.Parse(feetinput.Text);

            n1 = double.Parse(neckfeetinput.Text);

            w1 = double.Parse(waistfeetinput.Text);

            hi1 = double.Parse(hipfeetinput.Text);

            b1 = double.Parse(bustfeetinput.Text);

            totweight = double.Parse(poundinput.Text);

            if (unit == 0)
            {
                totheight = h1 * 0.3048;
                totneck   = n1 * 0.3048;
                totwaist  = w1 * 0.3048;
                tothip    = hi1 * 0.3048;
                totbust   = b1 * 0.3048;
                totweight = totweight * 0.453592;
            }
            if (unit == 1)
            {
                totheight = h1;
                totneck   = n1;
                totwaist  = w1;
                tothip    = hi1;
                totbust   = b1;
            }



            var s = conn.Insert(new userdata2()
            {
                Name1     = nam,
                Password1 = pass,
                Age1      = ageinput.Text,
                Gender1   = gend,
                Height1   = totheight,
                Weight1   = totweight,
                Activity1 = act,
                Neck1     = totneck,
                Waist1    = totwaist,
                Hip1      = tothip,
                Bust1     = totbust,
            });


            Window.Current.Content = new SignupPage();
        }
Example #30
0
        public void AddButtonExecute()
        {
            WorkerTable currentWorker = new WorkerTable();

            currentWorker.Lastname  = "Worker";
            currentWorker.Firstname = "New";
            Database.Insert(currentWorker);
            var current = Database.Query <WorkerTable>("SELECT * FROM WorkerTable Where id = (SELECT MAX(Id) FROM WorkerTable);");

            WorkerListing.Add(new Worker(currentWorker.Firstname, currentWorker.Lastname, current[0].Id));
        }
    private void Add_Click(object sender, RoutedEventArgs e)
    {
        var s = connection.Insert(new HNT_listView2.Models.Contact
        {
            Name  = name_textBox.Text,
            Phone = phone_textBox.Text,
            Photo = photo_textBox.Text
        });

        Debug.WriteLine("Added");
    }
        public async void SavePack_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                bool isAlreadyInDatabase = false;
                AppBarButton button = new AppBarButton { };
                button = sender as AppBarButton;
                int packnumber = 1;
                packnumber = Convert.ToInt32(button.Label.Substring(13, 1));

                using (SQLite.Net.SQLiteConnection db = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.path))
                {
                    int sizeQuery = db.Table<SavedCards>().Where(packs => packs.PackNumber == packnumber && packs.NounWord == currentModel.Noun &&
                                                                                        packs.Image == currentModel.Image &&
                                                                                        packs.VerbWord == currentModel.Verb &&
                                                                                        packs.AdjectiveWord == currentModel.Adjective).Count();

                    if (sizeQuery > 0)
                    {
                        isAlreadyInDatabase = true;
                    }

                    if (isAlreadyInDatabase == false)
                    {
                        int size = db.Table<SavedCards>().Where(me => me.PackNumber == packnumber).Count();
                        if (size < 12)
                        {
                            try
                            {
                                SavedCards savedcard = new SavedCards() { VerbWord = currentModel.Verb, AdjectiveWord = currentModel.Adjective, NounWord = currentModel.Noun, Image = currentModel.Image, CardNumber = size, PackNumber = packnumber };
                                db.Insert(savedcard);
                            }
                            catch (Exception error)
                            {
                                Debug.WriteLine(error.Message);
                            }
                        }
                        else
                        {
                            var dialog = new MessageDialog("Pack " + packnumber + " has maximum number of cards!");
                            await dialog.ShowAsync();
                        }
                    }
                    else
                    {
                        var dialog = new MessageDialog("This card is already in the database");
                        await dialog.ShowAsync();
                    }
                }
            }
            catch (Exception error)
            {
                Debug.WriteLine(error.Message);
            }
        }
 /// <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);
             }
         }
     }
 }