Beispiel #1
0
        public A_Show_Schedualing_TA(TeachingAssitant ta)
        {
            InitializeComponent();
            this.ta   = ta;
            name.Text = "Hello " + ta.getFirstName().ToString() + "!";
            SqlDataAdapter sda  = new SqlDataAdapter("SELECT ID, day, courseName, class, timeStart, timeEnd FROM schedualing WHERE ID LIKE'" + ta.getID().ToString() + "%'", cn);
            DataTable      data = new DataTable();

            sda.Fill(data);
            dataGridView1.DataSource = data;
        }
Beispiel #2
0
        //insert user to the table sched2_TA_A - lecturer that doesn't exsit in the table
        public bool insertToSchecd2(TeachingAssitant ta)
        {
            string constring = "Data Source=p17server.database.windows.net;Initial Catalog=P17DATABASE;Persist Security Info=True;User ID=P17;Password=Hadas@2017";

            int index;
            int nextIndex = 0;

            try
            {
                string q = "select MAX(num) from sched2_TA_A";
                cn  = new SqlConnection(constring);
                cmd = new SqlCommand(q, cn);
                cn.Open();
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    index     = Int32.Parse(dr[0].ToString()) + 1;
                    nextIndex = index; //in order to get index out of the red() loop
                }
                dr.Close();
                cn.Close();
            }
            catch (Exception exe) { MessageBox.Show(exe.Message); }

            try
            {
                cn = new SqlConnection(constring);
                cn.Open();

                string q = "insert into [sched2_TA_A]  (Num,ID, TA,day) values(@Num , @ID, @TA , @day );";
                cmd = new SqlCommand(q, cn);
                cmd.Parameters.AddWithValue("@Num", nextIndex);
                cmd.Parameters.AddWithValue("@ID", ta.getID());
                cmd.Parameters.AddWithValue("@TA", ta.mergetoOne(ta.getFirstName(), ta.getLastName()));
                cmd.Parameters.AddWithValue("@day", this.course.getDayL());

                //cmd.CommandText = "SELECT SCOPE_IDENTITY()";
                cmd.ExecuteNonQuery();
                cmd.Parameters.Clear();

                cn.Close();
                dr.Close();
                return(true);
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }

            return(false);
        }
Beispiel #3
0
        // to check the available hours of the TA and save then in variable List taHours
        public void findFreeHours(TeachingAssitant ta)
        {
            string constring = "Data Source=p17server.database.windows.net;Initial Catalog=P17DATABASE;Persist Security Info=True;User ID=P17;Password=Hadas@2017";
            string Query     = "SELECT * from sched2_TA_A WHERE TA ='" + ta.mergetoOne(ta.getFirstName(), ta.getLastName()) + "' and day = '" + this.cmbDay.SelectedItem + "' ";

            cn  = new SqlConnection(constring);
            cmd = new SqlCommand(Query, cn);
            cn.Open();
            dr = cmd.ExecuteReader();

            List <int> availableHours = new List <int>();

            while (dr.Read())
            {
                if (dr["8"].ToString() == "")
                {
                    availableHours.Add(8);
                }
                if (dr["9"].ToString() == "")
                {
                    availableHours.Add(9);
                }
                if (dr["10"].ToString() == "")
                {
                    availableHours.Add(10);
                }
                if (dr["11"].ToString() == "")
                {
                    availableHours.Add(11);
                }
                if (dr["12"].ToString() == "")
                {
                    availableHours.Add(12);
                }
                if (dr["13"].ToString() == "")
                {
                    availableHours.Add(13);
                }
                if (dr["14"].ToString() == "")
                {
                    availableHours.Add(14);
                }
                if (dr["15"].ToString() == "")
                {
                    availableHours.Add(15);
                }
                if (dr["16"].ToString() == "")
                {
                    availableHours.Add(16);
                }
                if (dr["17"].ToString() == "")
                {
                    availableHours.Add(17);
                }
                if (dr["18"].ToString() == "")
                {
                    availableHours.Add(18);
                }
                if (dr["19"].ToString() == "")
                {
                    availableHours.Add(19);
                }
                if (dr["20"].ToString() == "")
                {
                    availableHours.Add(20);
                }
                if (dr["21"].ToString() == "")
                {
                    availableHours.Add(21);
                }
                break;
            }
            dr.Close();
            cn.Close();
            //int flag = 0;

            //List<int> lectHours = new List<int>();

            for (int i = 0; i < availableHours.Count() - 1; i++)
            {
                if (availableHours[i] == availableHours[i + 1] - 1)
                {
                    taHours.Add(availableHours[i]);
                    if (taHours.Contains(availableHours[i + 1]))
                    {
                        continue;
                    }
                    else
                    {
                        taHours.Add(availableHours[i + 1]);
                    }
                    //flag++;
                    this.countHours++;
                }
            }
        }
