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.Threading.Tasks;
- using System.Windows.Forms;
- using System.IO;
- namespace Izpit_zad_2
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void BT2_Click(object sender, EventArgs e)
- {
- FileStream f = new FileStream("Studenti.txt", FileMode.Create, FileAccess.Write);
- BinaryWriter s = new BinaryWriter(f);
- string ime;
- string nomer;
- string grupa;
- string ocenka;
- for (int i = 0; i < DGV1.RowCount - 1; i++)
- {
- ime = DGV1[0, i].Value.ToString();
- nomer = DGV1[1, i].Value.ToString().ToUpper();
- grupa = DGV1[2, i].Value.ToString();
- ocenka = DGV1[3, i].Value.ToString();
- s.Write(ime);
- s.Write(nomer);
- s.Write(grupa);
- s.Write(ocenka);
- }
- f.Close();
- s.Close();
- DGV1.Rows.Clear();
- }
- private void BT1_Click(object sender, EventArgs e)
- {
- LB1.Items.Clear();
- int slab = 2;
- FileStream f = new FileStream("Studenti.txt", FileMode.Open, FileAccess.Read);
- BinaryReader s = new BinaryReader(f);
- string ime;
- string nomer;
- string grupa;
- string ocenka;
- while (f.Position < f.Length)
- {
- ime = s.ReadString();
- nomer = s.ReadString();
- grupa = s.ReadString();
- ocenka = s.ReadString();
- if (grupa == TB1.Text.ToUpper())
- {
- LB1.Items.Add(ime + " " + nomer);
- }
- int score = int.Parse(ocenka);
- if (score == slab)
- {
- LB2.Items.Add(ime + " " + nomer + " " + ocenka);
- }
- }
- f.Close();
- s.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement