Example #1
0
        private void buttonEnterGame_Click(object sender, EventArgs e)
        {
            string server = IPBox.Text;

            if (IPBox.Text == null || IPBox.Text == "")
            {
                Dialogue.Show("Enter Server IP", "", "Ok", "Cancel");
            }

            else
            {
                try
                {
                    IPHostEntry host = Dns.GetHostEntry(server);
                    foreach (IPAddress ip in host.AddressList)
                    {
                        if (ip.AddressFamily == AddressFamily.InterNetwork)
                        {
                            Program.serverIP = ip.ToString();
                            timer1.Start();
                        }
                    }
                }//end try

                catch
                {
                    Dialogue.Show("Connection Failed", "", "Ok", "Cancel");
                }
            }
        }
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                SqlDataAdapter sda = new SqlDataAdapter("select fullname AS 'Name' from participant p,classlist cl where p.participant_id=cl.participant_id AND class_id=(select class_id from classrooms where class_name = '" + comboBox1.SelectedItem + "') ", con);
                DataTable      dt  = new DataTable();
                sda.Fill(dt);
                if (dt.Rows.Count == 0)
                {
                    BindingSource bs = new BindingSource();
                    bs.DataSource = dt;
                    bunifuCustomDataGrid1.DataSource = bs;
                    sda.Update(dt);
                    bunifuCustomLabel1.Visible = true;
                }


                else
                {
                    BindingSource bs = new BindingSource();
                    bs.DataSource = dt;
                    bunifuCustomDataGrid1.DataSource = bs;
                    sda.Update(dt);
                    bunifuCustomLabel1.Visible = false;
                }
            }

            catch (Exception ex)
            {
                Dialogue.Show(" ' " + ex.Message.ToString() + "' ", "", "Ok", "Cancel");
            }
        }
Example #3
0
        private void GameParticipant_Load(object sender, EventArgs e)
        {
            try
            {
                SqlDataAdapter Name = new SqlDataAdapter("Select fullname from participant where participant_id='" + Program.par_id + "' ", con);
                DataTable      dt   = new DataTable();
                Name.Fill(dt);
                Pname = dt.Rows[0][0].ToString(); //tg balik ko



                if (GameType == "QB")
                {
                    label2.Text = "Quiz Bee";
                    label3.Text = System.IO.File.ReadAllText(@"QuizBeeRules.txt");
                }

                else if (GameType == "PZ")
                {
                    label2.Text = "Picture Puzzle";
                    label3.Text = System.IO.File.ReadAllText(@"PicturePuzzleRules.txt");
                }
            }

            catch (Exception ex)
            {
                Dialogue.Show(" ' " + ex.Message.ToString() + "' ", "", "Ok", "Cancel");
            }
        }
Example #4
0
        public void Load_Participant()
        {
            try
            {
                SqlDataAdapter sda = new SqlDataAdapter("select fullname AS 'Name' from participant p,classlist cl where p.participant_id=cl.participant_id AND class_id=(select class_id from classrooms where class_name = '" + className + "' AND facilitator_id='" + Program.user_id + "') ", con);
                DataTable      dt  = new DataTable();
                sda.Fill(dt);
                if (dt.Rows.Count == 0)
                {
                    label6.Text = "Of " + className + " ";
                    bunifuCustomLabel1.Visible = true;
                    BindingSource bs = new BindingSource();
                    bs.DataSource = dt;
                    bunifuCustomDataGrid2.DataSource = bs;
                    sda.Update(dt);
                    pictureBox2.Visible = true;
                }
                else
                {
                    label6.Text = "Of " + className + " ";
                    bunifuCustomLabel1.Visible = false;
                    BindingSource bs = new BindingSource();
                    bs.DataSource = dt;
                    bunifuCustomDataGrid2.DataSource = bs;
                    sda.Update(dt);
                    pictureBox2.Visible = true;
                }
            }

            catch (Exception ex)
            {
                Dialogue.Show(" ' " + ex.Message.ToString() + "' ", "", "Ok", "Cancel");
            }
        }
Example #5
0
        private void buttonEnterGame_Click(object sender, EventArgs e)
        {
            SqlDataAdapter sda = new SqlDataAdapter("Select Game_Pin,Mode From Pincode where Mode='GP' ", con);
            DataTable      dt  = new DataTable();

            sda.Fill(dt);
            if (dt.Rows.Count == 0)
            {
                Dialogue.Show("No Host Server Detected for Groups! Please Wait for the Host to Start.", "", "Ok", "Cancel");
            }

            else
            {
                string code = dt.Rows[0][0].ToString();


                if (code == bunifuMetroTextbox1.Text)
                {
                    LobbyParticipant lobby = new LobbyParticipant();
                    lobby.ShowDialog();
                }

                else if (bunifuMetroTextbox1.Text == null || bunifuMetroTextbox1.Text == "")
                {
                    bunifuCustomLabel1.Text = "* Please Enter Code";
                }
                else
                {
                    bunifuCustomLabel1.Text = "* Code is Invalid!";
                }
            }//end else */
        }
Example #6
0
        void Load_Quiz()
        {
            try
            {
                SqlDataAdapter sda  = new SqlDataAdapter("Select quiz_title AS 'Title' ,date_created AS 'Created',game_type from quizzes where facilitator_id= '" + Program.user_id + "' ", con);
                DataTable      data = new DataTable();
                sda.Fill(data);
                if (data.Rows.Count == 0)
                {
                    BindingSource bs = new BindingSource();
                    bs.DataSource = data;
                    bunifuCustomDataGrid1.DataSource = bs;
                    sda.Update(data);
                    bunifuCustomDataGrid1.ClearSelection();
                    bunifuCustomLabel2.Visible = true;
                }

                else
                {
                    BindingSource bs = new BindingSource();
                    bs.DataSource = data;
                    bunifuCustomDataGrid1.DataSource = bs;
                    sda.Update(data);
                    bunifuCustomDataGrid1.ClearSelection();
                    bunifuCustomLabel2.Visible = false;
                }
            }


            catch (Exception ex)
            {
                Dialogue.Show(" ' " + ex.Message.ToString() + "' ", "", "Ok", "Cancel");
            }
        }
Example #7
0
        private void editC_Click(object sender, EventArgs e)
        {
            try
            {
                if (bunifuCustomDataGrid1.SelectedCells.Count > 0)
                {
                    SqlDataAdapter adapt = new SqlDataAdapter("select Class_name from classrooms where class_name= '" + className + "' AND facilitator_id='" + Program.user_id + "' ", con);
                    DataTable      dt    = new DataTable();
                    adapt.Fill(dt);

                    SetValueForText1 = dt.Rows[0][0].ToString();//Getting the Name of The Classroom

                    EditClassroom EC = new EditClassroom();
                    EC.ShowDialog();
                }

                else
                {
                    Dialogue.Show("Nothing Selected", "", "Ok", "Cancel");
                }
            }//try


            catch (Exception ex)
            {
                Dialogue.Show(" ' " + ex.Message.ToString() + "' ", "", "Ok", "Cancel");
            }
        }
        private void bunifuFlatButton4_Click(object sender, EventArgs e)
        {
            try
            {
                if (bunifuCustomDataGrid1.SelectedCells.Count > 0)
                {
                    SqlDataAdapter adapt = new SqlDataAdapter("select group_name from groups where group_name= '" + GroupName + "'", con);
                    DataTable      dt    = new DataTable();
                    adapt.Fill(dt);

                    SetValueForText4 = dt.Rows[0][0].ToString(); //Getting the Name of The group
                    SetValueForText3 = Class;                    //Getting ClassName

                    EditGroup EG = new EditGroup();
                    EG.ShowDialog();
                }

                else
                {
                    Dialogue.Show("Nothing Selected", "", "Ok", "Cancel");
                }
            }//try


            catch (Exception ex)
            {
                Dialogue.Show(" ' " + ex.Message.ToString() + "' ", "", "Ok", "Cancel");
            }
        }
Example #9
0
        }//end if

        private void bunifuFlatButton1_Click(object sender, EventArgs e)
        {
            try
            {
                if (bunifuCustomDataGrid1.SelectedRows.Count > 0)
                {
                    SqlDataAdapter adapt = new SqlDataAdapter("select quiz_id from quizzes where quiz_title= '" + QuizName + "'", con);
                    DataTable      dt    = new DataTable();
                    adapt.Fill(dt);
                    int ID = Convert.ToInt32(dt.Rows[0][0].ToString());    //Getting the ID of The Quiz
                    SetValueForText1 = ID.ToString();
                    if (GameType == "Quiz Bee")
                    {
                        EditQuizBEE EQB = new EditQuizBEE();
                        EQB.ShowDialog();
                    }
                    else if (GameType == "Picture Puzzle")
                    {
                        EditPuzzle EP = new EditPuzzle();
                        EP.ShowDialog();
                    }
                }

                else
                {
                    Dialogue.Show("Nothing Selected", "", "Ok", "Cancel");
                }
            }//try


            catch (Exception ex)
            {
                //  Dialogue.Show(" ' " + ex.Message.ToString() + "'", "", "Ok", "Cancel");
            }
        }
        void Load_Participant()
        {
            try
            {
                SqlDataAdapter sad  = new SqlDataAdapter("Select group_id from groups WHERE group_name = '" + group + "' ", con);
                DataTable      data = new DataTable();
                sad.Fill(data);
                ID = Convert.ToInt32(data.Rows[0][0]);



                SqlDataAdapter sda = new SqlDataAdapter("Select fullname from participant p, grouplist gl WHERE p.participant_id = gl.participant_id AND gl.group_id= '" + ID + "' ", con);
                DataTable      dt  = new DataTable();
                sda.Fill(dt);
                BindingSource bs = new BindingSource();
                bs.DataSource = dt;
                bunifuCustomDataGrid1.DataSource = bs;
                sda.Update(dt);
            }

            catch (Exception ex)
            {
                Dialogue.Show(" ' " + ex.Message.ToString() + "' ", "", "Ok", "Cancel");
            }
        }
