Esempio n. 1
0
        //Create new account
        public bool createAccount(string username, string password, string role)
        {
            MySqlCommand command     = new MySqlCommand();
            string       insertQuery = "INSERT INTO `user`(`username`, `password`, `role`) VALUES (@usn,@pass,@role)";

            command.CommandText = insertQuery;
            command.Connection  = conn.getConnection();

            command.Parameters.Add("@usn", MySqlDbType.VarChar).Value  = username;
            command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = password;
            command.Parameters.Add("@role", MySqlDbType.VarChar).Value = role;

            conn.openConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                conn.closeConnection();
                return(true);
            }
            else
            {
                conn.closeConnection();
                return(false);
            }
        }
        //Add info
        public bool addInfo(string name, string type, string workplace, string telephone, string email, string topic, string username)
        {
            MySqlCommand command     = new MySqlCommand();
            string       insertQuery = "INSERT INTO `trainer`(`name`, `type`, `working place`, `telephone`, `email`, `topic_id`,`username`) VALUES (@name,@type,@workplace,@tel,@email,@topic,@usn)";

            command.CommandText = insertQuery;
            command.Connection  = conn.getConnection();

            //@name,@des,@topic,@cat
            command.Parameters.Add("@name", MySqlDbType.VarChar).Value      = name;
            command.Parameters.Add("@type", MySqlDbType.VarChar).Value      = type;
            command.Parameters.Add("@workplace", MySqlDbType.VarChar).Value = workplace;
            command.Parameters.Add("@tel", MySqlDbType.VarChar).Value       = telephone;
            command.Parameters.Add("@email", MySqlDbType.VarChar).Value     = email;
            command.Parameters.Add("@topic", MySqlDbType.Int32).Value       = topic;
            command.Parameters.Add("@usn", MySqlDbType.VarChar).Value       = username;

            conn.openConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                conn.closeConnection();
                return(true);
            }
            else
            {
                conn.closeConnection();
                return(false);
            }
        }
Esempio n. 3
0
        //Add method
        public bool addCategory(string name, string description)
        {
            MySqlCommand command     = new MySqlCommand();
            string       insertQuery = "INSERT INTO `course_category`(`category_name`, `category_description`) VALUES (@name,@des)";

            command.CommandText = insertQuery;
            command.Connection  = conn.getConnection();

            command.Parameters.Add("@name", MySqlDbType.VarChar).Value = name;
            command.Parameters.Add("@des", MySqlDbType.VarChar).Value  = description;


            conn.openConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                conn.closeConnection();
                return(true);
            }
            else
            {
                conn.closeConnection();
                return(false);
            }
        }
Esempio n. 4
0
        //Add new course
        public bool addCourse(string name, string description, string category, string topic)
        {
            MySqlCommand command     = new MySqlCommand();
            string       insertQuery = "INSERT INTO `course`(`Course Name`, `description`, `topic_id`, `category_id`) VALUES (@name,@des,@topic,@cat)";

            command.CommandText = insertQuery;
            command.Connection  = conn.getConnection();

            //@name,@des,@topic,@cat
            command.Parameters.Add("@name", MySqlDbType.VarChar).Value = name;
            command.Parameters.Add("@des", MySqlDbType.VarChar).Value  = description;
            command.Parameters.Add("@topic", MySqlDbType.Int32).Value  = topic;
            command.Parameters.Add("@cat", MySqlDbType.Int32).Value    = category;

            conn.openConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                conn.closeConnection();
                return(true);
            }
            else
            {
                conn.closeConnection();
                return(false);
            }
        }
Esempio n. 5
0
        //Add method
        public bool addTrainee(string name, string age, string DoB, string education, string proLanguage, string TOEIC, string expDetail, string department, string location, string course_id)
        {
            MySqlCommand command     = new MySqlCommand();
            string       insertQuery = "INSERT INTO `trainee`(`name`, `age`, `DoB`, `education`, `proLanguage`, `TOEIC`, `expDetail`, `department`, `location`,`course_id`) VALUES (@name,@age,@dob,@edu,@pro,@toeic,@exp,@dept,@loc,@crsid)";

            command.CommandText = insertQuery;
            command.Connection  = conn.getConnection();

            //@name,@age,@dob,@edu,@pro,@toeic,@exp,@dept,@loc
            command.Parameters.Add("@name", MySqlDbType.VarChar).Value  = name;
            command.Parameters.Add("@age", MySqlDbType.VarChar).Value   = age;
            command.Parameters.Add("@dob", MySqlDbType.VarChar).Value   = DoB;
            command.Parameters.Add("@edu", MySqlDbType.VarChar).Value   = education;
            command.Parameters.Add("@pro", MySqlDbType.VarChar).Value   = proLanguage;
            command.Parameters.Add("@toeic", MySqlDbType.VarChar).Value = TOEIC;
            command.Parameters.Add("@exp", MySqlDbType.VarChar).Value   = expDetail;
            command.Parameters.Add("@dept", MySqlDbType.VarChar).Value  = department;
            command.Parameters.Add("@loc", MySqlDbType.VarChar).Value   = location;
            command.Parameters.Add("@crsid", MySqlDbType.VarChar).Value = course_id;


            conn.openConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                conn.closeConnection();
                return(true);
            }
            else
            {
                conn.closeConnection();
                return(false);
            }
        }
Esempio n. 6
0
        //Add method
        public bool addTopic(string name, string description)
        {
            MySqlCommand command     = new MySqlCommand();
            string       insertQuery = "INSERT INTO `topic`(`name`, `description`) VALUES (@name,@des)";

            command.CommandText = insertQuery;
            command.Connection  = conn.getConnection();

            //@name,@age,@dob,@edu,@pro,@toeic,@exp,@dept,@loc
            command.Parameters.Add("@name", MySqlDbType.VarChar).Value = name;
            command.Parameters.Add("@des", MySqlDbType.VarChar).Value  = description;


            conn.openConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                conn.closeConnection();
                return(true);
            }
            else
            {
                conn.closeConnection();
                return(false);
            }
        }