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(); }
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(); }
// 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 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); } }
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); } } } }