Beispiel #4
0
        // to save all the teaching assistant in arr
        public bool savePotentialTa()
        {
            //int size = 0;
            string constring = "Data Source=p17server.database.windows.net;Initial Catalog=P17DATABASE;Persist Security Info=True;User ID=P17;Password=Hadas@2017";

            try
            {
                //string q = "select U.ID, U.LastName, U.FirstName from Users U, StaffCourses SC where U.type = 3 and U.Departments = '" + this.course.getCdepName() + "' and SC.IDcourse = '" + this.course.getIDcourse() + "' and U.ID = SC.ID";
                string q = "select distinct U.ID, U.LastName, U.FirstName from Users U, StaffCourses SC, UsersDepartment UD where U.type = 3 and UD.IDdepartment = '" + this.course.getIdDep() + "' and SC.IDcourse = '" + this.course.getIDcourse() + "' and U.ID = SC.ID  and U.ID = UD.ID";
                cn  = new SqlConnection(constring);
                cmd = new SqlCommand(q, cn);
                cn.Open();
                dr = cmd.ExecuteReader();

                while (dr.Read())
                {
                    // to know how many match ta
                    this.size++;
                }
                cn.Close();
                dr.Close();
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.Message);
            }

            arr = new TeachingAssitant[size];
            for (int j = 0; j < size; j++)
            {
                arr[j] = new TeachingAssitant();
            }

            try
            {
                //string q = "select U.ID, U.LastName, U.FirstName from Users U, StaffCourses SC where U.type = 3 and U.Departments = '" + this.course.getCdepName() + "' and SC.IDcourse = '" + this.course.getIDcourse() + "' and U.ID = SC.ID";
                string q = "select distinct U.ID, U.LastName, U.FirstName from Users U, StaffCourses SC, UsersDepartment UD where U.type = 3 and UD.IDdepartment = '" + this.course.getIdDep() + "' and SC.IDcourse = '" + this.course.getIDcourse() + "' and U.ID = SC.ID  and U.ID = UD.ID";
                cn  = new SqlConnection(constring);
                cmd = new SqlCommand(q, cn);
                cn.Open();
                dr = cmd.ExecuteReader();
                int i = 0;
                while (dr.Read())
                {
                    // to save the details into Lecturer arr
                    this.arr[i].setID(Int32.Parse(dr["ID"].ToString()));
                    this.arr[i].setFirstName(dr["FirstName"].ToString());
                    this.arr[i].setLastName(dr["LastName"].ToString());
                    i++;
                }
                cn.Close();
                dr.Close();
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.Message);
            }

            if (size == 0) // if no match ta
            {
                //MessageBox.Show("No ta assign to this course! (administrator responsibility - HD)", "Message");
                return(false);
            }
            else
            {
                //for (int i = 0; i < size; i++)
                //    MessageBox.Show(this.arr[i].getFirstName());
                return(true);
            }
        }
Beispiel #5
0
 public A_TeachingAssistant(TeachingAssitant ta)
 {
     InitializeComponent();
     this.ta = ta;
 }
 public A_Insert_work_hours_for_TA(TeachingAssitant ta)
 {
     InitializeComponent();
     this.ta   = ta;
     name.Text = "Hello " + ta.getFirstName().ToString() + "!";
 }
Beispiel #7
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 = "";
                }
            }
        }
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            bool          login = false;
            SqlConnection cn    = new SqlConnection("Data Source=p17server.database.windows.net;Initial Catalog=P17DATABASE;Persist Security Info=True;User ID=P17;Password=Hadas@2017");

            cn.Open();
            SqlCommand    cmd = new SqlCommand("select * from Users where ID ='" + this.id_text.Text + "' and Password = '******'", cn);
            SqlDataReader dr;

            dr = cmd.ExecuteReader();

            string headDepartment;
            string userType, user_name;
            int    result = 0;

            while (dr.Read())
            {
                login = true;

                userType = dr["Type"].ToString();

                //We dont have Student - therefor we doesnt need to know his type

                if (userType == "2")//for Lecturer Type
                {
                    result = 2;
                    lec    = new Lecturer();
                    lec.setID(int.Parse(dr["ID"].ToString()));
                    lec.setdeparName(dr["Departments"].ToString());
                    lec.setFirstName(dr["FirstName"].ToString());
                    lec.setLastName(dr["LastName"].ToString());
                }

                if (userType == "3")//for Teaching Assitant Type
                {
                    result = 3;
                    ta     = new TeachingAssitant();
                    ta.setID(int.Parse(dr["ID"].ToString()));
                    ta.setdeparName(dr["Departments"].ToString());
                    ta.setFirstName(dr["FirstName"].ToString());
                    ta.setLastName(dr["LastName"].ToString());
                }

                if (userType == "4")//for Head Department Type
                {
                    result         = 4;
                    dh             = new HeadDepartment();
                    headDepartment = dr["ID"].ToString();
                    dh.setID(int.Parse(headDepartment));
                    dh.setdeparName(dr["Departments"].ToString());
                    dh.setFirstName(dr["FirstName"].ToString());
                    dh.setLastName(dr["LastName"].ToString());
                }

                if (userType == "5")//for Secretary Type
                {
                    result = 5;
                }
            }
            dr.Close();
            cn.Close();

            if (login)
            {
                //MessageBox.Show("Connect SUCCESSFULY");

                if (result == 2)// in case user is Lecturer
                {
                    this.Hide();
                    A_LecturerMenu lec = new A_LecturerMenu(this.lec);

                    lec.ShowDialog();
                }

                if (result == 3)//in case user is Teaching Assitant
                {
                    this.Hide();
                    A_TeachingAssistant ta = new A_TeachingAssistant(this.ta);
                    ta.ShowDialog();
                }

                if (result == 4)// in case the user is Department Head
                {
                    this.Hide();
                    //A_DepartmentHead depHead = new A_DepartmentHead();
                    A_DepartmentHead depHead = new A_DepartmentHead(this.dh);
                    depHead.ShowDialog();
                }

                if (result == 5)// in case the user is secretary
                {
                    this.Hide();
                    A_menuForSecretary sec = new A_menuForSecretary();
                    sec.ShowDialog();
                }
            }
            else
            {
                MessageBox.Show("Login FAILED !!! Invalid ID/Password");
            }

            this.id_text.Clear();
            this.password_text.Clear();
        }