Advertisement
Guest User

yes

a guest
May 24th, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 43.36 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. using System.Text.RegularExpressions;
  12.  
  13. namespace Task_Manager
  14. {
  15. public partial class Check_Time : Form
  16. {
  17. public Check_Time()
  18. {
  19. InitializeComponent();
  20. }
  21.  
  22. private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
  23. {
  24. e.Handled = !(char.IsDigit(e.KeyChar) || e.KeyChar == (char)Keys.Back || char.IsControl(e.KeyChar));
  25. }
  26.  
  27. private void Check_Time_Load(object sender, EventArgs e)
  28. {
  29. listBox1.Items.AddRange(File.ReadAllLines("Tasks/" + Login.username + ".txt"));
  30. if(!File.Exists("Otcheti.txt"))
  31. {
  32. File.Create("Otcheti.txt").Close();
  33. }
  34. }
  35.  
  36. private void button1_Click(object sender, EventArgs e)
  37. {
  38. StreamWriter a = new StreamWriter("Otcheti.txt");
  39. string zaglavie=Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[1].ToString();
  40. DateTime date = DateTime.Now;
  41. string format = "dd.MM.yyyy";
  42. string data = date.ToString(format);
  43. a.WriteLine("Task:" + zaglavie + " " + "User:" + Login.username + " " + "Time:" + textBox1.Text + " " + "Date:" + data);
  44. a.Close();
  45. MessageBox.Show("Времето е отчетено успешно!");
  46. this.Close();
  47. }
  48. }
  49. }
  50. using System;
  51. using System.Collections.Generic;
  52. using System.ComponentModel;
  53. using System.Data;
  54. using System.Drawing;
  55. using System.Linq;
  56. using System.Text;
  57. using System.Threading.Tasks;
  58. using System.Windows.Forms;
  59. using System.IO;
  60. using System.Text.RegularExpressions;
  61.  
  62. namespace Task_Manager
  63. {
  64. public partial class Comment_Add : Form
  65. {
  66. public Comment_Add()
  67. {
  68. InitializeComponent();
  69. }
  70.  
  71. private void Comment_Add_Load(object sender, EventArgs e)
  72. {
  73. listBox1.Items.AddRange(File.ReadAllLines("Tasks/" + Login.username + ".txt"));
  74. }
  75.  
  76. private void button1_Click(object sender, EventArgs e)
  77. {
  78. string zaglavie = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[1].ToString();
  79. StreamWriter comment = new StreamWriter("Comments/"+zaglavie+".txt",true);
  80. comment.WriteLine(Login.username+":"+ richTextBox1.Text);
  81. comment.Close();
  82. MessageBox.Show("Успешно добавен коментар.");
  83. this.Close();
  84. }
  85.  
  86. private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
  87. {
  88. if (e.KeyCode == Keys.Enter)
  89. e.SuppressKeyPress = true;
  90. }
  91. }
  92. }
  93. using System;
  94. using System.Collections.Generic;
  95. using System.ComponentModel;
  96. using System.Data;
  97. using System.Drawing;
  98. using System.Linq;
  99. using System.Text;
  100. using System.Threading.Tasks;
  101. using System.Windows.Forms;
  102. using System.IO;
  103. using System.Text.RegularExpressions;
  104.  
  105. namespace Task_Manager
  106. {
  107. public partial class Comments_Look : Form
  108. {
  109. public Comments_Look()
  110. {
  111. InitializeComponent();
  112. }
  113.  
  114. private void Comments_Look_Load(object sender, EventArgs e)
  115. {
  116. listBox1.Items.AddRange(File.ReadAllLines("Tasks/" + Login.username + ".txt"));
  117. listBox1.SelectedIndex = 0;
  118. }
  119.  
  120. private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
  121. {
  122. string zaglavie = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[1].ToString();
  123. StreamReader comment = new StreamReader("Comments/"+zaglavie+".txt");
  124. richTextBox1.Text = comment.ReadToEnd();
  125. comment.Close();
  126. }
  127. }
  128. }
  129. using System;
  130. using System.Collections.Generic;
  131. using System.ComponentModel;
  132. using System.Data;
  133. using System.Drawing;
  134. using System.Linq;
  135. using System.Text;
  136. using System.Threading.Tasks;
  137. using System.Windows.Forms;
  138. using System.IO;
  139. using System.Text.RegularExpressions;
  140.  
  141. namespace Task_Manager
  142. {
  143. public partial class Login : Form
  144. {
  145. public static string username = null;
  146. public static bool admin = false;
  147. public static string regex = @"\bUsername:([a-zA-Z0-9]+)\s*Password:([a-zA-Z0-9_]+)\s*(true)?(false)?";
  148. public Login()
  149. {
  150. InitializeComponent();
  151. }
  152. private void button2_Click(object sender, EventArgs e)
  153. {
  154. Register a = new Register();
  155. a.ShowDialog();
  156. }
  157.  
  158. private void button1_Click(object sender, EventArgs e)
  159. {
  160. StreamReader a = new StreamReader("Accounts.txt", true);
  161. string check = a.ReadToEnd();
  162. Regex rg = new Regex(regex);
  163. MatchCollection matches = rg.Matches(check);
  164. foreach (Match m in matches)
  165. {
  166. if (textBox1.Text == m.Groups[1].ToString())
  167. {
  168. a.Close();
  169. StreamReader b = new StreamReader("Accounts.txt", true);
  170. if (textBox2.Text == m.Groups[2].ToString())
  171. {
  172. MessageBox.Show("Логин успешен!");
  173. username = textBox1.Text;
  174. if (m.Groups[3].ToString() == "true")
  175. {
  176. admin = true;
  177. }
  178. this.Close();
  179. break;
  180. }
  181. b.Close();
  182. }
  183. }
  184. if (username == null)
  185. {
  186. MessageBox.Show("Грешно име или парола!", "Грешка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  187. }
  188. a.Close();
  189. }
  190.  
  191. private void Login_Load(object sender, EventArgs e)
  192. {
  193. if(!File.Exists("Accounts.txt"))
  194. {
  195. File.Create("Accounts.txt").Close();
  196. }
  197. if (!Directory.Exists("Comments"))
  198. {
  199. Directory.CreateDirectory("Comments");
  200. }
  201. if (!Directory.Exists("Tasks"))
  202. {
  203. Directory.CreateDirectory("Tasks");
  204. }
  205. }
  206. }
  207. }
  208. using System;
  209. using System.Collections.Generic;
  210. using System.ComponentModel;
  211. using System.Data;
  212. using System.Drawing;
  213. using System.Linq;
  214. using System.Text;
  215. using System.Threading.Tasks;
  216. using System.Windows.Forms;
  217.  
  218. namespace Task_Manager
  219. {
  220. public partial class Main : Form
  221. {
  222. public Main()
  223. {
  224. InitializeComponent();
  225. }
  226.  
  227. private void Form1_Load(object sender, EventArgs e)
  228. {
  229. Login a = new Login();
  230. a.ShowDialog();
  231. if(Login.username==null)
  232. {
  233. MessageBox.Show("Не сте в системата!");
  234. Application.Exit();
  235. }
  236. }
  237.  
  238. private void добавиToolStripMenuItem2_Click(object sender, EventArgs e)
  239. {
  240. Users_Add a = new Users_Add();
  241. if(Login.admin==false)
  242. {
  243. MessageBox.Show("Това меню е само за админи!","Грешка",MessageBoxButtons.OK,MessageBoxIcon.Error);
  244. }
  245. else
  246. {
  247. a.ShowDialog();
  248. }
  249. }
  250.  
  251. private void редактирайToolStripMenuItem1_Click(object sender, EventArgs e)
  252. {
  253. Users_Change a = new Users_Change();
  254. if (Login.admin == false)
  255. {
  256. MessageBox.Show("Това меню е само за админи!", "Грешка", MessageBoxButtons.OK, MessageBoxIcon.Error);
  257. }
  258. else
  259. {
  260. a.ShowDialog();
  261. }
  262. }
  263.  
  264. private void изтрийToolStripMenuItem1_Click(object sender, EventArgs e)
  265. {
  266. Users_Delete a = new Users_Delete();
  267. if (Login.admin == false)
  268. {
  269. MessageBox.Show("Това меню е само за админи!", "Грешка", MessageBoxButtons.OK, MessageBoxIcon.Error);
  270. }
  271. else
  272. {
  273. a.ShowDialog();
  274. }
  275. }
  276.  
  277. private void прегледайToolStripMenuItem2_Click(object sender, EventArgs e)
  278. {
  279. Users_Look a = new Users_Look();
  280. if (Login.admin == false)
  281. {
  282. MessageBox.Show("Това меню е само за админи!", "Грешка", MessageBoxButtons.OK, MessageBoxIcon.Error);
  283. }
  284. else
  285. {
  286. a.ShowDialog();
  287. }
  288. }
  289.  
  290. private void добавиToolStripMenuItem_Click(object sender, EventArgs e)
  291. {
  292. Tasks_Create a = new Tasks_Create();
  293. a.ShowDialog();
  294. }
  295.  
  296. private void прегледайToolStripMenuItem_Click(object sender, EventArgs e)
  297. {
  298. Tasks_Look a = new Tasks_Look();
  299. a.ShowDialog();
  300. }
  301.  
  302. private void изтрийToolStripMenuItem_Click(object sender, EventArgs e)
  303. {
  304. Tasks_Delete a = new Tasks_Delete();
  305. a.ShowDialog();
  306. }
  307.  
  308. private void редактирайToolStripMenuItem_Click(object sender, EventArgs e)
  309. {
  310. Tasks_Change a = new Tasks_Change();
  311. a.ShowDialog();
  312. }
  313.  
  314. private void отчетиВремеПоЗадачаToolStripMenuItem_Click(object sender, EventArgs e)
  315. {
  316. Check_Time a = new Check_Time();
  317. a.ShowDialog();
  318. }
  319.  
  320. private void добавиToolStripMenuItem1_Click(object sender, EventArgs e)
  321. {
  322. Comment_Add a = new Comment_Add();
  323. a.ShowDialog();
  324. }
  325.  
  326. private void прегледайToolStripMenuItem1_Click(object sender, EventArgs e)
  327. {
  328. Comments_Look a = new Comments_Look();
  329. a.ShowDialog();
  330. }
  331.  
  332. }
  333. }
  334. using System;
  335. using System.Collections.Generic;
  336. using System.ComponentModel;
  337. using System.Data;
  338. using System.Drawing;
  339. using System.Linq;
  340. using System.Text;
  341. using System.Threading.Tasks;
  342. using System.Windows.Forms;
  343. using System.IO;
  344. using System.Text.RegularExpressions;
  345.  
  346. namespace Task_Manager
  347. {
  348. public partial class Register : Form
  349. {
  350. public Register()
  351. {
  352. InitializeComponent();
  353. }
  354.  
  355. private void button1_Click(object sender, EventArgs e)
  356. {
  357. StreamReader b = new StreamReader("Accounts.txt", true);
  358. if (textBox1.TextLength < 3 || textBox1.TextLength > 12)
  359. {
  360. MessageBox.Show("Името трябва да е между 3 и 12 символа!", "Грешка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  361. }
  362. else if (textBox2.TextLength < 3 || textBox2.TextLength > 12)
  363. {
  364. MessageBox.Show("Паролата трябва да е между 3 и 12 символа!", "Грешка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  365. }
  366. else if (textBox1.Text == Regex.Match(b.ReadToEnd(), Login.regex).Groups[1].ToString())
  367. {
  368. MessageBox.Show("Вече съществува такова име!", "Грешка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  369. }
  370. else
  371. {
  372. b.Close();
  373. StreamWriter a = new StreamWriter("Accounts.txt", true);
  374. if (checkBox1.Checked)
  375. {
  376. a.WriteLine("Username:" + textBox1.Text + " " + "Password:" + textBox2.Text + " " + "true");
  377. }
  378. else
  379. {
  380. a.WriteLine("Username:" + textBox1.Text + " " + "Password:" + textBox2.Text + " " + "false");
  381. }
  382. a.Close();
  383. File.Create("Tasks/" + textBox1.Text + ".txt").Close();
  384. MessageBox.Show("Регистрацията е успешна!");
  385. this.Close();
  386. }
  387. b.Close();
  388. }
  389.  
  390. private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
  391. {
  392. e.Handled = !(char.IsLetterOrDigit(e.KeyChar) || e.KeyChar == (char)Keys.Back);
  393. }
  394.  
  395. private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
  396. {
  397. e.Handled = !(char.IsLetterOrDigit(e.KeyChar) || e.KeyChar == (char)Keys.Back);
  398. }
  399.  
  400. private void Register_Load(object sender, EventArgs e)
  401. {
  402. if (!File.Exists("Accounts.txt"))
  403. {
  404. File.Create("Accounts.txt").Close();
  405. }
  406. }
  407. }
  408. }
  409. using System;
  410. using System.Collections.Generic;
  411. using System.ComponentModel;
  412. using System.Data;
  413. using System.Drawing;
  414. using System.Linq;
  415. using System.Text;
  416. using System.Threading.Tasks;
  417. using System.Windows.Forms;
  418. using System.IO;
  419. using System.Text.RegularExpressions;
  420.  
  421. namespace Task_Manager
  422. {
  423. public partial class Tasks_Change : Form
  424. {
  425. public static string proverka = "";
  426. public static string creator = "";
  427. public Tasks_Change()
  428. {
  429. InitializeComponent();
  430. }
  431.  
  432. private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
  433. {
  434. if(listBox1.SelectedIndex>=0 && listBox1.SelectedItem!=null)
  435. {
  436. textBox1.Text = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[1].ToString();
  437. textBox2.Text = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[2].ToString();
  438. textBox3.Text = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[3].ToString();
  439. comboBox1.SelectedItem = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[4].ToString();
  440. textBox4.Text = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[5].ToString();
  441. textBox5.Text = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[6].ToString();
  442. DateTime date = DateTime.Now;
  443. string format = "dd.MM.yyyy";
  444. textBox6.Text = date.ToString(format);
  445. comboBox2.SelectedItem = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[8].ToString();
  446. proverka = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[8].ToString();
  447. creator = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[5].ToString();
  448. }
  449. }
  450.  
  451. private void Tasks_Change_Load(object sender, EventArgs e)
  452. {
  453. listBox1.Items.AddRange(File.ReadAllLines("Tasks/" + Login.username + ".txt"));
  454. comboBox2.Items.Add("Waiting");
  455. comboBox2.Items.Add("Finished");
  456. StreamReader b = new StreamReader("Accounts.txt");
  457. string da = b.ReadLine();
  458. while (da != null)
  459. {
  460. comboBox1.Items.Add(Regex.Match(da, Login.regex).Groups[1].ToString());
  461. da = b.ReadLine();
  462. }
  463. b.Close();
  464. }
  465.  
  466. private void button1_Click(object sender, EventArgs e)
  467. {
  468. StreamReader haha = new StreamReader("Tasks/Zadachi.txt");
  469. if (textBox1.Text == null || textBox2.Text == null || textBox3.Text == null || comboBox1.SelectedItem == null || comboBox2.SelectedItem == null)
  470. {
  471. MessageBox.Show("Трябва да попълните всички полета!", "Грешка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  472. }
  473. else if (textBox1.Text == Regex.Match(haha.ReadToEnd(), Tasks_Create.task_regex).Groups[1].ToString())
  474. {
  475. MessageBox.Show("Вече има задача с такова име!", "Грешка", MessageBoxButtons.OK, MessageBoxIcon.Error);
  476. }
  477. else if (comboBox2.SelectedItem.ToString() != proverka && richTextBox1.Text == "")
  478. {
  479. MessageBox.Show("След като сте променили статуса на задачата, трябва да добавите коментар!", "Грешка", MessageBoxButtons.OK, MessageBoxIcon.Error);
  480. }
  481. else
  482. {
  483. haha.Close();
  484. int counter = 0;
  485. string prevrespuser = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[4].ToString();
  486. string newrespuser = comboBox1.SelectedItem.ToString();
  487. if (prevrespuser != newrespuser && prevrespuser!=creator)
  488. {
  489. StreamReader n = new StreamReader("Tasks/" + prevrespuser + ".txt");
  490. while (n.ReadLine() != null)
  491. {
  492. counter++;
  493. }
  494. n.Close();
  495. string[] masivche = new string[counter];
  496. StreamReader s = new StreamReader("Tasks/" + prevrespuser + ".txt");
  497. for (int i = 0; i < masivche.Length; i++)
  498. {
  499. masivche[i] = s.ReadLine().ToString();
  500. if (masivche[i] == listBox1.SelectedItem.ToString())
  501. {
  502. masivche[i] = null;
  503. }
  504. }
  505. s.Close();
  506. File.Delete("Tasks/" + prevrespuser + ".txt");
  507. File.Create("Tasks/" + prevrespuser + ".txt").Close();
  508. StreamWriter v = new StreamWriter("Tasks/" + prevrespuser + ".txt", true);
  509. for (int i = 0; i < masivche.Length; i++)
  510. {
  511. if (masivche[i] != null)
  512. {
  513. v.WriteLine(masivche[i]);
  514. }
  515. }
  516. v.Close();
  517. }
  518. int br2 = 0;
  519. StreamReader b = new StreamReader("Tasks/" + newrespuser + ".txt");
  520. while (b.ReadLine() != null)
  521. {
  522. br2++;
  523. }
  524. if (br2 == 0)
  525. {
  526. br2++;
  527. }
  528. b.Close();
  529. string[] temp = new string[br2];
  530. if (newrespuser == prevrespuser)
  531. {
  532. StreamReader da = new StreamReader("Tasks/" + newrespuser + ".txt");
  533. for (int i = 0; i < temp.Length; i++)
  534. {
  535. temp[i] = da.ReadLine().ToString();
  536. if (temp[i] == listBox1.SelectedItem.ToString())
  537. {
  538. temp[i] = "Name:" + textBox1.Text + " " + "Description:" + textBox2.Text + " " + "Grade:" + textBox3.Text + " " + "ResponsibleUser:" + comboBox1.SelectedItem.ToString() + " " + "Creator:" + textBox4.Text + " " + "DateCreation:" + textBox5.Text + " " + "DateChange:" + textBox6.Text + " " + "Status:" + comboBox2.SelectedItem.ToString();
  539. }
  540. }
  541. da.Close();
  542. b.Close();
  543. File.Delete("Tasks/" + newrespuser + ".txt");
  544. File.Create("Tasks/" + newrespuser + ".txt").Close();
  545. StreamWriter c = new StreamWriter("Tasks/" + newrespuser + ".txt", true);
  546. for (int i = 0; i < temp.Length; i++)
  547. {
  548. if (temp[i] != "")
  549. {
  550. c.WriteLine(temp[i]);
  551. }
  552. }
  553. c.Close();
  554. }
  555. else
  556. {
  557. StreamWriter g = new StreamWriter("Tasks/" + newrespuser + ".txt",true);
  558. g.WriteLine("Name:" + textBox1.Text + " " + "Description:" + textBox2.Text + " " + "Grade:" + textBox3.Text + " " + "ResponsibleUser:" + comboBox1.SelectedItem.ToString() + " " + "Creator:" + textBox4.Text + " " + "DateCreation:" + textBox5.Text + " " + "DateChange:" + textBox6.Text + " " + "Status:" + comboBox2.SelectedItem.ToString());
  559. g.Close();
  560. }
  561. int br = 0;
  562. StreamReader ne = new StreamReader("Tasks/Zadachi.txt");
  563. while (ne.ReadLine() != null)
  564. {
  565. br++;
  566. }
  567. ne.Close();
  568. string[] hue = new string[br];
  569. StreamReader d = new StreamReader("Tasks/Zadachi.txt");
  570. for (int i = 0; i < hue.Length; i++)
  571. {
  572. hue[i] = d.ReadLine().ToString();
  573. if (hue[i] == listBox1.SelectedItem.ToString())
  574. {
  575. hue[i] = "Name:" + textBox1.Text + " " + "Description:" + textBox2.Text + " " + "Grade:" + textBox3.Text + " " + "ResponsibleUser:" + comboBox1.SelectedItem.ToString() + " " + "Creator:" + textBox4.Text + " " + "DateCreation:" + textBox5.Text + " " + "DateChange:" + textBox6.Text + " " + "Status:" + comboBox2.SelectedItem.ToString();
  576. }
  577. }
  578. d.Close();
  579. System.GC.Collect();
  580. System.GC.WaitForPendingFinalizers();
  581. File.Delete("Tasks/Zadachi.txt");
  582. File.Create("Tasks/Zadachi.txt").Close();
  583. StreamWriter write = new StreamWriter("Tasks/Zadachi.txt", true);
  584. for (int i = 0; i < hue.Length; i++)
  585. {
  586. if (hue[i] != "")
  587. {
  588. write.WriteLine(hue[i]);
  589. }
  590. }
  591. write.Close();
  592. string[] masiv = new string[listBox1.Items.Count];
  593. StreamReader chetene = new StreamReader("Tasks/" + Login.username + ".txt");
  594. for (int i = 0; i < masiv.Length; i++)
  595. {
  596. masiv[i] = chetene.ReadLine().ToString();
  597. if (masiv[i] == listBox1.SelectedItem.ToString())
  598. {
  599. masiv[i] = "Name:" + textBox1.Text + " " + "Description:" + textBox2.Text + " " + "Grade:" + textBox3.Text + " " + "ResponsibleUser:" + comboBox1.SelectedItem.ToString() + " " + "Creator:" + textBox4.Text + " " + "DateCreation:" + textBox5.Text + " " + "DateChange:" + textBox6.Text + " " + "Status:" + comboBox2.SelectedItem.ToString();
  600. }
  601. }
  602. chetene.Close();
  603. File.Delete("Tasks/" + Login.username + ".txt");
  604. File.Create("Tasks/" + Login.username + ".txt").Close();
  605. StreamWriter pisane = new StreamWriter("Tasks/" + Login.username + ".txt", true);
  606. for (int i = 0; i < masiv.Length; i++)
  607. {
  608. if (masiv[i] != "")
  609. {
  610. pisane.WriteLine(masiv[i]);
  611. }
  612. }
  613. pisane.Close();
  614. string oldname = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[1].ToString();
  615. string newname = textBox1.Text;
  616. if(newname.ToLower()!=oldname.ToLower())
  617. {
  618. File.Copy("Comments/" + oldname + ".txt", "Comments/" + newname + ".txt");
  619. File.Delete("Comments/" + oldname + ".txt");
  620. }
  621. if (comboBox2.SelectedItem.ToString() != proverka && richTextBox1.Text != "")
  622. {
  623. StreamWriter comment = new StreamWriter("Comments/" + newname + ".txt",true);
  624. comment.WriteLine(richTextBox1.Text);
  625. comment.Close();
  626. }
  627. MessageBox.Show("Редакцията е успешна!");
  628. this.Close();
  629. }
  630. }
  631.  
  632. private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
  633. {
  634. e.Handled = !(char.IsLetter(e.KeyChar) || e.KeyChar == (char)Keys.Back || char.IsControl(e.KeyChar));
  635. }
  636.  
  637. private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
  638. {
  639. e.Handled = !(char.IsLetter(e.KeyChar) || e.KeyChar == (char)Keys.Back || char.IsWhiteSpace(e.KeyChar) || e.KeyChar == '.' || e.KeyChar == ',' || char.IsControl(e.KeyChar));
  640. }
  641.  
  642. private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
  643. {
  644. e.Handled = !(char.IsDigit(e.KeyChar) || e.KeyChar == (char)Keys.Back || char.IsControl(e.KeyChar));
  645. }
  646.  
  647. private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
  648. {
  649. if (e.KeyCode == Keys.Enter)
  650. e.SuppressKeyPress = true;
  651. }
  652. }
  653. }
  654. using System;
  655. using System.Collections.Generic;
  656. using System.ComponentModel;
  657. using System.Data;
  658. using System.Drawing;
  659. using System.Linq;
  660. using System.Text;
  661. using System.Threading.Tasks;
  662. using System.Windows.Forms;
  663. using System.IO;
  664. using System.Text.RegularExpressions;
  665.  
  666. namespace Task_Manager
  667. {
  668. public partial class Tasks_Create : Form
  669. {
  670. public static string task_regex = @"Name:([a-zA-Z]+)\sDescription:(.+)(?=Grade:)Grade:([0-9]+)\sResponsibleUser:([a-zA-Z0-9]+)\sCreator:([a-zA-Z0-9]+)\sDateCreation:([\d.]+)\sDateChange:([\d.]+)\sStatus:([\w]+)";
  671. public Tasks_Create()
  672. {
  673. InitializeComponent();
  674. }
  675.  
  676. private void Task_Create_Load(object sender, EventArgs e)
  677. {
  678. if(!File.Exists("Tasks/Zadachi.txt"))
  679. {
  680. File.Create("Tasks/Zadachi.txt").Close();
  681. }
  682. comboBox2.Items.Add("Waiting");
  683. comboBox2.Items.Add("Finished");
  684. StreamReader b = new StreamReader("Accounts.txt");
  685. string da = b.ReadLine();
  686. while (da != null)
  687. {
  688. comboBox1.Items.Add(Regex.Match(da, Login.regex).Groups[1].ToString());
  689. da = b.ReadLine();
  690. }
  691. b.Close();
  692. textBox4.Text = Login.username;
  693. DateTime date = DateTime.Now;
  694. string format="dd.MM.yyyy";
  695. textBox5.Text = date.ToString(format);
  696. textBox6.Text = date.ToString(format);
  697. textBox1.MaxLength = 15;
  698. textBox2.MaxLength = 100;
  699. textBox3.MaxLength = 4;
  700. }
  701.  
  702. private void button1_Click(object sender, EventArgs e)
  703. {
  704. StreamReader d = new StreamReader("Tasks/Zadachi.txt");
  705. if(textBox1.Text==null || textBox2.Text==null || textBox3.Text==null || comboBox1.SelectedItem==null || comboBox2.SelectedItem==null)
  706. {
  707. MessageBox.Show("Трябва да попълните всички полета!","Грешка!",MessageBoxButtons.OK,MessageBoxIcon.Error);
  708. }
  709. else if (textBox1.Text == Regex.Match(d.ReadToEnd(), task_regex).Groups[1].ToString())
  710. {
  711. MessageBox.Show("Вече има задача с такова име!", "Грешка", MessageBoxButtons.OK, MessageBoxIcon.Error);
  712. }
  713. else
  714. {
  715. d.Close();
  716. StreamWriter a = new StreamWriter("Tasks/"+comboBox1.SelectedItem + ".txt", true);
  717. a.WriteLine("Name:" + textBox1.Text + " " + "Description:" + textBox2.Text + " " + "Grade:" + textBox3.Text + " " + "ResponsibleUser:" + comboBox1.SelectedItem.ToString() + " " + "Creator:" + textBox4.Text + " " + "DateCreation:" + textBox5.Text + " " + "DateChange:" + textBox6.Text + " " + "Status:" + comboBox2.SelectedItem.ToString());
  718. a.Close();
  719. if (comboBox1.SelectedItem.ToString() != Login.username)
  720. {
  721. StreamWriter b = new StreamWriter("Tasks/"+Login.username + ".txt", true);
  722. b.WriteLine("Name:" + textBox1.Text + " " + "Description:" + textBox2.Text + " " + "Grade:" + textBox3.Text + " " + "ResponsibleUser:" + comboBox1.SelectedItem.ToString() + " " + "Creator:" + textBox4.Text + " " + "DateCreation:" + textBox5.Text + " " + "DateChange:" + textBox6.Text + " " + "Status:" + comboBox2.SelectedItem.ToString());
  723. b.Close();
  724. }
  725. StreamWriter c = new StreamWriter("Tasks/Zadachi.txt", true);
  726. c.WriteLine("Name:" + textBox1.Text + " " + "Description:" + textBox2.Text + " " + "Grade:" + textBox3.Text + " " + "ResponsibleUser:" + comboBox1.SelectedItem.ToString() + " " + "Creator:" + textBox4.Text + " " + "DateCreation:" + textBox5.Text + " " + "DateChange:" + textBox6.Text + " " + "Status:" + comboBox2.SelectedItem.ToString());
  727. c.Close();
  728. File.Create("Comments/"+textBox1.Text+".txt").Close();
  729. MessageBox.Show("Задачата е успешно създадена!");
  730. this.Close();
  731. }
  732. d.Close();
  733. }
  734.  
  735. private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
  736. {
  737. e.Handled = !(char.IsDigit(e.KeyChar) || e.KeyChar == (char)Keys.Back || char.IsControl(e.KeyChar));
  738. }
  739.  
  740. private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
  741. {
  742. e.Handled = !(char.IsLetter(e.KeyChar) || e.KeyChar == (char)Keys.Back || char.IsControl(e.KeyChar));
  743. }
  744.  
  745. private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
  746. {
  747. e.Handled = !(char.IsLetter(e.KeyChar) || e.KeyChar == (char)Keys.Back || char.IsWhiteSpace(e.KeyChar) || e.KeyChar == '.' || e.KeyChar == ',' || char.IsControl(e.KeyChar));
  748. }
  749. }
  750. }
  751. using System;
  752. using System.Collections.Generic;
  753. using System.ComponentModel;
  754. using System.Data;
  755. using System.Drawing;
  756. using System.Linq;
  757. using System.Text;
  758. using System.Threading.Tasks;
  759. using System.Windows.Forms;
  760. using System.IO;
  761. using System.Text.RegularExpressions;
  762.  
  763. namespace Task_Manager
  764. {
  765. public partial class Tasks_Delete : Form
  766. {
  767. public Tasks_Delete()
  768. {
  769. InitializeComponent();
  770. }
  771.  
  772. private void Tasks_Delete_Load(object sender, EventArgs e)
  773. {
  774. listBox1.Items.AddRange(File.ReadAllLines("Tasks/" + Login.username + ".txt"));
  775. }
  776.  
  777. private void button1_Click(object sender, EventArgs e)
  778. {
  779. int counter = 0;
  780. string respuser = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[4].ToString();
  781. string filename = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[1].ToString();
  782. File.Delete("Comments/"+filename+".txt");
  783. StreamReader b = new StreamReader("Tasks/" + respuser + ".txt");
  784. while(b.ReadLine()!=null)
  785. {
  786. counter++;
  787. }
  788. b.Close();
  789. string[] temp=new string [counter];
  790. StreamReader da = new StreamReader("Tasks/" + respuser + ".txt");
  791. for (int i = 0; i < temp.Length;i++)
  792. {
  793. temp[i] = da.ReadLine().ToString();
  794. if(temp[i]==listBox1.SelectedItem.ToString())
  795. {
  796. temp[i] = null;
  797. }
  798. }
  799. da.Close();
  800. File.Delete("Tasks/" + respuser + ".txt");
  801. File.Create("Tasks/" + respuser + ".txt").Close();
  802. StreamWriter c = new StreamWriter("Tasks/" + respuser + ".txt", true);
  803. for (int i = 0; i < temp.Length;i++)
  804. {
  805. if(temp[i]!=null)
  806. {
  807. c.WriteLine(temp[i]);
  808. }
  809. }
  810. c.Close();
  811. int br = 0;
  812. StreamReader ne = new StreamReader("Tasks/Zadachi.txt");
  813. while(ne.ReadLine()!=null)
  814. {
  815. br++;
  816. }
  817. ne.Close();
  818. string[] hue = new string[br];
  819. StreamReader d = new StreamReader("Tasks/Zadachi.txt");
  820. for (int i = 0; i < hue.Length; i++)
  821. {
  822. hue[i] = d.ReadLine().ToString();
  823. if(hue[i]==listBox1.SelectedItem.ToString())
  824. {
  825. hue[i] = null;
  826. }
  827. }
  828. d.Close();
  829. File.Delete("Tasks/Zadachi.txt");
  830. File.Create("Tasks/Zadachi.txt").Close();
  831. StreamWriter write = new StreamWriter("Tasks/Zadachi.txt",true);
  832. for (int i = 0; i < hue.Length;i++ )
  833. {
  834. if(hue[i]!=null)
  835. {
  836. write.WriteLine(hue[i]);
  837. }
  838. }
  839. write.Close();
  840. listBox1.Items.Remove(listBox1.SelectedItem);
  841. File.Delete("Tasks/" + Login.username + ".txt");
  842. File.Create("Tasks/" + Login.username + ".txt").Close();
  843. StreamWriter a = new StreamWriter("Tasks/" + Login.username + ".txt", true);
  844. foreach (var item in listBox1.Items)
  845. {
  846. a.WriteLine(item.ToString());
  847. }
  848. a.Close();
  849. MessageBox.Show("Изтриването е успешно!");
  850. this.Close();
  851. }
  852. }
  853. }
  854. using System;
  855. using System.Collections.Generic;
  856. using System.ComponentModel;
  857. using System.Data;
  858. using System.Drawing;
  859. using System.Linq;
  860. using System.Text;
  861. using System.Threading.Tasks;
  862. using System.Windows.Forms;
  863. using System.IO;
  864.  
  865. namespace Task_Manager
  866. {
  867. public partial class Tasks_Look : Form
  868. {
  869. public Tasks_Look()
  870. {
  871. InitializeComponent();
  872. }
  873.  
  874. private void Tasks_Look_Load(object sender, EventArgs e)
  875. {
  876. listBox1.Items.AddRange(File.ReadAllLines("Tasks/" + Login.username + ".txt"));
  877. }
  878. }
  879. }
  880. using System;
  881. using System.Collections.Generic;
  882. using System.ComponentModel;
  883. using System.Data;
  884. using System.Drawing;
  885. using System.Linq;
  886. using System.Text;
  887. using System.Threading.Tasks;
  888. using System.Windows.Forms;
  889. using System.IO;
  890. using System.Text.RegularExpressions;
  891.  
  892. namespace Task_Manager
  893. {
  894. public partial class Users_Add : Form
  895. {
  896. public Users_Add()
  897. {
  898. InitializeComponent();
  899. }
  900.  
  901. private void button1_Click(object sender, EventArgs e)
  902. {
  903. StreamReader b = new StreamReader("Accounts.txt");
  904. if(textBox1.TextLength<3 || textBox1.TextLength>12)
  905. {
  906. MessageBox.Show("Името трябва да е между 3 и 12 символа!","Грешка!",MessageBoxButtons.OK,MessageBoxIcon.Error);
  907. }
  908. else if(textBox2.TextLength<3 || textBox2.TextLength>12)
  909. {
  910. MessageBox.Show("Паролата трябва да е между 3 и 12 символа!", "Грешка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  911. }
  912. else if (textBox1.Text == Regex.Match(b.ReadToEnd(), Login.regex).Groups[1].ToString())
  913. {
  914. MessageBox.Show("Вече съществува такова име!", "Грешка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  915. }
  916. else
  917. {
  918. b.Close();
  919. System.GC.Collect();
  920. System.GC.WaitForPendingFinalizers();
  921. StreamWriter a = new StreamWriter("Accounts.txt", true);
  922. if (checkBox1.Checked)
  923. {
  924. a.WriteLine("Username:" + textBox1.Text + " " + "Password:" + textBox2.Text + " " + "true");
  925. }
  926. else
  927. {
  928. a.WriteLine("Username:" + textBox1.Text + " " + "Password:" + textBox2.Text + " " + "false");
  929. }
  930. a.Close();
  931. File.Create("Tasks/" + textBox1.Text + ".txt").Close();
  932. MessageBox.Show("Успешно добавен потребител!");
  933. this.Close();
  934. }
  935. b.Close();
  936. }
  937.  
  938. private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
  939. {
  940. e.Handled = !(char.IsLetterOrDigit(e.KeyChar) || e.KeyChar == (char)Keys.Back);
  941. }
  942.  
  943. private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
  944. {
  945. e.Handled = !(char.IsLetterOrDigit(e.KeyChar) || e.KeyChar == (char)Keys.Back);
  946. }
  947. }
  948. }
  949. using System;
  950. using System.Collections.Generic;
  951. using System.ComponentModel;
  952. using System.Data;
  953. using System.Drawing;
  954. using System.Linq;
  955. using System.Text;
  956. using System.Threading.Tasks;
  957. using System.Windows.Forms;
  958. using System.IO;
  959. using System.Text.RegularExpressions;
  960.  
  961. namespace Task_Manager
  962. {
  963. public partial class Users_Change : Form
  964. {
  965. public Users_Change()
  966. {
  967. InitializeComponent();
  968. }
  969.  
  970. private void Users_Change_Load(object sender, EventArgs e)
  971. {
  972. listBox1.Items.AddRange(File.ReadAllLines("Accounts.txt"));
  973. listBox1.SelectedIndex = 0;
  974. }
  975.  
  976. private void button1_Click(object sender, EventArgs e)
  977. {
  978. StreamReader b = new StreamReader("Accounts.txt");
  979. if (textBox1.TextLength < 3 || textBox1.TextLength > 12)
  980. {
  981. MessageBox.Show("Името трябва да е между 3 и 12 символа!", "Грешка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  982. }
  983. else if (textBox2.TextLength < 3 || textBox2.TextLength > 12)
  984. {
  985. MessageBox.Show("Паролата трябва да е между 3 и 12 символа!", "Грешка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  986. }
  987. else if (textBox1.Text == Regex.Match(b.ReadToEnd().ToString(), Login.regex).Groups[1].ToString())
  988. {
  989. MessageBox.Show("Вече съществува такова име!", "Грешка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  990. }
  991. else
  992. {
  993. b.Close();
  994. StreamReader mhm = new StreamReader("Accounts.txt");
  995. string[] file = new string[listBox1.Items.Count];
  996. for (int i = 0; i < file.Length; i++)
  997. {
  998. file[i] = mhm.ReadLine().ToString();
  999. if (file[i] == listBox1.SelectedItem.ToString())
  1000. {
  1001. if (checkBox1.Checked)
  1002. {
  1003. file[i] = "Username:" + textBox1.Text + " " + "Password:" + textBox2.Text + " " + "true";
  1004. }
  1005. else
  1006. {
  1007. file[i] = "Username:" + textBox1.Text + " " + "Password:" + textBox2.Text + " " + "false";
  1008. }
  1009. }
  1010. }
  1011. mhm.Close();
  1012. b.Close();
  1013. System.GC.Collect();
  1014. System.GC.WaitForPendingFinalizers();
  1015. File.Delete("Accounts.txt");
  1016. File.Create("Accounts.txt").Close();
  1017. StreamWriter c = new StreamWriter("Accounts.txt", true);
  1018. for (int i = 0; i < file.Length; i++)
  1019. {
  1020. c.WriteLine(file[i]);
  1021. }
  1022. c.Close();
  1023. string oldname = Regex.Match(listBox1.SelectedItem.ToString(), Login.regex).Groups[1].ToString();
  1024. string newname = textBox1.Text;
  1025. if(newname.ToLower()!=oldname.ToLower())
  1026. {
  1027. File.Copy("Tasks/" + oldname + ".txt", "Tasks/" + newname + ".txt");
  1028. File.Delete("Tasks/" + oldname + ".txt");
  1029. }
  1030. MessageBox.Show("Редакцията е успешна!");
  1031. this.Close();
  1032.  
  1033. }
  1034. }
  1035.  
  1036. private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
  1037. {
  1038. if(listBox1.SelectedIndex>=0 && listBox1.SelectedItem!=null)
  1039. {
  1040. string line = listBox1.SelectedItem.ToString();
  1041. textBox1.Text = Regex.Match(line, Login.regex).Groups[1].ToString();
  1042. textBox2.Text = Regex.Match(line, Login.regex).Groups[2].ToString();
  1043. }
  1044. }
  1045.  
  1046. private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
  1047. {
  1048. e.Handled = !(char.IsLetterOrDigit(e.KeyChar) || e.KeyChar == (char)Keys.Back);
  1049. }
  1050.  
  1051. private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
  1052. {
  1053. e.Handled = !(char.IsLetterOrDigit(e.KeyChar) || e.KeyChar == (char)Keys.Back);
  1054. }
  1055. }
  1056. }
  1057. using System;
  1058. using System.Collections.Generic;
  1059. using System.ComponentModel;
  1060. using System.Data;
  1061. using System.Drawing;
  1062. using System.Linq;
  1063. using System.Text;
  1064. using System.Threading.Tasks;
  1065. using System.Windows.Forms;
  1066. using System.IO;
  1067. using System.Text.RegularExpressions;
  1068.  
  1069. namespace Task_Manager
  1070. {
  1071. public partial class Users_Delete : Form
  1072. {
  1073. public Users_Delete()
  1074. {
  1075. InitializeComponent();
  1076. }
  1077.  
  1078. private void Users_Delete_Load(object sender, EventArgs e)
  1079. {
  1080. listBox1.Items.AddRange(File.ReadAllLines("Accounts.txt"));
  1081. }
  1082.  
  1083. private void button1_Click(object sender, EventArgs e)
  1084. {
  1085. listBox1.Items.Remove(listBox1.SelectedItem);
  1086. File.Delete("Accounts.txt");
  1087. File.Create("Accounts.txt").Close();
  1088. StreamWriter a = new StreamWriter("Accounts.txt",true);
  1089. foreach(var item in listBox1.Items)
  1090. {
  1091. a.WriteLine(item.ToString());
  1092. }
  1093. a.Close();
  1094. MessageBox.Show("Изтриването е успешно!");
  1095. this.Close();
  1096. }
  1097. }
  1098. }
  1099. using System;
  1100. using System.Collections.Generic;
  1101. using System.ComponentModel;
  1102. using System.Data;
  1103. using System.Drawing;
  1104. using System.Linq;
  1105. using System.Text;
  1106. using System.Threading.Tasks;
  1107. using System.Windows.Forms;
  1108. using System.IO;
  1109.  
  1110. namespace Task_Manager
  1111. {
  1112. public partial class Users_Look : Form
  1113. {
  1114. public Users_Look()
  1115. {
  1116. InitializeComponent();
  1117. }
  1118.  
  1119. private void Users_Look_Load(object sender, EventArgs e)
  1120. {
  1121. listBox1.Items.AddRange(File.ReadAllLines("Accounts.txt"));
  1122. }
  1123. }
  1124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement