private void btnViewOrder_Click(object sender, EventArgs e) { //Validate order id. Guid orderId; if (!ApplicationObjects.TryParseGuid(txtViewOrderId.Text)) { MessageBox.Show("Invalid order ID format.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { orderId = new Guid(txtViewOrderId.Text); } Order order = ApplicationObjects.GetOrder(orderId); if (order == null) { MessageBox.Show("Order ID does not exist.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } _loginForm.ShowOrderForm(userAccount, order, _loginForm); this.Close(); }
// DELETE FROM INVENTORY BUTTON click event private void btn_DeleteFromInventory_Click(object sender, EventArgs e) { // Verify that user selected an inventory item in the search result combobox if (cbx_ResultsList.SelectedItem == null) { MessageBox.Show("No Inventory Item Selected. Please select an inventory item from the drop-down list and try again", "Invalid Status Change", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } // Verify that the item is in SOLD status...any other status can't be marked as DELIVERED else if (inventoryItems[cbx_ResultsList.SelectedIndex].InventoryItemStatus != InventoryItemStatus.Sold) { MessageBox.Show("You can only deliver an item that is currently in 'Sold' status. Please try again", "Invalid Item Status", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } // If user input appears to be valid, continue else { // Delete inventory item from database ApplicationObjects.RemoveInventoryItemFromInventory(inventoryItems[cbx_ResultsList.SelectedIndex]); // Clear all fields to prepare for next search. ResetInventorySearch(); } }
// Method will refresh the UI notification information and display private void RefreshNotifications() { // Clear notification detail display box rbox_ClerkNotifications.Clear(); // Get list of user's notifications notifications = ApplicationObjects.CheckAllNotifications(userAccount); // Variable to be used for notificaion heaqding (new or read) string isRead = null; foreach (Notification notification in notifications) { // If notification is new (unread) if (notification.IsRead == false) { // String to insert into notification if notification is new isRead = "New "; } // Populate combobox drop-down with notifications cbx_Notifications.Items.Add(isRead + "Notification: " + notification.NotificationType.ToString()); } // Display total number of notifications lbl_Notifications.Text = (notifications.Count.ToString() + " total notifications found"); }
// DELETE NOTIFICATION button click event private void btn_DeleteNotification_Click(object sender, EventArgs e) { // Send notification to the database to be deleted if (cbx_Notifications.SelectedIndex >= 0) { int returnValue = ApplicationObjects.DeleteNotification(notifications[cbx_Notifications.SelectedIndex].NotificationId); } }
public OrderForm(UserAccount user, Guid orderId, InventoryItem invItem, LoginForm loginForm) { userAccount = user; _loginForm = loginForm; InitializeComponent(); order = ApplicationObjects.GetOrder(orderId); inventoryItem = invItem; }
// REVIEW ORDER DETAILS BUTTON click event private void btnReviewOrder_Click(object sender, EventArgs e) { //if statement for user account: manager or sales oriented forms Guid selectedOrderId = new Guid(dgvOrders.Rows[dgvOrders.SelectedRows[0].Index].Cells[0].Value.ToString()); Order order = ApplicationObjects.GetOrder(selectedOrderId); _loginForm.ShowOrderForm(userAccount, order, _loginForm); this.Close(); }
private void btnCreateUser_Click(object sender, EventArgs e) { bool userInfoIsValid = ValidateUserInformation(); if (!userInfoIsValid) { return; } UserAccount newUser = new UserAccount(txtUsername.Text, txtUserPassword.Text, false); newUser.EmailAddress = txtEmailAddress.Text; newUser.FirstName = txtFirstName.Text; newUser.LastName = txtLastName.Text; newUser.PhoneNumber = txtPhoneNumber.Text; foreach (object item in chklstRoles.CheckedItems) { PermissionSet permissionSet = new PermissionSet(); switch (item.ToString()) { case "Operational Manager": permissionSet.IsManager = true; permissionSet.IsStockClerk = true; permissionSet.IsCustomer = true; permissionSet.IsWorkSpecialist = true; break; case "Sales Person": permissionSet.IsCustomer = true; break; case "Printing / Engraving Specialist": permissionSet.IsWorkSpecialist = true; break; case "Stock Clerk": permissionSet.IsStockClerk = true; break; } newUser.PermissionSet = permissionSet; } int returnValue = ApplicationObjects.NewUser(newUser); ApplicationObjects.DisplayDataStatus(returnValue); if (returnValue == 1) { return; } else if (returnValue == 2) { MessageBox.Show("A user by this name already exists.", "Duplicate User", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } _loginForm.ShowManagerMainForm(userAccount, _loginForm); this.Close(); }
private void btnLogin_Click(object sender, EventArgs e) { //Do nothing if user name or password is empty. if ((txtUserName.Text == String.Empty) || (txtUserName.Text == null)) { return; } if ((txtPassword.Text == String.Empty) || (txtPassword.Text == null)) { return; } userAccount = ApplicationObjects.AuthenticateUser(txtUserName.Text, txtPassword.Text); if (userAccount.UserName == "invalid" && userAccount.PasswordHash == "invalid") { MessageBox.Show("Failed to authenticate with inputted username and password." , "Authentication Failed" , MessageBoxButtons.OK , MessageBoxIcon.Exclamation); Logout(); return; } if (userAccount.HighestPermission == null) { MessageBox.Show("Invalid permissions token. Please contact your manager." , "Authentication Failed" , MessageBoxButtons.OK , MessageBoxIcon.Exclamation); return; } //Auto forward them to the highest permission user page. switch (userAccount.HighestPermission) { case (Permission.OperationsManager): ShowDashBoardSelectionForm(userAccount, this); this.Hide(); break; case (Permission.SalesPerson): ShowSalesEmployeeForm(userAccount, this); this.Hide(); break; case (Permission.WorkSpecialist): ShowWorkSpecialistForm(userAccount, this); this.Hide(); break; case (Permission.StockClerk): ShowStockClerkForm(userAccount, this); this.Hide(); break; } }
// this event is triggered when the order button is clicked on the customer page. protected void btnOrderNow_Click(object sender, EventArgs e) { if ((txtDesiredText.Text == null) || (txtDesiredText.Text == string.Empty)) { lblError.Text = "Error: You need to enter your desired text"; lblError.Visible = true; return; } BusinessObjects _businessObjects = new BusinessObjects(); string strLastName = lastnamelbl.Text; // create new order and newitem objects Order newOrder = new Order(); OrderItem newItem = new OrderItem(); // populate the new order and newitem objects with data from the database string ItemName = ItemDPList.Items[ItemDPList.SelectedIndex].Text; CatelogItem = _businessObjects.GetCatalogItemByItemName(ItemName); Customer = _businessObjects.GetCustomerByLastName(strLastName); Customer ActualCustomer = new Customer(); foreach (Customer Cust in Customer) { if (Cust.PersonType.ToString() == "Customer") { ActualCustomer = Cust; } } lastnamelbl.Text = ActualCustomer.PersonType.ToString(); // fill new item object with data newItem.CatalogItem = CatelogItem; newItem.ItemInscription = txtDesiredText.Text; newOrder.ItemList.Add(newItem); newOrder.OrderEntryDate = DateTime.Now; newOrder.Person = ActualCustomer; OrderStatus orderstatus = (OrderStatus)Enum.Parse(typeof(OrderStatus), "Submitted"); newOrder.OrderStatus = orderstatus; // call the createorder method to create new order int returnValue = ApplicationObjects.CreateOrder(newOrder); if (returnValue == 0) { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Your Order is complete!" + "');", true); } Response.Redirect(Request.RawUrl); txtDesiredText = null; lblInscriptionType = null; lblItemCost = null; }
// DELETE NOTIFICATION button click event private void btn_DeleteNotificaiton_Click(object sender, EventArgs e) { // Send notification to the database to be deleted if (cbx_Notifications.SelectedItem != null) { int returnValue = ApplicationObjects.DeleteNotification(notifications[cbx_Notifications.SelectedIndex].NotificationId); } else { MessageBox.Show("Please select a notification before clicking the [delete] button.", "Delete Notification Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
protected void submitBtn_Click(object sender, EventArgs e) { if (lblError.Visible == true) { lblError.Text = null; } //Do nothing if user name or password is empty. if ((txtUserName.Text == String.Empty) || (txtUserName.Text == null)) { return; } if ((txtPassword.Text == String.Empty) || (txtPassword.Text == null)) { return; } // get user account information from the database userAccount = ApplicationObjects.AuthenticateUser(txtUserName.Text, txtPassword.Text); //If the user information is invalid, return error. if (userAccount.UserName == "invalid" && userAccount.PasswordHash == "invalid") { lblError.Text += "Failed to authenticate with inputted username and password, Authentication Failed"; lblError.Visible = true; return; } if (userAccount.HighestPermission == null) { lblError.Text += "Invalid permissions token. Please contact Help-Desk, Authentication Failed"; lblError.Visible = true; return; } txtError.Text = "Success"; txtError.Visible = true; //redirect users based on permissions switch (userAccount.HighestPermission) { case (Permission.Manager): ShowManagerMainForm(userAccount); break; case (Permission.Customer): ShowCustomerPage(userAccount); break; } }
public bool ValidateUserInformation() { // BEGIN USER INPUT DATA VALIDATION..... // Verify that PERSONAL information was not left blank if ((this.txtFirstName.Text == "") || (this.txtLastName.Text == "") || (this.txtPhoneNumber.Text == "") || (this.txtEmailAddress.Text == "") || (this.txtUsername.Text == "") || (this.txtUserPassword.Text == "") || (this.txtManagerPassword.Text == "")) { // If any personal information was blank, display error and break code ApplicationObjects.DisplayInvalidInput("Please make sure that you have filled out all of the personal fields and try again."); return(false); } // Variable used in TryParse functions long number; // Validate numeric input for phone number if ((!long.TryParse((txtPhoneNumber.Text), out number)) || (txtPhoneNumber.Text.Length != 10)) { // If phone number input was not numeric, display error and break code ApplicationObjects.DisplayInvalidInput("Invalid phone number entered. Please enter 10 digits (no dashes) & try again."); return(false); } // validate email address format if (!ApplicationObjects.EmailIsValid(txtEmailAddress.Text)) { // If email address was not in specified format, display error and break code ApplicationObjects.DisplayInvalidInput("Invalid e-mail address entered. Please try again."); return(false); } // validate user name if (!(txtUsername.Text.Length >= 4)) { ApplicationObjects.DisplayInvalidInput("Invalid username entered. Your username must be four characters or longer."); return(false); } // validate password if (!(txtUserPassword.Text.Length >= 4)) { ApplicationObjects.DisplayInvalidInput("Invalid password entered. Your password must be four characters or longer."); return(false); } // .....END USER INPUT DATA VALIDATION return(true); }
private void LoadOrders() { orderTable.Rows.Clear(); foreach (Order order in ApplicationObjects.GetAllOrders()) { DataRow newRow = orderTable.NewRow(); newRow["Order Id"] = order.OrderId.ToString(); newRow["First Name"] = order.Person.FirstName; newRow["Last Name"] = order.Person.LastName; newRow["Entry Date"] = order.OrderEntryDate.ToString(); newRow["Fulfilled Date"] = (order.OrderFulfillDate != null) ? order.OrderFulfillDate.ToString() : "not filled"; newRow["Number of Items"] = order.NumberOrderItems.ToString(); newRow["Order Status"] = order.OrderStatus.ToString(); orderTable.Rows.Add(newRow); } dgvOrders.DataBind(); }
// COMPLETE ORDER button click event private void btn_CompleteOrder_Click(object sender, EventArgs e) { //Validate order id. Guid orderId; int returnValue; if (!ApplicationObjects.TryParseGuid(tbx_CompleteOrder.Text)) { MessageBox.Show("Invalid order ID format. No update occurred.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { orderId = new Guid(tbx_CompleteOrder.Text); } Order order = ApplicationObjects.GetOrder(orderId); if (order == null) { MessageBox.Show("Order ID does not exist. No update occurred.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } order.OrderStatus = OrderStatus.WorkComplete; returnValue = ApplicationObjects.UpdateOrderStatusWithNotification(order, (Permission)userAccount.PermissionSet.GetHighestPermission()); // Display output messages based on success/failure of database updates if (returnValue == 0) { // Database update insert was successfull MessageBox.Show("Your inventory update request was successful.", "Inventory Update", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { // Database update failure MessageBox.Show("An error occurred and the order status was not updated", "Inventory Update", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnDelivered_Click(object sender, EventArgs e) { if (dgvOrders.SelectedRows.Count != 1) { MessageBox.Show("You must select one and only one order.", "Please select a row", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } //Get order object Guid selectedOrderId = new Guid(dgvOrders.Rows[dgvOrders.SelectedRows[0].Index].Cells[0].Value.ToString()); Order order = ApplicationObjects.GetOrder(selectedOrderId); order.OrderStatus = OrderStatus.Delivered; order.OrderFulfillDate = DateTime.Now; ApplicationObjects.UpdateOrderStatusWithNotification(order, (Permission)userAccount.PermissionSet.GetHighestPermission()); //refresh the view LoadOrders(); }
private void btnSubmit_Click(object sender, EventArgs e) { if (chbAllItems.Checked && chbCorrectInscriptions.Checked && chbDamage.Checked && chbMedia.Checked && chbSpelling.Checked) { //mark order valid and send notification _order.OrderStatus = OrderStatus.Complete; ApplicationObjects.UpdateOrderStatusWithNotification(_order, (Permission)userAccount.PermissionSet.GetHighestPermission()); } else { //mark order invalid and send notification _order.OrderStatus = OrderStatus.FailedValidation; ApplicationObjects.UpdateOrderStatusWithNotification(_order, (Permission)userAccount.PermissionSet.GetHighestPermission()); } _loginForm.ShowOrdersForm(userAccount, _loginForm); this.Close(); }
private void btn_clerknotifysubmit_Click(object sender, EventArgs e) { //Validate order id. Guid orderId; if (!ApplicationObjects.TryParseGuid(tbox_clerknotifyid.Text)) { MessageBox.Show("Invalid order ID format. No update occurred.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { orderId = new Guid(tbox_clerknotifyid.Text); } Order order = ApplicationObjects.GetOrder(orderId); if (order == null) { MessageBox.Show("Order ID does not exist. No update occurred.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } //Validate that at least one of the radio button is selected. if (!rbtn_NotifyEnRoute.Checked && !rbtn_NotifyDelivered.Checked) { MessageBox.Show("Either the \"En Route\" or the \"Delivered\" radio button must be selected. No update occurred.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } //Prevent decrementing if status was already maked as delivered. if ((order.OrderStatus != OrderStatus.Delivered) && (rbtn_NotifyDelivered.Checked)) { string message = "Marking this order as \"Delivered\" will set the status for all items in the order " + "and decrement the available number in stock. Are you sure you'd like to mark this order \"Delivered\"?"; DialogResult result = MessageBox.Show(message, "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result == DialogResult.Cancel) { return; } //Update order status and submit notifications order.OrderStatus = OrderStatus.Delivered; ApplicationObjects.UpdateOrderStatusWithNotification(order, (Permission)userAccount.PermissionSet.GetHighestPermission()); /*************************************/ //TODO: Re-think this location for the deletes. Should the stock clerk mark delivered to the customer or //just to the engraver. If to the engraver, then should the engraver handle the inventory decrementation? /*************************************/ //Delete from inventory because the material has been delivered. //ApplicationObjects.RemoveOrderItemsFromInventory(order); } //Do nothing if En Route was already set. else if ((order.OrderStatus != OrderStatus.EnRoute) && (rbtn_NotifyEnRoute.Checked)) { //Validate order id. if (!ApplicationObjects.TryParseGuid(tbox_clerknotifyid.Text)) { MessageBox.Show("Invalid order ID format. No update occurred.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { //Update order status and submit notifications order.OrderStatus = OrderStatus.EnRoute; ApplicationObjects.UpdateOrderStatusWithNotification(order, (Permission)userAccount.PermissionSet.GetHighestPermission()); BusinessObjects _notificationBusinessObject = new BusinessObjects(); int notificationReturnValue; Notification notification = new Notification(); notification.OrderId = new Guid(tbox_clerknotifyid.Text); notification.NotificationId = Guid.NewGuid(); notification.NotificationMessage = ("Inventory item has been ordered and is en route : " + inventoryItems[cbx_ResultsList.SelectedIndex].InventoryItemId.ToString()); notification.NotificationType = NotificationType.EnRoute; notification.IsRead = false; notification.PermissionScope = Permission.WorkSpecialist; // INSERT notification to database notificationReturnValue = _notificationBusinessObject.InsertNotification(notification); if (notificationReturnValue == 0) { /* Database (inventory update) & (notification insert) success message. * This message displays if the inventory database update was successful, * and the notificaiton insert was successfull*/ MessageBox.Show("Your inventory update request was successful. A notification has been sent to the Work Specialist", "Inventory Update", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { /* Database (inventory update SUCCESS) but (notification insert FAILURE) message. * This message displays if the inventory database update was successful, * but the notification failed for some reason*/ MessageBox.Show("Your inventory update request was successful. However, an error prevented a" + "notification from being sent to the Work Specialist", "Inventory Update", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } }
// INVENTORY SEARCH submit button click event private void btn_SearchSubmit_Click(object sender, EventArgs e) { BusinessObjects _businessObjects = new BusinessObjects(); // Element reset to be performed each time, before a search is ran lbl_ResultsFound.Text = null; // Clear contents of search result label cbx_ResultsList.Items.Clear(); // Clear old search results from results combo box cbx_ResultsList.Text = ""; // Clear text from visible combobox area rbox_clerkSearchDisplay.Clear(); // Clear search results each time a new search is submitted inventoryItems = null; // Verify that a query type was selected by the user if ((cbx_QueryType.SelectedItem == null) || (cbx_InventoryStatus.SelectedItem == null) || (tbx_QueryInput.Text == "")) { MessageBox.Show("Please make sure all search criteria is filled out and try again", "Invalid Query Input", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } // SEARCH BY MANUFACTURER NAME - Chech to see if user entered a Manufacturer Name else if (cbx_QueryType.SelectedItem.ToString() == "Manufacturer") { // Generate a list of Inventory Items that match the Manufacturer Name entered by the user inventoryItems = _businessObjects.GetInventoryItemByItemManufacturer(tbx_QueryInput.Text, cbx_InventoryStatus.SelectedIndex); } // SEARCH BY ITEM NAME - Check to see if user entered an Item Name else if (cbx_QueryType.SelectedItem.ToString() == "Item Name") { // Generate a list of Inventory Items that match the Item Name entered by the user inventoryItems = _businessObjects.GetInventoryItemByItemName(tbx_QueryInput.Text, cbx_InventoryStatus.SelectedIndex); } // SEARCH BY ITEM GUID - Check to see if user entered an ID Number else if (cbx_QueryType.SelectedItem.ToString() == "Inventory ID") { try { // Generate a list of Inventory Items that match the Item ID entered by the user inventoryItems = ApplicationObjects.GetInventoryItemByInventoryItemIdAndInventoryItemStatusId(new Guid(tbx_QueryInput.Text), cbx_InventoryStatus.SelectedIndex); } catch (Exception) { // Catch if a non-Guid was entered MessageBox.Show("Search failed! You may have entered an invalid ID. Please check your item ID and try again", "Search Failure", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); rbox_clerkSearchDisplay.AppendText("Input error - please try again"); return; } } // SEARCH BY CATALOG NUMBER - Check to see if user entered an Item Name else if (cbx_QueryType.SelectedItem.ToString() == "Catalog Number") { try { // Generate a list of Inventory Items that match the Item Name entered by the user inventoryItems = _businessObjects.GetInventoryItemByCatalogItemIdAndInventoryItemStatusId(new Guid(tbx_QueryInput.Text), cbx_InventoryStatus.SelectedIndex); } catch (Exception) { // Catch if a non-integer was entered MessageBox.Show("Search failed! You may have entered an invalid ID. Please check your catalog ID and try again", "Search Failure", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); rbox_clerkSearchDisplay.AppendText("Input error - please try again"); return; } } // If nothing is populated into the searchDisplay box, we can assume that there were no search results else { lbl_ResultsFound.Text = "No matches found - please try again"; } // Populate label that displays how many results were found lbl_ResultsFound.Text = (inventoryItems.Count.ToString() + " result(s) found!"); // This string list holds the results of an InventoryItem's ToItemDescription method, which actually // returns a list of individual line items, which each hold the item's attributes that will be // displayed on seperate lines of the text box try { List <string> itemDescriptions = inventoryItems.FirstOrDefault().ToItemDescription(); foreach (string lineItem in itemDescriptions) { // Add each description line item to the text box rbox_clerkSearchDisplay.AppendText(lineItem + Environment.NewLine); } // Populate the search result combobox with the catalog numbers of the search results foreach (InventoryItem inventoryItem in inventoryItems) { cbx_ResultsList.Items.Add(inventoryItem.InventoryItemId.ToString()); } // Set the combobox to show the catalog number of the first search record cbx_ResultsList.SelectedIndex = 0; } catch (Exception) { rbox_clerkSearchDisplay.AppendText("No matches found - please try again"); return; } }
// SAVE CHANGES BUTTON click event - Save changes made to currently selected customer private void btn_SaveChanges_Click(object sender, EventArgs e) { // BEGIN USER INPUT DATA VALIDATION..... // Verify that PERSONAL information was not left blank if ((this.tbx_FirstName.Text == "") || (this.tbx_LastName.Text == "") || (this.tbx_PhoneNumber.Text == "") || (this.tbx_EMail.Text == "")) { // If any personal information was blank, display error and break code ApplicationObjects.DisplayInvalidInput("Please make sure that you have filled out all of the personal fields and try again."); return; } // Verify that MAILING address information was not left blank if ((this.tbx_MailingStreetNumber.Text == "") || (this.tbx_MailingStreetName.Text == "") || (this.tbx_MailingCity.Text == "") || (this.tbx_MailingState.Text == "") || (this.tbx_MailingZipCode.Text == "")) { // If any mailing address information was blank, display error and break code ApplicationObjects.DisplayInvalidInput("Please make sure that you have filled out all of the mailing address fields and try again."); return; } // Verify that BILLING address information was not left blank if ((this.tbx_BillingStreetNumber.Text == "") || (this.tbx_BillingStreetName.Text == "") || (this.tbx_BillingCity.Text == "") || (this.tbx_BillingState.Text == "") || (this.tbx_BillingZipCode.Text == "")) { // If any billing address information was blank, display error and break code ApplicationObjects.DisplayInvalidInput("Please make sure that you have filled out all of the billing address fields and try again."); return; } // Validate numeric input for phone number if ((!long.TryParse((this.tbx_PhoneNumber.Text), out longValidation)) || (this.tbx_PhoneNumber.Text.Length != 10)) { // If phone number input was not numeric, display error and break code ApplicationObjects.DisplayInvalidInput("Invalid phone number entered. Please enter 10 digits (no dashes) & try again."); return; } // validate email address format if (!ApplicationObjects.EmailIsValid(this.tbx_EMail.Text)) { // If email address was not in specified format, display error and break code ApplicationObjects.DisplayInvalidInput("Invalid e-mail address entered. Please try again."); return; } // Validate numeric input for street numbers if ((!long.TryParse((this.tbx_MailingStreetNumber.Text), out longValidation)) || (!long.TryParse((this.tbx_BillingStreetNumber.Text), out longValidation))) { // If street number input was not numeric, display error and break code ApplicationObjects.DisplayInvalidInput("Invalid street number entered. Please enter only numeric values & try again."); return; } // Verify that the state is only 2 characters if ((this.tbx_MailingState.Text.Length != 2) || (this.tbx_BillingState.Text.Length != 2)) { // If state input does not have only 2 characters, display error and break code ApplicationObjects.DisplayInvalidInput("Invalid state entered. Please enter a 2-letter state abbreviation & try again."); return; } // Validate numeric input for zip codes if ((!long.TryParse((this.tbx_MailingZipCode.Text), out longValidation)) || (!long.TryParse((this.tbx_BillingZipCode.Text), out longValidation))) { // If zip code input was not numeric, display error and break code ApplicationObjects.DisplayInvalidInput("Invalid zip code entered. Please enter only numeric values & try again."); return; } // If zip is numeric, validate only 5 digits else if ((this.tbx_MailingZipCode.Text.Length != 5) || (this.tbx_BillingZipCode.Text.Length != 5)) { // If zip code does not have only 5 characters, display error and break code ApplicationObjects.DisplayInvalidInput("Invalid zip code entered. Please enter only 5 digits & try again."); return; } // .....END USER INPUT DATA VALIDATION // Take the user input from the text boxes and update the currently selected... // ...customer's information within the customer object PopulateCustomerObjectWithDetails(); // Send update request to business layer int returnValue = ApplicationObjects.UpdateCustomer(customers[cbx_CustomerResultsList.SelectedIndex]); // Re-run search if (returnValue == 0) { // If update successfull, re-run search based on the customerID of the customer that was just updated cbx_CustomerSearchType.SelectedIndex = 2; tbx_CustomerSearchInput.Text = customers[cbx_CustomerResultsList.SelectedIndex].CustomerId.ToString(); } // Perform search button click to re-populate search results gbx_SearchCriteria.Visible = true; btn_ViewOrders.Visible = true; btn_CreateCustomer.Visible = true; btn_CustomerSearch.Visible = true;; btn_MainPage.Visible = true; btn_EnableEditing.Visible = true; btn_NewOrder.Visible = true; btn_SaveChanges.Visible = false; lbl_CustomerResultSort.Visible = false; cbx_SameAsMailing.Visible = true; btn_CustomerSearch.PerformClick(); }
// CUSTOMER SEARCH BUTTON click event private void btn_CustomerSearch_Click(object sender, EventArgs e) { // Make sure all controls are visible gbx_SearchCriteria.Visible = true; btn_ViewOrders.Visible = true; btn_CreateCustomer.Visible = true; btn_CustomerSearch.Visible = true;; btn_MainPage.Visible = true; btn_EnableEditing.Visible = true; btn_NewOrder.Visible = true; btn_SaveChanges.Visible = false; lbl_CustomerResultSort.Visible = false; //Make all customer data fields read-only by default MakeReadOnly(); //Reset form to prepare for new search results ClearResults(); // Verify that a query type was selected by the user if ((cbx_CustomerSearchType.SelectedItem == null) || (tbx_CustomerSearchInput.Text == null)) { ApplicationObjects.DisplayInvalidInput("Please make sure all search criterea is filled out."); return; } // SEARCH BY CUSTOMER FIRST NAME - Chech to see if user entered a customer first name else if (cbx_CustomerSearchType.SelectedItem.ToString() == "First Name") { // Generate a list of customers that match the first name entered by the user customers = ApplicationObjects.GetCustomerByFirstName(tbx_CustomerSearchInput.Text); // If customer list is empty, display no results found if (customers == null) { lbl_CustomerResultsFound.Text = "No results found!"; } else { // Populate the search results combo box with result first and last names foreach (Customer customer in customers) { cbx_CustomerResultsList.Items.Add(customer.FirstName + " " + customer.LastName); } // Change result label to show how results are listed in the results combobox lbl_CustomerResultSort.Text = "results listed by [first name] [last name]"; lbl_CustomerResultsFound.Text = cbx_CustomerResultsList.Items.Count.ToString() + " results found!"; } } // SEARCH BY CUSTOMER LAST NAME - Check to see if user entered a customer last name else if (cbx_CustomerSearchType.SelectedItem.ToString() == "Last Name") { // Generate a list of customers that match the last name entered by the user customers = ApplicationObjects.GetCustomerByLastName(tbx_CustomerSearchInput.Text); if (customers == null) { lbl_CustomerResultsFound.Text = "No results found!"; } else { // Populate the search results combo box with result last, first names foreach (Customer customer in customers) { cbx_CustomerResultsList.Items.Add(customer.LastName + ", " + customer.FirstName); } // Change result label to show how results are listed in the results combobox lbl_CustomerResultSort.Text = "results listed by [last name], [first name]"; lbl_CustomerResultsFound.Text = cbx_CustomerResultsList.Items.Count.ToString() + " results found!"; } } // SEARCH BY CUSTOMER ID - Check to see if user entered a customer ID else if (cbx_CustomerSearchType.SelectedItem.ToString() == "Customer ID") { //if invalid Guid, display error if (!Guid.TryParse((tbx_CustomerSearchInput.Text), out guidValidation)) { ApplicationObjects.DisplayInvalidInput("Invalid customer ID. Please try again."); return; } //If valid Guid, continue with search else { // Generate a list of customers that match the customer ID entered by the user customers = ApplicationObjects.GetCustomerByCustomerId(Guid.Parse(tbx_CustomerSearchInput.Text)); if (customers == null) { lbl_CustomerResultsFound.Text = "No results found!"; } else { // Populate the search results combo box with result last, first names foreach (Customer customer in customers) { cbx_CustomerResultsList.Items.Add(customer.CustomerId.ToString()); } // Change result label to show how results are listed in the results combobox lbl_CustomerResultSort.Text = "results listed by [customer id]"; lbl_CustomerResultsFound.Text = cbx_CustomerResultsList.Items.Count.ToString() + " results found!"; } } } // SEARCH BY CUSTOMER PHONE NUMBER - Check to see if user entered a customer phone number else if (cbx_CustomerSearchType.SelectedItem.ToString() == "Phone Number") { // Validate numeric input for phone number if ((!long.TryParse((tbx_CustomerSearchInput.Text), out longValidation)) || (tbx_CustomerSearchInput.Text.Length != 10)) { ApplicationObjects.DisplayInvalidInput("Invalid phone number entered. Please enter 10 digits (no dashes) & try again."); return; } else { // Generate a list of customers that match the phone number entered by the user customers = ApplicationObjects.GetCustomerByPhoneNumber(tbx_CustomerSearchInput.Text); // If customer list is empty, display no results found if (customers == null) { lbl_CustomerResultsFound.Text = "No results found!"; } else { // Populate the search results combo box with result last, first names foreach (Customer customer in customers) { cbx_CustomerResultsList.Items.Add(customer.PhoneNumber); } // Change result label to show how results are listed in the results combobox lbl_CustomerResultSort.Text = "results listed by [phone number]"; lbl_CustomerResultsFound.Text = cbx_CustomerResultsList.Items.Count.ToString() + " results found!"; } } } // SEARCH BY CUSTOMER EMAIL ADDRESS - Check to see if user entered a customer email address else if (cbx_CustomerSearchType.SelectedItem.ToString() == "Email Address") { // validate email address format if (!ApplicationObjects.EmailIsValid(tbx_CustomerSearchInput.Text)) { ApplicationObjects.DisplayInvalidInput("Invalid e-mail address entered. Please try again."); return; } else { // Generate a list of customers that match the email address entered by the user customers = ApplicationObjects.GetCustomerByEmail(tbx_CustomerSearchInput.Text); // If customer list is empty, display no results found if (customers == null) { lbl_CustomerResultsFound.Text = "No results found!"; } else { // Populate the search results combo box with result last, first names foreach (Customer customer in customers) { cbx_CustomerResultsList.Items.Add(customer.EmailAddress); } // Change result label to show how results are listed in the results combobox lbl_CustomerResultSort.Text = "results listed by [email address]"; lbl_CustomerResultsFound.Text = cbx_CustomerResultsList.Items.Count.ToString() + " results found!"; } } } // If the customer list is empty (no results found) if (customers.Count == 0) { // Display no results found lbl_CustomerResultsFound.Text = "No results found!"; return; } // If customer list is not empty, display results else { lbl_CustomerResultSort.Visible = true; cbx_CustomerResultsList.Visible = true; cbx_CustomerResultsList.SelectedIndex = 0; //Populate Customer details for first search result PopulateCustomerDetailsWithSelectedIndex(); } }
private void btnOrderSearch_Click(object sender, EventArgs e) { List <Order> ordersList = new List <Order>(); if ((cbSearchFields.SelectedItem == null) || (tbx_Search.Text == "")) { ApplicationObjects.DisplayInvalidInput("Please make sure that you have entered search criteria."); } else if (cbSearchFields.SelectedItem.ToString() == "Inventory Item Id") { try { // Generate a list of IOrders that match the Inventory Item ID entered by the user ordersList = ApplicationObjects.GetOrderByInventoryItemId(new Guid(tbx_Search.Text)); } catch (Exception) { // Catch if a non-Guid was entered ApplicationObjects.DisplayInvalidInput("Search failed! You may have entered an invalid ID. Please check your item ID and try again"); return; } } else if (cbSearchFields.SelectedItem.ToString() == "Order Id") { try { // Generate a list of Orders that match the Order ID entered by the user ordersList.Add(ApplicationObjects.GetOrder(new Guid(tbx_Search.Text))); } catch (Exception) { // Catch if a non-Guid was entered ApplicationObjects.DisplayInvalidInput("Search failed! You may have entered an invalid ID. Please check your item ID and try again"); return; } } else if (cbSearchFields.SelectedItem.ToString() == "Order Status") { // Convert user input into enum, before passing to search method OrderStatus orderStatus = BusinessLayer.Translators.Order.ConvertStringToOrderStatus(tbx_Search.Text); if (orderStatus == OrderStatus.None) { ApplicationObjects.DisplayInvalidInput("You may have entered an invalid order status type. Please try again"); return; } // Generate a list of Orders that match the Order ID entered by the user ordersList = ApplicationObjects.GetOrderByOrderStatus(orderStatus); } orderTable.Rows.Clear(); if (ordersList.Count > 0) { foreach (Order order in ordersList) { DataRow newRow = orderTable.NewRow(); newRow["Order Id"] = order.OrderId.ToString(); newRow["First Name"] = order.Person.FirstName; newRow["Last Name"] = order.Person.LastName; newRow["Entry Date"] = order.OrderEntryDate.ToString(); newRow["Fulfilled Date"] = (order.OrderFulfillDate != null) ? order.OrderFulfillDate.ToString() : "not filled"; newRow["Number of Items"] = order.NumberOrderItems.ToString(); newRow["Order Status"] = order.OrderStatus; orderTable.Rows.Add(newRow); } dgvOrders.AutoResizeColumns(); } else { MessageBox.Show("Your search turned up no results. Please try again.", "No Results Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
protected void Page_Load(object sender, EventArgs e) { //TreeNode PNode = new TreeNode(); //PNode.Text = "Root1"; //PNode.Value = "2"; //PNode.NavigateUrl = "~/About.aspx"; //TreeNode c1 = new TreeNode(); //c1.Text = "Tr1"; //c1.Value = "1"; //c1.NavigateUrl = "~/About.aspx"; //TreeNode c2 = new TreeNode(); //c2.Text = "Tr1"; //c2.Value = "1"; //c2.NavigateUrl="~/About.aspx"; //c1.ChildNodes.Add(c2); //PNode.ChildNodes.Add(c1); //this.ApplicationObjects.Nodes.Add(PNode); //PNode = new TreeNode(); //PNode.Text = "Root2"; //PNode.Value = "2"; //c1 = new TreeNode(); //c1.Text = "Tr2"; //c1.Value = "1"; //c2 = new TreeNode(); //c2.Text = "Tr2"; //c2.Value = "1"; //c2.NavigateUrl = "~/About1.aspx"; //c1.ChildNodes.Add(c2); //PNode.ChildNodes.Add(c1); //this.ApplicationObjects.Nodes.Add(PNode); //ApplicationObjects.CollapseAll(); //case 2 for (int i = 0; i <= 5; i++) { TreeNode node = new TreeNode(); node.Text = "Troot" + i; node.Value = "1"; ApplicationObjects.Nodes.Add(node); for (int j = 0; j <= 3; j++) { TreeNode node1 = new TreeNode(); node1.Text = "Tchild" + j; node1.Value = "1"; node1.NavigateUrl = "~/About.aspx"; if (j == 2) { TreeNode node2 = new TreeNode(); node2.Text = "Tchild_" + j; node2.Value = "1"; node2.NavigateUrl = "~/Default.aspx"; node1.ChildNodes.Add(node2); } node.ChildNodes.Add(node1); } } ApplicationObjects.CollapseAll(); }
public void CreateStartObjects() { Sport sportBiathlon = new Sport(); sportBiathlon.Name = "Биатлон"; sportBiathlon.IsTeamOrIndividual = TeamOrIndividual.Individual; sportBiathlon.IsSummerOrWinter = SummerOrWinter.Winter; sportBiathlon.IsOlimpicOrNonOlimpic = OlimpicOrNonOlimpic.Olimpic; ApplicationObjects.Add(sportBiathlon); FunClub funClubDasha = new FunClub(); funClubDasha.Name = "Фаны Даши"; funClubDasha.NumberOfMembers = 5000; funClubDasha.Slogan = "Вперед Беларусь!"; ApplicationObjects.Add(funClubDasha); Sportsman sportsman = new Sportsman(); sportsman.FirstName = "Дарья"; sportsman.LastName = "Домрачева"; sportsman.Country = "Беларусь"; sportsman.Sport = sportBiathlon; sportsman.FunClub = funClubDasha; sportsman.SportsCategory = SportsCategory.MasterOfSports; sportsman.Parametres.Age = 27; sportsman.Parametres.Height = 180; sportsman.Parametres.Weight = 70; ApplicationObjects.Add(sportsman); Sport sportFootball = new Sport(); sportFootball.Name = "Футбол"; sportFootball.IsTeamOrIndividual = TeamOrIndividual.Team; sportFootball.IsSummerOrWinter = SummerOrWinter.Summer; sportFootball.IsOlimpicOrNonOlimpic = OlimpicOrNonOlimpic.Olimpic; ApplicationObjects.Add(sportFootball); FunClub funClubBarselona = new FunClub(); funClubBarselona.Name = "Фаны Барселоны"; funClubBarselona.NumberOfMembers = 10000; funClubBarselona.Slogan = "Viva Barsa"; ApplicationObjects.Add(funClubBarselona); FootballTeam footballTeam1 = new FootballTeam(); footballTeam1.Name = "Барселона"; footballTeam1.Stadium = "Камп-Ноу"; footballTeam1.Sponsor = "Viber"; //footballTeam1.FunClub = funClubBarselona; footballTeam1.Championat = Championat.LaLiga; ApplicationObjects.Add(footballTeam1); FootballTeam footballTeam2 = new FootballTeam(); footballTeam2.Name = "Арсенал"; footballTeam2.Stadium = "Эмирэйтс"; footballTeam2.Sponsor = "Emirates"; footballTeam2.Championat = Championat.EnglishPremierLeague; ApplicationObjects.Add(footballTeam2); FootballPlayer footballPlayer = new FootballPlayer(); footballPlayer.FirstName = "Леонель"; footballPlayer.LastName = "Месси"; footballPlayer.SportsCategory = SportsCategory.MasterOfSports; footballPlayer.Position = Position.Forward; footballPlayer.Sport = sportFootball; footballPlayer.FootballTeam = null; footballPlayer.Country = "Аргентина"; footballPlayer.Parametres.Age = 31; footballPlayer.Parametres.Height = 176; footballPlayer.Parametres.Weight = 75; ApplicationObjects.Add(footballPlayer); FootballPlayer footballPlayer2 = new FootballPlayer(); footballPlayer2.FirstName = "Серхио"; footballPlayer2.LastName = "Бускетс"; footballPlayer2.SportsCategory = SportsCategory.MasterOfSports; footballPlayer2.Position = Position.Midfielder; footballPlayer2.FootballTeam = footballTeam1; footballPlayer2.Sport = sportFootball; footballPlayer2.Country = "Испания"; footballPlayer2.Parametres.Age = 33; footballPlayer2.Parametres.Height = 181; footballPlayer2.Parametres.Weight = 85; ApplicationObjects.Add(footballPlayer2); FootballPlayer footballPlayer3 = new FootballPlayer(); footballPlayer3.FirstName = "Виктор"; footballPlayer3.LastName = "Вальдес"; footballPlayer3.SportsCategory = SportsCategory.MasterOfSports; footballPlayer3.Position = Position.GoalKeeper; footballPlayer3.FootballTeam = footballTeam1; footballPlayer3.Country = "Испания"; footballPlayer3.Sport = sportFootball; footballPlayer3.Parametres.Age = 40; footballPlayer3.Parametres.Height = 189; footballPlayer3.Parametres.Weight = 77; ApplicationObjects.Add(footballPlayer3); FootballPlayer footballPlayer4 = new FootballPlayer(); footballPlayer4.FirstName = "Александр"; footballPlayer4.LastName = "Глеб"; footballPlayer4.SportsCategory = SportsCategory.MasterOfSports; footballPlayer4.Position = Position.Midfielder; footballPlayer4.FootballTeam = footballTeam2; footballPlayer4.Country = "Беларусь"; footballPlayer4.Sport = sportFootball; footballPlayer4.Parametres.Age = 36; footballPlayer4.Parametres.Height = 178; footballPlayer4.Parametres.Weight = 72; ApplicationObjects.Add(footballPlayer4); }
public void RemoveObject(ISport sportObject) { ApplicationObjects.Remove(sportObject); sportObject.Remove(ref sportObject); }
public void AddObject(ISport sportObject) { ApplicationObjects.Add(sportObject); FormMain.AddObjectToListBox(sportObject); }
// Begin CREATE CUSTOMER button click event private void btnCreateCustomer_Click(object sender, EventArgs e) { // BEGIN USER INPUT DATA VALIDATION..... // Verify that PERSONAL information was not left blank if ((tbx_FirstName.Text == "") || (tbx_LastName.Text == "") || (tbx_PhoneNumber.Text == "") || (tbx_EMail.Text == "")) { // If any personal information was blank, display error and break code ApplicationObjects.DisplayInvalidInput("Please make sure that you have filled out all of the personal fields and try again."); return; } // Verify that MAILING address information was not left blank if ((tbx_MailingStreetNumber.Text == "") || (tbx_MailingStreetName.Text == "") || (tbx_MailingCity.Text == "") || (tbx_MailingState.Text == "") || (tbx_MailingZipCode.Text == "")) { // If any mailing address information was blank, display error and break code ApplicationObjects.DisplayInvalidInput("Please make sure that you have filled out all of the mailing address fields and try again."); return; } // Verify that BILLING address information was not left blank if ((tbx_BillingStreetNumber.Text == "") || (tbx_BillingStreetName.Text == "") || (tbx_BillingCity.Text == "") || (tbx_BillingState.Text == "") || (tbx_BillingZipCode.Text == "")) { // If any billing address information was blank, display error and break code ApplicationObjects.DisplayInvalidInput("Please make sure that you have filled out all of the billing address fields and try again."); return; } // Variable used in TryParse functions long number; // Validate numeric input for phone number if ((!long.TryParse((tbx_PhoneNumber.Text), out number)) || (tbx_PhoneNumber.Text.Length != 10)) { // If phone number input was not numeric, display error and break code ApplicationObjects.DisplayInvalidInput("Invalid phone number entered. Please enter 10 digits (no dashes) & try again."); return; } // validate email address format if (!ApplicationObjects.EmailIsValid(tbx_EMail.Text)) { // If email address was not in specified format, display error and break code ApplicationObjects.DisplayInvalidInput("Invalid e-mail address entered. Please try again."); return; } // Validate numeric input for street numbers if ((!long.TryParse((tbx_MailingStreetNumber.Text), out number)) || (!long.TryParse((tbx_BillingStreetNumber.Text), out number))) { // If street number input was not numeric, display error and break code ApplicationObjects.DisplayInvalidInput("Invalid street number entered. Please enter only numeric values & try again."); return; } // Verify that the state is only 2 characters if ((tbx_MailingState.Text.Length != 2) || (tbx_BillingState.Text.Length != 2)) { // If state input does not have only 2 characters, display error and break code ApplicationObjects.DisplayInvalidInput("Invalid state entered. Please enter a 2-letter state abbreviation & try again."); return; } // Validate numeric input for zip codes if ((!long.TryParse((tbx_MailingZipCode.Text), out number)) || (!long.TryParse((tbx_BillingZipCode.Text), out number))) { // If zip code input was not numeric, display error and break code ApplicationObjects.DisplayInvalidInput("Invalid zip code entered. Please enter only numeric values & try again."); return; } // If zip is numeric, validate only 5 digits else if ((tbx_MailingZipCode.Text.Length != 5) || (tbx_BillingZipCode.Text.Length != 5)) { // If zip code does not have only 5 characters, display error and break code ApplicationObjects.DisplayInvalidInput("Invalid zip code entered. Please enter only 5 digits & try again."); return; } // .....END USER INPUT DATA VALIDATION // Populate customer object with user input Customer customer = new Customer(); customer.FirstName = tbx_FirstName.Text; customer.LastName = tbx_LastName.Text; customer.PhoneNumber = tbx_PhoneNumber.Text; customer.EmailAddress = tbx_EMail.Text; // Populate mailing address object with user input Address mailingAddress = new Address(); mailingAddress.PersonId = customer.PersonId; mailingAddress.StreetNumber = int.Parse(tbx_MailingStreetNumber.Text); mailingAddress.StreetName = tbx_MailingStreetName.Text; mailingAddress.AddressCity = tbx_MailingCity.Text; mailingAddress.AddressState = tbx_MailingState.Text; mailingAddress.AddressZip = tbx_MailingZipCode.Text; mailingAddress.AddressType = AddressType.Mailing; // Populate billing address object with user input Address billingAddress = new Address(); billingAddress.PersonId = customer.PersonId; billingAddress.StreetNumber = int.Parse(tbx_BillingStreetNumber.Text); billingAddress.StreetName = tbx_BillingStreetName.Text; billingAddress.AddressCity = tbx_BillingCity.Text; billingAddress.AddressState = tbx_BillingState.Text; billingAddress.AddressZip = tbx_BillingZipCode.Text; billingAddress.AddressType = AddressType.Billing; // Transaction to perform 4 inter-related data inserts on multiple database tables using (TransactionScope scope = new TransactionScope()) { int returnValue = 1; // Write PERSON record to database BusinessObjects _personBusinessObject = new BusinessObjects(); returnValue = _personBusinessObject.InsertPersonFromCustomer(customer); if (returnValue == 1) { // If insert fails, rollback transaction & display error message scope.Dispose(); ApplicationObjects.DisplayDataStatus(returnValue); return; } // Write CUSTOMER record to database BusinessObjects _customerBusinessObject = new BusinessObjects(); returnValue = _customerBusinessObject.InsertCustomer(customer); if (returnValue == 1) { // If insert fails, rollback transaction & display error message scope.Dispose(); ApplicationObjects.DisplayDataStatus(returnValue); return; } // Write MAILING ADDRESS record to database BusinessObjects _mailingAddressBusinessObject = new BusinessObjects(); returnValue = _mailingAddressBusinessObject.InsertAddress(mailingAddress); if (returnValue == 1) { // If insert fails, rollback transaction & display error message scope.Dispose(); ApplicationObjects.DisplayDataStatus(returnValue); return; } // Write BILLING ADDRESS record to database BusinessObjects _billingAddressBusinessObject = new BusinessObjects(); returnValue = _billingAddressBusinessObject.InsertAddress(billingAddress); if (returnValue == 1) { // If insert fails, rollback transaction & display error message scope.Dispose(); ApplicationObjects.DisplayDataStatus(returnValue); return; } // Committ data transaction & display success message scope.Complete(); ApplicationObjects.DisplayDataStatus(returnValue); }// End transaction _loginForm.ShowCustomerInfoForm(userAccount, _loginForm); this.Close(); }// End CREATE CUSTOMER button click event
private void btnAccept_Click(object sender, EventArgs e) { //Authenticate user userAccount = ApplicationObjects.AuthenticateUser(this.txtUserID.Text, this.txtOldPwd.Text); if (userAccount == null || userAccount.HighestPermission == null) { DialogResult result = MessageBox.Show("Failed to authenticate user.", "Authentication failed!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Hand); if (result == DialogResult.Retry) { return; } else { _loginForm.Logout(); this.Close(); return; } } //Verify the text boxes are not empty if (!(this.txtNewPwd.Text == String.Empty) && !(this.txtConfirmPwd.Text == String.Empty)) { //Validate new and confirmed passwords match if (String.Compare(this.txtNewPwd.Text, this.txtConfirmPwd.Text) != 0) { DialogResult result = MessageBox.Show("Your new and confirmed passwords did not match.", "Password mismatch", MessageBoxButtons.RetryCancel, MessageBoxIcon.Hand); if (result == DialogResult.Retry) { return; } else { _loginForm.Logout(); this.Close(); return; } } } else { DialogResult result = MessageBox.Show("Both new and confirmed password boxes must be populated.", "Invalid input!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Hand); if (result == DialogResult.Retry) { return; } else { _loginForm.Logout(); this.Close(); return; } } //Change password userAccount.PasswordHash = this.txtNewPwd.Text; ApplicationObjects.ChangePassword(userAccount); //Logout to re-authenticate MessageBox.Show("Password change complete. Please re-log in.", "Success!", MessageBoxButtons.OK, MessageBoxIcon.None); _loginForm.Logout(); this.Close(); }
private void btnSave_Click(object sender, EventArgs e) { //populate objects with UI data //ORDER OrderStatus orderStatus = (OrderStatus)Enum.Parse(typeof(OrderStatus), this.cboxOrderStatus.Text); order.OrderStatus = orderStatus; //CUSTOMER char[] delimiterChars = { ' ' }; string[] names = this.txtCustomer.Text.Split(delimiterChars); Address mailingAddress = new Address { StreetNumber = Convert.ToInt32(this.txtStreetNumber.Text), StreetName = this.txtStreetName.Text, AddressCity = this.txtCity.Text, AddressState = this.txtState.Text, AddressZip = this.txtZipcode.Text }; Address billingAddress = new Address { StreetNumber = Convert.ToInt32(this.txtBillingStreetNumber.Text), StreetName = this.txtBillingStreetName.Text, AddressCity = this.txtBillingCity.Text, AddressState = this.txtBillingState.Text, AddressZip = this.txtBillingZipcode.Text }; Customer customer = new Customer { CustomerId = Guid.NewGuid(), FirstName = names[0], LastName = names[1], PhoneNumber = this.txtPhoneNumber.Text, EmailAddress = this.txtEmail.Text, MailingAddress = mailingAddress, BillingAddress = billingAddress }; order.Person = (Person)customer; if (order != null && customer != null) { int returnValue = ApplicationObjects.CreateCustomer(customer); if (returnValue == 0) { returnValue = ApplicationObjects.CreateOrder(order); } ApplicationObjects.DisplayDataStatus(returnValue); if (returnValue == 0) { //Return to order list _loginForm.ShowOrdersForm(userAccount, _loginForm); this.Close(); } } }
public static List <ApplicationObjects> GetMenuData() { try { Database db = DatabaseFactory.CreateDatabase("MyCTSSecurityDB"); DbCommand dbCommand = db.GetSqlStringCommand(SQL_APPLICATIONOBJECTS); List <ApplicationObjects> applicationObjectsList = new List <ApplicationObjects>(); using (IDataReader reader = db.ExecuteReader(dbCommand)) { int _id = reader.GetOrdinal("ID"); int _text = reader.GetOrdinal("Text"); int _name = reader.GetOrdinal("Name"); int _eventname = reader.GetOrdinal("EventName"); int _roles = reader.GetOrdinal("Roles"); int _parentid = reader.GetOrdinal("ParentID"); int _shortcut = reader.GetOrdinal("ShortCut"); int _imagename = reader.GetOrdinal("ImageName"); int _checked = reader.GetOrdinal("checked"); while (reader.Read()) { ApplicationObjects item = new ApplicationObjects(); item.ID = reader.GetInt32(_id); item.Text = reader.GetString(_text); item.Name = DBNull.Value == reader[_roles] ? string.Empty : reader.GetString(_name); item.EventName = DBNull.Value == reader[_eventname] ? string.Empty : reader.GetString(_eventname); item.Roles = DBNull.Value == reader[_roles] ? string.Empty : reader.GetString(_roles); item.ParentID = reader.GetInt32(_parentid); item.ShortCut = DBNull.Value == reader[_shortcut] ? string.Empty : reader.GetString(_shortcut); item.ImageName = DBNull.Value == reader[_imagename] ? string.Empty : reader.GetString(_imagename); item.Checked = Convert.ToBoolean(reader[_checked]); applicationObjectsList.Add(item); } } return(applicationObjectsList); } catch { Database db = DatabaseFactory.CreateDatabase("MyCTSSecurityDB_Mirror"); DbCommand dbCommand = db.GetSqlStringCommand(SQL_APPLICATIONOBJECTS); List <ApplicationObjects> applicationObjectsList = new List <ApplicationObjects>(); using (IDataReader reader = db.ExecuteReader(dbCommand)) { int _id = reader.GetOrdinal("ID"); int _text = reader.GetOrdinal("Text"); int _name = reader.GetOrdinal("Name"); int _eventname = reader.GetOrdinal("EventName"); int _roles = reader.GetOrdinal("Roles"); int _parentid = reader.GetOrdinal("ParentID"); int _shortcut = reader.GetOrdinal("ShortCut"); int _imagename = reader.GetOrdinal("ImageName"); int _checked = reader.GetOrdinal("checked"); while (reader.Read()) { ApplicationObjects item = new ApplicationObjects(); item.ID = reader.GetInt32(_id); item.Text = reader.GetString(_text); item.Name = DBNull.Value == reader[_roles] ? string.Empty : reader.GetString(_name); item.EventName = DBNull.Value == reader[_eventname] ? string.Empty : reader.GetString(_eventname); item.Roles = DBNull.Value == reader[_roles] ? string.Empty : reader.GetString(_roles); item.ParentID = reader.GetInt32(_parentid); item.ShortCut = DBNull.Value == reader[_shortcut] ? string.Empty : reader.GetString(_shortcut); item.ImageName = DBNull.Value == reader[_imagename] ? string.Empty : reader.GetString(_imagename); item.Checked = Convert.ToBoolean(reader[_checked]); applicationObjectsList.Add(item); } } return(applicationObjectsList); } }
private void btn_SearchSubmit_Click(object sender, EventArgs e) { BusinessObjects _businessObjects = new BusinessObjects(); // Element reset to be performed each time, before a search is ran lbl_CatalogResultsFound.Text = null; // Clear contents of search result label cbx_CatalogResultsList.Items.Clear(); // Clear old search results from results combo box cbx_CatalogResultsList.Text = ""; // Clear text from visible combobox area rbx_CatalogSearchResults.Clear(); // Clear search results each time a new search is submitted catalogItemCollection = null; // Clear inventory items from list // Verify that a query type was selected by the user if (cbx_CatalogQueryType.SelectedItem == null) { MessageBox.Show("You forgot to select a query type. Please try again", "Invalid Query", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } // SEARCH BY MANUFACTURER NAME - Chech to see if user entered a Manufacturer Name else if (cbx_CatalogQueryType.SelectedItem.ToString() == "Manufacturer") { // Generate a list of Inventory Items that match the Manufacturer Name entered by the user catalogItemCollection = _businessObjects.GetCatalogItemByManufacturer(tbx_CatalogQueryInput.Text); } // SEARCH BY ITEM NAME - Check to see if user entered an Item Name else if (cbx_CatalogQueryType.SelectedItem.ToString() == "Item Name") { // Generate a list of Catalog Items that match the Item Name entered by the user catalogItemCollection = (catalogItemCollection == null) ? new List <CatalogItem>() : catalogItemCollection; catalogItemCollection.Add(_businessObjects.GetCatalogItemByItemName(tbx_CatalogQueryInput.Text)); } // SEARCH BY ITEM GUID - Check to see if user entered an ID Number else if (cbx_CatalogQueryType.SelectedItem.ToString() == "Catalog ID") { try { // Generate a list of Catalog Items that match the Item ID entered by the user catalogItemCollection = (catalogItemCollection == null) ? new List <CatalogItem>() : catalogItemCollection; catalogItemCollection.Add(ApplicationObjects.GetCatalogItemByCatalogItemId(new Guid(tbx_CatalogQueryInput.Text))); } catch (Exception) { // Catch if a non-Guid was entered MessageBox.Show("You entered an invalid ID. Please make sure that the ID contains 32 characters and 4 hyphens", "Invalid GUID", MessageBoxButtons.OK, MessageBoxIcon.Hand); rbx_CatalogSearchResults.AppendText("Input error - please try again"); return; } } // If nothing is populated into the searchDisplay box, we can assume that there were no search results else { lbl_CatalogResultsFound.Text = "No results found"; } // Populate label that displays how many results were found lbl_CatalogResultsFound.Text = (catalogItemCollection.Count.ToString() + " result(s) found!"); // This string list holds the results of an CatalogItem's ToItemDescription method, which actually // returns a list of individual line items, which each hold the item's attributes that will be // displayed on seperate lines of the text box List <string> itemDescriptions = (catalogItemCollection.Count > 0) ? catalogItemCollection.FirstOrDefault().ToItemDescription() : new List <string>(); foreach (string lineItem in itemDescriptions) { // Add each description line item to the text box rbx_CatalogSearchResults.AppendText(lineItem + Environment.NewLine); } // Populate the search result combobox with the Catalog Id numbers of the search results foreach (CatalogItem catalogItem in catalogItemCollection) { cbx_CatalogResultsList.Items.Add(catalogItem.CatalogItemId.ToString()); } // Set the combobox to show the catalog number of the first search record if (cbx_CatalogResultsList.Items.Count > 0) { cbx_CatalogResultsList.SelectedIndex = 0; } }