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;
- using System.Text.RegularExpressions;
- namespace Task_Manager
- {
- public partial class Check_Time : Form
- {
- public Check_Time()
- {
- InitializeComponent();
- }
- private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
- {
- e.Handled = !(char.IsDigit(e.KeyChar) || e.KeyChar == (char)Keys.Back || char.IsControl(e.KeyChar));
- }
- private void Check_Time_Load(object sender, EventArgs e)
- {
- listBox1.Items.AddRange(File.ReadAllLines("Tasks/" + Login.username + ".txt"));
- if(!File.Exists("Otcheti.txt"))
- {
- File.Create("Otcheti.txt").Close();
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- StreamWriter a = new StreamWriter("Otcheti.txt");
- string zaglavie=Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[1].ToString();
- DateTime date = DateTime.Now;
- string format = "dd.MM.yyyy";
- string data = date.ToString(format);
- a.WriteLine("Task:" + zaglavie + " " + "User:" + Login.username + " " + "Time:" + textBox1.Text + " " + "Date:" + data);
- a.Close();
- MessageBox.Show("Времето е отчетено успешно!");
- this.Close();
- }
- }
- }
- 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;
- using System.Text.RegularExpressions;
- namespace Task_Manager
- {
- public partial class Comment_Add : Form
- {
- public Comment_Add()
- {
- InitializeComponent();
- }
- private void Comment_Add_Load(object sender, EventArgs e)
- {
- listBox1.Items.AddRange(File.ReadAllLines("Tasks/" + Login.username + ".txt"));
- }
- private void button1_Click(object sender, EventArgs e)
- {
- string zaglavie = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[1].ToString();
- StreamWriter comment = new StreamWriter("Comments/"+zaglavie+".txt",true);
- comment.WriteLine(Login.username+":"+ richTextBox1.Text);
- comment.Close();
- MessageBox.Show("Успешно добавен коментар.");
- this.Close();
- }
- private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- e.SuppressKeyPress = true;
- }
- }
- }
- 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;
- using System.Text.RegularExpressions;
- namespace Task_Manager
- {
- public partial class Comments_Look : Form
- {
- public Comments_Look()
- {
- InitializeComponent();
- }
- private void Comments_Look_Load(object sender, EventArgs e)
- {
- listBox1.Items.AddRange(File.ReadAllLines("Tasks/" + Login.username + ".txt"));
- listBox1.SelectedIndex = 0;
- }
- private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- string zaglavie = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[1].ToString();
- StreamReader comment = new StreamReader("Comments/"+zaglavie+".txt");
- richTextBox1.Text = comment.ReadToEnd();
- comment.Close();
- }
- }
- }
- 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;
- using System.Text.RegularExpressions;
- namespace Task_Manager
- {
- public partial class Login : Form
- {
- public static string username = null;
- public static bool admin = false;
- public static string regex = @"\bUsername:([a-zA-Z0-9]+)\s*Password:([a-zA-Z0-9_]+)\s*(true)?(false)?";
- public Login()
- {
- InitializeComponent();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- Register a = new Register();
- a.ShowDialog();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- StreamReader a = new StreamReader("Accounts.txt", true);
- string check = a.ReadToEnd();
- Regex rg = new Regex(regex);
- MatchCollection matches = rg.Matches(check);
- foreach (Match m in matches)
- {
- if (textBox1.Text == m.Groups[1].ToString())
- {
- a.Close();
- StreamReader b = new StreamReader("Accounts.txt", true);
- if (textBox2.Text == m.Groups[2].ToString())
- {
- MessageBox.Show("Логин успешен!");
- username = textBox1.Text;
- if (m.Groups[3].ToString() == "true")
- {
- admin = true;
- }
- this.Close();
- break;
- }
- b.Close();
- }
- }
- if (username == null)
- {
- MessageBox.Show("Грешно име или парола!", "Грешка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- a.Close();
- }
- private void Login_Load(object sender, EventArgs e)
- {
- if(!File.Exists("Accounts.txt"))
- {
- File.Create("Accounts.txt").Close();
- }
- if (!Directory.Exists("Comments"))
- {
- Directory.CreateDirectory("Comments");
- }
- if (!Directory.Exists("Tasks"))
- {
- Directory.CreateDirectory("Tasks");
- }
- }
- }
- }
- 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;
- namespace Task_Manager
- {
- public partial class Main : Form
- {
- public Main()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- Login a = new Login();
- a.ShowDialog();
- if(Login.username==null)
- {
- MessageBox.Show("Не сте в системата!");
- Application.Exit();
- }
- }
- private void добавиToolStripMenuItem2_Click(object sender, EventArgs e)
- {
- Users_Add a = new Users_Add();
- if(Login.admin==false)
- {
- MessageBox.Show("Това меню е само за админи!","Грешка",MessageBoxButtons.OK,MessageBoxIcon.Error);
- }
- else
- {
- a.ShowDialog();
- }
- }
- private void редактирайToolStripMenuItem1_Click(object sender, EventArgs e)
- {
- Users_Change a = new Users_Change();
- if (Login.admin == false)
- {
- MessageBox.Show("Това меню е само за админи!", "Грешка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- else
- {
- a.ShowDialog();
- }
- }
- private void изтрийToolStripMenuItem1_Click(object sender, EventArgs e)
- {
- Users_Delete a = new Users_Delete();
- if (Login.admin == false)
- {
- MessageBox.Show("Това меню е само за админи!", "Грешка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- else
- {
- a.ShowDialog();
- }
- }
- private void прегледайToolStripMenuItem2_Click(object sender, EventArgs e)
- {
- Users_Look a = new Users_Look();
- if (Login.admin == false)
- {
- MessageBox.Show("Това меню е само за админи!", "Грешка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- else
- {
- a.ShowDialog();
- }
- }
- private void добавиToolStripMenuItem_Click(object sender, EventArgs e)
- {
- Tasks_Create a = new Tasks_Create();
- a.ShowDialog();
- }
- private void прегледайToolStripMenuItem_Click(object sender, EventArgs e)
- {
- Tasks_Look a = new Tasks_Look();
- a.ShowDialog();
- }
- private void изтрийToolStripMenuItem_Click(object sender, EventArgs e)
- {
- Tasks_Delete a = new Tasks_Delete();
- a.ShowDialog();
- }
- private void редактирайToolStripMenuItem_Click(object sender, EventArgs e)
- {
- Tasks_Change a = new Tasks_Change();
- a.ShowDialog();
- }
- private void отчетиВремеПоЗадачаToolStripMenuItem_Click(object sender, EventArgs e)
- {
- Check_Time a = new Check_Time();
- a.ShowDialog();
- }
- private void добавиToolStripMenuItem1_Click(object sender, EventArgs e)
- {
- Comment_Add a = new Comment_Add();
- a.ShowDialog();
- }
- private void прегледайToolStripMenuItem1_Click(object sender, EventArgs e)
- {
- Comments_Look a = new Comments_Look();
- a.ShowDialog();
- }
- }
- }
- 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;
- using System.Text.RegularExpressions;
- namespace Task_Manager
- {
- public partial class Register : Form
- {
- public Register()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- StreamReader b = new StreamReader("Accounts.txt", true);
- if (textBox1.TextLength < 3 || textBox1.TextLength > 12)
- {
- MessageBox.Show("Името трябва да е между 3 и 12 символа!", "Грешка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- else if (textBox2.TextLength < 3 || textBox2.TextLength > 12)
- {
- MessageBox.Show("Паролата трябва да е между 3 и 12 символа!", "Грешка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- else if (textBox1.Text == Regex.Match(b.ReadToEnd(), Login.regex).Groups[1].ToString())
- {
- MessageBox.Show("Вече съществува такова име!", "Грешка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- else
- {
- b.Close();
- StreamWriter a = new StreamWriter("Accounts.txt", true);
- if (checkBox1.Checked)
- {
- a.WriteLine("Username:" + textBox1.Text + " " + "Password:" + textBox2.Text + " " + "true");
- }
- else
- {
- a.WriteLine("Username:" + textBox1.Text + " " + "Password:" + textBox2.Text + " " + "false");
- }
- a.Close();
- File.Create("Tasks/" + textBox1.Text + ".txt").Close();
- MessageBox.Show("Регистрацията е успешна!");
- this.Close();
- }
- b.Close();
- }
- private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
- {
- e.Handled = !(char.IsLetterOrDigit(e.KeyChar) || e.KeyChar == (char)Keys.Back);
- }
- private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
- {
- e.Handled = !(char.IsLetterOrDigit(e.KeyChar) || e.KeyChar == (char)Keys.Back);
- }
- private void Register_Load(object sender, EventArgs e)
- {
- if (!File.Exists("Accounts.txt"))
- {
- File.Create("Accounts.txt").Close();
- }
- }
- }
- }
- 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;
- using System.Text.RegularExpressions;
- namespace Task_Manager
- {
- public partial class Tasks_Change : Form
- {
- public static string proverka = "";
- public static string creator = "";
- public Tasks_Change()
- {
- InitializeComponent();
- }
- private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- if(listBox1.SelectedIndex>=0 && listBox1.SelectedItem!=null)
- {
- textBox1.Text = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[1].ToString();
- textBox2.Text = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[2].ToString();
- textBox3.Text = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[3].ToString();
- comboBox1.SelectedItem = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[4].ToString();
- textBox4.Text = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[5].ToString();
- textBox5.Text = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[6].ToString();
- DateTime date = DateTime.Now;
- string format = "dd.MM.yyyy";
- textBox6.Text = date.ToString(format);
- comboBox2.SelectedItem = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[8].ToString();
- proverka = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[8].ToString();
- creator = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[5].ToString();
- }
- }
- private void Tasks_Change_Load(object sender, EventArgs e)
- {
- listBox1.Items.AddRange(File.ReadAllLines("Tasks/" + Login.username + ".txt"));
- comboBox2.Items.Add("Waiting");
- comboBox2.Items.Add("Finished");
- StreamReader b = new StreamReader("Accounts.txt");
- string da = b.ReadLine();
- while (da != null)
- {
- comboBox1.Items.Add(Regex.Match(da, Login.regex).Groups[1].ToString());
- da = b.ReadLine();
- }
- b.Close();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- StreamReader haha = new StreamReader("Tasks/Zadachi.txt");
- if (textBox1.Text == null || textBox2.Text == null || textBox3.Text == null || comboBox1.SelectedItem == null || comboBox2.SelectedItem == null)
- {
- MessageBox.Show("Трябва да попълните всички полета!", "Грешка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- else if (textBox1.Text == Regex.Match(haha.ReadToEnd(), Tasks_Create.task_regex).Groups[1].ToString())
- {
- MessageBox.Show("Вече има задача с такова име!", "Грешка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- else if (comboBox2.SelectedItem.ToString() != proverka && richTextBox1.Text == "")
- {
- MessageBox.Show("След като сте променили статуса на задачата, трябва да добавите коментар!", "Грешка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- else
- {
- haha.Close();
- int counter = 0;
- string prevrespuser = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[4].ToString();
- string newrespuser = comboBox1.SelectedItem.ToString();
- if (prevrespuser != newrespuser && prevrespuser!=creator)
- {
- StreamReader n = new StreamReader("Tasks/" + prevrespuser + ".txt");
- while (n.ReadLine() != null)
- {
- counter++;
- }
- n.Close();
- string[] masivche = new string[counter];
- StreamReader s = new StreamReader("Tasks/" + prevrespuser + ".txt");
- for (int i = 0; i < masivche.Length; i++)
- {
- masivche[i] = s.ReadLine().ToString();
- if (masivche[i] == listBox1.SelectedItem.ToString())
- {
- masivche[i] = null;
- }
- }
- s.Close();
- File.Delete("Tasks/" + prevrespuser + ".txt");
- File.Create("Tasks/" + prevrespuser + ".txt").Close();
- StreamWriter v = new StreamWriter("Tasks/" + prevrespuser + ".txt", true);
- for (int i = 0; i < masivche.Length; i++)
- {
- if (masivche[i] != null)
- {
- v.WriteLine(masivche[i]);
- }
- }
- v.Close();
- }
- int br2 = 0;
- StreamReader b = new StreamReader("Tasks/" + newrespuser + ".txt");
- while (b.ReadLine() != null)
- {
- br2++;
- }
- if (br2 == 0)
- {
- br2++;
- }
- b.Close();
- string[] temp = new string[br2];
- if (newrespuser == prevrespuser)
- {
- StreamReader da = new StreamReader("Tasks/" + newrespuser + ".txt");
- for (int i = 0; i < temp.Length; i++)
- {
- temp[i] = da.ReadLine().ToString();
- if (temp[i] == listBox1.SelectedItem.ToString())
- {
- 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();
- }
- }
- da.Close();
- b.Close();
- File.Delete("Tasks/" + newrespuser + ".txt");
- File.Create("Tasks/" + newrespuser + ".txt").Close();
- StreamWriter c = new StreamWriter("Tasks/" + newrespuser + ".txt", true);
- for (int i = 0; i < temp.Length; i++)
- {
- if (temp[i] != "")
- {
- c.WriteLine(temp[i]);
- }
- }
- c.Close();
- }
- else
- {
- StreamWriter g = new StreamWriter("Tasks/" + newrespuser + ".txt",true);
- 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());
- g.Close();
- }
- int br = 0;
- StreamReader ne = new StreamReader("Tasks/Zadachi.txt");
- while (ne.ReadLine() != null)
- {
- br++;
- }
- ne.Close();
- string[] hue = new string[br];
- StreamReader d = new StreamReader("Tasks/Zadachi.txt");
- for (int i = 0; i < hue.Length; i++)
- {
- hue[i] = d.ReadLine().ToString();
- if (hue[i] == listBox1.SelectedItem.ToString())
- {
- 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();
- }
- }
- d.Close();
- System.GC.Collect();
- System.GC.WaitForPendingFinalizers();
- File.Delete("Tasks/Zadachi.txt");
- File.Create("Tasks/Zadachi.txt").Close();
- StreamWriter write = new StreamWriter("Tasks/Zadachi.txt", true);
- for (int i = 0; i < hue.Length; i++)
- {
- if (hue[i] != "")
- {
- write.WriteLine(hue[i]);
- }
- }
- write.Close();
- string[] masiv = new string[listBox1.Items.Count];
- StreamReader chetene = new StreamReader("Tasks/" + Login.username + ".txt");
- for (int i = 0; i < masiv.Length; i++)
- {
- masiv[i] = chetene.ReadLine().ToString();
- if (masiv[i] == listBox1.SelectedItem.ToString())
- {
- 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();
- }
- }
- chetene.Close();
- File.Delete("Tasks/" + Login.username + ".txt");
- File.Create("Tasks/" + Login.username + ".txt").Close();
- StreamWriter pisane = new StreamWriter("Tasks/" + Login.username + ".txt", true);
- for (int i = 0; i < masiv.Length; i++)
- {
- if (masiv[i] != "")
- {
- pisane.WriteLine(masiv[i]);
- }
- }
- pisane.Close();
- string oldname = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[1].ToString();
- string newname = textBox1.Text;
- if(newname.ToLower()!=oldname.ToLower())
- {
- File.Copy("Comments/" + oldname + ".txt", "Comments/" + newname + ".txt");
- File.Delete("Comments/" + oldname + ".txt");
- }
- if (comboBox2.SelectedItem.ToString() != proverka && richTextBox1.Text != "")
- {
- StreamWriter comment = new StreamWriter("Comments/" + newname + ".txt",true);
- comment.WriteLine(richTextBox1.Text);
- comment.Close();
- }
- MessageBox.Show("Редакцията е успешна!");
- this.Close();
- }
- }
- private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
- {
- e.Handled = !(char.IsLetter(e.KeyChar) || e.KeyChar == (char)Keys.Back || char.IsControl(e.KeyChar));
- }
- private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
- {
- e.Handled = !(char.IsLetter(e.KeyChar) || e.KeyChar == (char)Keys.Back || char.IsWhiteSpace(e.KeyChar) || e.KeyChar == '.' || e.KeyChar == ',' || char.IsControl(e.KeyChar));
- }
- private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
- {
- e.Handled = !(char.IsDigit(e.KeyChar) || e.KeyChar == (char)Keys.Back || char.IsControl(e.KeyChar));
- }
- private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- e.SuppressKeyPress = true;
- }
- }
- }
- 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;
- using System.Text.RegularExpressions;
- namespace Task_Manager
- {
- public partial class Tasks_Create : Form
- {
- 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]+)";
- public Tasks_Create()
- {
- InitializeComponent();
- }
- private void Task_Create_Load(object sender, EventArgs e)
- {
- if(!File.Exists("Tasks/Zadachi.txt"))
- {
- File.Create("Tasks/Zadachi.txt").Close();
- }
- comboBox2.Items.Add("Waiting");
- comboBox2.Items.Add("Finished");
- StreamReader b = new StreamReader("Accounts.txt");
- string da = b.ReadLine();
- while (da != null)
- {
- comboBox1.Items.Add(Regex.Match(da, Login.regex).Groups[1].ToString());
- da = b.ReadLine();
- }
- b.Close();
- textBox4.Text = Login.username;
- DateTime date = DateTime.Now;
- string format="dd.MM.yyyy";
- textBox5.Text = date.ToString(format);
- textBox6.Text = date.ToString(format);
- textBox1.MaxLength = 15;
- textBox2.MaxLength = 100;
- textBox3.MaxLength = 4;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- StreamReader d = new StreamReader("Tasks/Zadachi.txt");
- if(textBox1.Text==null || textBox2.Text==null || textBox3.Text==null || comboBox1.SelectedItem==null || comboBox2.SelectedItem==null)
- {
- MessageBox.Show("Трябва да попълните всички полета!","Грешка!",MessageBoxButtons.OK,MessageBoxIcon.Error);
- }
- else if (textBox1.Text == Regex.Match(d.ReadToEnd(), task_regex).Groups[1].ToString())
- {
- MessageBox.Show("Вече има задача с такова име!", "Грешка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- else
- {
- d.Close();
- StreamWriter a = new StreamWriter("Tasks/"+comboBox1.SelectedItem + ".txt", true);
- 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());
- a.Close();
- if (comboBox1.SelectedItem.ToString() != Login.username)
- {
- StreamWriter b = new StreamWriter("Tasks/"+Login.username + ".txt", true);
- 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());
- b.Close();
- }
- StreamWriter c = new StreamWriter("Tasks/Zadachi.txt", true);
- 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());
- c.Close();
- File.Create("Comments/"+textBox1.Text+".txt").Close();
- MessageBox.Show("Задачата е успешно създадена!");
- this.Close();
- }
- d.Close();
- }
- private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
- {
- e.Handled = !(char.IsDigit(e.KeyChar) || e.KeyChar == (char)Keys.Back || char.IsControl(e.KeyChar));
- }
- private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
- {
- e.Handled = !(char.IsLetter(e.KeyChar) || e.KeyChar == (char)Keys.Back || char.IsControl(e.KeyChar));
- }
- private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
- {
- e.Handled = !(char.IsLetter(e.KeyChar) || e.KeyChar == (char)Keys.Back || char.IsWhiteSpace(e.KeyChar) || e.KeyChar == '.' || e.KeyChar == ',' || char.IsControl(e.KeyChar));
- }
- }
- }
- 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;
- using System.Text.RegularExpressions;
- namespace Task_Manager
- {
- public partial class Tasks_Delete : Form
- {
- public Tasks_Delete()
- {
- InitializeComponent();
- }
- private void Tasks_Delete_Load(object sender, EventArgs e)
- {
- listBox1.Items.AddRange(File.ReadAllLines("Tasks/" + Login.username + ".txt"));
- }
- private void button1_Click(object sender, EventArgs e)
- {
- int counter = 0;
- string respuser = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[4].ToString();
- string filename = Regex.Match(listBox1.SelectedItem.ToString(), Tasks_Create.task_regex).Groups[1].ToString();
- File.Delete("Comments/"+filename+".txt");
- StreamReader b = new StreamReader("Tasks/" + respuser + ".txt");
- while(b.ReadLine()!=null)
- {
- counter++;
- }
- b.Close();
- string[] temp=new string [counter];
- StreamReader da = new StreamReader("Tasks/" + respuser + ".txt");
- for (int i = 0; i < temp.Length;i++)
- {
- temp[i] = da.ReadLine().ToString();
- if(temp[i]==listBox1.SelectedItem.ToString())
- {
- temp[i] = null;
- }
- }
- da.Close();
- File.Delete("Tasks/" + respuser + ".txt");
- File.Create("Tasks/" + respuser + ".txt").Close();
- StreamWriter c = new StreamWriter("Tasks/" + respuser + ".txt", true);
- for (int i = 0; i < temp.Length;i++)
- {
- if(temp[i]!=null)
- {
- c.WriteLine(temp[i]);
- }
- }
- c.Close();
- int br = 0;
- StreamReader ne = new StreamReader("Tasks/Zadachi.txt");
- while(ne.ReadLine()!=null)
- {
- br++;
- }
- ne.Close();
- string[] hue = new string[br];
- StreamReader d = new StreamReader("Tasks/Zadachi.txt");
- for (int i = 0; i < hue.Length; i++)
- {
- hue[i] = d.ReadLine().ToString();
- if(hue[i]==listBox1.SelectedItem.ToString())
- {
- hue[i] = null;
- }
- }
- d.Close();
- File.Delete("Tasks/Zadachi.txt");
- File.Create("Tasks/Zadachi.txt").Close();
- StreamWriter write = new StreamWriter("Tasks/Zadachi.txt",true);
- for (int i = 0; i < hue.Length;i++ )
- {
- if(hue[i]!=null)
- {
- write.WriteLine(hue[i]);
- }
- }
- write.Close();
- listBox1.Items.Remove(listBox1.SelectedItem);
- File.Delete("Tasks/" + Login.username + ".txt");
- File.Create("Tasks/" + Login.username + ".txt").Close();
- StreamWriter a = new StreamWriter("Tasks/" + Login.username + ".txt", true);
- foreach (var item in listBox1.Items)
- {
- a.WriteLine(item.ToString());
- }
- a.Close();
- MessageBox.Show("Изтриването е успешно!");
- this.Close();
- }
- }
- }
- 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 Task_Manager
- {
- public partial class Tasks_Look : Form
- {
- public Tasks_Look()
- {
- InitializeComponent();
- }
- private void Tasks_Look_Load(object sender, EventArgs e)
- {
- listBox1.Items.AddRange(File.ReadAllLines("Tasks/" + Login.username + ".txt"));
- }
- }
- }
- 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;
- using System.Text.RegularExpressions;
- namespace Task_Manager
- {
- public partial class Users_Add : Form
- {
- public Users_Add()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- StreamReader b = new StreamReader("Accounts.txt");
- if(textBox1.TextLength<3 || textBox1.TextLength>12)
- {
- MessageBox.Show("Името трябва да е между 3 и 12 символа!","Грешка!",MessageBoxButtons.OK,MessageBoxIcon.Error);
- }
- else if(textBox2.TextLength<3 || textBox2.TextLength>12)
- {
- MessageBox.Show("Паролата трябва да е между 3 и 12 символа!", "Грешка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- else if (textBox1.Text == Regex.Match(b.ReadToEnd(), Login.regex).Groups[1].ToString())
- {
- MessageBox.Show("Вече съществува такова име!", "Грешка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- else
- {
- b.Close();
- System.GC.Collect();
- System.GC.WaitForPendingFinalizers();
- StreamWriter a = new StreamWriter("Accounts.txt", true);
- if (checkBox1.Checked)
- {
- a.WriteLine("Username:" + textBox1.Text + " " + "Password:" + textBox2.Text + " " + "true");
- }
- else
- {
- a.WriteLine("Username:" + textBox1.Text + " " + "Password:" + textBox2.Text + " " + "false");
- }
- a.Close();
- File.Create("Tasks/" + textBox1.Text + ".txt").Close();
- MessageBox.Show("Успешно добавен потребител!");
- this.Close();
- }
- b.Close();
- }
- private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
- {
- e.Handled = !(char.IsLetterOrDigit(e.KeyChar) || e.KeyChar == (char)Keys.Back);
- }
- private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
- {
- e.Handled = !(char.IsLetterOrDigit(e.KeyChar) || e.KeyChar == (char)Keys.Back);
- }
- }
- }
- 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;
- using System.Text.RegularExpressions;
- namespace Task_Manager
- {
- public partial class Users_Change : Form
- {
- public Users_Change()
- {
- InitializeComponent();
- }
- private void Users_Change_Load(object sender, EventArgs e)
- {
- listBox1.Items.AddRange(File.ReadAllLines("Accounts.txt"));
- listBox1.SelectedIndex = 0;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- StreamReader b = new StreamReader("Accounts.txt");
- if (textBox1.TextLength < 3 || textBox1.TextLength > 12)
- {
- MessageBox.Show("Името трябва да е между 3 и 12 символа!", "Грешка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- else if (textBox2.TextLength < 3 || textBox2.TextLength > 12)
- {
- MessageBox.Show("Паролата трябва да е между 3 и 12 символа!", "Грешка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- else if (textBox1.Text == Regex.Match(b.ReadToEnd().ToString(), Login.regex).Groups[1].ToString())
- {
- MessageBox.Show("Вече съществува такова име!", "Грешка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- else
- {
- b.Close();
- StreamReader mhm = new StreamReader("Accounts.txt");
- string[] file = new string[listBox1.Items.Count];
- for (int i = 0; i < file.Length; i++)
- {
- file[i] = mhm.ReadLine().ToString();
- if (file[i] == listBox1.SelectedItem.ToString())
- {
- if (checkBox1.Checked)
- {
- file[i] = "Username:" + textBox1.Text + " " + "Password:" + textBox2.Text + " " + "true";
- }
- else
- {
- file[i] = "Username:" + textBox1.Text + " " + "Password:" + textBox2.Text + " " + "false";
- }
- }
- }
- mhm.Close();
- b.Close();
- System.GC.Collect();
- System.GC.WaitForPendingFinalizers();
- File.Delete("Accounts.txt");
- File.Create("Accounts.txt").Close();
- StreamWriter c = new StreamWriter("Accounts.txt", true);
- for (int i = 0; i < file.Length; i++)
- {
- c.WriteLine(file[i]);
- }
- c.Close();
- string oldname = Regex.Match(listBox1.SelectedItem.ToString(), Login.regex).Groups[1].ToString();
- string newname = textBox1.Text;
- if(newname.ToLower()!=oldname.ToLower())
- {
- File.Copy("Tasks/" + oldname + ".txt", "Tasks/" + newname + ".txt");
- File.Delete("Tasks/" + oldname + ".txt");
- }
- MessageBox.Show("Редакцията е успешна!");
- this.Close();
- }
- }
- private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- if(listBox1.SelectedIndex>=0 && listBox1.SelectedItem!=null)
- {
- string line = listBox1.SelectedItem.ToString();
- textBox1.Text = Regex.Match(line, Login.regex).Groups[1].ToString();
- textBox2.Text = Regex.Match(line, Login.regex).Groups[2].ToString();
- }
- }
- private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
- {
- e.Handled = !(char.IsLetterOrDigit(e.KeyChar) || e.KeyChar == (char)Keys.Back);
- }
- private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
- {
- e.Handled = !(char.IsLetterOrDigit(e.KeyChar) || e.KeyChar == (char)Keys.Back);
- }
- }
- }
- 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;
- using System.Text.RegularExpressions;
- namespace Task_Manager
- {
- public partial class Users_Delete : Form
- {
- public Users_Delete()
- {
- InitializeComponent();
- }
- private void Users_Delete_Load(object sender, EventArgs e)
- {
- listBox1.Items.AddRange(File.ReadAllLines("Accounts.txt"));
- }
- private void button1_Click(object sender, EventArgs e)
- {
- listBox1.Items.Remove(listBox1.SelectedItem);
- File.Delete("Accounts.txt");
- File.Create("Accounts.txt").Close();
- StreamWriter a = new StreamWriter("Accounts.txt",true);
- foreach(var item in listBox1.Items)
- {
- a.WriteLine(item.ToString());
- }
- a.Close();
- MessageBox.Show("Изтриването е успешно!");
- this.Close();
- }
- }
- }
- 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 Task_Manager
- {
- public partial class Users_Look : Form
- {
- public Users_Look()
- {
- InitializeComponent();
- }
- private void Users_Look_Load(object sender, EventArgs e)
- {
- listBox1.Items.AddRange(File.ReadAllLines("Accounts.txt"));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement