public List <RetireiveSessionRoomModel> getSessionsRooms() { List <RetireiveSessionRoomModel> listAssignRooms = new List <RetireiveSessionRoomModel>(); try { string Query = "Select session_id,room,building from RoomSession"; SqlCommand cmd = new SqlCommand(Query, DBConnection.DatabaseConnection); SqlDataReader myReader; DBConnection.OpenConnection(); myReader = cmd.ExecuteReader(); while (myReader.Read()) { RetireiveSessionRoomModel objSessionAssign = new RetireiveSessionRoomModel(); objSessionAssign.session_id = int.Parse(myReader["session_id"].ToString()); objSessionAssign.room = myReader["room"].ToString(); objSessionAssign.building = myReader["building"].ToString(); listAssignRooms.Add(objSessionAssign); } } catch (Exception ex) { Console.WriteLine(ex); } return(listAssignRooms); }
private void icnBtnAdd_Click_1(object sender, EventArgs e) { sessionID = int.Parse(txtSessionID.Text); studentCount = int.Parse(txtStudentCount.Text); room = cmbRoom.Text; building = cmbBuilding.Text; RetireiveSessionRoomModel objRooms = new RetireiveSessionRoomModel(); AssignRoomController objRoomControl = new AssignRoomController(); objRooms.session_id = sessionID; objRooms.building = building; objRooms.room = room; objRoomControl.insertAssignedRoomToSessions(objRooms); //reset feilds txtSessionID.Text = ""; txtStudentCount.Text = ""; cmbRoom.Text = ""; cmbBuilding.Text = ""; loadData(); MessageBox.Show("Insert Successfully!"); }
public bool insertAssignedRoomToSessions(RetireiveSessionRoomModel assignSessionRoom) { try { string Query = "Insert into RoomSession(session_id,building,room) values(" + assignSessionRoom.session_id + ",'" + assignSessionRoom.building + "', '" + assignSessionRoom.room + "')"; SqlCommand cmd = new SqlCommand(Query, DBConnection.DatabaseConnection); SqlDataReader myReader; DBConnection.OpenConnection(); myReader = cmd.ExecuteReader(); while (myReader.Read()) { } DBConnection.CloseConnection(); return(true); } catch (Exception ex) { return(false); } }