private void write_click(object sender, EventArgs e) { file f = null; for (int i = 0; i < data.get_filecount(); i++) { if (file_to_do.Text == data.get_file(i).Name) { f = data.get_file(i); break; } } if (f == null) { MessageBox.Show("Нема такого файлу"); file_to_do.Text = string.Empty; } else if (f.Get_Write(insertion_correct().Count) == 1) { MessageBox.Show("Запис в " + f.Name + " дозволено "); file_to_do.Text = string.Empty; } else { MessageBox.Show("Запис в " + f.Name + " не дозволено "); file_to_do.Text = string.Empty; } }
private void delegation_continue_enter_user(object sender, EventArgs e) { for (int i = 0; i < data.get_usercount(); i++) { if (file_to_do.Text == data.get_user(i).Name) { u_d = data.get_user(i); break; } } if (u_d == null) { MessageBox.Show("Немає такого користувача"); file_to_do.Text = string.Empty; todelegate.Click -= delegation_continue_enter_user; todelegate.Click += todelegate_click; insertion.Text = "Введіть файл"; u_d = null; f_d = null; operation = ""; } else if (operation == "Читання") { insertion.Text = "Введіть файл"; todelegate.Click -= delegation_continue_enter_user; todelegate.Click += todelegate_click; if (f_d.Get_Read(u_d.Count) == 1 || f_d.Get_Read(insertion_correct().Count) == 0) { MessageBox.Show("Помилка! Користувач вже має дані права, або недостатньо прав у делегуючого користувача"); u_d = null; f_d = null; operation = ""; file_to_do.Text = string.Empty; } else { f_d.Set_Read(u_d.Count, 1); T.Rows[f_d.Count + 1].Cells[u_d.Count + 1].Value = data.rigts_insertion(f_d, u_d); file_to_do.Text = string.Empty; MessageBox.Show("Право на читання надано користувачу " + u_d.Name); u_d = null; f_d = null; operation = ""; } } else if (operation == "Запис") { insertion.Text = "Введіть файл"; todelegate.Click -= delegation_continue_enter_user; todelegate.Click += todelegate_click; if (f_d.Get_Write(u_d.Count) == 1 || f_d.Get_Write(insertion_correct().Count) == 0) { MessageBox.Show("Помилка!Користувач вже має дані права, або недостатньо прав у делегуючого користувача"); u_d = null; f_d = null; operation = ""; file_to_do.Text = string.Empty; } else { f_d.Set_Write(u_d.Count, 1); T.Rows[f_d.Count + 1].Cells[u_d.Count + 1].Value = data.rigts_insertion(f_d, u_d); file_to_do.Text = string.Empty; MessageBox.Show("Право на запис надано користувачу " + u_d.Name); u_d = null; f_d = null; operation = ""; } } else if (operation == "Делегування") { insertion.Text = "Введіть файл"; todelegate.Click -= delegation_continue_enter_user; todelegate.Click += todelegate_click; if (f_d.Get_Todelegate(u_d.Count) == 1 || f_d.Get_Todelegate(insertion_correct().Count) == 0 || (f_d.Get_Read(u_d.Count) == 0) && (f_d.Get_Write(u_d.Count) == 0)) { MessageBox.Show("Помилка!Користувач вже має дані права, недостатньо прав у делегуючого користувача, або користувачу немає чого делегувати в майбутньому"); u_d = null; f_d = null; operation = ""; file_to_do.Text = string.Empty; } else { f_d.Set_Todelegate(u_d.Count, 1); T.Rows[f_d.Count + 1].Cells[u_d.Count + 1].Value = data.rigts_insertion(f_d, u_d); file_to_do.Text = string.Empty; MessageBox.Show("Право на делегування надано користувачу " + u_d.Name); u_d = null; f_d = null; operation = ""; } } }