Ejemplo n.º 1
0
        public static void insert(ObjGroupsList obj)
        {
            string query = $@"insert into is_group(name, faculty_id, course_id, dt) 

                            values(
                                '{obj.name}',
                                (select id from is_faculty where name = '{obj.faculty}' limit 1),
                                (select id from is_course where name = '{obj.course}' limit 1),
                                '{obj.dt}'
                            )

                            ";

            DBUtils.execQuery(query);
        }
Ejemplo n.º 2
0
        public static List <ObjGroupsList> getList()
        {
            List <ObjGroupsList> result = new List <ObjGroupsList>();

            string query = $@"

                select 

                isg.id,
                isg.name as groupname,
                isc.name as course,
                isf.name as faculty,
                isg.dt as dt

                from is_group isg

                join is_course isc on isc.id = isg.course_id
                join is_faculty isf on isf.id = isg.faculty_id

            ";

            MySqlConnection conn = DBUtils.getConnection();

            conn.Open();

            MySqlCommand cmd = new MySqlCommand(query, conn);

            MySqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                ObjGroupsList obj = new ObjGroupsList()
                {
                    id      = reader["id"].ToString(),
                    faculty = reader["faculty"].ToString(),
                    name    = reader["groupname"].ToString(),
                    course  = reader["course"].ToString(),
                    dt      = reader["dt"].ToString()
                };

                result.Add(obj);
            }

            conn.Close();

            return(result);
        }
Ejemplo n.º 3
0
        public static void update(ObjGroupsList obj)
        {
            string query = $@"

                            UPDATE is_group SET 

                            name = '{obj.name}', 
                            course_id = (select id from is_course where name = '{obj.course}' limit 1),
                            faculty_id = (select id from is_faculty where name = '{obj.faculty}' limit 1),
                            dt = {obj.dt}

                            WHERE id = '{obj.id}'

            ";

            DBUtils.execQuery(query);
        }