public MediaDAO() { mediaDataSet = new MediaDS(); tabMediaAdapter = new TabMediaTableAdapter(); viewMediaTableAdapter = new ViewMediaTableAdapter(); tabGenreTableAdapter = new TabGenreTableAdapter(); tabLanguageTableAdapter = new TabLanguageTableAdapter(); tabDirectorTableAdapter = new TabDirectorTableAdapter(); }
public MediaDAO() { mediaDataSet = new MediaDS(); viewMediaAdapter = new ViewMediaTableAdapter(); languageTableAdapter = new TabLanguageTableAdapter(); genreTableAdapter = new TabGenreTableAdapter(); tabMediaTableAdapter = new TabMediaTableAdapter(); borrowTableAdapter = new TabBorrowTableAdapter(); reservedTableAdapter = new TabReservedTableAdapter(); }
public MediaDAO() { viewMediaAdapter = new ViewMediaTableAdapter(); genreTableAdapter = new TabGenreTableAdapter(); tabMediaTableAdapter = new TabMediaTableAdapter(); languageTableAdapter = new TabLanguageTableAdapter(); directorTableAdapter = new TabDirectorTableAdapter(); tabReserveTableAdapter = new TabReservedTableAdapter(); tabBorrowTableAdapter = new TabBorrowTableAdapter(); }
public MediaDAO() { mediaDataSet = new MediaDS(); viewMediaTableAdapter = new ViewMediaTableAdapter(); languageTableAdapter = new TabLanguageTableAdapter(); genreTableAdapter = new TabGenreTableAdapter(); directorTableAdapter = new TabDirectorTableAdapter(); MediaTableAdapter = new TabMediaTableAdapter(); reserveTableAdapter = new TabReservedTableAdapter(); borrowTableAdapter = new TabBorrowTableAdapter(); returnTableAdapter = new TabReturnTableAdapter(); }
//if we need TabMediaTableAdapter, we'll add it later :/ public MediaDAO() { mediaDataSet = new MediaDS(); viewMediaAdapter = new ViewMediaTableAdapter(); languageTableAdapter = new TabLanguageTableAdapter(); genreTableAdapter = new TabGenreTableAdapter(); mediaTableAdapter = new TabMediaTableAdapter(); directorTableAdapter = new TabDirectorTableAdapter(); reservedTableAdapter = new TabReservedTableAdapter(); borrowTableAdapter = new TabBorrowTableAdapter(); viewMediaAvailavleAdapter = new ViewMediaAvailableTableAdapter(); viewMediaBorrwedAdapter = new ViewMediaBorrowedTableAdapter(); }
// get the list of borrowed media, including additional information public List <BorrowDTO> GetBorrowInfo() { // list of borrowed media with full info List <BorrowDTO> BorrowedMediaList = new List <BorrowDTO>(); try { // get data from Borrow Table tabBorrowTableAdapter.SelectBorrow(tabBorrowDataTable); // assign each data row to an item of BorrowedMediaList foreach (DataRow borrowRow in tabBorrowDataTable.Rows) { int uID = (int)borrowRow["UID"]; int mediaID = (int)borrowRow["MediaID"]; string title = ""; string userName = ""; // get title of borrowed media MediaDataSet.TabMediaDataTable tabMediaDataTable = new MediaDataSet.TabMediaDataTable(); TabMediaTableAdapter tabMediaTableAdapter = new TabMediaTableAdapter(); tabMediaTableAdapter.SelectMediaByMediaID(tabMediaDataTable, mediaID); foreach (DataRow mediaRow in tabMediaDataTable.Rows) { title = (string)mediaRow["Title"]; } // get name of user who borrowed the media UserDataSet.TabUserDataTable tabUserDataTable = new UserDataSet.TabUserDataTable(); TabUserTableAdapter UserAdapter = new TabUserTableAdapter(); UserAdapter.SelectUserByUID(tabUserDataTable, uID); foreach (DataRow userRow in tabUserDataTable.Rows) { userName = (string)userRow["UserName"]; } BorrowedMediaList.Add(new BorrowDTO(userName, title, borrowRow["BorrowDate"].ToString(), borrowRow["ReturnDate"].ToString(), borrowRow["ActualReturnDate"].ToString())); } } catch (Exception e) { Console.WriteLine(e.Message); } return(BorrowedMediaList); }
// get the list of reserved media, including additional info public List <ReserveDTO> GetReservedInfo() { List <ReserveDTO> ReservedMediaList = new List <ReserveDTO>(); try { //Query get reservation records tabReservedTableAdapter.SelectReserved(tabReservedDataTable); foreach (DataRow reservedRow in tabReservedDataTable.Rows) { int uID = (int)reservedRow["UID"]; int mediaID = (int)reservedRow["MediaID"]; string title = ""; string userName = ""; // get title of reserved media MediaDataSet.TabMediaDataTable tabMediaDataTable = new MediaDataSet.TabMediaDataTable(); TabMediaTableAdapter tabMediaTableAdapter = new TabMediaTableAdapter(); tabMediaTableAdapter.SelectMediaByMediaID(tabMediaDataTable, mediaID); foreach (DataRow mediaRow in tabMediaDataTable.Rows) { title = (string)mediaRow["Title"]; } // get name of user who reserved the media UserDataSet.TabUserDataTable tabUserDataTable = new UserDataSet.TabUserDataTable(); TabUserTableAdapter tabUserTableAdapter = new TabUserTableAdapter(); tabUserTableAdapter.SelectUserByUID(tabUserDataTable, uID); foreach (DataRow userRow in tabUserDataTable.Rows) { userName = (string)userRow["UserName"]; } ReservedMediaList.Add(new ReserveDTO(userName, title, reservedRow["ReservedDate"].ToString())); } } catch (Exception e) { Console.WriteLine(e.Message); } return(ReservedMediaList); }
public void DeleteMedia(int MediaID) { var mediaTable = new UserData.TabMediaDataTable(); var mediaAdapter = new TabMediaTableAdapter(); int rowCount = mediaAdapter.DeleteMedia(MediaID); }
//constructor public MediaDataAccessObject() { _mediaDataSet = new MediaDataSet(); _mediaTabTableAdapter = new TabMediaTableAdapter(); }
public List <MediaDTO> Search(string searchType, string searchText) { // list for storing media from search result List <MediaDTO> foundMediaList = new List <MediaDTO>(); MediaDataSet.TabMediaDataTable tabMediaDataTable = new MediaDataSet.TabMediaDataTable(); TabMediaTableAdapter tabMediaTableAdapter = new TabMediaTableAdapter(); try { // get results by query based on search type switch (searchType) { case "Title": searchText = "%" + searchText + "%"; tabMediaTableAdapter.SelectMediaByTitle(tabMediaDataTable, searchText); break; case "Genre": searchText = "%" + searchText + "%"; tabMediaTableAdapter.SelectMediaByGenreName(tabMediaDataTable, searchText); break; case "Director": searchText = "%" + searchText + "%"; tabMediaTableAdapter.SelectMediaByDirectorName(tabMediaDataTable, searchText); break; case "Language": searchText = "%" + searchText + "%"; tabMediaTableAdapter.SelectMediaByLanguageName(tabMediaDataTable, searchText); break; case "PublishYear": tabMediaTableAdapter.SelectMediaByPublishYear(tabMediaDataTable, Convert.ToInt32(searchText)); break; case "Budget": tabMediaTableAdapter.SelectMediaByBudget(tabMediaDataTable, Convert.ToDecimal(searchText)); break; default: tabMediaTableAdapter.Fill(tabMediaDataTable); break; } } catch (FormatException e) { Console.WriteLine(e.Message); try { tabMediaTableAdapter.Fill(tabMediaDataTable); } catch (Exception ex) { Console.WriteLine(ex.Message); } } catch (Exception e) { Console.WriteLine(e.Message); try { tabMediaTableAdapter.Fill(tabMediaDataTable); } catch (Exception ex) { Console.WriteLine(ex.Message); } } // convert raw data from table into media objects foreach (DataRow mediaRow in tabMediaDataTable.Rows) { MediaDTO media = new MediaDTO { MediaID = Convert.ToInt32(mediaRow[0]), Title = mediaRow[1].ToString(), Genre = mediaRow[4].ToString(), Director = mediaRow[5].ToString(), Language = mediaRow[6].ToString(), PublishYear = Convert.ToInt32(mediaRow[2]), Budget = Convert.ToDecimal(mediaRow[3]) }; foundMediaList.Add(media); } return(foundMediaList); }