Advertisement
Guest User

Untitled

a guest
Jun 12th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.30 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using System.Windows.Forms;
  7. using System.Globalization;
  8.  
  9. namespace Bibliotekac
  10. {
  11. class Program
  12. {
  13. static void zmiana(string a, string b, int ile)
  14. {
  15. string[] tmp = File.ReadAllLines(b);
  16. tmp[ile - 1] = a;
  17. File.WriteAllLines(b, tmp);
  18. }
  19. public class Globalne
  20. {
  21. public static int nowechk = 0;
  22. public static int stachk = 0;
  23. public static int idus = 0;
  24. public static int idks_n = 0;
  25. public static int idks_o = 0;
  26. public static int idem = 0;
  27.  
  28. }
  29. //ludzie - gotowe
  30. public class People
  31. {
  32. private string imie;
  33. private string nazwisko;
  34. private string pesel;
  35. public void setImie(string imie)
  36. {
  37. this.imie = imie;
  38. }
  39. public string getImie()
  40. {
  41. return imie;
  42. }
  43. public void setNazwisko(string nazwisko)
  44. {
  45. this.nazwisko = nazwisko;
  46. }
  47. public string getNazwisko()
  48. {
  49. return nazwisko;
  50. }
  51. public void setPesel(string pesel)
  52. {
  53. this.pesel = pesel;
  54. }
  55. public string getPesel()
  56. {
  57. return pesel;
  58. }
  59. }
  60. //uzytkownik - dziala
  61. public class User : People
  62. {
  63. private int idks;
  64. public int getIloscwypo(string wyb, int id)
  65. {
  66. if (wyb == "Nowe")
  67. {
  68. using (StreamReader nowe = File.OpenText("wypozy.txt")) {
  69. string[] loaded = nowe.ReadToEnd().Split(' ');
  70. string W = loaded[3 * (id - 1)].Trim();
  71. string X = loaded[(3 * (id - 1)) + 1].Trim();
  72. string Y = loaded[(3 * (id - 1)) + 2].Trim();
  73. int w = Int32.Parse(W);
  74. int x = Int32.Parse(X);
  75. int y = Int32.Parse(Y);
  76. if (w == id)
  77. {
  78. if (x != 0) return 1;
  79. else return 0;
  80. }
  81. }
  82. }
  83. else
  84. {
  85. using (StreamReader nowe = File.OpenText("wypozy.txt"))
  86. {
  87. string[] loaded = nowe.ReadToEnd().Split(' ');
  88. string W = loaded[3 * (id - 1)].Trim();
  89. string X = loaded[(3 * (id - 1)) + 1].Trim();
  90. string Y = loaded[(3 * (id - 1)) + 2].Trim();
  91. int w = Int32.Parse(W);;
  92. int x = Int32.Parse(X);
  93. int y = Int32.Parse(Y);
  94. if (w == id)
  95. {
  96. if (y != 0) return 1;
  97. else return 0;
  98. }
  99. }
  100. }
  101. return 0;
  102. }
  103. public void setWypozycz(string wyb, int id, int idtmp)
  104. {
  105. idks = idtmp;
  106. if (wyb == "Nowe")
  107. {
  108. using (StreamReader czyt = File.OpenText("wypozy.txt"))
  109. {
  110. string[] wczyta = czyt.ReadToEnd().Split(' ');
  111. string W = wczyta[3 * (id - 1)].Trim();
  112. string X = wczyta[(3 * (id - 1)) + 1].Trim();
  113. string Y = wczyta[(3 * (id - 1)) + 2].Trim();
  114. int w = Int32.Parse(W);
  115. int x = Int32.Parse(X);
  116. int y = Int32.Parse(Y);
  117. {
  118. if (w == id)
  119. {
  120. x = idtmp;
  121. }
  122. System.Text.StringBuilder line = new System.Text.StringBuilder();
  123. line.Append(w).Append(' ').Append(x).Append(' ').Append(y).Append(' ');
  124. czyt.Close();
  125. zmiana(line.ToString(), "wypozy.txt", id);
  126. };
  127. }
  128. }
  129. else
  130. {
  131.  
  132. using (StreamReader czyt = File.OpenText("wypozy.txt"))
  133. {
  134. string[] wczyta = czyt.ReadToEnd().Split(' ');
  135. string W = wczyta[3 * (id - 1)].Trim();
  136. string X = wczyta[(3 * (id - 1)) + 1].Trim();
  137. string Y = wczyta[(3 * (id - 1)) + 2].Trim();
  138. int w = Int32.Parse(W);
  139. int x = Int32.Parse(X);
  140. int y = Int32.Parse(Y);
  141. if (w == id)
  142. {
  143. y = idtmp;
  144. }
  145. System.Text.StringBuilder line = new System.Text.StringBuilder();
  146. line.Append(w).Append(' ').Append(x).Append(' ').Append(y).Append(' ');
  147. czyt.Close();
  148. zmiana(line.ToString(), "wypozy.txt", id);
  149. }
  150. };
  151.  
  152. }
  153. public int zwrot(string wyb, int id, int idtmp)
  154. {
  155. bool chk = false;
  156. idks = idtmp;
  157. if (wyb == "Nowe")
  158. {
  159.  
  160. using (StreamReader czyt = File.OpenText("wypozy.txt"))
  161. {
  162. string[] wczyta = czyt.ReadToEnd().Split(' ');
  163. string W = wczyta[3 * (id - 1)].Trim();
  164. string X = wczyta[(3 * (id - 1)) + 1].Trim();
  165. string Y = wczyta[(3 * (id - 1)) + 2].Trim();
  166. int w = Int32.Parse(W);
  167. int x = Int32.Parse(X);
  168. int y = Int32.Parse(Y);
  169. if (w == id && x == idks)
  170. {
  171. x = 0;
  172. chk = true;
  173. }
  174. System.Text.StringBuilder line = new System.Text.StringBuilder();
  175. line.Append(w).Append(' ').Append(x).Append(' ').Append(y).Append(' ');
  176. czyt.Close();
  177. zmiana(line.ToString(), "wypozy.txt", id);
  178. }
  179. }
  180. else
  181. {
  182. {
  183.  
  184. using (StreamReader czyt = File.OpenText("wypozy.txt"))
  185. {
  186. string[] wczyta = czyt.ReadToEnd().Split(' ');
  187. string W = wczyta[3 * (id - 1)].Trim();
  188. string X = wczyta[(3 * (id - 1)) + 1].Trim();
  189. string Y = wczyta[(3 * (id - 1)) + 2].Trim();
  190. int w = Int32.Parse(W);
  191. int x = Int32.Parse(X);
  192. int y = Int32.Parse(Y);
  193. if (w == id && y == idks)
  194. {
  195. y = 0;
  196. chk = true;
  197. }
  198. System.Text.StringBuilder line = new System.Text.StringBuilder();
  199. line.Append(w).Append(' ').Append(x).Append(' ').Append(y).Append(' ');
  200. czyt.Close();
  201. zmiana(line.ToString(), "wypozy.txt", id);
  202. }
  203. }
  204. };
  205. if (chk == true)
  206. {
  207. return idks;
  208. }
  209. else
  210. {
  211. return 0;
  212. }
  213. }
  214. public void getCo(int id)
  215. {
  216. using (StreamReader czyt = File.OpenText("wypozy.txt"))
  217. {
  218. bool mam = false;
  219. string[] wczyta = czyt.ReadToEnd().Split(' ');
  220. string W = wczyta[3 * (id - 1)].Trim();
  221. string X = wczyta[(3 * (id - 1)) +1].Trim();
  222. string Y = wczyta[(3 * (id - 1)) + 2].Trim();
  223. int w = Convert.ToInt32(W);
  224. int x = Convert.ToInt32(X);
  225. int y = Convert.ToInt32(Y);
  226. while (w != 0 && mam == false)
  227. {
  228. if (w == id)
  229. {
  230. mam = true;
  231. Globalne.nowechk = x;
  232. Globalne.stachk = y;
  233. }
  234. };
  235. }
  236. }
  237. }
  238. public class Employee : People
  239. {
  240. private int salary;
  241. private int bonus;
  242. string pass;
  243. public void setSalary(int salary)
  244. {
  245. this.salary = salary;
  246. }
  247. public int getSalary()
  248. {
  249. return salary;
  250. }
  251. float getExpanse(float sal, float bo)
  252. {
  253. return sal + bo;
  254. }
  255. public void setPass(string pass)
  256. {
  257. this.pass = pass;
  258. }
  259. public string getPass()
  260. {
  261. return pass;
  262. }
  263.  
  264. }
  265. //Klasa ksiazki - gotowa
  266. public class Books
  267. {
  268. private string tytul;
  269. private string autor;
  270. public void setTytul(string tytul)
  271. {
  272. this.tytul = tytul;
  273. }
  274. public string getTytul()
  275. {
  276. return tytul;
  277. }
  278. public void setAutor(string autor)
  279. {
  280. this.autor = autor;
  281. }
  282. public string getAutor()
  283. {
  284. return autor;
  285. }
  286. public int rdn(int y, int m, int d)
  287. {
  288. int tmp;
  289. if (m < 3)
  290. y--;
  291. m += 12;
  292. tmp = 365 * y + y / 4 - y / 100 + y / 400 + (153 * m - 457) / 5 + d - 306;
  293. return tmp;
  294. }
  295. public void setDatawypo(string wyb, int id, int r, int m, int d)
  296. {
  297. if (wyb == "Nowe")
  298. {
  299. using (StreamReader czyt = File.OpenText("new_date.txt"))
  300. {
  301. string[] wczyta = czyt.ReadToEnd().Split(' ');
  302. string W = wczyta[(id -1)*4].Trim();
  303. string X = wczyta[((id -1)*4)+1].Trim();
  304. string Y = wczyta[((id - 1) * 4) + 1].Trim();
  305. string Z = wczyta[((id -1)*4)+1].Trim();
  306. int w = Int32.Parse(W);
  307. int x = Int32.Parse(X);
  308. int y = Int32.Parse(Y);
  309. int z = Int32.Parse(Z);
  310.  
  311. if (w == id)
  312. {
  313. x = d;
  314. y = m;
  315. z = r;
  316. }
  317. System.Text.StringBuilder line = new System.Text.StringBuilder();
  318. line.Append(w).Append(' ').Append(x).Append(' ').Append(y).Append(' ').Append(z).Append(' ');
  319. czyt.Close();
  320. zmiana(line.ToString(), "new_date.txt", id);
  321. }
  322. }
  323. else
  324. {
  325.  
  326. using (StreamReader czyt = File.OpenText("old_date.txt"))
  327. {
  328. string[] wczyta = czyt.ReadToEnd().Split(' ');
  329. string W = wczyta[(id - 1) * 4].Trim();
  330. string X = wczyta[((id - 1) * 4) + 1].Trim();
  331. string Y = wczyta[((id - 1) * 4) + 1].Trim();
  332. string Z = wczyta[((id - 1) * 4) + 1].Trim();
  333. int w = Int32.Parse(W);
  334. int x = Int32.Parse(X);
  335. int y = Int32.Parse(Y);
  336. int z = Int32.Parse(Z);
  337. if (w == id)
  338. {
  339. x = d;
  340. y = m;
  341. z = r;
  342. }
  343. System.Text.StringBuilder line = new System.Text.StringBuilder();
  344. line.Append(w).Append(' ').Append(x).Append(' ').Append(y).Append(' ').Append(z).Append(' ');
  345. czyt.Close();
  346. zmiana(line.ToString(), "old_date.txt", id);
  347. }
  348. }
  349. }
  350. }
  351.  
  352. public class Old : Books
  353. {
  354. public int OldDozaplaty(int dni)
  355. {
  356. dni = dni - 14;
  357. if (dni > 0)
  358. return (dni * 2);
  359. else
  360. return 0;
  361. }
  362.  
  363. public int ileDni(int id, int r, int m, int d)
  364. {
  365. using (StreamReader czyt = File.OpenText("old_date.txt"))
  366. {
  367. string[] wczyta = czyt.ReadToEnd().Split(' ');
  368. string W = wczyta[(id - 1) * 4].Trim();
  369. string X = wczyta[((id - 1) * 4) + 1].Trim();
  370. string Y = wczyta[((id - 1) * 4) + 1].Trim();
  371. string Z = wczyta[((id - 1) * 4) + 1].Trim();
  372. int w = Int32.Parse(W);
  373. int x = Int32.Parse(X);
  374. int y = Int32.Parse(Y);
  375. int z = Int32.Parse(Z);
  376. if (w == id)
  377. {
  378. int days = rdn(r, m, d) - rdn(z, y,x);
  379. MessageBox.Show(days.ToString());
  380. return days;
  381. }
  382. }
  383. return 0;
  384.  
  385. }
  386. }
  387. public class New : Books
  388. {
  389. public int NewDozaplaty(int dni)
  390. {
  391. dni = dni - 30;
  392. if (dni > 0)
  393. return (dni * 1);
  394. else
  395. return 0;
  396. }
  397. public int ileDni(int id, int r, int m, int d)
  398. {
  399. using (StreamReader czyt = File.OpenText("new_date.txt"))
  400. {
  401. string[] wczyta = czyt.ReadToEnd().Split(' ');
  402. string W = wczyta[(id - 1) * 4].Trim();
  403. string X = wczyta[((id - 1) * 4) + 1].Trim();
  404. string Y = wczyta[((id - 1) * 4) + 1].Trim();
  405. string Z = wczyta[((id - 1) * 4) + 1].Trim();
  406. int w = Int32.Parse(W);
  407. int x = Int32.Parse(X);
  408. int y = Int32.Parse(Y);
  409. int z = Int32.Parse(Z);
  410. {
  411. if (w == id)
  412. {
  413. MessageBox.Show(z.ToString()+y.ToString()+x.ToString());
  414. int days = rdn(r, m, d) - rdn(z,y,x);
  415. return days;
  416. }
  417. };
  418. }
  419. return 0;
  420.  
  421. }
  422. }
  423.  
  424. Books item = new Books();
  425.  
  426. [STAThread]
  427. static void Main()
  428. {
  429. Application.EnableVisualStyles();
  430. Application.SetCompatibleTextRenderingDefault(false);
  431. Application.Run(new intro());
  432. }
  433. }
  434. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement