Exemplo n.º 1
0
        public void GetNameTest() //получить имя по ид теста
        {
            try
            {
                foreach (var a in Id)
                {
                    SqlConnection conn    = new SqlConnection(SqlConn.ConnectionString.defaultString);
                    SqlCommand    command = new SqlCommand("GetNameTestByIdTest", conn);
                    command.Parameters.AddWithValue("@idT", a.idTest);
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    conn.Open();
                    SqlDataReader result = command.ExecuteReader();

                    while (result.Read())
                    {
                        Models.TestModel name = new Models.TestModel(
                            result["NAME_TEST"].ToString()
                            );

                        NameT.Add(name);
                    }
                    conn.Close();
                }
                list.ItemsSource = NameT;
            }


            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void showUser()
        {
            SqlConnection conn    = new SqlConnection(SqlConn.ConnectionString.defaultString);
            SqlCommand    command = new SqlCommand("ListTestsSelect", conn);

            command.CommandType = System.Data.CommandType.StoredProcedure;
            conn.Open();
            SqlDataReader           result = command.ExecuteReader();
            List <Models.TestModel> Test   = new List <Models.TestModel>();

            while (result.Read())
            {
                Models.TestModel ListTest = new Models.TestModel(
                    result["NAME_TEST"].ToString()
                    );
                Test.Add(ListTest);
            }
            list.ItemsSource = Test;
            ListTest2        = Test;
            conn.Close();
        }
        public void SearchTest() /////////////////////////////////////////////////////////!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        {
            try
            {
                SqlCommand command = new SqlCommand("SearchTestByName", conn);
                //WHERE CONTAINS (Comments, 'FORMSOF(INFLECTIONAL, "foot")'  )   "\""
                //string s = "'FORMSOF(INFLECTIONAL," + name.Text+ ")'";
                command.Parameters.AddWithValue("@name", name.Text);
                command.CommandType = System.Data.CommandType.StoredProcedure;
                conn.Open();
                SqlDataReader result = command.ExecuteReader();
                while (result.Read())
                {
                    Models.TestModel test = new Models.TestModel(
                        result["NAME_TEST"].ToString()
                        );
                    Tests.Add(test);
                }

                if (Tests.Count > 0)
                {
                    list.ItemsSource = Tests;

                    // Tests2 = Tests;
                }
                else
                {
                    MessageBox.Show("Совпадений не найдено");
                }
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }