Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            StudentCalander Mc = new StudentCalander();

            this.Hide();
            Mc.Show();
        }
Exemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            //    StreamReader per = new StreamReader("permissionFile.txt");  //reads the permission from permission file.
            //     string permission = per.ReadLine();                         //now we will check the permission
            if (log_in_page.permission == "manager")                    //according to that, we wil be able to determine
            {                                                           //wich screed to go back to.
                ManagerCalander managerCalander = new ManagerCalander();
                managerCalander.Show();
                Visible = false;
            }
            else if (log_in_page.permission == "teacher")
            {
                TeacherCalander teacherCalander = new TeacherCalander();
                teacherCalander.Show();
                Visible = false;
            }

            else if (log_in_page.permission == "student")
            {
                StudentCalander frmCal = new StudentCalander();
                frmCal.Show();
                Visible = false;
            }

            //per.Close();
        }
Exemplo n.º 3
0
        private void return_btn_Click(object sender, EventArgs e)
        {
            StudentCalander n = new StudentCalander();

            n.Show();
            this.Hide();
        }
Exemplo n.º 4
0
        private void button2_Click(object sender, EventArgs e)
        {
            StudentCalander frmCal = new StudentCalander();

            frmCal.Show();
            Visible = false;
        }
Exemplo n.º 5
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (log_in_page.permission.ToLower() == "manager")
     {
         ManagerCalander n = new ManagerCalander();
         n.Show();
         this.Hide();
     }
     else if (log_in_page.permission.ToLower() == "teacher")
     {
         TeacherCalander n = new TeacherCalander();
         n.Show();
         this.Hide();
     }
     else
     {
         StudentCalander n = new StudentCalander();
         n.Show();
         this.Hide();
     }
 }
Exemplo n.º 6
0
        private void return_btn_Click(object sender, EventArgs e)
        {
            if (log_in_page.permission == "manager")
            {
                ManagerCalander managerCalander = new ManagerCalander();
                managerCalander.Show();
                Visible = false;
            }
            else if (log_in_page.permission == "teacher")
            {
                TeacherCalander teacherCalander = new TeacherCalander();
                teacherCalander.Show();
                Visible = false;
            }

            else if (log_in_page.permission == "student")
            {
                StudentCalander frmCal = new StudentCalander();
                frmCal.Show();
                Visible = false;
            }
        }
Exemplo n.º 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            string HobiesForReplacing = hobies_txt.Text;

            HobiesForReplacing = HobiesForReplacing.Replace("'", string.Empty);
            string FreeTextForReplacing = freetext_txt.Text;

            FreeTextForReplacing = FreeTextForReplacing.Replace("'", string.Empty);
            string AddressForReplace = address_txt.Text;

            AddressForReplace = AddressForReplace.Replace("'", string.Empty);
            string PhoneForReplace = phone_txt.Text;

            PhoneForReplace = PhoneForReplace.Replace("'", string.Empty);
            string EmailForReplace = Email_1st.Text;

            EmailForReplace = EmailForReplace.Replace("'", string.Empty);
            string PEmailForReplace = PEmail_txt.Text;

            PEmailForReplace = PEmailForReplace.Replace("'", string.Empty);
            string PasswordForReplace = pass_txt.Text;

            PasswordForReplace = PasswordForReplace.Replace("'", string.Empty);
            CheckDetails check = new CheckDetails();

            if (pass_txt.Text == userId)
            {
                MessageBox.Show("Your password is the same as before, please update it.");
            }
            else if (pass_txt.Text == "")
            {
                MessageBox.Show("Please update your password.");
            }
            else if (pass_txt.Text != confirm_pass_txt.Text)
            {
                MessageBox.Show("Passwords do not match.");
            }

            else if (!check.CheckEmail(Email_1st.Text))
            {
                MessageBox.Show("Email is not valid!");
            }
            else if (Email_1st.Text != Email_2nd.Text)
            {
                MessageBox.Show("Emails do not match.");
            }
            else if (phone_txt.Text == "")
            {
                MessageBox.Show("Please update your phone number.");
            }
            else if (!check.Check_onlyNums(phone_txt.Text) || phone_txt.Text.Length != 10)
            {
                MessageBox.Show("Invalid phone number.");
            }
            else if (!check.CheckEmail(PEmail_txt.Text) && log_in_page.permission == "student")
            {
                MessageBox.Show("Parent Email is not valid!");
            }
            else if (PEmail_txt.Text != confirm_PEmail_txt.Text)
            {
                MessageBox.Show("Parent Emails do not match.");
            }
            else if (PEmail_txt.Text == Email_1st.Text)
            {
                MessageBox.Show("Parent Email is the same as yours.");
            }
            else if (yearCB.SelectedIndex == -1 && log_in_page.permission == "student")
            {
                MessageBox.Show("Please fill year.");
            }
            else if (classCB.SelectedIndex == -1 && log_in_page.permission == "student")
            {
                MessageBox.Show("Please fill class.");
            }



            else
            {
                try
                {
                    dataBase      dataBase = new dataBase();
                    SqlConnection conn     = dataBase.connect_to_scheduluz_DB();
                    conn.Open();
                    SqlCommand cmd1 = new SqlCommand("UPDATE users SET phoneNumber ='" + PhoneForReplace + "' WHERE id ='" + userId + "'", conn);
                    cmd1.ExecuteNonQuery();

                    conn = dataBase.connect_to_scheduluz_DB();
                    conn.Open();
                    SqlCommand cmd2 = new SqlCommand("UPDATE users SET Email ='" + EmailForReplace + "' WHERE id ='" + userId + "'", conn);
                    cmd2.ExecuteNonQuery();

                    if (log_in_page.permission == "student")
                    {
                        conn = dataBase.connect_to_scheduluz_DB();
                        conn.Open();
                        SqlCommand cmd3 = new SqlCommand("UPDATE users SET ParentEmail ='" + PEmailForReplace + "' WHERE id ='" + userId + "'", conn);
                        cmd3.ExecuteNonQuery();


                        conn = dataBase.connect_to_scheduluz_DB();
                        conn.Open();
                        SqlCommand cmd4 = new SqlCommand("UPDATE users SET grade ='" + yearCB.Items[yearCB.SelectedIndex].ToString() + "' WHERE id ='" + userId + "'", conn);
                        cmd4.ExecuteNonQuery();

                        conn = dataBase.connect_to_scheduluz_DB();
                        conn.Open();
                        SqlCommand cmd5 = new SqlCommand("UPDATE users SET classNumber ='" + classCB.Items[classCB.SelectedIndex].ToString() + "' WHERE id ='" + userId + "'", conn);
                        cmd5.ExecuteNonQuery();
                    }

                    conn = dataBase.connect_to_scheduluz_DB();
                    conn.Open();
                    SqlCommand cmd6 = new SqlCommand("UPDATE users SET address ='" + AddressForReplace + "' WHERE id ='" + userId + "'", conn);
                    cmd6.ExecuteNonQuery();

                    conn = dataBase.connect_to_scheduluz_DB();
                    conn.Open();
                    SqlCommand cmd7 = new SqlCommand("UPDATE users SET birthDate ='" + birthdate_pckr.Text + "' WHERE id ='" + userId + "'", conn);
                    cmd7.ExecuteNonQuery();

                    conn = dataBase.connect_to_scheduluz_DB();
                    conn.Open();
                    SqlCommand cmd8 = new SqlCommand("UPDATE users SET freeTxt ='" + FreeTextForReplacing + "' WHERE id ='" + userId + "'", conn);
                    cmd8.ExecuteNonQuery();


                    conn = dataBase.connect_to_scheduluz_DB();
                    conn.Open();
                    SqlCommand cmd9 = new SqlCommand("UPDATE users SET hobies ='" + HobiesForReplacing + "' WHERE id ='" + userId + "'", conn);
                    cmd9.ExecuteNonQuery();


                    conn = dataBase.connect_to_scheduluz_DB();
                    conn.Open();
                    SqlCommand cmd10 = new SqlCommand("UPDATE connection_details SET password ='******' WHERE id ='" + userId + "'", conn);
                    cmd10.ExecuteNonQuery();

                    /* adding the image - dont ask*/
                    if (imgLocation != "")
                    {
                        byte[]       images = null;
                        FileStream   stream = new FileStream(imgLocation, FileMode.Open, FileAccess.Read);
                        BinaryReader brs    = new BinaryReader(stream);
                        images = brs.ReadBytes((int)stream.Length);

                        conn = dataBase.connect_to_scheduluz_DB();
                        conn.Open();
                        string sqlQuery = "UPDATE users SET picture =@images WHERE id ='" + userId + "'";
                        cmd = new SqlCommand(sqlQuery, conn);
                        cmd.Parameters.Add(new SqlParameter("@images", images));
                        int N = cmd.ExecuteNonQuery();
                    }

                    MessageBox.Show("Your Details has been updated." + userId);



                    if (per == "manager")
                    {
                        ManagerCalander managerCalander = new ManagerCalander();
                        managerCalander.Show();
                        Visible = false;
                    }
                    else if (per == "teacher")
                    {
                        TeacherCalander teacherCalander = new TeacherCalander();
                        teacherCalander.Show();
                        Visible = false;
                    }

                    else
                    {
                        StudentCalander frmCal = new StudentCalander();
                        frmCal.Show();
                        Visible = false;
                    }
                }
                catch
                {
                    MessageBox.Show("Problem detected. please contact your Scheduluz Guide for more information.");
                }
            }
        }
Exemplo n.º 8
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (text_title.Text == "")
            {
                MessageBox.Show("please fill the title");
            }
            else if (Place.Text == "")
            {
                MessageBox.Show("please fill the place");
            }
            else if (hours_start.Value > hours_end.Value)
            {
                MessageBox.Show("your start hours is later than your end hours.");
            }
            else if (hours_start.Value == hours_end.Value && minutes_start.Value >= minutes_end.Value)
            {
                MessageBox.Show("your start hour is later or equal to your end hour.");
            }
            else if (listView1.Items.Count == 0)
            {
                MessageBox.Show("there are no student to invite.");
            }
            else
            {
                dataBase      dataBase = new dataBase();
                SqlConnection conn     = dataBase.connect_to_scheduluz_DB();

                conn.Open();
                SqlCommand cmd = new SqlCommand("INSERT INTO Events(Event_name,event_kind,date,hours_start,minutes_start,hours_end,minutes_end,Event_details,event_place,up_for_cancellation,event_privacy) VALUES(@Event_name,@event_kind,@date,@hours_start,@minutes_start,@hours_end,@minutes_end,@Event_details,@Place,@up_for_cancellation,@event_privacy) ", conn);

                cmd.Parameters.Add("@event_privacy", "Private");
                cmd.Parameters.Add("@up_for_cancellation", "YES");
                cmd.Parameters.Add("@event_kind", "Muliplayer");
                cmd.Parameters.Add("@Event_name", text_title.Text.ToString());
                cmd.Parameters.Add("@date", date.Text);
                cmd.Parameters.Add("@hours_start", hours_start.Value);
                cmd.Parameters.Add("@minutes_start", minutes_start.Text);
                cmd.Parameters.Add("@hours_end", hours_end.Text);
                cmd.Parameters.Add("@minutes_end", minutes_end.Text);
                cmd.Parameters.Add("@Event_details", richTextBox1.Text.ToString());
                cmd.Parameters.Add("@Place", Place.Text.ToString());
                cmd.ExecuteNonQuery();
                //take the max id event from Event table
                string         query = "Select MAX(Event_id) from Events";
                SqlDataAdapter sda   = new SqlDataAdapter(query, conn);
                DataTable      dtbl  = new DataTable();
                sda.Fill(dtbl);
                int    eve_id = int.Parse(dtbl.Rows[0][0].ToString().Trim());
                int    usr_id;
                String fullName;
                //insert the max id event and the event id to Events_to_Users table
                for (int i = listView1.Items.Count - 1; i >= 0; i--)
                {
                    fullName = listView1.Items[i].Text.ToString().Trim();
                    var names = fullName.Split(' ');
                    if (names.Length != 2)
                    {
                        friend_name.Clear();
                        MessageBox.Show("illegal enter first name and last name separate.");
                        conn.Close();
                    }
                    else
                    {
                        string firstName = names[0];
                        string lastName  = names[1];
                        query = "Select * from users Where name = '" + firstName + "' and LastName = '" + lastName + "'"; sda = new SqlDataAdapter(query, conn);
                        dtbl  = new DataTable();
                        sda.Fill(dtbl);
                        usr_id = int.Parse(dtbl.Rows[0][0].ToString().Trim());

                        cmd = new SqlCommand("INSERT INTO Events_to_Users (User_ID,Event_ID) VALUES(@User_ID,@Event_ID) ", conn);
                        cmd.Parameters.Add("@User_ID", usr_id);
                        cmd.Parameters.Add("@Event_ID", eve_id);
                        cmd.ExecuteNonQuery();
                    }
                }


                MessageBox.Show("Your event added successfully");
                StudentCalander n = new StudentCalander();
                n.Show();
                this.Hide();
                conn.Close();
                text_title.Clear();
                richTextBox1.Clear();
                Place.Clear();
                listView1.Clear();
            }
        }