예제 #1
0
    // Check si modification ou nouvel utilisateur
    public void CreateUser()
    {
        if (!String.IsNullOrEmpty(firstname.text) && !String.IsNullOrEmpty(lastname.text) && !String.IsNullOrEmpty(email.text) && !String.IsNullOrEmpty(password.text))
        {
            User currentUser;

            // Prof
            if (String.Equals(status.captionText.text, "Prof."))
            {
                int id = DBCommands.InsertTeacher(lastname.text, firstname.text, email.text, password.text);
                currentUser = GUser.CreateTeacher(id, firstname.text, lastname.text, email.text, password.text);
                GApp.SetPrefUser(firstname.text, lastname.text, email.text, password.text, "Prof.", "", "", "", "2019-02-11");
            }
            // Student
            else
            {
                Promo p  = GPromo.GetPromo(1, promo.captionText.text);
                int   id = DBCommands.InsertStudent(firstname.text, lastname.text, p.Id, email.text, password.text);
                currentUser = GUser.CreateStudent(id, firstname.text, lastname.text, email.text, password.text, p);
                GApp.SetPrefUser(firstname.text, lastname.text, email.text, password.text, "Elève", p.Specialty, td.captionText.text, tp.captionText.text, "2019-02-11");
            }

            GApp.ChangeScene(nextScene);
        }
    }
예제 #2
0
    public static void RetrieveUsers()
    {
        IDataReader reader = DBCommands.RetrieveUsers();

        while (reader.Read())
        {
            int    id        = Int32.Parse(reader[0].ToString());
            string firstname = reader[1].ToString();
            string lastname  = reader[2].ToString();
            string email     = reader[3].ToString();
            string password  = reader[4].ToString();

            IDataReader userReader = DBCommands.RetrieveStudentPromo(email, password);
            if (userReader != null)
            {
                userReader.Read();
                int idPromo = Int32.Parse(userReader[0].ToString());

                CreateStudent(id, firstname, lastname, email, password, GPromo.GetPromo(idPromo));
            }
            else
            {
                CreateTeacher(id, firstname, lastname, email, password);
            }
        }
    }
예제 #3
0
    public static void RetrieveLessons()
    {
        IDataReader reader = DBCommands.RetrieveLessons();

        while (reader.Read())
        {
            int id     = Int32.Parse(reader[0].ToString());
            int roomId = Int32.Parse(reader[1].ToString());
            int floor  = Int32.Parse(reader[2].ToString());
            Debug.Log("date: " + reader[3].ToString().Split(' ')[0] + " " + reader[4].ToString().Split(' ')[1]);
            DateTime start       = Convert.ToDateTime(reader[3].ToString().Split(' ')[0] + " " + reader[4].ToString().Split(' ')[1]); // ????
            int      duration    = Int32.Parse(reader[5].ToString());
            int      idPromo     = Int32.Parse(reader[6].ToString());
            int      idProf      = Int32.Parse(reader[7].ToString());
            string   description = reader[8].ToString();

            Room  room    = GRoom.GetRoom(roomId, floor);
            User  teacher = GUser.GetUser(idProf);
            Promo promo   = GPromo.GetPromo(idPromo);
            CreateLesson(id, room, start, duration, teacher, promo, description);
        }
    }