示例#1
0
        public Dictionary(MainWindow mainWindow, Classes.User user)
        {
            this.user       = user;
            this.mainWindow = mainWindow;
            InitializeComponent();

            string connectionString      = DataBase.data;
            string getThemeForDictionary = "GET_THEME_FOR_DICTIONARY";
            string getPodThemes          = "GET_POD_THEMES";

            try
            {
                using (SqlConnection sqlConnection = new SqlConnection(connectionString))
                {
                    sqlConnection.Open();

                    SqlCommand getThemeForDictionaryCommand = new SqlCommand(getThemeForDictionary, sqlConnection);
                    getThemeForDictionaryCommand.CommandType = System.Data.CommandType.StoredProcedure;
                    SqlDataReader reader = getThemeForDictionaryCommand.ExecuteReader();


                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            Classes.ThemesForDictionary themesForDictionary = new Classes.ThemesForDictionary();
                            themesForDictionary.IdTheme = reader.GetValue(0);
                            themesForDictionary.IdAdmin = reader.GetValue(1);
                            themesForDictionary.NameThemeForDictionary = reader.GetValue(2);
                            listThemseForDictionaries.Add(themesForDictionary);
                        }
                    }
                    reader.Close();

                    for (int i = 0; i < listThemseForDictionaries.Count; i++)
                    {
                        switch (i)
                        {
                        case 0:
                            txbThemeDictionary1.Text = listThemseForDictionaries[i].NameThemeForDictionary.ToString();
                            break;

                        case 1:
                            txbThemeDictionary2.Text = listThemseForDictionaries[i].NameThemeForDictionary.ToString();
                            break;

                        case 2:
                            txbThemeDictionary3.Text = listThemseForDictionaries[i].NameThemeForDictionary.ToString();
                            break;

                        case 3:
                            txbThemeDictionary4.Text = listThemseForDictionaries[i].NameThemeForDictionary.ToString();
                            break;
                        }
                    }
                    /////////////////////////////////////////////////////////////////

                    SqlCommand getPodThemesCommand = new SqlCommand(getPodThemes, sqlConnection);
                    getPodThemesCommand.CommandType = System.Data.CommandType.StoredProcedure;
                    SqlDataReader reader2 = getPodThemesCommand.ExecuteReader();


                    if (reader2.HasRows)
                    {
                        while (reader2.Read())
                        {
                            Classes.PodTheme podTheme = new Classes.PodTheme();
                            podTheme.IdTheme = reader2.GetValue(0);
                            podTheme.IdThemeForDictionary = reader2.GetValue(1);
                            podTheme.NameTheme            = reader2.GetValue(2);
                            listPodThemes.Add(podTheme);
                        }
                    }
                    reader2.Close();

                    List <string> listThemesDict1 = new List <string>();
                    List <string> listThemesDict2 = new List <string>();
                    List <string> listThemesDict3 = new List <string>();
                    List <string> listThemesDict4 = new List <string>();
                    for (int i = 0; i < listPodThemes.Count; i++)
                    {
                        if ((int)listPodThemes[i].IdThemeForDictionary == 1)
                        {
                            listThemesDict1.Add(listPodThemes[i].NameTheme.ToString());
                        }
                        if ((int)listPodThemes[i].IdThemeForDictionary == 2)
                        {
                            listThemesDict2.Add(listPodThemes[i].NameTheme.ToString());
                        }
                        if ((int)listPodThemes[i].IdThemeForDictionary == 3)
                        {
                            listThemesDict3.Add(listPodThemes[i].NameTheme.ToString());
                        }
                        if ((int)listPodThemes[i].IdThemeForDictionary == 4)
                        {
                            listThemesDict4.Add(listPodThemes[i].NameTheme.ToString());
                        }
                    }

                    this.listFormThemeDict1.ItemsSource = listThemesDict1;
                    this.listFormThemeDict2.ItemsSource = listThemesDict2;
                    this.listFormThemeDict3.ItemsSource = listThemesDict3;
                    this.listFormThemeDict4.ItemsSource = listThemesDict4;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#2
0
        public TestDictionary(Classes.PodTheme podTheme, Classes.User user)
        {
            this.user     = user;
            this.podTheme = podTheme;
            InitializeComponent();

            ThemeDictionaryId       = (int)podTheme.IdThemeForDictionary;
            btnBeginTest.Visibility = Visibility.Visible;
            txbNameTest.Text        = podTheme.NameTheme.ToString();

            string connectionString = DataBase.data;
            string testDictionary   = "TEST_DICTIONARY";

            try
            {
                using (SqlConnection sqlConnection = new SqlConnection(connectionString))
                {
                    sqlConnection.Open();

                    SqlCommand testDictionaryCommand = new SqlCommand(testDictionary, sqlConnection);
                    testDictionaryCommand.CommandType = System.Data.CommandType.StoredProcedure;
                    SqlParameter themeIdParameter = new SqlParameter
                    {
                        ParameterName = "@theme_id",
                        Value         = podTheme.IdThemeForDictionary
                    };
                    SqlParameter podthemeIdParameter = new SqlParameter
                    {
                        ParameterName = "@podtheme_id",
                        Value         = podTheme.IdTheme
                    };
                    testDictionaryCommand.Parameters.Add(themeIdParameter);
                    testDictionaryCommand.Parameters.Add(podthemeIdParameter);


                    SqlDataReader reader = testDictionaryCommand.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            Classes.Dictionary dictionary = new Classes.Dictionary();
                            dictionary.IdWord      = reader.GetValue(0);
                            dictionary.EnglishWord = reader.GetValue(1);
                            dictionary.RussianWord = reader.GetValue(2);
                            dictionaries.Add(dictionary);
                        }
                    }
                    reader.Close();

                    for (int i = 0; i < dictionaries.Count; i++)
                    {
                        switch (i)
                        {
                        case 0:
                            txbEnglishWord1.Text = dictionaries[i].EnglishWord.ToString();
                            txbRussianWord1.Text = dictionaries[i].RussianWord.ToString();
                            break;

                        case 1:
                            txbEnglishWord2.Text = dictionaries[i].EnglishWord.ToString();
                            txbRussianWord2.Text = dictionaries[i].RussianWord.ToString();
                            break;

                        case 2:
                            txbEnglishWord3.Text = dictionaries[i].EnglishWord.ToString();
                            txbRussianWord3.Text = dictionaries[i].RussianWord.ToString();
                            break;

                        case 3:
                            txbEnglishWord4.Text = dictionaries[i].EnglishWord.ToString();
                            txbRussianWord4.Text = dictionaries[i].RussianWord.ToString();
                            break;

                        case 4:
                            txbEnglishWord5.Text = dictionaries[i].EnglishWord.ToString();
                            txbRussianWord5.Text = dictionaries[i].RussianWord.ToString();
                            break;

                        case 5:
                            txbEnglishWord6.Text = dictionaries[i].EnglishWord.ToString();
                            txbRussianWord6.Text = dictionaries[i].RussianWord.ToString();
                            break;

                        case 6:
                            txbEnglishWord7.Text = dictionaries[i].EnglishWord.ToString();
                            txbRussianWord7.Text = dictionaries[i].RussianWord.ToString();
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }