public void bindDataTableData() { userDataManipulations userDataManipulations = new userDataManipulations(); List <user> userList = userDataManipulations.getAllUsers(); usersDataGrid.DataSource = userList; }
private void deleteBtn_Click(object sender, EventArgs e) { int selectedIndex = usersDataGrid.CurrentCell.RowIndex; if (selectedIndex > -1) { string userName = usersDataGrid.Rows[selectedIndex].Cells[0].Value.ToString(); string role = usersDataGrid.Rows[selectedIndex].Cells[1].Value.ToString(); string password = usersDataGrid.Rows[selectedIndex].Cells[2].Value.ToString(); string fName = usersDataGrid.Rows[selectedIndex].Cells[3].Value.ToString(); string lName = usersDataGrid.Rows[selectedIndex].Cells[4].Value.ToString(); string address = usersDataGrid.Rows[selectedIndex].Cells[5].Value.ToString(); string telephone = usersDataGrid.Rows[selectedIndex].Cells[6].Value.ToString(); string nic = usersDataGrid.Rows[selectedIndex].Cells[7].Value.ToString(); user selectedUser = new user(userName, role, password, fName, lName, address, telephone, nic); userDataManipulations userDataManipulations = new userDataManipulations(); Boolean stockDeletion = userDataManipulations.deleteUser(selectedUser); if (stockDeletion) { MessageBox.Show("Deletion Successfull. Data deleted successfully", "Important Note", MessageBoxButtons.OK); bindDataTableData(); } else { MessageBox.Show("Deletion Failed. Error occured while deleting data", "Important Note", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } } }
private void button1_Click(object sender, EventArgs e) { String userName = ((txtUsrname.Text).Clone().ToString()).Replace(" ", string.Empty); String password = (txtPwrd.Text).Clone().ToString(); Console.WriteLine("Login"); if (userName == "" && password == "") { usernameVerifyMessage.Show(); passwordVerifyMessage.Show(); hideLabels(); } else if (userName == "") { usernameVerifyMessage.Show(); hideLabels(); } else if (password == "") { passwordVerifyMessage.Show(); hideLabels(); } else { user User = new user(userName, "", password, null, null, null, null, null); userDataManipulations userDataManipulations = new userDataManipulations(); Boolean userValidity = userDataManipulations.authenticateUser(User); if (userValidity) { wrapperDataBuffer.WrapperObject.Flag = 0; MainMenuAdmin newMainMenuAdmin = new MainMenuAdmin(); newMainMenuAdmin.Show(); this.Hide(); } else { loginVerifyMessage.Show(); hideLabels(); } } }
private void btnAddService_Click(object sender, EventArgs e) { String fName = ((txtFname.Text).Replace(" ", string.Empty)).Clone().ToString(); String lName = ((txtLname.Text).Replace(" ", string.Empty)).Clone().ToString(); String nic = ((txtNIC.Text).Replace(" ", string.Empty)).Clone().ToString(); String role = ((cmbRole.Text).Replace(" ", string.Empty)).Clone().ToString(); String usName = ((userName.Text).Replace(" ", string.Empty)).Clone().ToString(); if (fName == "") { fnameVerify.Show(); hideLabelsTimer(); } else if (lName == "") { lnameVerify.Show(); hideLabelsTimer(); } else if (usName == "") { userNameVerify.Show(); hideLabelsTimer(); } else if (nic == "") { nicVerify.Show(); hideLabelsTimer(); } else if (role == "") { roleVerify.Show(); hideLabelsTimer(); } else if (password.Text == "") { passwordVerify.Show(); hideLabelsTimer(); } else { String uName = (userName.Text).Clone().ToString(); String urole = ((KeyValuePair <String, String>)cmbRole.SelectedItem).Key; String uPword = (password.Text).Clone().ToString(); String uFName = (txtFname.Text).Clone().ToString(); String uLName = (txtLname.Text).Clone().ToString(); String uAddress = (txtAddress.Text).Clone().ToString(); String uTel = (txtTel.Text).Clone().ToString(); String uLNic = (txtNIC.Text).Clone().ToString(); userDataManipulations userDataManipulations = new userDataManipulations(); if ((userDataManipulations.validateUserName(uName))) { user user = new user(uName, urole, uPword, uFName, uLName, uAddress, uTel, uLNic); Boolean userInsertionFlag = userDataManipulations.updateUser(user); if (userInsertionFlag) { MessageBox.Show("Update Successfull. Data Updated successfully", "Important Note", MessageBoxButtons.OK); currentView.bindDataTableData(); this.Dispose(); } else { MessageBox.Show("Update Failed. Check the Updated data again", "Important Note", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } } else { userNameVerify.Show(); } } }