private void LogOut_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)26) { undoRedoOperations(undoStack, redoStack); } else if (e.KeyChar == (char)25) { undoRedoOperations(redoStack, undoStack); } else { CareTakerDatas datas = new CareTakerDatas(); User tempUser = new User(txtUserName.Text, TxtPassword.Text, false, "", TxtName.Text, TxtSurname.Text, MTxtPhoneNumber.Text, TxtAddress.Text, TxtEmail.Text, "", ""); if (flag == 0) { tempUser.Photo = LoginedUser.getInstance().UserGetSet.Photo; } else { tempUser.Photo = Util.ImageToBase64(PicPhoto.ImageLocation); } datas.Memento = tempUser.Save(); undoStack.Push(datas); } }
public static List <Notes> LoadNotebook(string path) { List <Notes> listBook = new List <Notes>(); try { StreamReader sr = new StreamReader(path); string notes; notes = sr.ReadLine(); while (notes != null) { string[] pieces = notes.Split(','); string username = pieces[0]; string not = pieces[1]; Notes note1 = new Notes(username, not); if (LoginedUser.getInstance().UserGetSet.Username == username) { note1.Note = Regex.Unescape(not); if (note1.Note.Contains("#")) { note1.Note = note1.Note.Replace("#", ","); } listBook.Add(note1); } notes = sr.ReadLine(); } sr.Close(); sr.Dispose(); } catch (Exception) { } return(listBook); }
private void btnLogin_Click(object sender, EventArgs e) { string username = txtName.Text; string password = txtPassword.Text; bool rememberMe = RememberMe.Checked; for (int i = 0; i < userList.Count; i++) { User user = userList[i]; if (user.IsValid(username, password, rememberMe) == true) { user.RememberMe = rememberMe; LoginedUser.getInstance().UserGetSet = user; lblMesaj.BackColor = Color.Green; lblMesaj.Text = "successful login"; lblMesaj.Visible = true; if (rememberMe == true) { Util.SaveCsv(userList, path); } Delay.Start(); return; } } lblMesaj.BackColor = Color.Red; lblMesaj.Text = "failed login"; lblMesaj.Visible = true; txtName.Text = ""; txtPassword.Text = ""; }
private void btnLogOut_Click(object sender, EventArgs e) { this.Hide(); User user = LoginedUser.getInstance().UserGetSet; user.RememberMe = false; Util.SaveCsv(LoginForm.userList, LoginForm.path); this.Close(); }
private void btnUpdate_Click(object sender, EventArgs e) { Util.LoadCsv(LoginForm.userList, LoginForm.path); for (int i = 0; i < LoginForm.userList.Count; i++) { if (LoginForm.userList[i].Username == user.Username) { LoginForm.userList[i].Salary = txtBoxSalary.Text; } } LoginedUser.getInstance().UserGetSet.Salary = txtBoxSalary.Text; Util.SaveCsv(LoginForm.userList, path); }
private void checkRememberUser() { foreach (User user in userList) { if (user.RememberMe) { LoginedUser.getInstance().UserGetSet = user; this.Hide(); if (logOut.ShowDialog() == DialogResult.Cancel && LoginedUser.getInstance().UserGetSet.RememberMe == true) { System.Environment.Exit(1); } } } }
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { User user = LoginedUser.getInstance().UserGetSet; int secilen = dataGridView1.SelectedCells[0].RowIndex; if (secilen == 0 && user.Usertypes != "*Admin") { MessageBox.Show("No changes can be made via admin", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { TxtRegisterNo.Text = dataGridView1.Rows[secilen].Cells[0].Value.ToString(); TxtUsername.Text = dataGridView1.Rows[secilen].Cells[1].Value.ToString(); TxtPassword.Text = dataGridView1.Rows[secilen].Cells[2].Value.ToString(); TxtUsertypes.Text = dataGridView1.Rows[secilen].Cells[4].Value.ToString(); } }
private void Delay_Tick(object sender, EventArgs e) { txtName.Text = ""; txtPassword.Text = ""; lblMesaj.Text = ""; Delay.Enabled = false; this.Hide(); if (logOut.ShowDialog() == DialogResult.Cancel && LoginedUser.getInstance().UserGetSet.RememberMe == true) { this.Close(); } else { LoginForm Frm = new LoginForm(); if (Frm.ShowDialog() == DialogResult.Cancel) { this.Close(); } } }
private void Form2_Load(object sender, EventArgs e) { this.KeyPreview = true; User user = LoginedUser.getInstance().UserGetSet; txtUserName.Text = user.Username; TxtUserType.Text = user.Usertypes; TxtName.Text = user.Name; TxtSurname.Text = user.Surname; MTxtPhoneNumber.Text = user.PhoneNumber; TxtSalary.Text = user.Salary; if (user.Address.Contains("#")) { user.Address = user.Address.Replace("#", ","); } TxtAddress.Text = user.Address; TxtEmail.Text = user.Email; PicPhoto.Image = Util.Base64ToImage(user.Photo); if (user.Usertypes == "Admin" || user.Usertypes == "*Admin" || user.Usertypes == "admin") { btnAdmin.Enabled = true; btnAdmin.BackColor = Color.Green; } }
private void BtnUpdate_Click(object sender, EventArgs e) { User user = LoginedUser.getInstance().UserGetSet; List <User> userList = new List <User>(); Util.LoadCsv(userList, path); int counter = 0; int count = 0; for (int i = 0; i < userList.Count; i++) { if (txtUserName.Text == user.Username) { break; } else if (userList[i].Username == txtUserName.Text) { counter++; break; } } if (counter != 1) { user.Username = txtUserName.Text; if (TxtPassword.Text != "") { user.AccoundPassword = Util.ComputeStringToSha256Hash(TxtPassword.Text); } user.Name = TxtName.Text; user.Surname = TxtSurname.Text; if (TxtAddress.Text.Contains(",")) { TxtAddress.Text = TxtAddress.Text.Replace(",", "#"); } user.Address = TxtAddress.Text; if (Util.isEmailValid(TxtEmail.Text)) { user.Email = TxtEmail.Text; if (MTxtPhoneNumber.Text.Length == 14) { user.PhoneNumber = MTxtPhoneNumber.Text; TxtPassword.Text = ""; if (TxtAddress.Text.Contains("#")) { TxtAddress.Text = TxtAddress.Text.Replace("#", ","); } MessageBox.Show("Update Successful!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { count++; MessageBox.Show("Phone number order incorrect!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { count++; MessageBox.Show("Email order incorrect!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } string photo; if (flag > 0) { photo = Util.ImageToBase64(PicPhoto.ImageLocation); if (count == 0) { user.Photo = photo; } else { PicPhoto.Image = Util.Base64ToImage(user.Photo); } } } else { MessageBox.Show("Username already taken.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }