// Timetables public int AddTimetables(Timetablesc td) { try { cmd.CommandText = "INSERT INTO timetables(date,time,batch,modcode,lecname,lechall,lab,fac) VALUES (@d,@t,@b,@mc,@ln,@lh,@lb,'Business')"; cmd.Parameters.AddWithValue("d", td.Date); cmd.Parameters.AddWithValue("t", td.Time); cmd.Parameters.AddWithValue("b", td.Batch); cmd.Parameters.AddWithValue("mc", td.Modcode); cmd.Parameters.AddWithValue("ln", td.Lecname); cmd.Parameters.AddWithValue("lh", td.Lechall); cmd.Parameters.AddWithValue("lb", td.Lab); con.Open(); cmd.CommandType = CommandType.Text; return(cmd.ExecuteNonQuery()); } catch (Exception) { throw; } finally { con.Close(); } }
public List <Timetablesc> GetComTimetables() { List <Timetablesc> studetails = new List <Timetablesc>(); try { cmd.CommandText = "SELECT id AS 'Explorer',date AS 'Date',time AS 'Time',batch AS 'Batch',modcode AS 'Module Code',lecname AS 'Lec Name',lechall AS 'Lec Hall',lab AS 'Lab' FROM timetables WHERE fac='Computing'"; cmd.CommandType = CommandType.Text; con.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Timetablesc lecgv = new Timetablesc() { Id = reader[0].ToString(), Date = reader[1].ToString(), Time = reader[2].ToString(), Batch = reader[3].ToString(), Modcode = reader[4].ToString(), Lecname = reader[5].ToString(), Lechall = reader[6].ToString(), Lab = reader[7].ToString(), }; studetails.Add(lecgv); } return(studetails); } catch (Exception) { throw; } finally { if (con != null) { con.Close(); } } }