Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Globalization;
- namespace Bibliotekac
- {
- class Program
- {
- static void zmiana(string a, string b, int ile)
- {
- string[] tmp = File.ReadAllLines(b);
- tmp[ile - 1] = a;
- File.WriteAllLines(b, tmp);
- }
- public class Globalne
- {
- public static int nowechk = 0;
- public static int stachk = 0;
- public static int idus = 0;
- public static int idks_n = 0;
- public static int idks_o = 0;
- public static int idem = 0;
- }
- //ludzie - gotowe
- public class People
- {
- private string imie;
- private string nazwisko;
- private string pesel;
- public void setImie(string imie)
- {
- this.imie = imie;
- }
- public string getImie()
- {
- return imie;
- }
- public void setNazwisko(string nazwisko)
- {
- this.nazwisko = nazwisko;
- }
- public string getNazwisko()
- {
- return nazwisko;
- }
- public void setPesel(string pesel)
- {
- this.pesel = pesel;
- }
- public string getPesel()
- {
- return pesel;
- }
- }
- //uzytkownik - dziala
- public class User : People
- {
- private int idks;
- public int getIloscwypo(string wyb, int id)
- {
- if (wyb == "Nowe")
- {
- using (StreamReader nowe = File.OpenText("wypozy.txt")) {
- string[] loaded = nowe.ReadToEnd().Split(' ');
- string W = loaded[3 * (id - 1)].Trim();
- string X = loaded[(3 * (id - 1)) + 1].Trim();
- string Y = loaded[(3 * (id - 1)) + 2].Trim();
- int w = Int32.Parse(W);
- int x = Int32.Parse(X);
- int y = Int32.Parse(Y);
- if (w == id)
- {
- if (x != 0) return 1;
- else return 0;
- }
- }
- }
- else
- {
- using (StreamReader nowe = File.OpenText("wypozy.txt"))
- {
- string[] loaded = nowe.ReadToEnd().Split(' ');
- string W = loaded[3 * (id - 1)].Trim();
- string X = loaded[(3 * (id - 1)) + 1].Trim();
- string Y = loaded[(3 * (id - 1)) + 2].Trim();
- int w = Int32.Parse(W);;
- int x = Int32.Parse(X);
- int y = Int32.Parse(Y);
- if (w == id)
- {
- if (y != 0) return 1;
- else return 0;
- }
- }
- }
- return 0;
- }
- public void setWypozycz(string wyb, int id, int idtmp)
- {
- idks = idtmp;
- if (wyb == "Nowe")
- {
- using (StreamReader czyt = File.OpenText("wypozy.txt"))
- {
- string[] wczyta = czyt.ReadToEnd().Split(' ');
- string W = wczyta[3 * (id - 1)].Trim();
- string X = wczyta[(3 * (id - 1)) + 1].Trim();
- string Y = wczyta[(3 * (id - 1)) + 2].Trim();
- int w = Int32.Parse(W);
- int x = Int32.Parse(X);
- int y = Int32.Parse(Y);
- {
- if (w == id)
- {
- x = idtmp;
- }
- System.Text.StringBuilder line = new System.Text.StringBuilder();
- line.Append(w).Append(' ').Append(x).Append(' ').Append(y).Append(' ');
- czyt.Close();
- zmiana(line.ToString(), "wypozy.txt", id);
- };
- }
- }
- else
- {
- using (StreamReader czyt = File.OpenText("wypozy.txt"))
- {
- string[] wczyta = czyt.ReadToEnd().Split(' ');
- string W = wczyta[3 * (id - 1)].Trim();
- string X = wczyta[(3 * (id - 1)) + 1].Trim();
- string Y = wczyta[(3 * (id - 1)) + 2].Trim();
- int w = Int32.Parse(W);
- int x = Int32.Parse(X);
- int y = Int32.Parse(Y);
- if (w == id)
- {
- y = idtmp;
- }
- System.Text.StringBuilder line = new System.Text.StringBuilder();
- line.Append(w).Append(' ').Append(x).Append(' ').Append(y).Append(' ');
- czyt.Close();
- zmiana(line.ToString(), "wypozy.txt", id);
- }
- };
- }
- public int zwrot(string wyb, int id, int idtmp)
- {
- bool chk = false;
- idks = idtmp;
- if (wyb == "Nowe")
- {
- using (StreamReader czyt = File.OpenText("wypozy.txt"))
- {
- string[] wczyta = czyt.ReadToEnd().Split(' ');
- string W = wczyta[3 * (id - 1)].Trim();
- string X = wczyta[(3 * (id - 1)) + 1].Trim();
- string Y = wczyta[(3 * (id - 1)) + 2].Trim();
- int w = Int32.Parse(W);
- int x = Int32.Parse(X);
- int y = Int32.Parse(Y);
- if (w == id && x == idks)
- {
- x = 0;
- chk = true;
- }
- System.Text.StringBuilder line = new System.Text.StringBuilder();
- line.Append(w).Append(' ').Append(x).Append(' ').Append(y).Append(' ');
- czyt.Close();
- zmiana(line.ToString(), "wypozy.txt", id);
- }
- }
- else
- {
- {
- using (StreamReader czyt = File.OpenText("wypozy.txt"))
- {
- string[] wczyta = czyt.ReadToEnd().Split(' ');
- string W = wczyta[3 * (id - 1)].Trim();
- string X = wczyta[(3 * (id - 1)) + 1].Trim();
- string Y = wczyta[(3 * (id - 1)) + 2].Trim();
- int w = Int32.Parse(W);
- int x = Int32.Parse(X);
- int y = Int32.Parse(Y);
- if (w == id && y == idks)
- {
- y = 0;
- chk = true;
- }
- System.Text.StringBuilder line = new System.Text.StringBuilder();
- line.Append(w).Append(' ').Append(x).Append(' ').Append(y).Append(' ');
- czyt.Close();
- zmiana(line.ToString(), "wypozy.txt", id);
- }
- }
- };
- if (chk == true)
- {
- return idks;
- }
- else
- {
- return 0;
- }
- }
- public void getCo(int id)
- {
- using (StreamReader czyt = File.OpenText("wypozy.txt"))
- {
- bool mam = false;
- string[] wczyta = czyt.ReadToEnd().Split(' ');
- string W = wczyta[3 * (id - 1)].Trim();
- string X = wczyta[(3 * (id - 1)) +1].Trim();
- string Y = wczyta[(3 * (id - 1)) + 2].Trim();
- int w = Convert.ToInt32(W);
- int x = Convert.ToInt32(X);
- int y = Convert.ToInt32(Y);
- while (w != 0 && mam == false)
- {
- if (w == id)
- {
- mam = true;
- Globalne.nowechk = x;
- Globalne.stachk = y;
- }
- };
- }
- }
- }
- public class Employee : People
- {
- private int salary;
- private int bonus;
- string pass;
- public void setSalary(int salary)
- {
- this.salary = salary;
- }
- public int getSalary()
- {
- return salary;
- }
- float getExpanse(float sal, float bo)
- {
- return sal + bo;
- }
- public void setPass(string pass)
- {
- this.pass = pass;
- }
- public string getPass()
- {
- return pass;
- }
- }
- //Klasa ksiazki - gotowa
- public class Books
- {
- private string tytul;
- private string autor;
- public void setTytul(string tytul)
- {
- this.tytul = tytul;
- }
- public string getTytul()
- {
- return tytul;
- }
- public void setAutor(string autor)
- {
- this.autor = autor;
- }
- public string getAutor()
- {
- return autor;
- }
- public int rdn(int y, int m, int d)
- {
- int tmp;
- if (m < 3)
- y--;
- m += 12;
- tmp = 365 * y + y / 4 - y / 100 + y / 400 + (153 * m - 457) / 5 + d - 306;
- return tmp;
- }
- public void setDatawypo(string wyb, int id, int r, int m, int d)
- {
- if (wyb == "Nowe")
- {
- using (StreamReader czyt = File.OpenText("new_date.txt"))
- {
- string[] wczyta = czyt.ReadToEnd().Split(' ');
- string W = wczyta[(id -1)*4].Trim();
- string X = wczyta[((id -1)*4)+1].Trim();
- string Y = wczyta[((id - 1) * 4) + 1].Trim();
- string Z = wczyta[((id -1)*4)+1].Trim();
- int w = Int32.Parse(W);
- int x = Int32.Parse(X);
- int y = Int32.Parse(Y);
- int z = Int32.Parse(Z);
- if (w == id)
- {
- x = d;
- y = m;
- z = r;
- }
- System.Text.StringBuilder line = new System.Text.StringBuilder();
- line.Append(w).Append(' ').Append(x).Append(' ').Append(y).Append(' ').Append(z).Append(' ');
- czyt.Close();
- zmiana(line.ToString(), "new_date.txt", id);
- }
- }
- else
- {
- using (StreamReader czyt = File.OpenText("old_date.txt"))
- {
- string[] wczyta = czyt.ReadToEnd().Split(' ');
- string W = wczyta[(id - 1) * 4].Trim();
- string X = wczyta[((id - 1) * 4) + 1].Trim();
- string Y = wczyta[((id - 1) * 4) + 1].Trim();
- string Z = wczyta[((id - 1) * 4) + 1].Trim();
- int w = Int32.Parse(W);
- int x = Int32.Parse(X);
- int y = Int32.Parse(Y);
- int z = Int32.Parse(Z);
- if (w == id)
- {
- x = d;
- y = m;
- z = r;
- }
- System.Text.StringBuilder line = new System.Text.StringBuilder();
- line.Append(w).Append(' ').Append(x).Append(' ').Append(y).Append(' ').Append(z).Append(' ');
- czyt.Close();
- zmiana(line.ToString(), "old_date.txt", id);
- }
- }
- }
- }
- public class Old : Books
- {
- public int OldDozaplaty(int dni)
- {
- dni = dni - 14;
- if (dni > 0)
- return (dni * 2);
- else
- return 0;
- }
- public int ileDni(int id, int r, int m, int d)
- {
- using (StreamReader czyt = File.OpenText("old_date.txt"))
- {
- string[] wczyta = czyt.ReadToEnd().Split(' ');
- string W = wczyta[(id - 1) * 4].Trim();
- string X = wczyta[((id - 1) * 4) + 1].Trim();
- string Y = wczyta[((id - 1) * 4) + 1].Trim();
- string Z = wczyta[((id - 1) * 4) + 1].Trim();
- int w = Int32.Parse(W);
- int x = Int32.Parse(X);
- int y = Int32.Parse(Y);
- int z = Int32.Parse(Z);
- if (w == id)
- {
- int days = rdn(r, m, d) - rdn(z, y,x);
- MessageBox.Show(days.ToString());
- return days;
- }
- }
- return 0;
- }
- }
- public class New : Books
- {
- public int NewDozaplaty(int dni)
- {
- dni = dni - 30;
- if (dni > 0)
- return (dni * 1);
- else
- return 0;
- }
- public int ileDni(int id, int r, int m, int d)
- {
- using (StreamReader czyt = File.OpenText("new_date.txt"))
- {
- string[] wczyta = czyt.ReadToEnd().Split(' ');
- string W = wczyta[(id - 1) * 4].Trim();
- string X = wczyta[((id - 1) * 4) + 1].Trim();
- string Y = wczyta[((id - 1) * 4) + 1].Trim();
- string Z = wczyta[((id - 1) * 4) + 1].Trim();
- int w = Int32.Parse(W);
- int x = Int32.Parse(X);
- int y = Int32.Parse(Y);
- int z = Int32.Parse(Z);
- {
- if (w == id)
- {
- MessageBox.Show(z.ToString()+y.ToString()+x.ToString());
- int days = rdn(r, m, d) - rdn(z,y,x);
- return days;
- }
- };
- }
- return 0;
- }
- }
- Books item = new Books();
- [STAThread]
- static void Main()
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new intro());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement