コード例 #1
0
        public static void update(ObjProjectsEdit obj)
        {
            string query = $@"

                set @token = (select token from is_project where id = {obj.id});     

                update is_project 

                set 

                name = '{obj.name}',
                token = '{obj.token}',
                descr = '{obj.descr}',
                deadline = {obj.deadline},
                deadline1 = {obj.deadline1},
                deadline2 = {obj.deadline2},
                deadline3 = {obj.deadline3},
                deadline4 = {obj.deadline4},
                deadline5 = {obj.deadline5},
                deadline6 = {obj.deadline6}

                where token = @token

            ";

            DBUtils.execQuery(query);
        }
コード例 #2
0
        public static List <ObjProjectsEdit> getList(int userId)
        {
            List <ObjProjectsEdit> result = new List <ObjProjectsEdit>();

            string query = $@"

                select 
                
                isp.id as id,
                isp.descr as descr, 
                isp.deadline as deadline,
                isd.name as discipline,
                isp.name,
                isp.deadline1, 
                isp.deadline2, 
                isp.deadline3, 
                isp.deadline4, 
                isp.deadline5, 
                isp.deadline6

                from is_user isu

                join is_project isp on isp.teacher_id = isu.id
                join is_discipline isd on isd.id = isp.discipline_id               


                where isu.id = {userId} and fl_unique = 1

            ";

            MySqlConnection conn = DBUtils.getConnection();

            conn.Open();

            MySqlCommand cmd = new MySqlCommand(query, conn);

            MySqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                ObjProjectsEdit obj = new ObjProjectsEdit()
                {
                    id         = int.Parse(reader["id"].ToString()),
                    name       = reader["name"].ToString(),
                    discipline = reader["discipline"].ToString(),
                    descr      = reader["descr"].ToString(),
                    deadline   = reader["deadline"].ToString().Replace("0:00:00", string.Empty),
                    deadline1  = reader["deadline1"].ToString().Replace("0:00:00", string.Empty),
                    deadline2  = reader["deadline2"].ToString().Replace("0:00:00", string.Empty),
                    deadline3  = reader["deadline3"].ToString().Replace("0:00:00", string.Empty),
                    deadline4  = reader["deadline4"].ToString().Replace("0:00:00", string.Empty),
                    deadline5  = reader["deadline5"].ToString().Replace("0:00:00", string.Empty),
                    deadline6  = reader["deadline6"].ToString().Replace("0:00:00", string.Empty)
                };

                result.Add(obj);
            }

            conn.Close();

            return(result);
        }