private void Endofwork_Click(object sender, EventArgs e) { if (ActionSelectionBox.SelectedIndex >= 0) { if (NextuserselectionBox.SelectedIndex >= 0) { if (!templateok) { object path = fullpath; WordDoc.SaveAs2(ref path); WordDoc.Close(ref miss, ref miss, ref miss); WordApp.Quit(ref miss, ref miss, ref miss); } File file = new File(pathf, DocumentName.Text, NextuserselectionBox.Text, ActionSelectionBox.Text, form2.current.name, NoticeBox.Text); System.IO.File.WriteAllBytes(file.pathtofile, Cryptfunc.AESEncrypt(System.IO.File.ReadAllBytes(file.pathtofile))); Cryptfunc.Loging(file); Cryptfunc.Signing(file); this.Close(); form2.UpdateGrid(); } else { MessageBox.Show("Choose next user at first!"); } } else { MessageBox.Show("Choose action at first!"); } }
private void EndWork() { System.IO.File.WriteAllBytes(file.pathtofile, Cryptfunc.AESEncrypt(System.IO.File.ReadAllBytes(file.pathtofile))); Cryptfunc.Loging(file); Cryptfunc.Signing(file); MessageBox.Show("Changes accepted"); this.Close(); }
private void DetailsForm_FormClosing(object sender, FormClosingEventArgs e) { if (see) { WordDoc.Close(ref miss, ref miss, ref miss); WordApp.Quit(ref miss, ref miss, ref miss); System.IO.File.WriteAllBytes(file.pathtofile, Cryptfunc.AESEncrypt(compl)); } form2.UpdateGrid(); }
private void ConfirmChanges_Click(object sender, EventArgs e) { List <User> ul = new List <User>(); int leadercounter = 0; for (int i = 0; i < dataGridView.RowCount - 1; i++) { try { string un = "", ua = "", up = ""; un = dataGridView.Rows[i].Cells[0].Value.ToString(); ua = dataGridView.Rows[i].Cells[1].Value.ToString(); if (ua == "Leadership") { leadercounter++; } up = dataGridView.Rows[i].Cells[2].Value.ToString(); ul.Add(new User(un, up)); ul[i].Accesslevel = ua; } catch (Exception) { } } if (leadercounter != 0) { string strout = ""; foreach (User u in ul) { strout += u.name + ' ' + u.accesslevel + ' ' + u.pass + "\r\n"; } System.IO.File.WriteAllBytes(form1.pathtobase, Cryptfunc.AESEncrypt(System.Text.Encoding.UTF8.GetBytes(strout))); form1.userbase = ul; this.Close(); } else { MessageBox.Show("Company need one leader at least!!!"); } }
public static void Loging(File f) { byte[] logs; if (f.IsLogsExist()) { logs = Cryptfunc.AESDecrypt(System.IO.File.ReadAllBytes(f.pathtolog)); } else { logs = null; } string laststr = f.state + " -- " + f.fromuser + " -- " + f.touser + " -- " + DateTime.Now + " -- " + f.note; if (logs != null) { string slogs = System.Text.Encoding.UTF8.GetString(logs); System.IO.File.WriteAllBytes(f.pathtolog, Cryptfunc.AESEncrypt(System.Text.Encoding.UTF8.GetBytes(slogs + "\r\n" + laststr))); } else { System.IO.File.WriteAllBytes(f.pathtolog, Cryptfunc.AESEncrypt(System.Text.Encoding.UTF8.GetBytes(laststr))); } }