private void RegisterNewUserForm_Load(object sender, EventArgs e) { // Identifying correct protocol for current user in session if (SystemProtocols.ApplySessionsProtocols(1, null, null)) { // Disabling the other Products option registerNewProductMenuSubOption.Visible = false; registerNewProductMenuSubOption.Enabled = false; restockProductsMenuSubOption.Visible = false; restockProductsMenuSubOption.Enabled = false; // Disabling all admin options adminMenuOption.Visible = false; adminMenuOption.Enabled = false; } // Inictializing message labels messageLabel.Text = ""; usernameErrorLable.Visible = false; passwordErrorLabel.Text = "Invalid Password"; passwordErrorLabel.Visible = false; confirmationPasswordErrorLabel.Visible = false; // Executing correct activity according to given code SystemProtocols.ApplyActivityProtocols("USE2", null, null); }
private void CreateAndReturnButton_Click(object sender, EventArgs e) { if (ValidateUserInput()) // Verifying if user input confirm with all requirements { String message = UserInformationManager.CreateNewUserProfileInformation(CreateUserProfile()); // Confimring the user creation process if (message == "SUCCESS") // Creation process has been successful { messageLabel.Text = "User has been created succesfully!"; ClearTextBoxBuffers(); // cleaning textboxes // Closing form while freeing system resources FormsMenuList.registerNewUserForm.Dispose(); // Summon Users Registry Form FormsMenuList.usersRegistryForm = new UsersRegistryForm(); FormsMenuList.usersRegistryForm.Show(); } else { // Executing correct activity according to given code SystemProtocols.ApplyActivityProtocols("ERR2", null, null); messageLabel.Text = "A Fatal Error has occured!"; // The new user profile has not been created due to en error } } else { messageLabel.Text = "Please fill in every information correctly"; // user input has not been validated } }
/// <summary> /// Funtion to add one or more selected products into the cart /// </summary> private void AddItemsToCart() { // Capturing the data of multiple selected products foreach (DataGridViewRow row in productDataGridView.SelectedRows) { if (FormatToInt(row.Cells[10].Value.ToString()) > 0) // only works if the product in the inventory has atleast 1 unit in existence { Product product = new Product(); // creating new product product.Id = row.Cells[0].Value.ToString(); // getting the selected product's id product.Name = row.Cells[2].Value.ToString(); // getting the selected product's name product.Brand = row.Cells[3].Value.ToString(); // getting the selected product's brand product.Unit = row.Cells[5].Value.ToString(); // getting the selected product's unit product.UnitPrice = FormatToDecimal(row.Cells[9].Value.ToString()); // getting the selected product's price product.Quantity = quantityNumericUpDown.Value < FormatToInt(row.Cells[10].Value.ToString()) ? // getting the desired quantity of the selected product (int)quantityNumericUpDown.Value : // the client desires less units than the limit in existence FormatToInt(row.Cells[10].Value.ToString()); // the client wants all units in existence // Adding product to cart or updating the amount of units of already added product SystemProtocols.ApplyCartManagementProtocol(2, null, 0, product, FormatToInt(row.Cells[10].Value.ToString())); } } // Updating numeric up down quantityNumericUpDown.Value = 1; quantityNumericUpDown.Maximum = 2; UpdateCartSummaryDataGrid(); // updating the cart summary }
private void CompleteSaleButton_Click(object sender, EventArgs e) { if (SystemProtocols.ApplyCartManagementProtocol(1, null, 0, null, 0).Count > 0) { // Requesting the creation of a new transaction String message = SystemProtocols.ApplySalesTransactionProtocols(1, CreateSalesObject()); if (message == "SUCCESS") { MessageBox.Show("This transaction has been completed successfully!"); // Updating grids PopulateProductDataGrid(); UpdateCartSummaryDataGrid(); } else { MessageBox.Show("FATEL ERROR!"); // TODO: manage errors and exceptions } } else { MessageBox.Show("Please add items to complete a purchase."); } }
private void ConfirmButton_Click(object sender, EventArgs e) { if (sale.NumberItems != purchasedItems.Count) // Confirming at least one item has been returned { // No need to change or nullify the old sales id, given that a new one will be assigned to the resulting transaction // and the old id will still be needed for future refrence. sale.NumberItems = FormatToInt(numberOfPurchasedItemsLabel.Text.Split(':')[1]); // updating the new amount of item that have not been returned sale.Total = FormatToDecimal(purchasedTotalLabel.Text.Split('$')[1]); // updating the new total of the transaction // Requesting a return policy String message = SystemProtocols.ApplyReturnPolicyProtocols(sale, purchasedItems, returnedItems); if (message == "VOIDED") // all products have been returned thus creating a void transaction instead of a partial return { MessageBox.Show("Transaction voided successfully!"); this.Dispose(); } else // Return request has been approved { MessageBox.Show("Products have successfully been returned to the inventory!"); FormsMenuList.salesRecordForm.RefreshSalesRecordsDataGrid(); // updating grandparent form FormsMenuList.salesRecordForm.ShowNewReturnedTransactionInformation(message); // requesting the grandparent to show the new resulting transaction child form FormsMenuList.salesRecordForm.UpdateChildAfterSuccessfulReturn(sale.Id); // requesting grandparent to update this form's parent as well this.Dispose(); } } else { MessageBox.Show("Nothing was returned, please check form or cancel process."); } }
private void ReportsAnalyticsForm_Load(object sender, EventArgs e) { // Identifying correct protocol for current user in session if (SystemProtocols.ApplySessionsProtocols(1, null, null)) { // Disabling the other Products option registerNewProductMenuSubOption.Visible = false; registerNewProductMenuSubOption.Enabled = false; restockProductsMenuSubOption.Visible = false; restockProductsMenuSubOption.Enabled = false; // Disabling all admin options adminMenuOption.Visible = false; adminMenuOption.Enabled = false; } // Initializing latest date time pickers #region Users' Timesheet Report newestTimesheetDateTimePicker.Value = DateTime.Now; newestTimesheetDateTimePicker.MaxDate = DateTime.Today.AddDays(1); #endregion #region Users's Sales Record newestSalesRecordDateTimePicker.Value = DateTime.Now; newestSalesRecordDateTimePicker.MaxDate = DateTime.Today.AddDays(1); #endregion // Recording admin access to this form SystemProtocols.ApplyActivityProtocols("REP1", null, null); }
private void RegisterNewSaleFrom_Load(object sender, EventArgs e) { // Identifying correct protocol for current user in session if (SystemProtocols.ApplySessionsProtocols(1, null, null)) { // Disabling the other Products option registerNewProductMenuSubOption.Visible = false; registerNewProductMenuSubOption.Enabled = false; restockProductsMenuSubOption.Visible = false; restockProductsMenuSubOption.Enabled = false; // Disabling all admin options adminMenuOption.Visible = false; adminMenuOption.Enabled = false; SystemProtocols.ApplyActivityProtocols("SAL1", null, null); } else { SystemProtocols.ApplyActivityProtocols("SAL4", null, null); } PopulateProductDataGrid(); UpdateCartSummaryDataGrid(); }
private void InitiateLogInProtocols() { // Executing credential validation protocols before triggering a session or being denied one String message = SystemProtocols.ApplyCredentialsValidationProtocol(usernameTextBox.Text, passwordTextBox.Text); if (message == "INVALID USER") // provided username was not registered in the system { ClearTextBoxBuffer(); usernameTextBox.BackColor = Color.Red; // highlighting incorrect username } else if (message == "INACTIVE USER") // provided username belongs to an inactive/suspended account { MessageBox.Show("This user has been deacivated, please try with a different account."); ClearTextBoxBuffer(); } else if (message == "INCORRECT") // provided credentials were incorrect for that username { passwordTextBox.Text = ""; passwordTextBox.BackColor = Color.Red; // highlighting incorrect password } else // credentials were successfully validated { // Executing correct login protocols for new user session SystemProtocols.ApplyLogInProtocols(usernameTextBox.Text); ClearTextBoxBuffer(); FormsMenuList.loginForm.Hide(); // TODO: replace this with close once program is ancored to splash page // Summon Product Browser Form FormsMenuList.inventorySearchForm = new InventorySearchForm(); FormsMenuList.inventorySearchForm.Show(); } }
private void LogOutLabel_Click(object sender, EventArgs e) { // Executing correct log out processes SystemProtocols.ApplyLogOutProtocols(); FormsMenuList.loginForm.Show(); // Closing form while freeing system resources FormsMenuList.errorsLogForm.Dispose(); }
/// <summary> /// Function to populate the cart summary data grid /// </summary> private void UpdateCartSummaryDataGrid() { // Code needed to refresh the cart summary cartSummaryDataGridView.DataSource = new List <Product>(); // reseting the datasource as a clean and empty list cartSummaryDataGridView.Refresh(); // refreshing the data grid to clean any old information an update it with the new one List <Product> summary = SystemProtocols.ApplyCartManagementProtocol(1, null, 0, null, 0); // fetching the cart if (summary.Count() > 0) { cartSummaryDataGridView.DataSource = summary; // feeding the grid view with the new information on the cart summary cartSummaryDataGridView.Refresh(); // refreshing the data grid to clean any old information an update it with the new one // Hidding unnecessary fields cartSummaryDataGridView.Columns["Id"].Visible = false; cartSummaryDataGridView.Columns["Key"].Visible = false; cartSummaryDataGridView.Columns["Brand"].Visible = false; cartSummaryDataGridView.Columns["Supplier"].Visible = false; cartSummaryDataGridView.Columns["Category"].Visible = false; cartSummaryDataGridView.Columns["Type"].Visible = false; cartSummaryDataGridView.Columns["UnitCost"].Visible = false; cartSummaryDataGridView.Columns["MinimumQuantity"].Visible = false; cartSummaryDataGridView.Columns["MaximumQuantity"].Visible = false; cartSummaryDataGridView.Columns["RegisteredBy"].Visible = false; cartSummaryDataGridView.Columns["RegistrationDate"].Visible = false; cartSummaryDataGridView.Columns["ModifiedBy"].Visible = false; cartSummaryDataGridView.Columns["ModificationDate"].Visible = false; cartSummaryDataGridView.Columns["Discontinued"].Visible = false; cartSummaryDataGridView.Columns["Total"].Visible = false; // Formationg columns cartSummaryDataGridView.Columns["Name"].Width = 180; cartSummaryDataGridView.Columns["Unit"].Width = 50; cartSummaryDataGridView.Columns["UnitPrice"].Width = 70; cartSummaryDataGridView.Columns["Quantity"].Width = 80; int quantity = 0; // variable to track the amount of items requested decimal total = 0; // variable to track the total of the entire purchase foreach (Product item in summary) { quantity += item.Quantity; // counting how many products are in the cart total += item.UnitPrice; // calculating the total price } // publishing the purchase information of a full cart numberLabel.Text = "Number of Item: " + quantity; totalLabel.Text = "Total: $" + total.ToString("0.00"); } else { // publishing the purchase information of an empty cart numberLabel.Text = "Number of Item: 0"; totalLabel.Text = "Total: $0.00"; } }
private void RemoveOneButton_Click(object sender, EventArgs e) { // Capturing the data of multiple selected products foreach (DataGridViewRow row in cartSummaryDataGridView.SelectedRows) { // Removing one unit from a product in the cart SystemProtocols.ApplyCartManagementProtocol(5, row.Cells[0].Value.ToString(), FormatToDecimal(row.Cells[9].Value.ToString()) / FormatToInt(row.Cells[10].Value.ToString()), null, 0); } UpdateCartSummaryDataGrid(); // updating the cart summary }
private void LogOutLabel_Click(object sender, EventArgs e) { // Executing correct log out processes SystemProtocols.ApplyLogOutProtocols(); FormsMenuList.loginForm.Show(); SystemProtocols.ApplyCartManagementProtocol(3, null, 0, null, 0); // clearing the cart before logging out // Closing form while freeing system resources FormsMenuList.registerNewProduct.Dispose(); }
private void ProductList_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (!SystemProtocols.ApplySessionsProtocols(1, null, null)) { // Declare an non oficial auxiliary form to display product information, given a product's internal identification number ProductInformationTemplateForm child = new ProductInformationTemplateForm(productList.SelectedCells[0].Value.ToString()); child.Show(); // Summon the temporary summary form children.Add(child); // adding product to list of children } }
private void RemoveItemButton_Click(object sender, EventArgs e) { // Capturing the data of multiple selected products foreach (DataGridViewRow row in cartSummaryDataGridView.SelectedRows) { // Adding product to cart or updating the amount of units of already added product SystemProtocols.ApplyCartManagementProtocol(4, row.Cells[0].Value.ToString(), 0, null, 0); } UpdateCartSummaryDataGrid(); // updating the cart summary }
protected override void OnFormClosing(FormClosingEventArgs e) { base.OnFormClosing(e); // Executing correct log out processes SystemProtocols.ApplyLogOutProtocols(); FormsMenuList.loginForm.Show(); // Closing form while freeing system resources FormsMenuList.errorsLogForm.Dispose(); }
/// <summary> /// Function used by grandchild to notify when a new transaction has originated from a successfull return /// </summary> /// <param name="newSaleId">Identification number of the new transaction</param> public void ShowNewReturnedTransactionInformation(String newSaleId) { if (!SystemProtocols.ApplySessionsProtocols(1, null, null)) // option only available for non basic users { // Creating a new child given the new information available SaleInformationTemplateForm child = new SaleInformationTemplateForm(newSaleId); child.Show(); children.Add(child); // adding that new child to the list of living children } }
protected override void OnFormClosing(FormClosingEventArgs e) { base.OnFormClosing(e); // Executing correct log out processes SystemProtocols.ApplyLogOutProtocols(); FormsMenuList.loginForm.Show(); SystemProtocols.ApplyCartManagementProtocol(3, null, 0, null, 0); // clearing the cart before logging out // Closing form while freeing system resources FormsMenuList.registerNewProduct.Dispose(); }
private void SalesList_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (!SystemProtocols.ApplySessionsProtocols(1, null, null)) // option only available for non basic users { if (!IsChildAlive(salesList.SelectedCells[0].Value.ToString())) // Verifying that requested child is killed or active before proceeding { // Starting or resecusating child SaleInformationTemplateForm child = new SaleInformationTemplateForm(salesList.SelectedCells[0].Value.ToString()); child.Show(); children.Add(child); // adding child to the list of children to keep track of opened auxiliary forms } } }
private void LogOutLabel_Click(object sender, EventArgs e) { // Executing correct log out processes SystemProtocols.ApplyLogOutProtocols(); FormsMenuList.loginForm.Show(); if (userInformationForm != null) { userInformationForm.Dispose(); // Closing Child } SystemProtocols.ApplyCartManagementProtocol(3, null, 0, null, 0); // clearing the cart before logging out // Closing form while freeing system resources FormsMenuList.usersRegistryForm.Dispose(); }
private void GraphsAnalyticsForm_Load(object sender, EventArgs e) { // Identifying correct protocol for current user in session if (SystemProtocols.ApplySessionsProtocols(1, null, null)) { // Disabling the entire Products option given the remainder of options are prohibited for a basic user registerNewProductMenuSubOption.Visible = false; registerNewProductMenuSubOption.Enabled = false; restockProductsMenuSubOption.Visible = false; restockProductsMenuSubOption.Enabled = false; // Disabling all admin options adminMenuOption.Visible = false; adminMenuOption.Enabled = false; } // Recording user access to this form SystemProtocols.ApplyActivityProtocols("GRA1", null, null); // Hiding message lables missingMessageLabel.Visible = false; shownMessageLabel.Visible = false; // Initilizing combo box timeComboBox.Items.Add("24 hours"); timeComboBox.Items.Add("72 hours"); timeComboBox.Items.Add("week"); timeComboBox.Items.Add("2 weeks"); timeComboBox.Items.Add("month"); timeComboBox.Items.Add("2 months"); timeComboBox.SelectedIndex = 0; // Populating Graphs PopulateUsernameTimesheetListBox(); PopulateUsernameSalesListBox(); // Initializing date time pickers #region Bubble Chart newestBubbleDateTimePicker.Value = DateTime.Now; newestBubbleDateTimePicker.MaxDate = DateTime.Today.AddDays(1); #endregion #region Sales Bar Chart newestSalesBarChartDateTimePicker.Value = DateTime.Now; newestSalesBarChartDateTimePicker.MaxDate = DateTime.Today.AddDays(1); #endregion }
private void ProductInformationTemplateForm_Load(object sender, EventArgs e) { // Limiting user features to prevent non admins to edit a product's information if (SystemProtocols.ApplySessionsProtocols(1, null, null)) { // Disabling the text fields and combo boxes for basic users keyTextBox.Enabled = false; unitTextBox.Enabled = false; unitCostNumericUpDown.Enabled = false; unitPriceNumericUpDown.Enabled = false; quantityNumericUpDown.Enabled = false; minimumQuantityNumericUpDown.Enabled = false; maximumQuantityNumericUpDown.Enabled = false; brandComboBox.Enabled = false; supplierComboBox.Enabled = false; categoryComboBox.Enabled = false; typeComboBox.Enabled = false; discontinuedCheckBox.Enabled = false; // Disabling and hiding the edit button editButton.Enabled = false; editButton.Visible = false; } else { // Enabling the text fields and combo boxes for basic users keyTextBox.Enabled = true; unitTextBox.Enabled = true; unitCostNumericUpDown.Enabled = true; unitPriceNumericUpDown.Enabled = true; quantityNumericUpDown.Enabled = true; minimumQuantityNumericUpDown.Enabled = true; maximumQuantityNumericUpDown.Enabled = true; brandComboBox.Enabled = true; supplierComboBox.Enabled = true; categoryComboBox.Enabled = true; typeComboBox.Enabled = true; discontinuedCheckBox.Enabled = true; // Enabling and hiding the edit button editButton.Enabled = false; } }
protected override void OnFormClosing(FormClosingEventArgs e) { base.OnFormClosing(e); // Executing correct log out processes SystemProtocols.ApplyLogOutProtocols(); FormsMenuList.loginForm.Show(); if (userInformationForm != null) { userInformationForm.Dispose(); // Closing Child } SystemProtocols.ApplyCartManagementProtocol(3, null, 0, null, 0); // clearing the cart before logging out // Closing form while freeing system resources FormsMenuList.usersRegistryForm.Dispose(); }
private void ErrorsLogForm_Load(object sender, EventArgs e) { // Identifying correct protocol for current user in session if (SystemProtocols.ApplySessionsProtocols(1, null, null)) { // Disabling the entire Products option given the remainder of options are prohibited for a basic user registerNewProductMenuSubOption.Visible = false; registerNewProductMenuSubOption.Enabled = false; restockProductsMenuSubOption.Visible = false; restockProductsMenuSubOption.Enabled = false; // Disabling all admin options adminMenuOption.Visible = false; adminMenuOption.Enabled = false; } SystemProtocols.ApplyActivityProtocols("ERR1", null, null); }
private void RestockProductsForm_Load(object sender, EventArgs e) { // Identifying correct protocol for current user in session if (SystemProtocols.ApplySessionsProtocols(1, null, null)) { // Disabling the other Products option registerNewProductMenuSubOption.Visible = false; registerNewProductMenuSubOption.Enabled = false; // Disabling all admin options adminMenuOption.Visible = false; adminMenuOption.Enabled = false; } SystemProtocols.ApplyActivityProtocols("PRO1", null, null); PopulateProductListDataGrid(); UpdateDisplayLabels(); }
private void LogOutLabel_Click(object sender, EventArgs e) { // Executing correct log out processes SystemProtocols.ApplyLogOutProtocols(); FormsMenuList.loginForm.Show(); if (timesheetChild != null) { timesheetChild.Dispose(); // disposing of child timesheet if open } if (salesRecordChild != null) { salesRecordChild.Dispose(); // disposing of child sales record if open } SystemProtocols.ApplyCartManagementProtocol(3, null, 0, null, 0); // clearing the cart before logging out // Closing form while freeing system resources FormsMenuList.reportsAnalyticsForm.Dispose(); }
private void InventorySearchForm_Load(object sender, EventArgs e) { // Identifying correct protocol for current user in session if (SystemProtocols.ApplySessionsProtocols(1, null, null)) { // Disabling the entire Products option given the remainder of options are prohibited for a basic user productsMenuOption.Visible = false; productsMenuOption.Enabled = false; // Disabling all admin options adminMenuOption.Visible = false; adminMenuOption.Enabled = false; } PopulateProductListDataGrid(); // Initializing the data grid upon load // Executing correct activity according to given code SystemProtocols.ApplyActivityProtocols("INV1", null, null); }
private void ActivitiesLogForm_Load(object sender, EventArgs e) { // Limiting option according to current user's access level if (SystemProtocols.ApplySessionsProtocols(1, null, null)) { // Disabling the entire Products option given the remainder of options are prohibited for a basic user registerNewProductMenuSubOption.Visible = false; registerNewProductMenuSubOption.Enabled = false; restockProductsMenuSubOption.Visible = false; restockProductsMenuSubOption.Enabled = false; // Disabling all admin options adminMenuOption.Visible = false; adminMenuOption.Enabled = false; } // Executing correct activity according to given code SystemProtocols.ApplyActivityProtocols("ACT1", null, null); PopulateActivityListDataGrid(); }
private void UserInformationTemplateForm_Load(object sender, EventArgs e) { // Disabling features according to target user's aacces level compared to current user in session's access level if (SystemProtocols.ApplySessionsProtocols(2, user.Username, user.Role)) // If the target user is of a different account and access level is equals to the current user in session { // TODO: Hide System resources in business layer changeAccessLevelButtom.Visible = false; changeAccessLevelButtom.Enabled = false; changePasswordButton.Visible = false; changePasswordButton.Enabled = false; } else if (SystemProtocols.ApplySessionsProtocols(3, user.Username, null)) // If the target user the one with the current open sesison { changeAccessLevelButtom.Visible = false; changeAccessLevelButtom.Enabled = false; suspendUserButton.Visible = false; suspendUserButton.Enabled = false; } else // If the target user is of a different account and access level is different to the current user in session { changePasswordButton.Visible = false; changePasswordButton.Enabled = false; } // Modifuing components based on target user's access level changeAccessLevelButtom.Text = user.Role == "Admin" ? "Demote to User Level" : "Promote to Admin Level"; suspendUserButton.Text = user.Status == "Active" ? "Suspend User" : "Reinstate User"; // Displaying target user's information usernameTextBox.Text = user.Username; firstNameTextBox.Text = user.FirstName; lastNameTextBox.Text = user.LastName; roleTextBox.Text = user.Role; creatorTextBox.Text = user.Creator; statusTextBox.Text = user.Status; createdOnLabel.Text = user.RegistrationDate.ToString(); LastLabel.Text = user.LastLogin.ToString(); PopulateActivityList(); }
private void RegisterNewProductForm_Load(object sender, EventArgs e) { // Identifying correct protocol for current user in session if (SystemProtocols.ApplySessionsProtocols(1, null, null)) { // Disabling the other Products option restockProductsMenuSubOption.Visible = false; restockProductsMenuSubOption.Enabled = false; // Disabling all admin options adminMenuOption.Visible = false; adminMenuOption.Enabled = false; } PopulateBrandListBox(); PopulateSupplierListBox(); PopulateCategoryComboBox(); PopulateTypeComboBox(); // Executing correct activity according to given code SystemProtocols.ApplyActivityProtocols("PRO2", null, null); }
private void ChangeAccessLevelButtom_Click(object sender, EventArgs e) { // Requesting a access level change for a target user UserInformationManager.UpdateTargetUserAccessLevelInformation(user.Username, user.Role == "Admin" ? "User" : "Admin"); // Updating information of the form user.Role = user.Role == "Admin" ? "User" : "Admin"; roleTextBox.Text = user.Role; changeAccessLevelButtom.Text = user.Role == "Admin" ? "Demote to User Level" : "Promote to Admin Level"; // Disabling features according to target user's access level compared to current user in session's access level if (SystemProtocols.ApplySessionsProtocols(2, user.Username, user.Role)) { changeAccessLevelButtom.Visible = false; changeAccessLevelButtom.Enabled = false; changePasswordButton.Visible = false; changePasswordButton.Enabled = false; } // Refreshing and updating information of parent form FormsMenuList.usersRegistryForm.RefreshDatagridInformation(); }