Example #11
0
        private void ButtonParticipantSignIn_Click(object sender, EventArgs e)
        {
            SqlDataAdapter sda = new SqlDataAdapter("Select count(*) From participant Where p_username='******' COLLATE SQL_Latin1_General_CP1_CS_AS and p_password= '******' COLLATE SQL_Latin1_General_CP1_CS_AS", con);
            DataTable      dt  = new DataTable();

            sda.Fill(dt);
            if (dt.Rows[0][0].ToString() == "1")
            {
                SqlCommand cmd = new SqlCommand("Select participant_id from participant where p_username='******' COLLATE SQL_Latin1_General_CP1_CS_AS and p_password= '******' COLLATE SQL_Latin1_General_CP1_CS_AS", con);

                con.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    Program.par_id = Convert.ToInt32(dr["participant_id"]);
                }
                dr.Close();
                con.Close();

                Program.PSession_id = TextboxUsername.Text; //For Session
                //  Dialogue.Show("Login Successful!", "", "Ok", "Cancel");
                this.Hide();

                MainMenu2 mm = new MainMenu2();
                mm.Show();
            }
            else
            {
                Dialogue.Show("Login Failed! \r\n Please Check your Username and Password!", "", "Ok", "Cancel");
            }
        }
Example #12
0
        private void deleteP_Click(object sender, EventArgs e)
        {
            if (bunifuCustomDataGrid2.SelectedCells.Count > 0)
            {
                SqlDataAdapter adapt = new SqlDataAdapter("select class_id from classrooms where class_name= '" + className + "' AND facilitator_id='" + Program.user_id + "' ", con);
                DataTable      dt    = new DataTable();
                adapt.Fill(dt);
                int ID = int.Parse(dt.Rows[0][0].ToString());//Getting the ID of The Classroom



                SqlDataAdapter add  = new SqlDataAdapter("select participant_id from participant where fullname= '" + participantName + "'", con);
                DataTable      data = new DataTable();
                add.Fill(data);
                int id = int.Parse(data.Rows[0][0].ToString());//Getting the ID of The Participant



                DialogResult result = Dialogue1.Show("Are You Sure?", "", "Ok", "Cancel");
                if (result == DialogResult.Yes)
                {
                    con.Open();


                    String query = "DELETE FROM classlist WHERE class_id= '" + ID + "' AND facilitator_id = '" + Program.user_id + "' AND participant_id= '" + id + "' ";

                    SqlDataAdapter sda = new SqlDataAdapter(query, con);

                    int m = sda.SelectCommand.ExecuteNonQuery();
                    con.Close();
                    if (m > 0)
                    {
                        Load_Class();
                        Load_Participant();
                        bunifuCustomDataGrid1.ClearSelection();
                        bunifuCustomDataGrid2.ClearSelection();

                        Dialogue.Show("Successfully Deleted!", "", "Ok", "Cancel");
                    }


                    else
                    {
                        Dialogue.Show("Fail to Delete!", "", "Ok", "Cancel");
                        Load_Class();
                        Load_Participant();
                        bunifuCustomDataGrid1.ClearSelection();
                        bunifuCustomDataGrid2.ClearSelection();
                    }
                }//end if result
            }

            else
            {
                Dialogue.Show("Nothing Selected", "", "Ok", "Cancel");
            }
        }
