private void btnBrowse_Click(object sender, EventArgs e) { int movie_number; if (!Int32.TryParse(txtMovieNumber.Text.Trim(), out movie_number)) { MessageBox.Show(MsgBoxHelper.MustBe(lblMovieNumber.Text), "Invalid " + lblMovieNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtMovieNumber.Focus(); } else { if (movie_number > short.MaxValue) // 32767 { MessageBox.Show(MsgBoxHelper.LTETmax(lblMovieNumber.Text), "Invalid " + lblMovieNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtMovieNumber.Focus(); } else if (movie_number < short.MinValue)//-32768 { MessageBox.Show(MsgBoxHelper.GTETmin(lblMovieNumber.Text), "Invalid " + lblMovieNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtMovieNumber.Focus(); } else { Movie objMovie; try { objMovie = Movies.GetMovie(movie_number); if (objMovie == null) { MessageBox.Show(MsgBoxHelper.Selected("Movie " + lblMovieNumber.Text + " " + movie_number), "Failure", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { txtMovieTitle.Text = objMovie.movie_title; txtDescription.Text = objMovie.Description; txtMovieYearMade.Text = objMovie.movie_year_made.ToString(); cmbGenreID.SelectedValue = objMovie.genre_id; cmbMovieRating.Text = objMovie.movie_rating.Trim(); cmbMediaType.Text = objMovie.media_type; txtMovieRetailCost.Text = objMovie.movie_retail_cost.ToString(); txtCopiesOnHand.Text = objMovie.copies_on_hand.ToString(); txtImage.Text = objMovie.image; picImage.ImageLocation = objMovie.image; txtTrailer.Text = objMovie.trailer; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void btnDelete_Click(object sender, EventArgs e) { int movie_number; if (!Int32.TryParse(txtMovieNumber.Text.Trim(), out movie_number)) { MessageBox.Show(MsgBoxHelper.MustBe(lblMovieNumber.Text), "Invalid " + lblMovieNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtMovieNumber.Focus(); } else { if (movie_number > short.MaxValue) // 32767 { MessageBox.Show(MsgBoxHelper.LTETmax(lblMovieNumber.Text), "Invalid " + lblMovieNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtMovieNumber.Focus(); } else if (movie_number < short.MinValue)//-32768 { MessageBox.Show(MsgBoxHelper.GTETmin(lblMovieNumber.Text), "Invalid " + lblMovieNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtMovieNumber.Focus(); } else { Movie objMovie = new Movie(); objMovie.movie_number = movie_number; try { bool status = Movies.DeleteMovie(objMovie); if (status) { MessageBox.Show(MsgBoxHelper.Deleted("Movie"), "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); movieList = Movies.GetMovies(); movieDataGridView.DataSource = movieList; //TODO genre not -1? } else { MessageBox.Show(MsgBoxHelper.Deleted("Movie not"), "Failure", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void btnDelete_Click(object sender, EventArgs e) { int number; if (!Int32.TryParse(txtNumber.Text.Trim(), out number)) { MessageBox.Show(MsgBoxHelper.MustBe(lblNumber.Text), "Invalid " + lblNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtNumber.Focus(); } else { if (number > short.MaxValue) // 32767 { MessageBox.Show(MsgBoxHelper.LTETmax(lblNumber.Text), "Invalid " + lblNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtNumber.Focus(); } else if (number < short.MinValue)//-32768 { MessageBox.Show(MsgBoxHelper.GTETmin(lblNumber.Text), "Invalid " + lblNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtNumber.Focus(); } else { Member objMember = new Member(); objMember.number = number; try { bool status = Members.DeleteMember(objMember); if (status) { MessageBox.Show(MsgBoxHelper.Deleted("Member"), "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); memberList = Members.GetMembers(); memberDataGridView.DataSource = memberList; } else { MessageBox.Show(MsgBoxHelper.Deleted("Member not"), "Failure", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void btnDelete_Click(object sender, EventArgs e) { int id; if (!Int32.TryParse(txtID.Text.Trim(), out id)) { MessageBox.Show(MsgBoxHelper.MustBe(lblID.Text), "Invalid " + lblID.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtID.Focus(); } else { if (id > short.MaxValue) // 32767 { MessageBox.Show(MsgBoxHelper.LTETmax(lblID.Text), "Invalid " + lblID.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtID.Focus(); } else if (id < short.MinValue)//-32768 { MessageBox.Show(MsgBoxHelper.GTETmin(lblID.Text), "Invalid " + lblID.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtID.Focus(); } else { Genre objGenre = new Genre(); objGenre.id = id; objGenre.name = txtName.Text.Trim(); try { bool status = Genres.DeleteGenre(objGenre); if (status) { MessageBox.Show(MsgBoxHelper.Deleted("Genre"), "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); frmGenre_Load(sender, e); } else { MessageBox.Show(MsgBoxHelper.Deleted("Genre not"), "Failure", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void btnUpdate_Click(object sender, EventArgs e) { int id; if (!Int32.TryParse(txtID.Text.Trim(), out id)) { MessageBox.Show(MsgBoxHelper.MustBe(lblID.Text), "Invalid " + lblID.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtID.Focus(); } else { if (id > short.MaxValue) // 32767 { MessageBox.Show(MsgBoxHelper.LTETmax(lblID.Text), "Invalid " + lblID.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtID.Focus(); } else if (id < short.MinValue)//-32768 { MessageBox.Show(MsgBoxHelper.GTETmin(lblID.Text), "Invalid " + lblID.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtID.Focus(); } else if (CheckAll()) { Vendor objVendor = new Vendor(); objVendor.id = id; objVendor.name = txtName.Text.Trim(); try { bool status = Vendors.UpdateVendor(objVendor); if (status) { MessageBox.Show(MsgBoxHelper.Updated("Vendor"), "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); frmVendor_Load(sender, e); } else { MessageBox.Show(MsgBoxHelper.Updated("Vendor not"), "Failure", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void btnBrowse_Click(object sender, EventArgs e) { int id; if (!Int32.TryParse(txtID.Text.Trim(), out id)) { MessageBox.Show(MsgBoxHelper.MustBe(lblID.Text), "Invalid " + lblID.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtID.Focus(); } else { if (id > short.MaxValue) // 32767 { MessageBox.Show(MsgBoxHelper.LTETmax(lblID.Text), "Invalid " + lblID.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtID.Focus(); } else if (id < short.MinValue)//-32768 { MessageBox.Show(MsgBoxHelper.GTETmin(lblID.Text), "Invalid " + lblID.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtID.Focus(); } else { Genre objGenre; try { objGenre = Genres.GetGenre(id); if (objGenre == null) { MessageBox.Show(MsgBoxHelper.Selected("Genre " + lblID.Text + " " + id), "Failure", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { txtName.Text = objGenre.name; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void btnUpdate_Click(object sender, EventArgs e) { int number; if (!Int32.TryParse(txtNumber.Text.Trim(), out number)) { MessageBox.Show(MsgBoxHelper.MustBe(lblNumber.Text), "Invalid " + lblNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtNumber.Focus(); } else { if (number > short.MaxValue) // 32767 { MessageBox.Show(MsgBoxHelper.LTETmax(lblNumber.Text), "Invalid " + lblNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtNumber.Focus(); } else if (number < short.MinValue)//-32768 { MessageBox.Show(MsgBoxHelper.GTETmin(lblNumber.Text), "Invalid " + lblNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtNumber.Focus(); } else if (CheckAll()) { Member objMember = new Member(); Int32.TryParse(txtNumber.Text.Trim(), out number); objMember.number = number; objMember.joindate = dtpJoinDate.Value; objMember.firstname = txtFirstName.Text.Trim(); objMember.lastname = txtLastName.Text.Trim(); objMember.address = txtAddress.Text.Trim(); objMember.city = txtCity.Text.Trim(); objMember.state = txtState.Text.Trim(); objMember.zipcode = txtZipCode.Text.Trim(); objMember.phone = txtPhone.Text.Trim(); objMember.member_status = rdoActive.Checked ? "A" : "I"; objMember.login_name = txtLoginName.Text.Trim(); objMember.password = txtPassword.Text.Trim(); objMember.email = txtEmail.Text.Trim(); if (rdoEmail.Checked) { objMember.contact_method = 1; } else if (rdoFacebook.Checked) { objMember.contact_method = 2; } else if (rdoPhoneText.Checked) { objMember.contact_method = 3; } else if (rdoTwitter.Checked) { objMember.contact_method = 4; } else { objMember.contact_method = 0; } objMember.subscription_id = (int)cmbSubscriptionID.SelectedValue; objMember.photo = imageLocation; try { bool status = Members.UpdateMember(objMember); if (status) { MessageBox.Show(MsgBoxHelper.Updated("Member"), "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); memberList = Members.GetMembers(); memberDataGridView.DataSource = memberList; } else { MessageBox.Show(MsgBoxHelper.Updated("Member not"), "Failure", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void btnBrowse_Click(object sender, EventArgs e) { int number; if (!Int32.TryParse(txtNumber.Text.Trim(), out number)) { MessageBox.Show(MsgBoxHelper.MustBe(lblNumber.Text), "Invalid " + lblNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtNumber.Focus(); } else { if (number > short.MaxValue) // 32767 { MessageBox.Show(MsgBoxHelper.LTETmax(lblNumber.Text), "Invalid " + lblNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtNumber.Focus(); } else if (number < short.MinValue)//-32768 { MessageBox.Show(MsgBoxHelper.GTETmin(lblNumber.Text), "Invalid " + lblNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtNumber.Focus(); } else { Member objMember; try { objMember = Members.GetMember(number); if (objMember == null) { MessageBox.Show(MsgBoxHelper.Selected("Member " + lblNumber.Text + " " + number), "Failure", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { dtpJoinDate.Value = objMember.joindate; txtFirstName.Text = objMember.firstname.Trim(); txtLastName.Text = objMember.lastname.Trim(); txtAddress.Text = objMember.address.Trim(); txtCity.Text = objMember.city.Trim(); txtState.Text = objMember.state; txtZipCode.Text = objMember.zipcode; txtPhone.Text = objMember.phone; if (objMember.member_status == "A") { rdoActive.Checked = true; } else { rdoInactive.Checked = true; } txtLoginName.Text = objMember.login_name; txtPassword.Text = objMember.password; txtEmail.Text = objMember.email; if (objMember.contact_method == 1) { rdoEmail.Checked = true; } else if (objMember.contact_method == 2) { rdoFacebook.Checked = true; } else if (objMember.contact_method == 3) { rdoPhoneText.Checked = true; } else if (objMember.contact_method == 4) { rdoTwitter.Checked = true; } else { objMember.contact_method = 0; } cmbSubscriptionID.SelectedValue = objMember.subscription_id; imageLocation = objMember.photo; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
public bool CheckAll() { if (txtMovieTitle.Text.Trim() != string.Empty) { if (txtMovieTitle.Text.Trim().Length > Movie.movie_titleLength) { MessageBox.Show(MsgBoxHelper.LTETmax(lblMovieTitle.Text, Movie.movie_titleLength), "Invalid " + lblMovieTitle.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtMovieTitle.Focus(); return(false); } } else { MessageBox.Show(MsgBoxHelper.NotBlank(lblMovieTitle.Text), "Invalid " + lblMovieTitle.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtMovieTitle.Focus(); return(false); } if (txtDescription.Text.Trim() != string.Empty) { if (txtDescription.Text.Trim().Length > Movie.DescriptionLength) { MessageBox.Show(MsgBoxHelper.LTETmax(lblDescription.Text, Movie.DescriptionLength), "Invalid " + lblDescription.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtDescription.Focus(); return(false); } } else { MessageBox.Show(MsgBoxHelper.NotBlank(lblDescription.Text), "Invalid " + lblDescription.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtDescription.Focus(); return(false); } int movie_year_made; if (Int32.TryParse(txtMovieYearMade.Text.Trim(), out movie_year_made)) { if (movie_year_made > short.MaxValue) // 32767 { MessageBox.Show(MsgBoxHelper.LTETmax(lblMovieYearMade.Text), "Invalid " + lblMovieYearMade.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtMovieYearMade.Focus(); return(false); } else if (movie_year_made < short.MinValue)//-32768 { MessageBox.Show(MsgBoxHelper.GTETmin(lblMovieYearMade.Text), "Invalid " + lblMovieYearMade.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtMovieYearMade.Focus(); return(false); } } else { MessageBox.Show(MsgBoxHelper.MustBe(lblMovieYearMade.Text), "Invalid " + lblMovieYearMade.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtMovieYearMade.Focus(); return(false); } if (cmbGenreID.SelectedIndex == -1) { MessageBox.Show(MsgBoxHelper.NotBlank(lblGenreID.Text), "Invalid " + lblGenreID.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); cmbGenreID.Focus(); return(false); } if (cmbMovieRating.SelectedIndex == -1) { MessageBox.Show(MsgBoxHelper.NotBlank(lblMovieRating.Text), "Invalid " + lblMovieRating.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); cmbMovieRating.Focus(); return(false); } if (cmbMediaType.SelectedIndex == -1) { MessageBox.Show(MsgBoxHelper.NotBlank(lblMediaType.Text), "Invalid " + lblMediaType.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); cmbMediaType.Focus(); return(false); } float movie_retail_cost; if (float.TryParse(txtMovieRetailCost.Text.Trim(), out movie_retail_cost)) { if (movie_retail_cost > float.MaxValue) //3.40282347E+38 { MessageBox.Show(lblMovieRetailCost.Text + " must be less than or equal to " + float.MaxValue + ".", "Invalid " + lblMovieRetailCost.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtMovieRetailCost.Focus(); return(false); } else if (movie_retail_cost < 0) { MessageBox.Show(lblMovieRetailCost.Text + " must be greater than or equal to 0.00.", "Invalid " + lblMovieRetailCost.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtMovieRetailCost.Focus(); return(false); } } else { MessageBox.Show(lblMovieRetailCost.Text + " must be a monetary value (0.00 - " + float.MaxValue + ").", "Invalid " + lblMovieRetailCost.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtMovieRetailCost.Focus(); return(false); } int copies_on_hand; if (Int32.TryParse(txtCopiesOnHand.Text.Trim(), out copies_on_hand)) { if (copies_on_hand > short.MaxValue) // 32767 { MessageBox.Show(MsgBoxHelper.LTETmax(lblCopiesOnHand.Text), "Invalid " + lblCopiesOnHand.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtCopiesOnHand.Focus(); return(false); } else if (copies_on_hand < short.MinValue)//-32768 { MessageBox.Show(MsgBoxHelper.GTETmin(lblCopiesOnHand.Text), "Invalid " + lblCopiesOnHand.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtCopiesOnHand.Focus(); return(false); } } else { MessageBox.Show(lblCopiesOnHand.Text + " must be an integer (0 - " + short.MaxValue + ").", "Invalid " + lblCopiesOnHand.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtCopiesOnHand.Focus(); return(false); } if (txtImage.Text.Trim().Length > Movie.imageLength) { MessageBox.Show(MsgBoxHelper.LTETmax(lblImage.Text, Movie.imageLength), "Invalid " + lblImage.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtImage.Focus(); return(false); } if (txtTrailer.Text.Trim().Length > Movie.trailerLength) { MessageBox.Show(MsgBoxHelper.LTETmax(lblTrailer.Text, Movie.trailerLength), "Invalid " + lblTrailer.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtTrailer.Focus(); return(false); } return(true); }
private void btnUpdate_Click(object sender, EventArgs e) { int movie_number; if (!Int32.TryParse(txtMovieNumber.Text.Trim(), out movie_number)) { MessageBox.Show(MsgBoxHelper.MustBe(lblMovieNumber.Text), "Invalid " + lblMovieNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtMovieNumber.Focus(); } else { if (movie_number > short.MaxValue) // 32767 { MessageBox.Show(MsgBoxHelper.LTETmax(lblMovieNumber.Text), "Invalid " + lblMovieNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtMovieNumber.Focus(); } else if (movie_number < short.MinValue)//-32768 { MessageBox.Show(MsgBoxHelper.GTETmin(lblMovieNumber.Text), "Invalid " + lblMovieNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtMovieNumber.Focus(); } else if (CheckAll()) { Movie objMovie = new Movie(); int movie_year_made, copies_on_hand; float movie_retail_cost; objMovie.movie_number = movie_number; objMovie.movie_title = txtMovieTitle.Text.Trim(); objMovie.Description = txtDescription.Text.Trim(); Int32.TryParse(txtMovieYearMade.Text.Trim(), out movie_year_made); objMovie.movie_year_made = movie_year_made; objMovie.genre_id = (int)cmbGenreID.SelectedValue; objMovie.movie_rating = cmbMovieRating.Text; objMovie.media_type = cmbMediaType.Text; float.TryParse(txtMovieRetailCost.Text.Trim(), out movie_retail_cost); objMovie.movie_retail_cost = movie_retail_cost; Int32.TryParse(txtCopiesOnHand.Text.Trim(), out copies_on_hand); objMovie.copies_on_hand = copies_on_hand; objMovie.image = txtImage.Text.Trim(); picImage.ImageLocation = objMovie.image; objMovie.trailer = txtTrailer.Text.Trim(); try { bool status = Movies.UpdateMovie(objMovie); if (status) { MessageBox.Show(MsgBoxHelper.Updated("Movie"), "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); movieList = Movies.GetMovies(); movieDataGridView.DataSource = movieList; //TODO genre not -1? } else { MessageBox.Show(MsgBoxHelper.Updated("Movie not"), "Failure", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }