Advertisement
Guest User

Untitled

a guest
May 16th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 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.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO;
  11.  
  12. namespace fasz
  13. {
  14.  
  15. public partial class Form1 : Form
  16. {
  17.  
  18. public int bekertosszeg, teljesosszeg = 0;
  19. public string bekertnev;
  20. public string path = Environment.CurrentDirectory + "\\mentes.txt";
  21. public Form1()
  22. {
  23. InitializeComponent();
  24. }
  25.  
  26. private void Form1_Load(object sender, EventArgs e)
  27. {
  28. radioButton1.Checked = true;
  29. if (!File.Exists(path))
  30. {
  31. File.CreateText("mentes.txt");
  32. }
  33. else
  34. {
  35. FileStream fajl = new FileStream("mentes.txt", FileMode.Open);
  36. StreamReader olvaso = new StreamReader(fajl);
  37. // olvaso.ReadLine().Split(';');
  38. olvaso.Close();
  39. fajl.Close();
  40. }
  41.  
  42. }
  43.  
  44. private void radioButton1_CheckedChanged(object sender, EventArgs e)
  45. {
  46.  
  47. }
  48.  
  49. private void button2_Click(object sender, EventArgs e)
  50. {
  51. FileStream fajl = new FileStream("mentes.txt", FileMode.Open);
  52. StreamWriter iro = new StreamWriter(fajl);
  53. foreach (var item in listBox1.Items)
  54. {
  55. iro.WriteLine(item.ToString());
  56. }
  57. iro.Close();
  58. fajl.Close();
  59.  
  60. }
  61.  
  62. private void button1_Click(object sender, EventArgs e)
  63. {
  64. DateTime most = DateTime.Now;
  65. try
  66. {
  67. bekertnev = textBox1.Text;
  68. bekertosszeg = int.Parse(textBox2.Text);
  69. }
  70. catch (FormatException)
  71. {
  72. MessageBox.Show("Számot adj meg a kurva anyádat");
  73. }
  74. catch (OverflowException ofe)
  75. {
  76. MessageBox.Show(ofe.ToString());
  77. }
  78. if (radioButton1.Checked)
  79. {
  80. teljesosszeg += bekertosszeg;
  81. listBox1.Items.Add(bekertnev + " " + bekertosszeg + " " + most + " " + teljesosszeg);
  82. MessageBox.Show(teljesosszeg.ToString());
  83. }
  84. if (radioButton2.Checked)
  85. {
  86. teljesosszeg -= bekertosszeg;
  87. if (teljesosszeg < 0)
  88. {
  89. MessageBox.Show("anyáddal szórakozz üres a kassza");
  90. }
  91. else
  92. {
  93.  
  94. listBox1.Items.Add(bekertnev + " " + bekertosszeg + " " + most + " " + teljesosszeg);
  95. MessageBox.Show(teljesosszeg.ToString());
  96. }
  97. }
  98. }
  99. }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement