Ejemplo n.º 1
0
        private void StudentDisplayDetails_B_Load(object sender, EventArgs e)
        {
            string        Messenge1 = null, Messenge2 = null;
            SqlConnection connect = new SqlConnection(Return_Connection_String_Class.Return_Connection_String());

            try
            {
                connect.Open();
            }
            catch (Exception ex)
            {
                // output the error to see what's going on
                MessageBox.Show(ex.Message);
            }
            if (connect.State == System.Data.ConnectionState.Open)
            {
                string        command = "select * from Messege_Box where ID = '" + SD.getID().ToString() + "'";
                SqlCommand    cmd     = new SqlCommand(command, connect);
                SqlDataReader dataRead;
                dataRead = cmd.ExecuteReader();
                while (dataRead.Read())
                {
                    Messenge1 = (dataRead["S_Messege"].ToString());
                    Messenge2 = (dataRead["L_Messege"].ToString());
                }
                if (Messenge1 != "" || Messenge2 != "")
                {
                    if (Messenge1 != "" && Messenge2 != "")
                    {
                        Massange1_.Show();
                        Massange2_.Show();
                        Massange1_.Text = Messenge1;
                        Massange2_.Text = Messenge2;
                    }
                    else if (Messenge1 != "")
                    {
                        Massange1_.Show();
                        Massange1_.Text = Messenge1;
                    }
                    else if (Messenge2 != "")
                    {
                        Massange1_.Show();
                        Massange1_.Text = Messenge2;
                    }
                    Clear_Massange.Show();
                }
                else
                {
                    Massange1_.Show();
                }
            }
            ID_.Text         = SD.getID().ToString();
            FirstName_.Text  = SD.getFirstName().ToString();
            LastName_.Text   = SD.getLasttName().ToString();
            Year_.Text       = SD.getYear().ToString();
            Department_.Text = SD.getDepartment().ToString();
            Semester_.Text   = SD.getSemester().ToString();
        }
Ejemplo n.º 2
0
        public void Fill_Courses_Box()
        {
            int temp = sd.getID();
            //count = 0;
            //לזכור לצרף את השמות של ההרצאות
            string        Query       = "select * from StudentsCourses where ID = '" + temp + "'";
            SqlConnection conDatabase = new SqlConnection(Connecting_String);
            SqlCommand    cmdDatabase = new SqlCommand(Query, conDatabase);
            SqlDataReader myReader;

            try
            {
                conDatabase.Open();
                myReader = cmdDatabase.ExecuteReader();
                while (myReader.Read())
                {
                    int    CourseID        = myReader.GetInt32(2);
                    string ItemCourses_Box = Convert.ToString(myReader.GetInt32(2)) + "-" + Convert_IDcourse_to_NameCourse(CourseID);

                    if (!regicourseint.Contains(CourseID))
                    {
                        if (!is_listed_to_Course(sd.getID(), CourseID))
                        {
                            Courses_Box.Items.Add(ItemCourses_Box);
                            courses.Add(CourseID);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            if (Courses_Box.Items.Count == 0)
            {
                MessageBox.Show("No More Courses - Please Click Save!");
                pictureBox1.Show();
                //Exit
                button1.Show();
            }
            else
            {
                MessageBox.Show("You Have " + Courses_Box.Items.Count + " Courses Left");
                Save.Hide();
                //Exit
                button1.Hide();
            }
        }
Ejemplo n.º 3
0
 private void Student_Menu_B_Load(object sender, EventArgs e)
 {
     MessangePic.Hide();
     currStudentForm = this;
     if (Massange)
     {
         MessangePic.Show();
     }
     if (SD != null)
     {
         HelloMassange.Text = "Hello " + SD.getFirstName() + " your ID " + SD.getID() + "";
     }
 }
Ejemplo n.º 4
0
        public void StudentSchedule_B_Load(object sender, EventArgs e)
        {
            List <int> CoursesForStudent = new List <int>(); // create list of courses that student is signed to

            SqlConnection connect = new SqlConnection(Connecting_String);

            try
            {
                connect.Open();
            }
            catch (Exception ex)
            {
                // output the error to see what's going on
                MessageBox.Show(ex.Message);
            }
            if (connect.State == System.Data.ConnectionState.Open)
            {
                for (int course = 1205; course <= 1206; course++) // run on all courses in data base
                {
                    //find courses of student//
                    string FindStudentCourses = "select * from CoursePlacement where CourseID = '" + course.ToString() + "'"; // search on CoursePlacement

                    SqlCommand    cmd = new SqlCommand(FindStudentCourses, connect);                                          // check specific course
                    SqlDataReader dataReadcourse;
                    dataReadcourse = cmd.ExecuteReader();
                    while (dataReadcourse.Read())
                    {
                        int id1 = Convert.ToInt32(dataReadcourse["StudentID1"]);
                        int id2 = Convert.ToInt32(dataReadcourse["StudentID2"]);
                        int id3 = Convert.ToInt32(dataReadcourse["StudentID3"]);
                        if (SD.getID() == id1 || SD.getID() == id2 || SD.getID() == id3)
                        {
                            int courseassigned = Convert.ToInt32(dataReadcourse["CourseID"]);
                            CoursesForStudent.Add(courseassigned); // add course to list of student
                            //MessageBox.Show("found course for student to register");
                        }
                    }
                }
                // find lectures//
                int i = 0;                                                                                              // index for list of lecturesID
                for (int j = 1; j < 2; j++)                                                                             // run on all courses in data base
                {
                    string        FindStudentlec = "select * from Lectures_B where SerialNum = '" + j.ToString() + "'"; // search on Lectures_B classes.
                    SqlCommand    cmd1           = new SqlCommand(FindStudentlec, connect);                             // check specific course
                    SqlDataReader dataReadLecture;
                    dataReadLecture = cmd1.ExecuteReader();
                    while (dataReadLecture.Read())
                    {
                        // run on all table and gets lecture id and time
                        String Day = dataReadLecture["Day"].ToString();
                        int    CourseIDFromTable  = Convert.ToInt32(dataReadLecture["CourseID"]);
                        int    LectureIDfromTable = Convert.ToInt32(dataReadLecture["LectureID"]);
                        int    HourBegin          = Convert.ToInt32(dataReadLecture["HourBegin"]);
                        int    HourEnd            = Convert.ToInt32(dataReadLecture["HourEnd"]);

                        if (CoursesForStudent[i] == CourseIDFromTable)
                        {
                            int    courseIDassigned = Convert.ToInt32(dataReadLecture["CourseID"]);
                            Course temp             = new Course();
                            // set on temp
                            temp.SetCourseID(CourseIDFromTable);
                            temp.SetLectureID(LectureIDfromTable);
                            temp.SetLecBegin(HourBegin);
                            temp.SetLecEnd(HourEnd);
                            temp.SetLectureDay(Day);
                            //add
                            ClassesCanRegister.Add(temp); // add lec details to list of student
                        }
                    }
                    i++; // inc for LecturesForStudent
                }


                i = 0;                                                                                                        // index for list of PracticeID
                for (int j = 1; j < 2; j++)                                                                                   // run on all practice in data base
                {
                    string        FindStudentpractice = "select * from Practices_B where SerialNum = '" + j.ToString() + "'"; // search on Practice_B classes.
                    SqlCommand    cmd_practice        = new SqlCommand(FindStudentpractice, connect);                         // check specific practice options for student
                    SqlDataReader dataReadPractice;
                    dataReadPractice = cmd_practice.ExecuteReader();
                    while (dataReadPractice.Read())
                    {
                        // run on all table and gets lecture id and time
                        String Day = dataReadPractice["Day"].ToString();
                        int    CourseIDFromTable   = Convert.ToInt32(dataReadPractice["CourseID"]);
                        int    PracticeIDfromTable = Convert.ToInt32(dataReadPractice["PracticeID"]);
                        int    HourBegin           = Convert.ToInt32(dataReadPractice["HourBegin"]);
                        int    HourEnd             = Convert.ToInt32(dataReadPractice["HourEnd"]);

                        if (CoursesForStudent[i] == CourseIDFromTable)
                        {
                            int    courseIDassigned = Convert.ToInt32(dataReadPractice["CourseID"]);
                            Course temp             = new Course();
                            // set on temp
                            temp.SetCourseID(CourseIDFromTable);
                            temp.SetPracticeID(PracticeIDfromTable);
                            temp.SetPracticeBegin(HourBegin);
                            temp.SetPracticeEnd(HourEnd);
                            temp.SetPracticeDay(Day);
                            //add
                            ClassesCanRegister.Add(temp); // add lec details to list of student
                        }
                    }
                    i++; // inc for PracticeForStudent
                }


                i = 0;                                                                                              // index for list of LabID
                for (int j = 1; j < 2; j++)                                                                         // run on all practice in data base
                {
                    string        FindStudentLab = "select * from Labs_B where SerialNum = '" + j.ToString() + "'"; // search on Practice_B classes.
                    SqlCommand    cmd_Lab        = new SqlCommand(FindStudentLab, connect);                         // check specific Lab options for student
                    SqlDataReader dataReadLab;
                    dataReadLab = cmd_Lab.ExecuteReader();
                    while (dataReadLab.Read())
                    {
                        // run on all table and gets lecture id and time
                        String Day = dataReadLab["Day"].ToString();
                        int    CourseIDFromTable   = Convert.ToInt32(dataReadLab["CourseID"]);
                        int    PracticeIDfromTable = Convert.ToInt32(dataReadLab["LabID"]);
                        int    HourBegin           = Convert.ToInt32(dataReadLab["HourBegin"]);
                        int    HourEnd             = Convert.ToInt32(dataReadLab["HourEnd"]);

                        if (CoursesForStudent[i] == CourseIDFromTable)
                        {
                            int    courseIDassigned = Convert.ToInt32(dataReadLab["CourseID"]);
                            Course temp             = new Course();
                            // set on temp
                            temp.SetCourseID(CourseIDFromTable);
                            temp.SetLabID(PracticeIDfromTable);
                            temp.SetLabBegin(HourBegin);
                            temp.SetLabEnd(HourEnd);
                            temp.SetLabDay(Day);
                            //add
                            ClassesCanRegister.Add(temp); // add lec details to list of student
                        }
                    }
                    i++; // inc for LabForStudent

                    //Student_SelfPlacement a = new Student_SelfPlacement();
                    //a.passValue = ClassesCanRegister;
                    //a.Show();
                }


                //print to screen options
                //MessageBox.Show(ClassesCanRegister[0].GetLecBegin().ToString());
            }


            label1.Text = classes_show(ClassesCanRegister);
        }//end load
        public int BuildSchdule()
        {
            List <int> CoursesForStudent = new List <int>(); // create list of courses that student is signed to

            SqlConnection connect = new SqlConnection(Connecting_String);

            try
            {
                connect.Open();
            }
            catch (Exception ex)
            {
                // output the error to see what's going on
                MessageBox.Show(ex.Message);
            }
            if (connect.State == System.Data.ConnectionState.Open)
            {
                // find courses assined
                string        FindStudentCourses = "select * from StudentsCourses ";            // search on CoursePlacement
                SqlCommand    cmdCourses         = new SqlCommand(FindStudentCourses, connect); // check specific course
                SqlDataReader dataReadcourse;
                dataReadcourse = cmdCourses.ExecuteReader();

                while (dataReadcourse.Read())
                {
                    int id = Convert.ToInt32(dataReadcourse["ID"]); // gets id

                    if (SD.getID() == id)                           // check if 'this' is in course
                    {
                        int courseassigned = Convert.ToInt32(dataReadcourse["IDcourse"]);
                        CoursesForStudent.Add(courseassigned);     // add course to list of courses to student
                        ClassesRegisted.Add(new Course(courseassigned));
                    }
                }


                // find name
                string        Findcoursesname = "select * from Courses ";                 // search on CoursePlacement
                SqlCommand    cmdname         = new SqlCommand(Findcoursesname, connect); // check specific course
                SqlDataReader dataReadname;
                dataReadname = cmdname.ExecuteReader();

                while (dataReadname.Read())
                {
                    int  course_id = Convert.ToInt32(dataReadname["IDcourse"]); // gets id
                    bool flag      = false;
                    for (int i = 0; i < ClassesRegisted.Count; i++)
                    {
                        if (course_id == ClassesRegisted[i].GetCourseID())
                        {
                            flag = true;
                        }
                    }

                    if (flag) // check if 'this' is in course
                    {
                        string name = dataReadname["Name"].ToString();

                        for (int c = 0; c < ClassesRegisted.Count; c++)
                        {
                            if (ClassesRegisted[c].GetCourseID() == course_id)
                            {
                                ClassesRegisted[c].setCourseName(name);
                            }
                        }
                    }
                }


                // find lectures
                string        FindStudentLec = "select * from StudentLec_B ";           // search on CoursePlacement
                SqlCommand    cmdLec         = new SqlCommand(FindStudentLec, connect); // check specific course
                SqlDataReader dataReadLec;
                dataReadLec = cmdLec.ExecuteReader();

                while (dataReadLec.Read())
                {
                    int id = Convert.ToInt32(dataReadLec["ID_Student"]); // gets id

                    if (SD.getID() == id)                                // check if 'this' is in course
                    {
                        int    start     = Convert.ToInt32(dataReadLec["Start"]);
                        int    end       = Convert.ToInt32(dataReadLec["Ending"]);
                        string day       = dataReadLec["Day"].ToString();
                        int    course_id = Convert.ToInt32(dataReadLec["CourseID"]);

                        for (int c = 0; c < ClassesRegisted.Count; c++)
                        {
                            if (ClassesRegisted[c].GetCourseID() == course_id)
                            {
                                ClassesRegisted[c].SetLecBegin(start);
                                ClassesRegisted[c].SetLecEnd(end);
                                ClassesRegisted[c].SetLectureDay(day);
                            }
                        }
                    }
                }


                // find practices
                string        FindStudentPrac = "select * from StudentPrac_B "; // search on StudentPrac
                SqlCommand    cmdPrac         = new SqlCommand(FindStudentPrac, connect);
                SqlDataReader dataReadPrac;
                dataReadPrac = cmdPrac.ExecuteReader();

                while (dataReadPrac.Read())
                {
                    int id = Convert.ToInt32(dataReadPrac["ID_Student"]); // gets id

                    if (SD.getID() == id)                                 // check if 'this' is in course
                    {
                        int    start     = Convert.ToInt32(dataReadPrac["Start"]);
                        int    end       = Convert.ToInt32(dataReadPrac["Ending"]);
                        int    course_id = Convert.ToInt32(dataReadPrac["CourseID"]);
                        string day       = dataReadPrac["Day"].ToString();
                        for (int c = 0; c < ClassesRegisted.Count; c++)
                        {
                            if (ClassesRegisted[c].GetCourseID() == course_id)
                            {
                                ClassesRegisted[c].SetPracticeBegin(start);
                                ClassesRegisted[c].SetPracticeEnd(end);
                                ClassesRegisted[c].SetPracticeDay(day);
                            }
                        }
                    }
                }//

                // find labs
                string        FindStudentlab = "select * from StudentLab_B "; // search on StudentPrac
                SqlCommand    cmdlab         = new SqlCommand(FindStudentlab, connect);
                SqlDataReader dataReadlab;
                dataReadlab = cmdlab.ExecuteReader();

                while (dataReadlab.Read())
                {
                    int id = Convert.ToInt32(dataReadlab["ID_Student"]); // gets id

                    if (SD.getID() == id)                                // check if 'this' is in course
                    {
                        int    start     = Convert.ToInt32(dataReadlab["Start"]);
                        int    end       = Convert.ToInt32(dataReadlab["Ending"]);
                        int    course_id = Convert.ToInt32(dataReadlab["CourseID"]);
                        string day       = dataReadlab["Day"].ToString();
                        for (int c = 0; c < ClassesRegisted.Count; c++)
                        {
                            if (ClassesRegisted[c].GetCourseID() == course_id)
                            {
                                ClassesRegisted[c].SetLabBegin(start);
                                ClassesRegisted[c].SetLabEnd(end);
                                ClassesRegisted[c].SetLabDay(day);
                            }
                        }
                    }
                }//
            }

            return(CoursesForStudent.Count());
        }
Ejemplo n.º 6
0
        private void Login_button_Click(object sender, EventArgs e)
        {
            if (ID_Box.TextLength != 9)
            {
                MessageBox.Show("ooops Wrong ID please try again");
                ID_Box.Text       = "";
                Password_box.Text = "";
            }
            SqlConnection connect = new SqlConnection(Return_Connection_String_Class.Return_Connection_String());

            try
            {
                connect.Open();
            }
            catch (Exception ex)
            {
                // output the error to see what's going on
                MessageBox.Show(ex.Message);
            }

            if (connect.State == System.Data.ConnectionState.Open)
            {
                string        command = "select * from Users where ID = '" + ID_Box.Text + "' and Password = '******'";
                SqlCommand    cmd     = new SqlCommand(command, connect);
                SqlDataReader dataRead;
                dataRead = cmd.ExecuteReader();
                int    type = 0;
                string Messenge1 = "", Messenge2 = "";

                while (dataRead.Read())
                {
                    type = Convert.ToInt32(dataRead["Type"]);
                    int    id   = Convert.ToInt32(dataRead["ID"]);
                    string ln   = (dataRead["LastName"].ToString());
                    string fn   = (dataRead["FirstName"].ToString());
                    string depa = (dataRead["Departments"].ToString());
                    if (type == 1)
                    {
                        // 317509073/

                        //int id = Convert.ToInt32(dataRead["ID"]);
                        //string ln = (dataRead["LastName"].ToString());
                        //string fn = (dataRead["FirstName"].ToString());
                        string year = (dataRead["Year"].ToString());
                        //string depa = (dataRead["Departments"].ToString());
                        int semester = Convert.ToInt32(dataRead["Semester"]);
                        S1 = new StudentClass(id, fn, ln, type, year, semester, depa);
                        string        readMassange       = "select * from Messege_Box where ID = '" + S1.getID().ToString() + "'";
                        SqlCommand    ReadMessageCommand = new SqlCommand(readMassange, connect);
                        SqlDataReader messangeRead;
                        messangeRead = ReadMessageCommand.ExecuteReader();
                        while (messangeRead.Read())
                        {
                            Messenge1 = (messangeRead["S_Messege"].ToString());
                            Messenge2 = (messangeRead["L_Messege"].ToString());
                        }
                    }

                    if (type == 2) // to create the object Lecturer
                    {
                        int    pid   = Convert.ToInt32(dataRead["ID"]);
                        string pln   = (dataRead["LastName"].ToString());
                        string pfn   = (dataRead["FirstName"].ToString());
                        string pdepa = (dataRead["Departments"].ToString());
                        P1 = new ProfessorClass(pid, pln, pfn, type, pdepa);
                        string        readMassange       = "select * from Messege_Box where ID = '" + P1.getID().ToString() + "'";
                        SqlCommand    ReadMessageCommand = new SqlCommand(readMassange, connect);
                        SqlDataReader messangeRead;
                        messangeRead = ReadMessageCommand.ExecuteReader();
                        while (messangeRead.Read())
                        {
                            Messenge1 = (messangeRead["S_Messege"].ToString());
                            Messenge2 = (messangeRead["L_Messege"].ToString());
                        }
                        lec = new Lecturer();
                        this.lec.setLastName(ln);
                        this.lec.setFirstName(fn);
                        this.lec.setID(id);
                        this.lec.setdeparName(depa);
                    }


                    if (type == 3)     // to create the object TeachingAssitant
                    {
                        ta = new TeachingAssitant();
                        this.ta.setLastName(ln);
                        this.ta.setFirstName(fn);
                        this.ta.setID(id);
                        this.ta.setdeparName(depa);
                    }

                    if (type == 4) // to create the object HeadDepartmrent
                    {
                        hd = new HeadDepartment();
                        this.hd.setLastName(ln);
                        this.hd.setFirstName(fn);
                        this.hd.setID(id);
                        this.hd.setdeparName(depa);
                    }

                    if (type == 5)
                    {
                        sec = new Secretary();
                        this.sec.setLastName(ln);
                        this.sec.setFirstName(fn);
                        this.sec.setID(id);
                        this.sec.setdeparName(depa);
                    }
                    if (type == 7)
                    {
                        sec = new Secretary();
                        this.sec.setLastName(ln);
                        this.sec.setFirstName(fn);
                        this.sec.setID(id);
                        this.sec.setdeparName(depa);
                    }
                }
                if (save_id.Checked)
                {
                    Properties.Settings.Default.IDREMEMBER = ID_Box.Text.ToString();
                    Properties.Settings.Default.Save();
                }
                if (!save_id.Checked)
                {
                    Properties.Settings.Default.IDREMEMBER = "";
                    Properties.Settings.Default.Save();
                }

                if (type == 1)
                {
                    MessageBox.Show("wellcome " + S1.getFirstName() + " to student menu your ID " + S1.getID() + "");
                    this.Hide();
                    Student_Menu_B student = new Student_Menu_B();
                    if (Messenge1 != "" || Messenge2 != "")
                    {
                        student.Massange = true;
                    }
                    connect.Close();
                    student.passValue = S1;
                    dataRead.Close();
                    student.Show();
                }
                else if (type == 2)
                {
                    MessageBox.Show("wellcome " + P1.getFirstName() + " to Lecturer Menu your ID " + P1.getID() + "");
                    this.Hide();
                    //Proffesor_Menu_B professor = new Proffesor_Menu_B();
                    A_LecturerMenu lecMenu = new A_LecturerMenu(lec);
                    lecMenu.passValue = P1;
                    connect.Close();
                    dataRead.Close();
                    lecMenu.ShowDialog();

                    /*
                     * this.Hide();
                     * A_LecturerMenu lecMenu = new A_LecturerMenu(lec);
                     * lecMenu.ShowDialog();
                     */
                    //MessageBox.Show("Connceted Professor");
                    //this.Hide();
                    //Proffesor_Menu_B professor = new Proffesor_Menu_B();
                    //professor.Show();
                    // קבוצה B שימו לב !!!!!!!!
                    // אתם צריכים לשנות את הסוג של פרופסור אצלכם ל-2 ולשנות את זה בכל מקום! גם בקוד וגם בדטהבייס
                    // ואז לשלוח אותו לפורם הבא: A_lecturerMenu  אחרי שתאחדו את הדרישות שלכם בפורם הזה
                }

                else if (type == 3)
                {
                    this.Hide();
                    MessageBox.Show("wellcome " + ta.getFirstName() + " to Teaching Assistant Menu your ID " + ta.getID() + "");
                    A_TeachingAssistant taMenu = new A_TeachingAssistant(ta);
                    taMenu.passValue = ta;
                    connect.Close();
                    dataRead.Close();
                    taMenu.ShowDialog();



                    //change branch B ---  type of proffesor to type 2
                    //MessageBox.Show("Connceted Professor");
                    //this.Hide();
                    //Proffesor_Menu_B professor = new Proffesor_Menu_B();
                    //professor.Show();
                }
                else if (type == 4)
                {
                    this.Hide();
                    //HeadDepartment hd = new HeadDepartment();
                    A_DepartmentHead hdMenu = new A_DepartmentHead();
                    hdMenu.passValue = hd;
                    connect.Close();
                    dataRead.Close();
                    hdMenu.ShowDialog();
                }
                else if (type == 5)
                {
                    MessageBox.Show("wellcome " + sec.getFirstName() + " to Secretary Menu your ID " + sec.getID() + "");
                    this.Hide();
                    Secretary_Menu_B secretary = new Secretary_Menu_B();
                    secretary.passsec = sec;
                    secretary.Show();
                }
                else if (type == 6)
                {
                    MessageBox.Show("Connceted TECH");
                    this.Hide();
                    support__manager supp = new support__manager();
                    supp.Show();
                }
                else if (type == 7)
                {
                    this.Hide();

                    MessageBox.Show("wellcome " + sec.getFirstName() + " to Secretary Menu your ID " + sec.getID() + "");
                    A_menuForSecretary secMenu = new A_menuForSecretary();
                    // secMenu.passValue = sec;
                    //connect.Close();
                    //dataRead.Close();
                    secMenu.Show();
                }
                else
                {
                    MessageBox.Show("Wrong password");
                    Password_box.Text = "";
                }
            }
        }