private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            RemoveRow(this.id.Text);
            MessageBox.Show("Row has been removed successfully");
            AdminPanel admin = Application.Current.Windows.OfType <AdminPanel>().FirstOrDefault();

            //admin.Get_Synonyms.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            admin.wrap.Children.Remove(this);
        }
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     this.Close();
     if (CheckUser(Login.Text, Password.Text.GetHashCode().ToString()))
     {
         AdminPanel admin = new AdminPanel();
         admin.ShowDialog();
     }
     else
     {
         MessageBox.Show("Wrong credentials inserted");
     }
 }
Beispiel #3
0
        private void RemoveRow(string id)
        {
            using (SqlConnection conn = new SqlConnection(Fill.cs))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(@"DELETE FROM Answers WHERE Answer_ID=@id"
                                                , conn);

                cmd.Parameters.AddWithValue("@id", Convert.ToInt32(id));

                SqlDataReader dr    = cmd.ExecuteReader();
                AdminPanel    admin = Application.Current.Windows.OfType <AdminPanel>().FirstOrDefault();
                admin.Get_Answers.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
        }
        private void AddTpc(object sender, RoutedEventArgs e)
        {
            using (SqlConnection conn = new SqlConnection(Fill.cs))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(@"INSERT INTO Topics VALUES ( @topic )"
                                                , conn);

                cmd.Parameters.AddWithValue("@topic", this.topic.Text);

                SqlDataReader dr = cmd.ExecuteReader();
                MessageBox.Show("Successfully added");
                AdminPanel admin = Application.Current.Windows.OfType <AdminPanel>().FirstOrDefault();
                admin.Get_Topics.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
        }
        public void SaveTopic(string id, string topic)
        {
            using (SqlConnection conn = new SqlConnection(Fill.cs))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(@"UPDATE Topics SET Topic = @topic WHERE ID=@id"
                                                , conn);

                cmd.Parameters.AddWithValue("@id", Convert.ToInt32(id));
                cmd.Parameters.AddWithValue("@topic", topic);

                SqlDataReader dr = cmd.ExecuteReader();
                MessageBox.Show("Row has been successfully changed");
                AdminPanel admin = Application.Current.Windows.OfType <AdminPanel>().FirstOrDefault();
                admin.Get_Topics.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
        }
Beispiel #6
0
        public void SaveAns(string id, string ans, string altans)
        {
            using (SqlConnection conn = new SqlConnection(Fill.cs))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(@"UPDATE Answers SET AnswerText = @ans, AlterAnswer1=@altans WHERE Answer_ID=@id"
                                                , conn);

                cmd.Parameters.AddWithValue("@id", Convert.ToInt32(id));
                cmd.Parameters.AddWithValue("@ans", ans);
                cmd.Parameters.AddWithValue("@altans", altans);

                SqlDataReader dr = cmd.ExecuteReader();
                MessageBox.Show("Row has been successfully changed");
                AdminPanel admin = Application.Current.Windows.OfType <AdminPanel>().FirstOrDefault();
                admin.Get_Answers.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
        }
        public void SaveSyns(string id, string word, string syns)
        {
            using (SqlConnection conn = new SqlConnection(Fill.cs))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(@"UPDATE Synonyms SET Word = @word, Synonyms=@syn WHERE Id=@id"
                                                , conn);

                cmd.Parameters.AddWithValue("@id", Convert.ToInt32(id));
                cmd.Parameters.AddWithValue("@word", word);
                cmd.Parameters.AddWithValue("@syn", syns);

                SqlDataReader dr = cmd.ExecuteReader();
                MessageBox.Show("Row has been successfully changed");
                AdminPanel admin = Application.Current.Windows.OfType <AdminPanel>().FirstOrDefault();
                admin.Get_Synonyms.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
        }
        private void AddAns(object sender, RoutedEventArgs e)
        {
            using (SqlConnection conn = new SqlConnection(Fill.cs))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(@"INSERT INTO Questions(QuestionText, Answer_ID, Topic_ID) VALUES ( @quest, @ans_id, @q_id)"
                                                , conn);

                cmd.Parameters.AddWithValue("@quest", this.question.Text);
                cmd.Parameters.AddWithValue("@ans_id", Convert.ToInt32(this.answer_id.Text));
                cmd.Parameters.AddWithValue("@q_id", Convert.ToInt32(this.topic_id.Text));

                SqlDataReader dr = cmd.ExecuteReader();
                MessageBox.Show("Successfully added");
                AdminPanel admin = Application.Current.Windows.OfType <AdminPanel>().FirstOrDefault();
                admin.Get_Questions.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
        }
        public void SaveQuestion(string id, string quest, string answer_id, string topic_id)
        {
            using (SqlConnection conn = new SqlConnection(Fill.cs))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(@"UPDATE Questions SET QuestionText = @quest, Answer_ID=@ans_id, Topic_ID=@t_id WHERE Question_ID=@id"
                                                , conn);

                cmd.Parameters.AddWithValue("@id", Convert.ToInt32(id));
                cmd.Parameters.AddWithValue("@quest", quest);
                cmd.Parameters.AddWithValue("@ans_id", Convert.ToInt32(answer_id));
                cmd.Parameters.AddWithValue("@t_id", Convert.ToInt32(topic_id));

                SqlDataReader dr = cmd.ExecuteReader();
                MessageBox.Show("Row has been successfully changed");
                AdminPanel admin = Application.Current.Windows.OfType <AdminPanel>().FirstOrDefault();
                admin.Get_Questions.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
        }