/// <summary> /// Handles navigation button click events /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void nav_click(object sender, EventArgs e) { Control flatbtn = (FlatButton_WOC)sender; if (flatbtn.TabIndex == 0) { Home_Tab.getInstance().populateCharts(); Home_Tab.getInstance().populateDataGridAgeAnalysis(); Home_Tab.getInstance().populateDataGridDREAnalysis(); Home_Tab.getInstance().populateDataGridDRRAnalysis(); materialSkinManager.ColorScheme = new ColorScheme(Primary.BlueGrey900, Primary.Red700, Primary.Red700, Accent.Red700, TextShade.WHITE); } if (flatbtn.TabIndex == 1) { Users_Tab.getInstance().populateDataGridView(); materialSkinManager.ColorScheme = new ColorScheme(Primary.Red700, Primary.Red700, Primary.Red700, Accent.Red700, TextShade.WHITE); } else if (flatbtn.TabIndex == 2) { Projects_Tab.getInstance().populateDataGridView(); materialSkinManager.ColorScheme = new ColorScheme(Primary.Red700, Primary.Red700, Primary.Red700, Accent.Red700, TextShade.WHITE); } else if (flatbtn.TabIndex == 3) { Defects_Tab.getInstance().populateDataGridView(); materialSkinManager.ColorScheme = new ColorScheme(Primary.Red700, Primary.Red700, Primary.Red700, Accent.Red700, TextShade.WHITE); } navAdapter.ShowTab((flatbtn).TabIndex); }
/// <summary> /// Setup navigation between tabs /// </summary> private void SetupNavigation() { navAdapter.AddTab(Home_Tab.getInstance(), true); navAdapter.AddTab(Users_Tab.getInstance(), false); navAdapter.AddTab(Projects_Tab.getInstance(), false); navAdapter.AddTab(Defects_Tab.getInstance(), false); panelTabs_Holder.Controls.Add(Users_Tab_Child.getInstance()); Users_Tab_Child.getInstance().Dock = DockStyle.Fill; panelTabs_Holder.Controls.Add(Projects_Tab_Child.getInstance()); Projects_Tab_Child.getInstance().Dock = DockStyle.Fill; panelTabs_Holder.Controls.Add(Modules_Tab.getInstance()); Modules_Tab.getInstance().Dock = DockStyle.Fill; panelTabs_Holder.Controls.Add(Modules_Tab_Child.getInstance()); Modules_Tab_Child.getInstance().Dock = DockStyle.Fill; panelTabs_Holder.Controls.Add(Defects_Tab_Child.getInstance()); Defects_Tab_Child.getInstance().Dock = DockStyle.Fill; panelTabs_Holder.Controls.Add(Defects_Tab_Child2.getInstance()); Defects_Tab_Child2.getInstance().Dock = DockStyle.Fill; }
/// <summary> /// Handle the function of adding an user to the database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUserSave_Click(object sender, EventArgs e) { string username = txtUsername.Text.Trim(); string userType = comboBoxUserType.Text; string fname = txtFName.Text.Trim(); string lname = txtLName.Text.Trim(); if (username != "" && userType != "" && fname != "" && lname != "" && txtPass.Text != "") // Check if required fields are filled { if (txtPass.Text == txtConfirmPass.Text) // Check whether the password and confirm password matches { if (txtPass.Text.Length >= 8) // Check whether the password length is at least 8 characters { if (DbConnector.OpenSQLConnection()) // Open connection to the database { // Connection opened UserAdminDataAccess user = new UserAdminDataAccess(); if (btnUserSave.Text == "Save") { if (user.IsUsernameExist(username)) // Check if the username already taken { // Username exists MessageBox.Show("Username entered already exists in the database", "error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (user.InsertUser(username, userType, fname, lname, txtPass.Text, switchUserStatus.IsOn ? "Available" : "Assigned", switchAccStatus.IsOn ? "Active" : "Inactive")) { // Record inserted successfully MessageBox.Show("Record has been inserted successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); Users_Tab.getInstance().BringToFront(); Users_Tab.getInstance().populateDataGridView(); } else { // Record was not inserted MessageBox.Show("The record could not be saved", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (btnUserSave.Text == "Update") { if (user.UpdateUser(username, userType, fname, lname, txtPass.Text, switchUserStatus.IsOn ? "Available" : "Assigned", switchAccStatus.IsOn ? "Active" : "Inactive")) { // Record updated successfully MessageBox.Show("Record has been updated successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); Users_Tab.getInstance().BringToFront(); Users_Tab.getInstance().populateDataGridView(); } else { // Record was not updated MessageBox.Show("The record could not be updated", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { // Connection could not be opened MessageBox.Show("Connection to the database could not be established", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { // Password length less than 8 characters MessageBox.Show("Password should at least contain 8 characters", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { // Password and Confirm Password do not match MessageBox.Show("Password and Confirm Password do not match", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { // Fields not filled correctly MessageBox.Show("Please fill all the required fields", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// Navigate to the Users List view /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUserCancel_Click(object sender, EventArgs e) { Users_Tab.getInstance().BringToFront(); Users_Tab.getInstance().populateDataGridView(); }