Пример #1
0
        //private void Back_Click(object sender, RoutedEventArgs e)
        //{
        //    Frame.Navigate(typeof(MainPage));

        //}

        private async void Save_Click(object sender, RoutedEventArgs e)
        {
            if (myPath == null)
            {
                MessageDialog dialog = new MessageDialog("please take a picture", "Warning");
                await dialog.ShowAsync();
            }
            else
            {
                try
                {
                    MyClothes mClothes = new MyClothes()
                    {
                        // the Id will be set by SQlite
                        nameClothes = txtClothesName.Text,
                        typeClothes = ((ComboBoxItem)cmbCathegory.SelectedItem).Content.ToString(),
                        imgPath     = myPath,
                        season      = ((ComboBoxItem)cmbSeason.SelectedItem).Content.ToString(),
                    };
                    Debug.WriteLine("pfff" + mClothes.typeClothes.ToString());
                    // Add row to the User Table
                    SQLiteAsyncConnection conn = new SQLiteAsyncConnection("MYFASHION.db");

                    await conn.InsertAsync(mClothes);

                    MessageDialog dialog = new MessageDialog("Content saved", "My Fashion assistant");
                    await dialog.ShowAsync();
                }
                catch
                {
                    Debug.WriteLine("cannot insert content");
                }
            }
        }
        //private void Back_Click(object sender, RoutedEventArgs e)
        //{
        //    Frame.Navigate(typeof(MainPage));

        //}

        private async void Save_Click(object sender, RoutedEventArgs e)
        {
            if (myPath == null)
            {
                MessageDialog dialog = new MessageDialog("please take a picture", "Warning");
                await dialog.ShowAsync();
            }
            else
            {
                MyClothes mClothes = new MyClothes()
                {
                    // the Id will be set by SQlite
                    nameClothes = txtClothesName.Text,
                    typeClothes = ((ComboBoxItem)cmbCathegory.SelectedItem).Content.ToString(),
                    imgPath     = myPath,
                    season      = ((ComboBoxItem)cmbSeason.SelectedItem).Content.ToString(),
                };
                Debug.WriteLine("pfff" + mClothes.typeClothes.ToString());
                // Add row to the User Table
                //verify if the name exist
                bool trouve  = false;
                var  query   = conn.Table <MyClothes>();
                var  allData = await query.ToListAsync();

                allClothe = allData;
                for (int i = 0; i < allClothe.Count; i++)
                {
                    if (txtClothesName.Text == allClothe[i].nameClothes && ((ComboBoxItem)cmbSeason.SelectedItem).Content.ToString() == allClothe[i].season && ((ComboBoxItem)cmbCathegory.SelectedItem).Content.ToString() == allClothe[i].typeClothes || myPath == allClothe[i].imgPath)
                    {
                        trouve = true;
                    }
                }


                if (trouve == false)
                {
                    await conn.InsertAsync(mClothes);

                    MessageDialog dialog = new MessageDialog("Content saved", "My Fashion assistant");
                    await dialog.ShowAsync();
                }
                else
                {
                    MessageDialog dialog = new MessageDialog("Item already exist \nYou have entred " + txtClothesName.Text + " before\nPlease choose another item", "My Fashion assistant");
                    await dialog.ShowAsync();
                }
            }
        }
        //private void Back_Click(object sender, RoutedEventArgs e)
        //{
        //    Frame.Navigate(typeof(MainPage));

        //}

        private async void Save_Click(object sender, RoutedEventArgs e)
        {
            if (myPath == null)
            {
                MessageDialog dialog = new MessageDialog("please take a picture", "Warning");
                await dialog.ShowAsync();
            }
            else
            {
                
                MyClothes mClothes = new MyClothes()
                {
                    // the Id will be set by SQlite
                    nameClothes = txtClothesName.Text,
                    typeClothes = ((ComboBoxItem)cmbCathegory.SelectedItem).Content.ToString(),
                    imgPath = myPath,
                    season = ((ComboBoxItem)cmbSeason.SelectedItem).Content.ToString(),
                };
                Debug.WriteLine("pfff" + mClothes.typeClothes.ToString());
                // Add row to the User Table
                //verify if the name exist
                bool trouve = false;
                var query = conn.Table<MyClothes>();
                var allData = await query.ToListAsync();
                allClothe = allData;
                for (int i = 0; i < allClothe.Count; i++)
                {
                    if (txtClothesName.Text == allClothe[i].nameClothes && ((ComboBoxItem)cmbSeason.SelectedItem).Content.ToString() == allClothe[i].season && ((ComboBoxItem)cmbCathegory.SelectedItem).Content.ToString()== allClothe[i].typeClothes || myPath == allClothe[i].imgPath)
                    {
                        trouve = true;
                    }
                }
              
                    
              if(trouve == false)
              { 
                await conn.InsertAsync(mClothes);
                
                MessageDialog dialog = new MessageDialog("Content saved", "My Fashion assistant");
                await dialog.ShowAsync();
                    }
              else
              {
                  MessageDialog dialog = new MessageDialog("Item already exist \nYou have entred "+txtClothesName.Text+" before\nPlease choose another item", "My Fashion assistant");
                await dialog.ShowAsync();
              }
                
            }
        }
        //private void Back_Click(object sender, RoutedEventArgs e)
        //{
        //    Frame.Navigate(typeof(MainPage));

        //}

        private async void Save_Click(object sender, RoutedEventArgs e)
        {
            if (myPath == null)
            {
                MessageDialog dialog = new MessageDialog("please take a picture", "Warning");
                await dialog.ShowAsync();
            }
            else
            {
                try
                { 
                MyClothes mClothes = new MyClothes()
                {
                    // the Id will be set by SQlite
                    nameClothes = txtClothesName.Text,
                    typeClothes = ((ComboBoxItem)cmbCathegory.SelectedItem).Content.ToString(),
                    imgPath = myPath,
                    season = ((ComboBoxItem)cmbSeason.SelectedItem).Content.ToString(),
                };
                Debug.WriteLine("pfff" + mClothes.typeClothes.ToString());
                // Add row to the User Table
               SQLiteAsyncConnection conn = new SQLiteAsyncConnection("MYFASHION.db");
              
                await conn.InsertAsync(mClothes);
                
                MessageDialog dialog = new MessageDialog("Content saved", "My Fashion assistant");
                await dialog.ShowAsync();
                    }
                catch
                {
                    Debug.WriteLine("cannot insert content");
                }
            }
        }