//add movies to table private void btnAddMOvie_Click(object sender, EventArgs e) { string Title, RentCost, Year, Rating, Genre, StoryLine; Title = TextBoxMOvieTitle.Text; RentCost = TextBoxRent.Text; Rating = TextBoxStarRating.Text; Year = TextBoxYear.Text; Genre = TextBoxGenre.Text; StoryLine = textBoxStoryLine.Text; if (Title == "") { MessageBox.Show("Movie title required!"); TextBoxMOvieTitle.Focus(); } else if (Year == "") { MessageBox.Show("Movie released year required!"); TextBoxYear.Focus(); } else if (Genre == "") { MessageBox.Show("Movie genre required!"); TextBoxGenre.Focus(); } else if (Rating == "") { MessageBox.Show("Movie rating required!"); TextBoxStarRating.Focus(); } else if (StoryLine == "") { MessageBox.Show("Story required!"); textBoxStoryLine.Focus(); } else { MoviesDataTbl data = new MoviesDataTbl(); data.Title = Title; data.Year = Year; data.Rating = Rating; data.Genre = Genre; data.RentCost = int.Parse(RentCost); data.StoryLine = StoryLine; if (new Movies().InsertMovie(data)) { MoviesTableGridDataBind(); // method calling to Bind Grid Movies BindDropDownMovie(); // method calling to Bind dropdown Movies MessageBox.Show("Movie Saved to Database!!"); TextBoxMOvieTitle.Text = ""; TextBoxYear.Text = ""; TextBoxStarRating.Text = ""; TextBoxGenre.Text = ""; TextBoxRent.Text = ""; textBoxStoryLine.Text = ""; } } }
//Update movie private void btnUpdate_Click(object sender, EventArgs e) { try { string MovieId = TextBoxMovieID.Text; string Title, RentCost, Year, Rating, Genre, StoryLine; Title = TextBoxMOvieTitle.Text; RentCost = TextBoxRent.Text; Rating = TextBoxStarRating.Text; Year = TextBoxYear.Text; Genre = TextBoxGenre.Text; StoryLine = textBoxStoryLine.Text; if (Title == "") { MessageBox.Show("Movie title required!"); TextBoxMOvieTitle.Focus(); } else if (Year == "") { MessageBox.Show("Movie released year required!"); TextBoxYear.Focus(); } else if (Genre == "") { MessageBox.Show("Movie genre required!"); TextBoxGenre.Focus(); } else if (RentCost == "") { MessageBox.Show("Movie rent cost required!"); } else if (StoryLine == "") { MessageBox.Show("Story required!"); textBoxStoryLine.Focus(); } else if (Rating == "") { MessageBox.Show("Movie rating required!"); TextBoxStarRating.Focus(); } else { MoviesDataTbl data = new MoviesDataTbl(); data.Title = Title; data.Year = Year; data.Rating = Rating; data.Genre = Genre; data.RentCost = int.Parse(RentCost); data.MovieId = int.Parse(MovieId); data.StoryLine = StoryLine; if (new Movies().UpdateMovie(data)) { MoviesTableGridDataBind(); BindDropDownMovie(); btnAddMOvie.Enabled = true; // enable Add movie button MessageBox.Show("Movie Updated!!"); TextBoxMovieID.Text = ""; TextBoxMOvieTitle.Text = ""; TextBoxYear.Text = ""; TextBoxStarRating.Text = ""; TextBoxGenre.Text = ""; TextBoxRent.Text = ""; textBoxStoryLine.Text = ""; } else { MessageBox.Show("Unable to update this movie!"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); DataBaseConnection.CloseConnection(); // close connection with database when error occured } }
//insert movies private void BtnAddMOvie_Click(object sender, EventArgs e) { string Title, RentCost, Year, Rating, Genre, StoryLine; Title = TextBoxMOvieTitle.Text; RentCost = TextBoxRent.Text; Rating = TextBoxStarRating.Text; Year = TextBoxYear.Text; Genre = TextBoxGenre.Text; StoryLine = textBoxStoryLine.Text; if (Title == "") { MessageBox.Show("Movie title is required!"); TextBoxMOvieTitle.Focus(); } else if (Year == "") { MessageBox.Show("Movie released year is required!"); TextBoxYear.Focus(); } else if (Genre == "") { MessageBox.Show("Movie genre is required!"); TextBoxGenre.Focus(); } else if (Rating == "") { MessageBox.Show("Movie rating is required!"); TextBoxStarRating.Focus(); } else if (StoryLine == "") { MessageBox.Show("Story Line is required!"); textBoxStoryLine.Focus(); } else { MoviesData data = new MoviesData { Title = Title, Year = Year, Rating = Rating, Genre = Genre, RentCost = int.Parse(RentCost), StoryLine = StoryLine }; if (new Movies().InsertMovie(data)) { MoviesGridViewDataBind(); // method calling to Bind Grid Movies BindDropDownMovie(); // method calling to Bind dropdown Movies MessageBox.Show("Movie Inseted Successfully!"); TextBoxMOvieTitle.Text = "Movie Title..."; TextBoxYear.Text = "Release Year..."; TextBoxStarRating.Text = "Star Rating..."; TextBoxGenre.Text = "Genre..."; TextBoxRent.Text = "($)Rent... "; textBoxStoryLine.Text = "Story Line..."; } } }
//Update movie private void BtnUpdate_Click(object sender, EventArgs e) { try { string MovieId = TextBoxMovieID.Text; string Title, RentCost, Year, Rating, Genre, StoryLine; Title = TextBoxMOvieTitle.Text; RentCost = TextBoxRent.Text; Rating = TextBoxStarRating.Text; Year = TextBoxYear.Text; Genre = TextBoxGenre.Text; StoryLine = textBoxStoryLine.Text; if (Title == "") { MessageBox.Show("Movie title is required!"); TextBoxMOvieTitle.Focus(); } else if (Year == "") { MessageBox.Show("Movie released year is required!"); TextBoxYear.Focus(); } else if (Genre == "") { MessageBox.Show("Movie genre is required!"); TextBoxGenre.Focus(); } else if (RentCost == "") { MessageBox.Show("Movie rent cost is required!"); } else if (StoryLine == "") { MessageBox.Show("Story Line is required!"); textBoxStoryLine.Focus(); } else if (Rating == "") { MessageBox.Show("Movie rating is required!"); TextBoxStarRating.Focus(); } else { MoviesData data = new MoviesData { Title = Title, Year = Year, Rating = Rating, Genre = Genre, RentCost = int.Parse(RentCost), MovieId = int.Parse(MovieId), StoryLine = StoryLine }; if (new Movies().UpdateMovie(data)) { MoviesGridViewDataBind(); BindDropDownMovie(); btnAddMOvie.Enabled = true; // enable Add movie button MessageBox.Show("Movie Updated Successfully!"); TextBoxMovieID.Text = ""; TextBoxMOvieTitle.Text = "Movie Title..."; TextBoxYear.Text = "Release Year..."; TextBoxStarRating.Text = "Star Rating..."; TextBoxGenre.Text = "Genre..."; TextBoxRent.Text = "($)Rent... "; textBoxStoryLine.Text = "Story Line..."; } else { MessageBox.Show("Unable to update this movie!"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); DataBaseConnection.CloseConnection(); // close connection with database when error occured } }
public void getData() { if (string.IsNullOrEmpty(TextBoxName.Text)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Eksik Alan", "<script>alert('Kullanıcı adını giriniz');</script>"); TextBoxName.Focus(); } else if (string.IsNullOrEmpty(TextBoxEmail.Text)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Eksik Alan", "<script>alert('Email adresini giriniz');</script>"); TextBoxEmail.Focus(); } else { newFilterInfo.UserName = TextBoxName.Text; newFilterInfo.Email = TextBoxEmail.Text; newFilterInfo.Brand = DropDownList1.SelectedItem.Text.ToLower(); newFilterInfo.Series = DropDownList2.SelectedItem.Text.ToLower(); int kmValid; if (string.IsNullOrEmpty(TextBoxKm.Text)) { newFilterInfo.MaxKm = null; } else if (!int.TryParse(TextBoxKm.Text, out kmValid)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Yanlış formatlı giriş", "<script>alert('Maksimum Kilometre alanı sadece sayı değerleri içermelidir');</script>"); TextBoxKm.Focus(); } else { newFilterInfo.MaxKm = TextBoxKm.Text; } int fiyatValid; if (string.IsNullOrEmpty(TextBoxFiyat.Text)) { newFilterInfo.MaxPrice = null; } else if (!int.TryParse(TextBoxFiyat.Text, out fiyatValid)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Yanlış formatlı giriş", "<script>alert('Maksimum Fiyat alanı sadece sayı değerleri içermelidir');</script>"); TextBoxFiyat.Focus(); } else { newFilterInfo.MaxPrice = TextBoxFiyat.Text; } int yearValid; if (string.IsNullOrEmpty(TextBoxYear.Text)) { newFilterInfo.MinModelYear = null; } else if (!int.TryParse(TextBoxYear.Text, out yearValid)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Yanlış formatlı giriş", "<script>alert('Minimum model yılı alanı sadece sayı değerleri içermelidir');</script>"); TextBoxYear.Focus(); } else { newFilterInfo.MinModelYear = TextBoxYear.Text; } int yearValid1; if (string.IsNullOrEmpty(TextBoxYear1.Text)) { newFilterInfo.MaxModelYear = null; } else if (!int.TryParse(TextBoxYear1.Text, out yearValid1)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Yanlış formatlı giriş", "<script>alert('Maksimum model yılı alanı sadece sayı değerleri içermelidir');</script>"); TextBoxYear.Focus(); } else { newFilterInfo.MaxModelYear = TextBoxYear1.Text; } newFilterInfo.Color = RadioButtonList1.SelectedValue.ToString(); Parser.brandName = newFilterInfo.Brand; Parser.seriesName = newFilterInfo.Series; string totalURL = goSelectedUrl(); Parser.getUrl(totalURL); // create url to take the data Parser.makeClient(); // create client Parser.getHTML(); // load html file Parser.getCarList(carList); // store filtered car list locally carList.Sort((x, y) => x.MONEY.CompareTo(y.MONEY)); Parser.storeList(carList); // copy the car list to action layer Parser.getUserData(newFilterInfo.UserName, newFilterInfo.Email); // copy the user data to action layer } }