Example #13
0
        private void bunifuFlatButton3_Click(object sender, EventArgs e)
        {
            try
            {
                if (bunifuCustomDataGrid1.SelectedRows.Count > 0)
                {
                    SqlDataAdapter sed = new SqlDataAdapter("select class_id from classrooms where class_name= '" + Class + "' ", con);
                    DataTable      det = new DataTable();
                    sed.Fill(det);
                    int id = Convert.ToInt32(det.Rows[0][0]);



                    DialogResult result = Dialogue1.Show("Are You Sure?", "", "Ok", "Cancel");
                    if (result == DialogResult.Yes)
                    {
                        con.Open();

                        String         q = "DELETE FROM grouplist WHERE group_id IN (select group_id from groups where group_name= '" + GroupName + "')";
                        SqlDataAdapter s = new SqlDataAdapter(q, con);
                        int            n = s.SelectCommand.ExecuteNonQuery();


                        String         query = "DELETE FROM groups WHERE group_name= '" + GroupName + "' AND class_id= '" + id + "' ";
                        SqlDataAdapter sda   = new SqlDataAdapter(query, con);
                        int            m     = sda.SelectCommand.ExecuteNonQuery();
                        con.Close();
                        if (m > 0)
                        {
                            Load_Group();
                            bunifuCustomDataGrid1.ClearSelection();

                            Dialogue.Show("Successfully Deleted!", "", "Ok", "Cancel");
                        }

                        else
                        {
                            Load_Group();
                            Dialogue.Show("Fail to Delete!", "", "Ok", "Cancel");
                            bunifuCustomDataGrid1.ClearSelection();
                        }
                    }//end if result
                }

                else
                {
                    Dialogue.Show("Nothing Selected", "", "Ok", "Cancel");
                }
            }//try


            catch (Exception ex)
            {
                Dialogue.Show(" ' " + ex.Message.ToString() + "' ", "", "Ok", "Cancel");
            }
        }
        private void bunifuThinButton21_Click(object sender, EventArgs e)
        {
            SqlDataAdapter adapter = new SqlDataAdapter("select count(class_id) from classrooms where class_name= '" + ClassNameBox.Text + "' ", con);
            DataTable      dat     = new DataTable();

            adapter.Fill(dat);
            int Count = int.Parse(dat.Rows[0][0].ToString());

            if (string.IsNullOrWhiteSpace(ClassNameBox.Text) && ClassNameBox.Text.Length > 0 || ClassNameBox.Text == "")
            {
                Dialogue.Show("Invalid Input or Empty", "", "Ok", "Cancel");
            }//If End

            else if (Count != 0)
            {
                Dialogue.Show("Classroom Already Exist! Please use Other Name", "", "Ok", "Cancel");
            }


            else
            {
                DialogResult result = Dialogue1.Show("Are You Sure?", "", "Ok", "Cancel");
                if (result == DialogResult.Yes)
                {
                    SqlDataAdapter adapt = new SqlDataAdapter("select class_id from classrooms where class_name= '" + Cname + "'", con);
                    DataTable      dt    = new DataTable();
                    adapt.Fill(dt);
                    int ID = int.Parse(dt.Rows[0][0].ToString());//Getting the ID of The Classroom


                    con.Open();
                    String         query = "UPDATE classrooms SET class_name= '" + ClassNameBox.Text + " '  WHERE facilitator_id= '" + Program.user_id + "' AND class_id= '" + ID + "' ";
                    SqlDataAdapter sda   = new SqlDataAdapter(query, con);
                    int            n     = sda.SelectCommand.ExecuteNonQuery();

                    con.Close();


                    CreateMyClassroom CC = (CreateMyClassroom)Application.OpenForms["CreateMyClassroom"];


                    CC.Load_Class();
                    CC.Load_Participant();



                    this.Close();
                }

                else
                {
                    Dialogue.Show("Fail to Update", "", "Ok", "Cancel");
                }
            }
        }
        private void ButtonFacilitatorCreateAccount_Click(object sender, EventArgs e)
        {
            if (FName.Text == "" || Mname.Text == "" || Lname.Text == "")
            {
                Dialogue.Show("Fill All Fields!", "", "Ok", "Cancel");
            }

            else
            {
                /////Password

                char[] letters      = "q1we2rty3uio4pas5dfgh6jklz7x8cv9bnm0".ToCharArray();
                Random r            = new Random();
                string randomString = "";
                for (int i = 0; i < 9; i++) //i < # depends how long the password
                {
                    randomString += letters[r.Next(0, 34)].ToString();
                }
                // MessageBox.Show(randomString);



                /////Username

                string fName = FName.Text;
                string mName = Mname.Text;
                string lName = Lname.Text;

                string usernameFormat = String.Format("{0}_" + "{1}" + "{2}", lName.ToLower(), fName.Substring(0, 3), mName.Substring(0, 1));

                // MessageBox.Show(usernameFormat);



                con.Open();

                SqlCommand cmd = new SqlCommand("Insert into participant(fullname,p_username,p_password,F_name,M_name,L_name) Values('" + fName + " " + mName + " " + lName + "','" + usernameFormat + "','" + randomString + "','" + fName + "','" + mName + "','" + lName + "')", con);
                int        n   = cmd.ExecuteNonQuery();
                con.Close();


                if (n > 0)
                {
                    Dialogue.Show("Successfully Created", "", "Ok", "Cancel");
                    FName.Text = null;
                    Mname.Text = null;
                    Lname.Text = null;
                }

                else
                {
                    Dialogue.Show("Failed! Please Retry", "", "Ok", "Cancel");
                }
            }
        }
Example #16
0
        private void createC_Click(object sender, EventArgs e)
        {
            SqlDataAdapter adapt = new SqlDataAdapter("select count(class_id) from classrooms where class_name= '" + textBoxCreateClassroom.Text + "' AND facilitator_id= '" + Program.user_id + "' ", con);
            DataTable      dt    = new DataTable();

            adapt.Fill(dt);
            int ID = int.Parse(dt.Rows[0][0].ToString());//Counting The Instances of Same Classroom


            //if (textBoxCreateClassroom.Text == " ")
            if (string.IsNullOrWhiteSpace(textBoxCreateClassroom.Text) && textBoxCreateClassroom.Text.Length > 0 || textBoxCreateClassroom.Text == "")
            {
                Dialogue.Show("Invalid Input or Empty", "", "Ok", "Cancel");
            }


            else if (ID != 0)
            {
                Dialogue.Show("Classroom Already Exist!", "", "Ok", "Cancel");
            }


            else
            {
                Random random       = new Random();
                int    randomNumber = random.Next(101010, 999999);
                string code         = Convert.ToString(randomNumber);



                con.Open();
                String         query = "INSERT INTO classrooms (class_name,facilitator_id,class_code) VALUES ('" + textBoxCreateClassroom.Text + "','" + Program.user_id + "','" + code + "')";
                SqlDataAdapter sda   = new SqlDataAdapter(query, con);
                int            n     = sda.SelectCommand.ExecuteNonQuery();

                con.Close();
                if (n > 0)
                {
                    Dialogue.Show("Classroom Created!", "", "Ok", "Cancel");
                }
                else
                {
                    Dialogue.Show("Creation Failed!", "", "Ok", "Cancel");
                }
                className = " ";
                Load_Class();
                bunifuCustomDataGrid1.ClearSelection();

                textBoxCreateClassroom.Text = " ";

                // Load_Participant();
                bunifuCustomDataGrid2.ClearSelection();
            }
        }
        private void updatescore(string name, string points)
        {
            if (participant == "PUBLIC")
            {
                int counter = 0;
                for (int i = 0; i < EmptyData.Rows.Count; i++)
                {
                    if (EmptyData.Rows[i][0].ToString() == name.ToString())
                    {
                        this.Invoke((MethodInvoker)(() => EmptyData.Rows[i][1] = points.ToString()));
                        this.Invoke((MethodInvoker)(() => leaderboardFREE()));
                        this.Invoke((MethodInvoker)(() => bunifuCustomDataGrid1.Update()));
                        this.Invoke((MethodInvoker)(() => bunifuCustomDataGrid1.Refresh()));
                        counter++;
                    }
                }

                if (counter == 0)
                {
                    DataRow DR = EmptyData.NewRow();
                    this.Invoke((MethodInvoker)(() => DR[0] = name.ToString()));
                    this.Invoke((MethodInvoker)(() => DR[1] = points.ToString()));
                    this.Invoke((MethodInvoker)(() => EmptyData.Rows.Add(DR)));

                    this.Invoke((MethodInvoker)(() => leaderboardFREE()));
                    this.Invoke((MethodInvoker)(() => bunifuCustomDataGrid1.Update()));
                    this.Invoke((MethodInvoker)(() => bunifuCustomDataGrid1.Refresh()));
                }
            }

            else
            {
                for (int i = 0; i < data.Rows.Count; i++)
                {
                    try
                    {
                        if (data.Rows[i][0].ToString() == name.ToString())
                        {
                            this.Invoke((MethodInvoker)(() => data.Rows[i][1] = points.ToString()));
                            this.Invoke((MethodInvoker)(() => leaderboard()));
                            this.Invoke((MethodInvoker)(() => bunifuCustomDataGrid1.Update()));
                            this.Invoke((MethodInvoker)(() => bunifuCustomDataGrid1.Refresh()));
                        }
                    }



                    catch (Exception ex)
                    {
                        Dialogue.Show(" ' " + ex.Message.ToString() + "' ", "", "Ok", "Cancel");
                    }
                }
            }
        }
Example #18
0
 private void btn_print_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedItem == null)
     {
         Dialogue.Show("Please Select Class First", "", "Ok", "Cancel");
     }
     else
     {
         exporttopdf(bunifuCustomDataGrid1, comboBox1.SelectedItem.ToString());
     }
 }
Example #19
0
        private void create_Click(object sender, EventArgs e)
        {
            SqlDataAdapter sda = new SqlDataAdapter("Select count(*) From quizzes Where quiz_title ='" + textBoxQuizTitle.Text + "' ", con);
            DataTable      dt  = new DataTable();

            sda.Fill(dt);
            int check = Convert.ToInt32(dt.Rows[0][0].ToString());



            if (splitPicture.ImageLocation == null || textBoxQuizTitle.Text == "" || string.IsNullOrWhiteSpace(textBoxQuizTitle.Text) && textBoxQuizTitle.Text.Length > 0 || textBox1.Text == "" || string.IsNullOrWhiteSpace(textBox1.Text) && textBox1.Text.Length > 0)
            {
                Dialogue.Show("Please Fill All Fields", "", "Ok", "Cancel");
            }

            else if (check >= 1)
            {
                Dialogue.Show("Quiz already exist, please use other Title", "", "Ok", "Cancel");
            }


            else
            {
                SetValueForText3 = splitPicture.ImageLocation;
                SetValueForText2 = textBoxQuizTitle.Text;
                SetValueForText4 = textBox1.Text;

                if (textBoxQuizTimeLimit.Text == "" || string.IsNullOrWhiteSpace(textBoxQuizTimeLimit.Text) && textBoxQuizTimeLimit.Text.Length > 0)
                {
                    time = "";
                }
                else
                {
                    if (bunifuDropdown1.selectedIndex == 0)//Minutes
                    {
                        time = textBoxQuizTimeLimit.Text + "(Minutes)";
                    }

                    else
                    {
                        time = textBoxQuizTimeLimit.Text + "(Seconds)";
                    }
                }

                SetWidth  = splitPicture.Image.Width;
                SetHeight = splitPicture.Image.Height;


                this.Hide();
                PicturePuzzle pz = new PicturePuzzle();
                pz.ShowDialog();
            }
        }
Example #20
0
        private void DeleteQuiz_Click(object sender, EventArgs e)
        {
            try
            {
                if (bunifuCustomDataGrid1.SelectedRows.Count > 0)
                {
                    SqlDataAdapter adapt = new SqlDataAdapter("select quiz_id from quizzes where quiz_title= '" + QuizName + "'", con);
                    DataTable      dt    = new DataTable();
                    adapt.Fill(dt);
                    int ID = int.Parse(dt.Rows[0][0].ToString());//Getting the ID of The Quiz


                    DialogResult result = Dialogue1.Show("Are You Sure?", "", "Ok", "Cancel");
                    if (result == DialogResult.Yes)
                    {
                        con.Open();

                        String         qer   = "DELETE FROM QuestionAnswers WHERE quiz_id= '" + ID + "' ";
                        String         query = "DELETE FROM quizzes WHERE quiz_id= '" + ID + "' AND facilitator_id = '" + Program.user_id + "' ";
                        SqlDataAdapter sad   = new SqlDataAdapter(qer, con);
                        SqlDataAdapter sda   = new SqlDataAdapter(query, con);
                        int            n     = sad.SelectCommand.ExecuteNonQuery();
                        int            m     = sda.SelectCommand.ExecuteNonQuery();
                        con.Close();
                        if (n >= 0 && m > 0)
                        {
                            Load_Quiz();
                            bunifuCustomDataGrid1.ClearSelection();
                            search.Text = "";
                            Dialogue.Show("Successfully Deleted!", "", "Ok", "Cancel");
                        }

                        else
                        {
                            Dialogue.Show("Fail to Delete!", "", "Ok", "Cancel");

                            bunifuCustomDataGrid1.ClearSelection();
                        }
                    }//end if result
                }

                else
                {
                    Dialogue.Show("Nothing Selected", "", "Ok", "Cancel");
                }
            }//try


            catch (Exception ex)
            {
                //  Dialogue.Show(" ' " + ex.Message.ToString() + "' ", "", "Ok", "Cancel");
            }
        }
Example #21
0
        private void bunifuFlatButton1_Click(object sender, EventArgs e)
        {
            if (comboBox1.SelectedItem == null)
            {
                Dialogue.Show("Classroom Not Specified", "", "Ok", "Cancel");
            }

            else
            {
                SetValueForText1 = Class;
                AddGroup AG = new AddGroup();
                AG.ShowDialog();
            }
        }
Example #22
0
        private void MyAccountEdit_Click(object sender, EventArgs e)
        {
            switch (MyAccountEdit.Text)
            {
            case "Edit":
            {
                fullname.Enabled    = true;
                username.Enabled    = true;
                password.Enabled    = true;
                MyAccountEdit.Text  = "Save";
                password.isPassword = false;
            }
            break;

            case "Save":
            {
                if (fullname.Text != "" && username.Text != "" && password.Text != "")
                {
                    DialogResult result = Dialogue1.Show("Are you sure ?", "", "Ok", "Cancel");
                    if (result == DialogResult.Yes)
                    {
                        fullname.Enabled   = false;
                        username.Enabled   = false;
                        password.Enabled   = false;
                        MyAccountEdit.Text = "Edit";



                        con.Open();
                        String         query = "UPDATE participant SET fullname= '" + fullname.Text + "', p_username='******', p_password = '******' WHERE participant_id= '" + Program.par_id + "' ";
                        SqlDataAdapter sda   = new SqlDataAdapter(query, con);
                        int            n     = sda.SelectCommand.ExecuteNonQuery();

                        con.Close();

                        password.isPassword = true;

                        load_account();
                    }
                }

                else
                {
                    Dialogue.Show("Please Fill all Fields!", "", "Ok", "Cancel");
                }
            }
            break;
            }
        }
Example #23
0
        private void bunifuFlatButton1_Click(object sender, EventArgs e)
        {
            if (bunifuMetroTextbox1.Text == null || bunifuMetroTextbox1.Text == "")
            {
                Dialogue.Show("Please Provide a Screen Name", "", "Ok", "Cancel");
            }

            else
            {
                NameFREE = bunifuMetroTextbox1.Text;
                this.Hide();
                LobbyParticipant con = new LobbyParticipant();
                con.Show();
            }
        }
Example #24
0
        private void bunifuFlatButton2_Click(object sender, EventArgs e)
        {
            if (bunifuCustomDataGrid1.SelectedRows.Count > 0)
            {
                SetValueForText2 = GroupName;
                SetValueForText3 = Class;

                ViewGroupParticipant VGP = new ViewGroupParticipant();
                VGP.ShowDialog();
            }

            else
            {
                Dialogue.Show("Nothing Selected", "", "Ok", "Cancel");
            }
        }
Example #25
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                SqlDataAdapter sda = new SqlDataAdapter("select p_username AS 'Username',p_password AS 'Password',fullname AS 'Name' from participant p,classlist cl where p.participant_id=cl.participant_id AND class_id=(select class_id from classrooms where class_name = '" + comboBox1.SelectedItem + "' AND facilitator_id='" + Program.user_id + "') ", con);
                DataTable      dt  = new DataTable();
                sda.Fill(dt);


                SqlDataAdapter sad  = new SqlDataAdapter("Select class_code from classrooms where class_name = '" + comboBox1.SelectedItem + "' ", con);
                DataTable      data = new DataTable();
                sad.Fill(data);

                string code = data.Rows[0][0].ToString();

                label5.Text    = code;
                label4.Visible = true;

                if (dt.Rows.Count == 0)
                {
                    BindingSource bs = new BindingSource();
                    bs.DataSource = dt;
                    bunifuCustomDataGrid1.DataSource = bs;
                    sda.Update(dt);
                    bunifuCustomLabel2.Visible = true;
                }


                else
                {
                    BindingSource bs = new BindingSource();
                    bs.DataSource = dt;
                    bunifuCustomDataGrid1.DataSource = bs;
                    sda.Update(dt);
                    bunifuCustomLabel2.Visible = false;

                    bunifuCustomDataGrid1.ClearSelection();
                }
            }

            catch (Exception ex)
            {
                Dialogue.Show(" ' " + ex.Message.ToString() + "' ", "", "Ok", "Cancel");
            }
        }
        void Load_List()
        {
            try
            {
                SqlDataAdapter sad  = new SqlDataAdapter("select class_id from classrooms where class_name = '" + Class + "' ", con);
                DataTable      data = new DataTable();
                sad.Fill(data);

                int ClassID = Convert.ToInt32(data.Rows[0][0]);

                SqlDataAdapter s  = new SqlDataAdapter("Select count(l_name) from participant p left join classlist cl on p.participant_id = cl.participant_id where cl.class_id = '" + ClassID + "' ", con);
                DataTable      dt = new DataTable();
                s.Fill(dt);

                if (dt.Rows[0][0].ToString() == "0")
                {
                    bunifuFlatButton1.Visible = false;
                    bunifuFlatButton2.Visible = false;
                    Dialogue.Show("No Classroom Participant Found", "", "Ok", "Cancel");
                }

                else
                {
                    SqlCommand cmd = new SqlCommand("Select DISTINCT l_name from participant p left join classlist cl on p.participant_id =cl.participant_id where cl.class_id = '" + ClassID + "' ", con);

                    con.Open();
                    SqlDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        comboBox1.Items.Add(dr["l_name"]);
                    }
                    dr.Close();
                    con.Close();

                    grouptext.Text = group;
                    classtext.Text = Class;
                }
            }


            catch (Exception ex)
            {
                Dialogue.Show(" ' " + ex.Message.ToString() + "' ", "", "Ok", "Cancel");
            }
        }
        private void bunifuFlatButton2_Click(object sender, EventArgs e)
        {
            try
            {
                if (bunifuCustomDataGrid1.SelectedRows.Count > 0)
                {
                    DialogResult result = Dialogue1.Show("Are You Sure?", "", "Ok", "Cancel");
                    if (result == DialogResult.Yes)
                    {
                        con.Open();

                        String         q = "DELETE FROM grouplist WHERE participant_id=(select participant_id from participant where fullname= '" + ParticipantName + "')";
                        SqlDataAdapter s = new SqlDataAdapter(q, con);
                        int            n = s.SelectCommand.ExecuteNonQuery();


                        con.Close();
                        if (n > 0)
                        {
                            Load_Participant();
                            bunifuCustomDataGrid1.ClearSelection();

                            Dialogue.Show("Successfully Deleted!", "", "Ok", "Cancel");
                        }

                        else
                        {
                            Dialogue.Show("Fail to Delete!", "", "Ok", "Cancel");
                            bunifuCustomDataGrid1.ClearSelection();
                        }
                    }//end if result
                }

                else
                {
                    Dialogue.Show("Nothing Selected", "", "Ok", "Cancel");
                }
            }//try


            catch (Exception ex)
            {
                Dialogue.Show(" ' " + ex.Message.ToString() + "' ", "", "Ok", "Cancel");
            }
        }
Example #28
0
        private void bunifuFlatButton1_Click(object sender, EventArgs e)
        {
            if (comboBox1.SelectedItem != null)
            {
                SqlDataAdapter cd = new SqlDataAdapter("SELECT class_id FROM classrooms where class_name='" + comboBox1.SelectedItem.ToString() + "' ", con);
                DataTable      dt = new DataTable();
                cd.Fill(dt);
                ID = dt.Rows[0][0].ToString();

                this.Hide();
                GameSettings LF = new GameSettings();
                LF.Show();
            }
            else
            {
                Dialogue.Show("Select Class First.", "", "Ok", "Cancel");
            }
        }
Example #29
0
        private void TextboxUsername_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                try
                {
                    SqlDataAdapter sda = new SqlDataAdapter("Select count(*) From facilitator Where username='******' COLLATE SQL_Latin1_General_CP1_CS_AS and password= '******' COLLATE SQL_Latin1_General_CP1_CS_AS", con);
                    DataTable      dt  = new DataTable();
                    sda.Fill(dt);
                    if (dt.Rows[0][0].ToString() == "1")
                    {
                        SqlCommand cmd = new SqlCommand("Select facilitator_id from facilitator where username='******' COLLATE SQL_Latin1_General_CP1_CS_AS and password= '******' COLLATE SQL_Latin1_General_CP1_CS_AS", con);

                        con.Open();
                        SqlDataReader dr = cmd.ExecuteReader();
                        while (dr.Read())
                        {
                            Program.user_id = Convert.ToInt32(dr["facilitator_id"]);
                        }
                        dr.Close();
                        con.Close();

                        Program.Session_id = TextboxUsername1.Text; //For Session

                        this.Hide();

                        MainMenu mm = new MainMenu();
                        mm.Show();
                    }
                    else
                    {
                        Dialogue.Show("Login Failed!   Please Check your Username and Password!", "", "Ok", "Cancel");
                    }
                }


                catch (Exception ex)
                {
                    Dialogue.Show(" ' " + ex.Message.ToString() + "' ", "", "Ok", "Cancel");
                }

                e.SuppressKeyPress = true;
            }
        }
Example #30
0
        private void MyAccountEdit_Click(object sender, EventArgs e)
        {
            switch (MyAccountEdit.Text)
            {
            case "Edit":
            {
                pin.Enabled = true;

                MyAccountEdit.Text = "Save";
            }
            break;

            case "Save":
            {
                if (pin.Text != "")
                {
                    DialogResult result = Dialogue1.Show("Are you sure ?", "", "Ok", "Cancel");
                    if (result == DialogResult.Yes)
                    {
                        pin.Enabled = false;

                        MyAccountEdit.Text = "Edit";



                        con.Open();
                        String         query = "UPDATE SERVER SET PIN= '" + pin.Text + "' ";
                        SqlDataAdapter sda   = new SqlDataAdapter(query, con);
                        int            n     = sda.SelectCommand.ExecuteNonQuery();

                        con.Close();

                        PIN();
                    }
                }

                else
                {
                    Dialogue.Show("Please Fill !", "", "Ok", "Cancel");
                }
            }
            break;
            }
        }