private void DgvManagers_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)//select the manager to updating or deactiving { BtnAdd.Hide(); BtnUpdate.Show(); BtnDeactive.Show(); BtnCancel.Show(); TxtPassword.Hide(); LblPassword.Text = "New Password"; LblComment.Show(); TxtNewPassword.Show(); int Id = Convert.ToInt32(DgvManagers.Rows[e.RowIndex].Cells[0].Value); _selectedManager = _managerService.Find(Id); //index of selected manager on datagridview _selectedIndex = e.RowIndex; //fill the selected manager information to the textboxes TxtName.Text = _selectedManager.Name; TxtSurname.Text = _selectedManager.Surname; TxtPhone.Text = _selectedManager.Phone; TxtUsername.Text = _selectedManager.Username; if (_selectedManager.IsAdmin == true) { CmbPosition.SelectedIndex = 0; return; } CmbPosition.SelectedIndex = 1; }
private void BtnLogin_Click_1(object sender, EventArgs e)//Login the program { //checks if the username or password are null if (TxtUsername.Text == string.Empty || TxtPassword.Text == string.Empty) { MessageBox.Show("Username and password should not be empty"); return; } int Id = _managerService.Login(TxtUsername.Text, Hash(TxtPassword.Text)); //checks if the password is false if (Id == -1) { MessageBox.Show("Username or Password are False"); return; } this.Hide(); Manager manager = _managerService.Find(Id); Operation operation = new Operation(manager); operation.Show(); operation.FormClosed += (s, args) => this.Close(); }