コード例 #1
0
 private void facebook_login_btn_Click(object sender, EventArgs e)
 {
     try
     {
         Globals._session.FB_ID = this.facebook_login_btn.getLoginData()["id"];
         if (Globals._session.FB_ID != null && Globals._session.FB_ID != "")
         {
             if (SqlWorker.SaveUser(Globals._session))
             {
                 MessageBox.Show("User Was Connected To Facebook seccessfuly!");
                 this.Close();
             }
         }
     }catch
     {
         MessageBox.Show("Login with Facebook Failded!\n Please try again!");
     }
 }
コード例 #2
0
 public void save_btn_Click(object sender, EventArgs e)
 {
     try
     {
         user.Name = this.name_input.Text;
         user.Pwd  = this.pwd_input.Text;
         if (user.Type == "Student")
         {
             (user as Student).SemCount = this.sem_sbox.SelectedIndex + 1;
         }
         if (SqlWorker.SaveUser(user))
         {
             MessageBox.Show("Saved successfully!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "ERROR");
     }
 }
コード例 #3
0
        private void save_btn_Click(object sender, EventArgs e)
        {
            String constraints = "";

            for (int col = 1; col < this.constrainsWeekGrid.ColumnCount; col++)
            {
                for (int row = 0; row < this.constrainsWeekGrid.RowCount; row++)
                {
                    if (this.constrainsWeekGrid[col, row].Selected)
                    {
                        constraints += "Day: " + col + " Hour: " + row + ";";
                    }
                }
            }

            currentStudent.Constraints = constraints;
            if (SqlWorker.SaveUser(currentStudent))
            {
                MessageBox.Show("Saved successfully!");
            }

            this.Close();
        }
コード例 #4
0
        public void pass_btn_Click(object sender, EventArgs e)
        {
            Boolean Flag;
            string  ACtiveLects = "";

            if (this.student_list.SelectedItem != null && this.courses_list.SelectedItem != null)
            {
                ((Student)this.student_list.SelectedItem).PassedCourses += ((Course)this.courses_list.SelectedItem).Name + ",";
                string [] ev = ((Student)this.student_list.SelectedItem).ActiveLects.Split(',');
                for (int i = 0; i < ev.Length; i++)
                {
                    Flag = true;
                    foreach (Event eve in ((Course)this.courses_list.SelectedItem).LectEventsList)
                    {
                        if (eve.ID.ToString() == ev[i] && ev[i] != "")
                        {
                            Flag = false;
                        }
                    }
                    if (Flag && ev[i] != "")
                    {
                        ACtiveLects += ev[i] + ',';
                    }
                }
                ((Student)this.student_list.SelectedItem).ActiveLects = ACtiveLects;


                ACtiveLects = "";
                ev          = ((Student)this.student_list.SelectedItem).ActivePracLabs.Split(',');
                for (int i = 0; i < ev.Length; i++)
                {
                    Flag = true;
                    foreach (Event eve in ((Course)this.courses_list.SelectedItem).PractEventsList)
                    {
                        if (eve.ID.ToString() == ev[i] && ev[i] != "")
                        {
                            Flag = false;
                        }
                    }
                    if (Flag && ev[i] != "")
                    {
                        ACtiveLects += ev[i] + ',';
                    }
                }
                ((Student)this.student_list.SelectedItem).ActivePracLabs = ACtiveLects;


                ACtiveLects = "";
                ev          = ((Student)this.student_list.SelectedItem).ActivePracLabs.Split(',');
                for (int i = 0; i < ev.Length; i++)
                {
                    Flag = true;
                    foreach (Event eve in ((Course)this.courses_list.SelectedItem).LabsEventsList)
                    {
                        if (eve.ID.ToString() == ev[i] && ev[i] != "")
                        {
                            Flag = false;
                        }
                    }
                    if (Flag && ev[i] != "")
                    {
                        ACtiveLects += ev[i] + ',';
                    }
                }
                ((Student)this.student_list.SelectedItem).ActivePracLabs = ACtiveLects;


                SqlWorker.SaveUser((Student)this.student_list.SelectedItem);
                this.courses_list.Items.Remove(this.courses_list.SelectedItem);
                MessageBox.Show("Course passed successfuly!");
            }
        }
コード例 #5
0
ファイル: AddStudent.cs プロジェクト: JFlow22/ScheduleProgram
        public bool SaveUser()
        {
            if (this.name_input.Text != "" &&
                this.id_input.Text != "" &&
                this.sem_sbox.Text != "")
            {
                try
                {
                    DataTable users_list = SqlWorker.GetUsersList();
                    Student   student    = new Student();
                    student.Type     = "Student";
                    student.Name     = this.name_input.Text;
                    student.ID       = this.id_input.Text;
                    student.Pwd      = this.pwd_input.Text;
                    student.SemCount = int.Parse(this.sem_sbox.Text);

                    foreach (DataRow row in users_list.Rows)
                    {
                        if ((row["id"].ToString()) == this.id_input.Text)
                        {
                            if (row["Type"].ToString() == "Student")
                            {
                                // Configure the message box to be displayed
                                string messageBoxText = "Student with that ID is already in system. Do you want to update?";
                                string caption        = "Confirme Update";

                                if (MessageBox.Show(messageBoxText, caption, MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                                {
                                    Student DbStudent = (Student)SqlWorker.GetUser(student.ID.ToString());
                                    student.ActiveLects    = DbStudent.ActiveLects;
                                    student.ActivePracLabs = DbStudent.ActivePracLabs;
                                    student.Constraints    = DbStudent.Constraints;

                                    if (SqlWorker.SaveUser(student))
                                    {
                                        return(true);
                                    }
                                }
                                return(false);
                            }
                            else
                            {
                                MessageBox.Show("User with that ID is already in system");
                                return(false);
                            }
                        }
                    }

                    if (SqlWorker.AddStudent(student))
                    {
                        return(true);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                throw new Exception("Fields can't be empty!");
            }
            return(false);
        }
コード例 #6
0
        private void save_event_grp_Click(object sender, EventArgs e)
        {
            // grab all fields
            Event SelectedLect  = (Event)this.lectures_list.SelectedItem;
            Event SelectedPract = (Event)this.practice_list.SelectedItem;
            Event SelectedLab   = (Event)this.labs_list.SelectedItem;

            // add the events to Student active events list
            if (SelectedLect != null)
            {
                currentStudent.ActiveEventsList.Add(SelectedLect);
                SelectedLect.btn.Style = MetroFramework.MetroColorStyle.Green;
            }
            //else throw new Exception("A course without a Lecture?!");
            if (SelectedPract != null)
            {
                currentStudent.ActiveEventsList.Add(SelectedPract);
                SelectedPract.btn.Style = MetroFramework.MetroColorStyle.Green;
            }
            if (SelectedLab != null)
            {
                currentStudent.ActiveEventsList.Add(SelectedLab);
                SelectedLab.btn.Style = MetroFramework.MetroColorStyle.Green;
            }

            // update Student fields
            currentStudent.ActiveLects    = "";
            currentStudent.ActivePracLabs = "";
            foreach (Event ev in currentStudent.ActiveEventsList)
            {
                switch (ev.EventType)
                {
                case "Lecture":
                    currentStudent.ActiveLects += ev.ID + ",";
                    break;

                case "Practice":
                case "Lab":
                    currentStudent.ActivePracLabs += ev.ID + ",";
                    break;
                }
            }

            // update DB
            if (SqlWorker.SaveUser(currentStudent))
            {
                MessageBox.Show("Course saved!");
            }

            // add ONLY the course to the ACTIVE box.
            if (SelectedLect != null && SelectedLect.ParentCourse != null)
            {
                this.active_courses_list.Items.Add(SelectedLect.ParentCourse);

                // remove the ocurse from it's original box
                if (SelectedLect.ParentCourse.Must)
                {
                    this.must_do_courses_list.Items.Remove(SelectedLect.ParentCourse);
                }
                else
                {
                    this.can_do_courses_list.Items.Remove(SelectedLect.ParentCourse);
                }
            }
            // clear all selections when done
            this.must_do_courses_list.ClearSelected();
            this.can_do_courses_list.ClearSelected();
            ClearEventsSelection();
            DisableSaveBtn();
        }