public static Classroom getProperClassroom(int size, int time) { SqlConnection con = new SqlConnection(); con.ConnectionString = "server=ELAINEC-HP\\SQLEXPRESS;database=Schedule;Trusted_Connection=SSPI"; con.Open(); String sql = "select top 1 * " + "from classroom" + "where classroomSize>" + size.ToString() + "AND substring(occupied," + time.ToString() + ",1)=0" + "order by classroomSize ASC"; SqlDataAdapter adapter = new SqlDataAdapter(sql, con); DataTable table = new DataTable(); adapter.Fill(table); con.Close(); Classroom classroom = new Classroom(Convert.ToInt32(table.Rows[0]["classroomId"]), table.Rows[0]["classroomName"].ToString(), table.Rows[0]["classroomType"].ToString(), Convert.ToInt32(table.Rows[0]["classroomSize"])); return(classroom); }
public static Classroom getClassroomById(int id) { Classroom result = new Classroom(); return(result); }