private void buttonDleteUserOk_Click(object sender, EventArgs e) { if (textBoxDeleteUsername.Text == "") { textBoxDeleteUsername.Text = "Please type User Name"; textBoxDeleteUserPassword.Clear(); textBoxDeleteUsername.Select(); } else if (textBoxDeleteUserPassword.Text == "") { textBoxDeleteUsername.Text = "Password cannot be blank"; textBoxDeleteUsername.Select(); } else { int userExist; filehandler = new FileHandler("users.bin"); userExist = filehandler.FindUser(textBoxDeleteUsername.Text, textBoxDeleteUserPassword.Text); if (userExist >= 0) { deleteOk = filehandler.DeleteUser(userExist); userName = textBoxDeleteUsername.Text; Close(); } else { userName = "******"; deleteOk = false; Close(); } } }
private void buttonLoginOk_Click(object sender, EventArgs e) { int exist; if (textBoxLoginUsername.Text == "") { textBoxLoginUsername.Text = "Please type User Name"; textBoxLoginPassword.Clear(); textBoxLoginUsername.Select(); } else if (textBoxLoginPassword.Text == "") { textBoxLoginUsername.Text = "Password cannot be blank"; textBoxLoginUsername.Select(0, textBoxLoginUsername.MaxLength); } else { FileHandler filehandler = new FileHandler("users.bin"); exist = filehandler.FindUser(textBoxLoginUsername.Text.ToString(), textBoxLoginPassword.Text.ToString()); if (exist >= 0) { currentUser = textBoxLoginUsername.Text; userfound = true; Close(); } else if (exist < 0) { textBoxLoginUsername.Text = "User Not Exist or Wrong Password."; textBoxLoginPassword.Clear(); textBoxLoginUsername.Select(); } } }
private void buttonEditUserOk_Click(object sender, EventArgs e) { if (textBoxEditUsername.Text == "") { textBoxEditUsername.Text = "Please type User Name"; textBoxEditUserPassword.Clear(); textBoxEditUsername.Select(); } else if (textBoxEditUserPassword.Text == "") { textBoxEditUsername.Text = "Password cannot be blank"; textBoxEditUsername.Select(); } else { filehandler = new FileHandler("users.bin"); position = filehandler.FindUser(textBoxEditUsername.Text, textBoxEditUserPassword.Text); if (position >= 0) { userName = textBoxEditUsername.Text; userEditOk = true; Close(); } else { userName = "******"; userEditOk = false; Close(); } } }
private void UserReport_Load(object sender, EventArgs e) { FileHandler filehandler = new FileHandler("users.bin"); String[] tempdate = new String[(filehandler.countFile()) * 2]; tempdate = filehandler.GetUsers(); String[] temp = new String[2]; DataGridViewRowCollection rows = this.dataGridView1.Rows; int j = 0; for (int i = 0; i < tempdate.Length/2; i++) { temp[0] = tempdate[i + j]; temp[1] = " ********"; rows.Add(temp); j++; } }
private void buttonEditNewUserOk_Click(object sender, EventArgs e) { if (textBoxEditNewUsername.Text == "") { textBoxEditNewUsername.Text = "Please type User Name"; textBoxEditNewUserPassword.Clear(); textBoxConfermNewPassword.Clear(); textBoxEditNewUsername.Select(); } else if (textBoxEditNewUserPassword.Text == "") { textBoxEditNewUsername.Text = "Password cannot be blank"; textBoxConfermNewPassword.Clear(); textBoxEditNewUserPassword.Clear(); textBoxEditNewUsername.Select(); } else if (textBoxEditNewUserPassword.Text != textBoxConfermNewPassword.Text) { textBoxEditNewUsername.Text = "Password do not match"; textBoxConfermNewPassword.Clear(); textBoxEditNewUserPassword.Clear(); textBoxEditNewUsername.Select(); } else { int userExist; filehandler = new FileHandler("users.bin"); userExist = filehandler.FindUser(textBoxEditNewUsername.Text, textBoxEditNewUserPassword.Text); if (userExist >=0) { MessageBox.Show("-- Internal Error -- \nPlease try diferrent Username or Password", "Internal Error"); textBoxEditNewUsername.Select(); textBoxConfermNewPassword.Clear(); textBoxEditNewUserPassword.Clear(); } else { filehandler.EditUser(textBoxEditNewUsername.Text, textBoxEditNewUserPassword.Text, currentPosition); dataOk = true; Close(); } } }
private void buttonNewUserOk_Click(object sender, EventArgs e) { int check; if (textBoxNewUsername.Text == "") { textBoxNewUserPassword.Clear(); textBoxNewUsername.Text = "Please type User Name"; textBoxNewUsername.Select(); } else if (textBoxNewUserPassword.Text == "") { textBoxNewUsername.Text = "Password cannot be blank"; textBoxNewUserConferm.Clear(); textBoxNewUserPassword.Clear(); textBoxNewUsername.Select(); } else if (textBoxNewUserPassword.Text != textBoxNewUserConferm.Text) { textBoxNewUsername.Text = "Password do not match"; textBoxNewUserConferm.Clear(); textBoxNewUserPassword.Clear(); textBoxNewUsername.Select(); } else { FileHandler filehanlder = new FileHandler("users.bin"); check = filehanlder.InsertUser(textBoxNewUsername.Text, textBoxNewUserPassword.Text); if (check == 1) { textBoxNewUserPassword.Clear(); textBoxNewUserConferm.Clear(); MessageBox.Show("-- Internal Error -- \nPlease try diferrent Username or Password", "Internal Error"); textBoxNewUsername.Select(); } else if (check == 0) { newUserAdded = true; Close(); } } }
private void SubLogin_Load(object sender, EventArgs e) { FileHandler usersFile = new FileHandler("users.bin"); if (!usersFile.FileExist()) { MessageBox.Show("New Users Database Created. Username = \"admin\", Password = \"admin\".", "Oil Press Information Window"); usersFile.CreateFile(); } }