private void buttonSearch_Click(object sender, EventArgs e) { bool found = false; BUS.MovieLibrary oneMovie = new BUS.MovieLibrary(); foreach (BUS.MovieLibrary element in this.myMovieList) { if (element.Number == Convert.ToInt32(textBoxSearch.Text)) { found = true; oneMovie = element; } } if (found) { MessageBox.Show("Account Found..."); MessageBox.Show(oneMovie.Number + "\t" + oneMovie.Title); } else { MessageBox.Show("..Account NOT Found..."); } }
private void buttonReadTxt_Click(object sender, EventArgs e) { myMovieList.Clear(); this.listViewMovieLibrary.Items.Clear(); StreamReader reader = new StreamReader(path); String line = null; while ((line = reader.ReadLine()) != null) { BUS.MovieLibrary anMovie = new BUS.MovieLibrary(); String[] tokens = line.Split('|'); anMovie.Number = Convert.ToInt32(tokens[0]); anMovie.Title = tokens[1]; anMovie.Genre = (EnumMovieGenre)Enum.Parse(typeof(EnumMovieGenre), tokens[2]); anMovie.Country = (EnumCountry)Enum.Parse(typeof(EnumCountry), tokens[3]); anMovie.Language = (EnumLanguage)Enum.Parse(typeof(EnumLanguage), tokens[4]); anMovie.Duration = Convert.ToInt32(tokens[5]); Date anDuration = new Date(); anDuration.Year = Convert.ToInt32(tokens[6]); anMovie.RegDate = DateTime.Parse(tokens[7]); myMovieList.Add(anMovie); anMovie.RelDate = anDuration; } foreach (BUS.MovieLibrary element in myMovieList) { ListViewItem item = new ListViewItem(Convert.ToString(element.Number)); item.SubItems.Add(element.Title); item.SubItems.Add(Convert.ToString(element.Genre)); item.SubItems.Add(Convert.ToString(element.Country)); item.SubItems.Add(Convert.ToString(element.Language)); item.SubItems.Add(Convert.ToString(element.Duration)); item.SubItems.Add(Convert.ToString(element.RelDate.Year)); item.SubItems.Add(Convert.ToString(element.RegDate)); this.listViewMovieLibrary.Items.Add(item); } reader.Close(); }
private void buttonAdd_Click(object sender, EventArgs e) { BUS.MovieLibrary anMovie = new BUS.MovieLibrary(); //declaration & initialization Date reldate = new Date(); String input; String input2; int number; String title; int duration; // int year; // String y; title = textBoxTitle.Text; reldate.Year = Convert.ToInt32(this.textBoxYear.Text); BUS.EnumCountry country; BUS.EnumLanguage language; BUS.EnumMovieGenre genre; input = textBoxNumber.Text; number = Convert.ToInt32(input); input2 = textBoxDuration.Text; duration = Convert.ToInt32(input2); // y = textBoxYear.Text; // year = Convert.ToInt32(y); genre = (BUS.EnumMovieGenre)comboBoxGenre.SelectedIndex; country = (BUS.EnumCountry)comboBoxCountry.SelectedIndex; language = (BUS.EnumLanguage)comboBoxLanguage.SelectedIndex; anMovie.Number = number; anMovie.Title = title; anMovie.Genre = genre; anMovie.Country = country; anMovie.Duration = duration; anMovie.Language = language; anMovie.RelDate = reldate; anMovie.RegDate = this.dateTimePickerRegDate.Value; this.myMovieList.Add(anMovie); textBoxCounter.Text = Convert.ToString(BUS.MovieLibrary.Counter); }