Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 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 Feladat
  13. {
  14. public partial class Form1 : Form
  15. {
  16. public Form1()
  17. {
  18. InitializeComponent();
  19. }
  20.  
  21. struct krumplisteszta
  22. {
  23. public string nev;
  24. public int hozott;
  25. public int szerzett;
  26. public int plusz;
  27. }
  28.  
  29. private void button1_Click(object sender, EventArgs e)
  30. {
  31. dataGridView1.Rows.Clear();
  32. string fname = textBox1.Text;
  33. int n = 0;
  34. const int MAX = 100;
  35. krumplisteszta[] emberek = new krumplisteszta[MAX];
  36.  
  37. if (File.Exists(fname))
  38. {
  39. StreamReader sr = new StreamReader(fname);
  40. while (!sr.EndOfStream)
  41. {
  42. string input = sr.ReadLine();
  43. string[] split = input.Split(';');
  44. emberek[n].nev = split[0];
  45. emberek[n].hozott = int.Parse(split[1]);
  46. emberek[n].szerzett = int.Parse(split[2]);
  47. emberek[n].plusz = int.Parse(split[3]);
  48. dataGridView1.Rows.Add(emberek[n].nev, emberek[n].hozott, emberek[n].szerzett, emberek[n].plusz);
  49. n++;
  50. }
  51. }
  52. else
  53. {
  54. Dialog:
  55. DialogResult dialogResult = MessageBox.Show("Biztos vagy benne hogy létezik a fájl?", "ERROR", MessageBoxButtons.YesNo);
  56. if (dialogResult == DialogResult.Yes)
  57. {
  58. MessageBox.Show("Hát akkor rosszul tudod.");
  59. goto Dialog;
  60. }
  61. else if (dialogResult == DialogResult.No)
  62. {
  63. MessageBox.Show("Akkor kérlek javítsd.");
  64. }
  65. }
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement