private void AddToWishlist_Click(object sender, EventArgs e) { DVDExpressDataContext db = new DVDExpressDataContext(); Table <Wishlist> Wishlists = db.GetTable <Wishlist>(); Table <Movie> Movies = db.GetTable <Movie>(); var getCorrectWishlist = from wishlist in Wishlists where (wishlist.Title == WishlistBox.SelectedItem && wishlist.MemberID == userAccount.MemberID) select wishlist; var getCorrectMovie = from movie in Movies where movie.Title == MovieList.SelectedCells[0].Value.ToString() select movie; foreach (Wishlist wishlist in getCorrectWishlist) { foreach (Movie movie in getCorrectMovie) { wishlist.MovieID = movie.MovieID; } } db.SubmitChanges(); MessageBox.Show("Movie Added to Wishlist!"); }
private void SaveButton_Click(object sender, EventArgs e) { string newPassword = ConfirmPasswordEntry.Text; string oldPassword = OldPasswordEntry.Text; DVDExpressDataContext db = new DVDExpressDataContext(); Table <Login> Logins = db.GetTable <Login>(); if (newPassword != NewPasswordEntry.Text) { MessageBox.Show("Error: New passwords don't match."); return; } var query = from login in Logins where login.MemberID == userAccount.MemberID select login; foreach (Login login in query) { if (login.Password == oldPassword) { login.Password = newPassword; } else { MessageBox.Show("Error: Old password incorrect."); return; } } db.SubmitChanges(); MessageBox.Show("Password Updated!"); }
private void WishlistBox_SelectedIndexChanged(object sender, EventArgs e) { DVDExpressDataContext db = new DVDExpressDataContext(); Table <Wishlist> Wishlists = db.GetTable <Wishlist>(); Table <Movie> Movies = db.GetTable <Movie>(); var getCorrectWishlist = from wishlist in Wishlists where wishlist.Title == WishlistBox.SelectedItem select wishlist; DataTable MoviesInWishlist = new DataTable(); MoviesInWishlist.Columns.Add("Title"); MoviesInWishlist.Columns.Add("Genre"); MoviesInWishlist.Columns.Add("Run Time"); MoviesInWishlist.Columns.Add("Rating"); foreach (Wishlist wishlist in getCorrectWishlist) { var getCorrectMovies = from movie in Movies where movie.MovieID == wishlist.MovieID select movie; foreach (Movie movie in getCorrectMovies) { MoviesInWishlist.Rows.Add(movie.Title, movie.Genre, movie.RunTime, movie.Rating); } } WishlistView.DataSource = MoviesInWishlist; }
private void SaveButton_Click(object sender, EventArgs e) { DVDExpressDataContext db = new DVDExpressDataContext(); Table <Movie> Movies = db.GetTable <Movie>(); var getMovieID = from movie in Movies orderby movie.MovieID descending select movie.MovieID; int newMovieID = getMovieID.First() + 1; Movie newMovie = new Movie { MovieID = newMovieID, Title = TitleBox.Text, Genre = GenreBox.Text, ReleaseDate = ReleaseDateBox.Value, RunTime = RuntimeBox.Text, Rating = RatingBox.Text, DaysForRent = 14 }; db.Movies.InsertOnSubmit(newMovie); db.SubmitChanges(); MessageBox.Show("New Movie Added!"); }
private void TransReport_Load(object sender, EventArgs e) { DVDExpressDataContext db = new DVDExpressDataContext(); Table <Transaction> Transactions = db.GetTable <Transaction>(); var getAllTransactions = from transaction in Transactions select transaction; DataTable transactionList = new DataTable(); transactionList.Columns.Add("Transaction ID"); transactionList.Columns.Add("Account ID"); transactionList.Columns.Add("Movie ID"); transactionList.Columns.Add("Reward ID"); transactionList.Columns.Add("Rent Date"); transactionList.Columns.Add("Due Date"); transactionList.Columns.Add("Total"); foreach (Transaction transaction in getAllTransactions) { transactionList.Rows.Add(transaction.TransactionID, transaction.AccountID, transaction.MovieID, transaction.RewardID, transaction.RentDate, transaction.DueDate, transaction.Total); } TransactionList.DataSource = transactionList; }
private void AddWishlist_Click(object sender, EventArgs e) { DVDExpressDataContext db = new DVDExpressDataContext(); Table <Wishlist> Wishlists = db.GetTable <Wishlist>(); var getNextWishlistID = from wishlist in Wishlists orderby wishlist.WishlistID descending select wishlist.WishlistID; int newWishlistID = getNextWishlistID.First() + 1; if (!NewWishlistName.Text.Any()) { MessageBox.Show("Error: Please enter a name for your new wishlist."); return; } Wishlist newWishlist = new Wishlist { WishlistID = newWishlistID, MovieID = null, Title = NewWishlistName.Text, MemberID = userAccount.MemberID }; db.Wishlists.InsertOnSubmit(newWishlist); db.SubmitChanges(); MessageBox.Show("New Wishlist Created!"); }
private void _M_ViewCart_Load(object sender, EventArgs e) { DVDExpressDataContext db = new DVDExpressDataContext(); Table <Movie> Movies = db.GetTable <Movie>(); Table <Transaction> Transactions = db.GetTable <Transaction>(); var getTransactions = from transaction in Transactions where (transaction.AccountID == userAccount.AccountID && transaction.RentDate == null) select transaction; DataTable TransactionTable = new DataTable(); TransactionTable.Columns.Add("Movie Name"); TransactionTable.Columns.Add("Movie Genre"); TransactionTable.Columns.Add("Movie Rating"); foreach (Transaction transaction in getTransactions) { var getMovies = from movie in Movies where movie.MovieID == transaction.MovieID select movie; foreach (Movie movie in getMovies) { TransactionTable.Rows.Add(movie.Title, movie.Genre, movie.Rating); } } MovieList.DataSource = TransactionTable; }
private void MovieReport_Load(object sender, EventArgs e) { DVDExpressDataContext db = new DVDExpressDataContext(); Table <Movie> Movies = db.GetTable <Movie>(); var getAllMovies = from movie in Movies select movie; DataTable movieList = new DataTable(); movieList.Columns.Add("Movie ID"); movieList.Columns.Add("Title"); movieList.Columns.Add("Genre"); movieList.Columns.Add("Release Date"); movieList.Columns.Add("Run Time"); movieList.Columns.Add("Rating"); movieList.Columns.Add("Days For Rent"); foreach (Movie movie in getAllMovies) { movieList.Rows.Add(movie.MovieID, movie.Title, movie.Genre, movie.ReleaseDate, movie.RunTime, movie.Rating, movie.DaysForRent); } MovieList.DataSource = movieList; }
private void CustAcctReport_Load(object sender, EventArgs e) { DVDExpressDataContext db = new DVDExpressDataContext(); Table <Member> Members = db.GetTable <Member>(); var getAllMembers = from member in Members select member; DataTable memberList = new DataTable(); memberList.Columns.Add("Member ID"); memberList.Columns.Add("Account ID"); memberList.Columns.Add("First Name"); memberList.Columns.Add("Last Name"); memberList.Columns.Add("DOB"); memberList.Columns.Add("Address 1"); memberList.Columns.Add("Address 2"); memberList.Columns.Add("City"); memberList.Columns.Add("State"); memberList.Columns.Add("ZIP"); memberList.Columns.Add("Phone"); foreach (Member member in getAllMembers) { memberList.Rows.Add(member.MemberID, member.AccountID, member.FirstName, member.LastName, member.DOB, member.Address1, member.Address2, member.City, member.State, member.Zip, member.Phone); } MemberList.DataSource = memberList; }
private void SearchBox_TextChanged(object sender, EventArgs e) { DVDExpressDataContext db = new DVDExpressDataContext(); Table <Movie> Movies = db.GetTable <Movie>(); string searchText = SearchBox.Text; var query = from mov in Movies where mov.Title.Contains(searchText) select mov; DataTable SearchedMovies = new DataTable(); SearchedMovies.Columns.Add("Movie ID"); SearchedMovies.Columns.Add("Title"); SearchedMovies.Columns.Add("Genre"); SearchedMovies.Columns.Add("Run Time"); SearchedMovies.Columns.Add("Rating"); SearchedMovies.Columns.Add("Days for rent"); foreach (var mov in query) { SearchedMovies.Rows.Add(mov.MovieID, mov.Title, mov.Genre, mov.RunTime, mov.Rating, mov.DaysForRent); } MovieList.DataSource = SearchedMovies; }
private void SaveChanges_Click(object sender, EventArgs e) { DVDExpressDataContext db = new DVDExpressDataContext(); Table <Member> Members = db.GetTable <Member>(); Table <Login> Logins = db.GetTable <Login>(); var memQuery = from member in Members where member.MemberID == userAccount.MemberID select member; var loginQuery = from login in Logins where login.MemberID == userAccount.MemberID select login; //make sure new username isn't already taken var checkUsername = from login in Logins where login.Username == UsernameEntry.Text select login; if (checkUsername.Any() || !UsernameEntry.Text.Any()) { MessageBox.Show("Error: Username is already taken, or the field was left blank."); return; } //update stuff foreach (Member member in memQuery) { if (FirstNameEntry.Text.Any()) { member.FirstName = FirstNameEntry.Text; } if (LastNameEntry.Text.Any()) { member.LastName = LastNameEntry.Text; } member.DOB = DOBEntry.Value; } foreach (Login login in loginQuery) { Login newLogin = new Login { Username = UsernameEntry.Text, MemberID = userAccount.MemberID, Password = login.Password, IsAdmin = login.IsAdmin }; db.Logins.InsertOnSubmit(newLogin); db.Logins.DeleteOnSubmit(login); } db.SubmitChanges(); MessageBox.Show("Account information updated!"); }
private void AddToCart_Click(object sender, EventArgs e) { DVDExpressDataContext db = new DVDExpressDataContext(); Table <Movie> Movies = db.GetTable <Movie>(); Table <Transaction> Transactions = db.GetTable <Transaction>(); var getTransactions = from transaction in Transactions where (transaction.AccountID == userAccount.AccountID && transaction.RentDate == null) select transaction; var getTID = from transaction in Transactions orderby transaction.TransactionID descending select transaction.TransactionID; int newTID = getTID.First() + 1; var getCorrectMovie = from movie in Movies where movie.Title == MovieList.SelectedCells[0].Value.ToString() select movie; Transaction newTransaction = new Transaction { TransactionID = 0, AccountID = userAccount.AccountID, MovieID = null, RewardID = null, RentDate = null, DueDate = null, Total = null }; foreach (Transaction transaction in getTransactions) { newTransaction.TransactionID = transaction.TransactionID; if (!transaction.TransactionID.ToString().Any()) { newTransaction.TransactionID = newTID; } foreach (Movie movie in getCorrectMovie) { newTransaction.MovieID = movie.MovieID; } } db.Transactions.InsertOnSubmit(newTransaction); db.SubmitChanges(); MessageBox.Show("Movie Added to Cart!"); }
private void _M_ViewWishlists_Load(object sender, EventArgs e) { DVDExpressDataContext db = new DVDExpressDataContext(); Table <Wishlist> Wishlists = db.GetTable <Wishlist>(); Table <Movie> MoviesInWishlist = db.GetTable <Movie>(); var matchWishlists = from wishlist in Wishlists where wishlist.MemberID == userAccount.MemberID select wishlist; List <string> userWishlists = new List <string>(); foreach (Wishlist wishlist in matchWishlists) { userWishlists.Add(wishlist.Title); } WishlistBox.DataSource = userWishlists; }
private void SaveButton_Click(object sender, EventArgs e) { DVDExpressDataContext db = new DVDExpressDataContext(); Table <Movie> Movies = db.GetTable <Movie>(); int MovieID; int.TryParse(MovieIDBox.Text, out MovieID); var getMovie = from movie in Movies where movie.MovieID == MovieID select movie; foreach (Movie movie in getMovie) { if (TitleBox.Text.Any()) { movie.Title = TitleBox.Text; } if (GenreBox.Text.Any()) { movie.Genre = GenreBox.Text; } if (ReleaseDateBox.Text.Any()) { movie.ReleaseDate = ReleaseDateBox.Value; } if (RuntimeBox.Text.Any()) { movie.RunTime = RuntimeBox.Text; } if (RatingBox.Text.Any()) { movie.Rating = RatingBox.Text; } } db.SubmitChanges(); MessageBox.Show("Movie Entry Updated!"); }
private void _M_Search_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 's2T5DataSet.Movie' table. You can move, or remove it, as needed. this.movieTableAdapter.Fill(this.s2T5DataSet.Movie); DVDExpressDataContext db = new DVDExpressDataContext(); Table <Wishlist> Wishlists = db.GetTable <Wishlist>(); Table <Movie> Movies = db.GetTable <Movie>(); var matchWishlists = from wishlist in Wishlists where wishlist.MemberID == userAccount.MemberID select wishlist; List <string> userWishlists = new List <string>(); foreach (Wishlist wishlist in matchWishlists) { userWishlists.Add(wishlist.Title); } WishlistBox.DataSource = userWishlists; }
private void SaveButton_Click(object sender, EventArgs e) { DVDExpressDataContext db = new DVDExpressDataContext(); Table <Member> Members = db.GetTable <Member>(); var query = from member in Members where member.MemberID == userAccount.MemberID select member; int newZIP; int.TryParse(ZIPEntry.Text, out newZIP); foreach (Member member in query) { if (Address1Text.Text.Any()) { member.Address1 = Address1Text.Text; } if (Address2Text.Text.Any()) { member.Address2 = Address2Text.Text; } if (CityText.Text.Any()) { member.City = CityText.Text; } if (StateEntry.Text.Any()) { member.State = StateEntry.Text; } if (ZIPEntry.Text.Any()) { member.Zip = newZIP; } } db.SubmitChanges(); MessageBox.Show("Address updated!"); }
private void DeleteButton_Click(object sender, EventArgs e) { DVDExpressDataContext db = new DVDExpressDataContext(); Table <Movie> Movies = db.GetTable <Movie>(); int MovieID; int.TryParse(MovieIDBox.Text, out MovieID); var getMovieDelete = from movie in Movies where movie.MovieID == MovieID select movie; foreach (Movie movie in getMovieDelete) { db.Movies.DeleteOnSubmit(movie); } db.SubmitChanges(); MessageBox.Show("Movie Deleted."); MovieIDBox.Clear(); }
private void UpdateButton_Click(object sender, EventArgs e) { DVDExpressDataContext db = new DVDExpressDataContext(); Table <Account> Accounts = db.GetTable <Account>(); var query = from account in Accounts where account.AccountID == userAccount.AccountID select account; long newCardNo; long.TryParse(CardNumberText.Text, out newCardNo); int newCVV; int.TryParse(CVVText.Text, out newCVV); foreach (Account account in query) { if (CardNumberText.Text.Any()) { account.CardNumber = newCardNo; } if (CVVText.Text.Any()) { account.CVV = newCVV; } if (ExpDateEntry.Text.Any()) { account.ExpirationDate = ExpDateEntry.Text; } } db.SubmitChanges(); MessageBox.Show("Payment information updated!"); }
private void AdminLogin_Click(object sender, EventArgs e) { DVDExpressDataContext db = new DVDExpressDataContext(); Table <Login> Logins = db.GetTable <Login>(); Table <Member> Members = db.GetTable <Member>(); string username = UsernameBox.Text; string password = PasswordBox.Text; bool loginSuccessful = false; var loginQuery = from login in db.Logins where (login.Username == username && login.Password == password && login.IsAdmin == true) select login.MemberID; foreach (var login in loginQuery) { var memberQuery = from account in db.Members where account.MemberID == login select account; foreach (var account in memberQuery) { AdminMainPage homePage = new AdminMainPage(); homePage.adminAccount = account; homePage.Show(); MessageBox.Show("Login Succesful"); loginSuccessful = true; this.Hide(); } } if (loginSuccessful == false) { MessageBox.Show("Incorrect Username or Password."); } }
private void ConfirmProfileButton_Click(object sender, EventArgs e) { DVDExpressDataContext db = new DVDExpressDataContext(); Table <Account> Accounts = db.GetTable <Account>(); Table <Login> Logins = db.GetTable <Login>(); Table <Member> Members = db.GetTable <Member>(); //make sure entered passwords match if (PasswordEntry.Text != ConfirmPassword.Text) { MessageBox.Show("Error: Passwords don't match"); return; } //generate new IDs var acctIDQuery = from account in Accounts orderby account.AccountID descending select account.AccountID; int newAcctID = acctIDQuery.First() + 1; var memIDQuery = from member in Members orderby member.MemberID descending select member.MemberID; int newMemID = memIDQuery.First() + 1; //make sure new username isn't taken var checkUsername = from login in Logins where login.Username == UsernameEntry.Text select login; if (checkUsername.Any()) { MessageBox.Show("Error: Username is already taken"); return; } //generate new member, account, and login int newZIP; int.TryParse(ZIPEntry.Text, out newZIP); Member newMem = new Member { MemberID = newMemID, AccountID = newAcctID, FirstName = FirstNameEntry.Text, LastName = LastNameEntry.Text, DOB = DOBEntry.Value, Address1 = Address1Entry.Text, Address2 = "", City = CityEntry.Text, State = StateEntry.Text, Zip = newZIP, Phone = PhoneEntry.Text, }; Login newLogin = new Login { Username = UsernameEntry.Text, MemberID = newMemID, Password = ConfirmPassword.Text, IsAdmin = false, }; long newCardNo; long.TryParse(CreditCardEntry.Text, out newCardNo); int newCVV; int.TryParse(CCNEntry.Text, out newCVV); Account newAcct = new Account { AccountID = newAcctID, MemStatus = "Bronze", Balance = 0, CardNumber = newCardNo, PaymentType = true, ExpirationDate = ExpirDateEntry.Text, CVV = newCVV, }; //submit changes to DB db.Accounts.InsertOnSubmit(newAcct); db.Logins.InsertOnSubmit(newLogin); db.Members.InsertOnSubmit(newMem); db.SubmitChanges(); MessageBox.Show("Account Created!"); }