Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.53 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.IO;
  10.  
  11. namespace WindowsFormsApplication2
  12. {
  13. public partial class Remove : Form
  14. {
  15. public Remove()
  16. {
  17. InitializeComponent();
  18. }
  19.  
  20. private void button2_Click(object sender, EventArgs e)
  21. {
  22. this.Hide();
  23. StartScreen f = new StartScreen();
  24. f.ShowDialog();
  25. }
  26. Show head = null;
  27. Show temp;
  28. private void Remove_Load(object sender, EventArgs e)
  29. {
  30. int boundWidth = Screen.PrimaryScreen.Bounds.Width;
  31. int boundHeight = Screen.PrimaryScreen.Bounds.Height;
  32. int x = boundWidth - this.Width;
  33. int y = boundHeight - this.Height;
  34. this.Location = new Point(x / 2, y / 4);
  35.  
  36. FileStream f = new FileStream("C:\\Users\\Tal\\Desktop\\School\\גלינה\\tal\\tal\\save.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite);
  37. StreamReader rd = new StreamReader(f);
  38. do
  39. {
  40. Show show = new Show();
  41. Actor leadActor = new Actor();
  42. Date birthDate = new Date();
  43. show.SetGenre(rd.ReadLine());
  44. show.SetName(rd.ReadLine());
  45. leadActor.SetName(rd.ReadLine());
  46. birthDate.SetDay(rd.ReadLine());
  47. birthDate.SetMonth(rd.ReadLine());
  48. birthDate.SetYear(rd.ReadLine());
  49. leadActor.SetBirthDate(birthDate);
  50. show.SetLeadActor(leadActor);
  51. show.SetNumOfSeasons(rd.ReadLine());
  52. show.SetYear(rd.ReadLine());
  53. if (head == null)
  54. {
  55. head = show;
  56. }
  57. else
  58. {
  59. temp = head;
  60. if (temp.GetName().CompareTo(show.GetName()) < 0)
  61. {
  62. while (temp.GetName().CompareTo(show.GetName()) < 0 && temp.GetNext() != null)
  63. temp = temp.GetNext();
  64. if (temp.GetNext() == null)
  65. {
  66. temp.SetNext(show);
  67. show.SetPrev(temp);
  68. }
  69. else
  70. {
  71. temp.GetPrev().SetNext(show);
  72. show.SetPrev(temp.GetNext());
  73. show.SetNext(temp);
  74. temp.SetPrev(show);
  75. }
  76. }
  77. else
  78. {
  79. head = show;
  80. show.SetNext(temp);
  81. temp.SetPrev(show);
  82. }
  83. }
  84. }
  85. while (rd.ReadLine() != null);
  86. rd.Close();
  87. f.Close();
  88. }
  89.  
  90. private void button1_Click(object sender, EventArgs e)
  91. {
  92. temp = head;
  93. bool exist = false;
  94. FileStream f = new FileStream("C:\\Users\\Tal\\Desktop\\School\\גלינה\\tal\\tal\\save.txt", FileMode.CreateNew, FileAccess.ReadWrite);
  95. StreamWriter wr = new StreamWriter(f);
  96. while (temp != null)
  97. {
  98. if (temp.GetName() != textBox1.Text)
  99. {
  100. MessageBox.Show("Test");
  101. wr.WriteLine(temp.GetGenre());
  102. wr.WriteLine(temp.GetName());
  103. wr.WriteLine(temp.GetLeadActor().GetName());
  104. wr.WriteLine(temp.GetLeadActor().GetBirthDate().GetDay());
  105. wr.WriteLine(temp.GetLeadActor().GetBirthDate().GetMonth());
  106. wr.WriteLine(temp.GetLeadActor().GetBirthDate().GetYear());
  107. wr.WriteLine(Convert.ToString(temp.GetNumOfSeasons()));
  108. wr.WriteLine(temp.GetYear());
  109. wr.WriteLine("~~~~~~~~~~~~~");
  110. temp = temp.GetNext();
  111. }
  112. else
  113. {
  114. exist = true;
  115. MessageBox.Show("Removed");
  116. temp = temp.GetNext();
  117. }
  118. }
  119. if(!exist)
  120. MessageBox.Show("The Show Doesn't Exist In The Current Database");
  121. }
  122. }
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement