Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.IO;
- namespace WindowsFormsApplication2
- {
- public partial class Remove : Form
- {
- public Remove()
- {
- InitializeComponent();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- this.Hide();
- StartScreen f = new StartScreen();
- f.ShowDialog();
- }
- Show head = null;
- Show temp;
- private void Remove_Load(object sender, EventArgs e)
- {
- int boundWidth = Screen.PrimaryScreen.Bounds.Width;
- int boundHeight = Screen.PrimaryScreen.Bounds.Height;
- int x = boundWidth - this.Width;
- int y = boundHeight - this.Height;
- this.Location = new Point(x / 2, y / 4);
- FileStream f = new FileStream("C:\\Users\\Tal\\Desktop\\School\\גלינה\\tal\\tal\\save.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite);
- StreamReader rd = new StreamReader(f);
- do
- {
- Show show = new Show();
- Actor leadActor = new Actor();
- Date birthDate = new Date();
- show.SetGenre(rd.ReadLine());
- show.SetName(rd.ReadLine());
- leadActor.SetName(rd.ReadLine());
- birthDate.SetDay(rd.ReadLine());
- birthDate.SetMonth(rd.ReadLine());
- birthDate.SetYear(rd.ReadLine());
- leadActor.SetBirthDate(birthDate);
- show.SetLeadActor(leadActor);
- show.SetNumOfSeasons(rd.ReadLine());
- show.SetYear(rd.ReadLine());
- if (head == null)
- {
- head = show;
- }
- else
- {
- temp = head;
- if (temp.GetName().CompareTo(show.GetName()) < 0)
- {
- while (temp.GetName().CompareTo(show.GetName()) < 0 && temp.GetNext() != null)
- temp = temp.GetNext();
- if (temp.GetNext() == null)
- {
- temp.SetNext(show);
- show.SetPrev(temp);
- }
- else
- {
- temp.GetPrev().SetNext(show);
- show.SetPrev(temp.GetNext());
- show.SetNext(temp);
- temp.SetPrev(show);
- }
- }
- else
- {
- head = show;
- show.SetNext(temp);
- temp.SetPrev(show);
- }
- }
- }
- while (rd.ReadLine() != null);
- rd.Close();
- f.Close();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- temp = head;
- bool exist = false;
- FileStream f = new FileStream("C:\\Users\\Tal\\Desktop\\School\\גלינה\\tal\\tal\\save.txt", FileMode.CreateNew, FileAccess.ReadWrite);
- StreamWriter wr = new StreamWriter(f);
- while (temp != null)
- {
- if (temp.GetName() != textBox1.Text)
- {
- MessageBox.Show("Test");
- wr.WriteLine(temp.GetGenre());
- wr.WriteLine(temp.GetName());
- wr.WriteLine(temp.GetLeadActor().GetName());
- wr.WriteLine(temp.GetLeadActor().GetBirthDate().GetDay());
- wr.WriteLine(temp.GetLeadActor().GetBirthDate().GetMonth());
- wr.WriteLine(temp.GetLeadActor().GetBirthDate().GetYear());
- wr.WriteLine(Convert.ToString(temp.GetNumOfSeasons()));
- wr.WriteLine(temp.GetYear());
- wr.WriteLine("~~~~~~~~~~~~~");
- temp = temp.GetNext();
- }
- else
- {
- exist = true;
- MessageBox.Show("Removed");
- temp = temp.GetNext();
- }
- }
- if(!exist)
- MessageBox.Show("The Show Doesn't Exist In The Current Database");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement