Esempio n. 1
0
        public static void RemoveInventoryItemFromInventory(InventoryItem item)
        {
            BusinessObjects _businessObjects = new BusinessObjects();
            int             returnValue;

            returnValue = _businessObjects.DeleteInventoryItem(item);
            DisplayDataStatus(returnValue);
            if (returnValue == 0)
            {
                int             notificationReturnValue;
                BusinessObjects _notificationBusinessObject = new BusinessObjects();
                Notification    notification = new Notification();
                notification.OrderId             = item.OrderId;
                notification.NotificationId      = Guid.NewGuid();
                notification.NotificationMessage = ("Inventory item is en route : " +
                                                    item.InventoryItemId.ToString());
                notification.NotificationType = BusinessLayer.Enumerations.NotificationType.EnRoute;
                notification.IsRead           = false;
                notification.PermissionScope  = BusinessLayer.Enumerations.Permission.Manager;

                // INSERT notification to database
                notificationReturnValue = _notificationBusinessObject.InsertNotification(notification);

                if (notificationReturnValue == 0)
                {
                    MessageBox.Show("A notification has been sent to the Work specialist", "Item Sent to Work Specialist", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (notificationReturnValue == 1)
                {
                    MessageBox.Show("There was a problem sending a notification to the Work Specialist - please notify them manually that the item is on the way", "Item Sent to Work Specialist", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Esempio n. 2
0
        public static int NewNotification(Notification notification)
        {
            BusinessObjects _businessObjects = new BusinessObjects();
            int             returnValue      = _businessObjects.InsertNotification(notification);

            return(returnValue);
        }
        // INVENTORY REQUEST submit button click event
        private void btn_InventoryRequest_Click(object sender, EventArgs e)
        {
            // Verify all fields are NOT null
            if ((tbx_CatalogId.Text != null) && (tbx_Quantity.Text != null))
            {
                try
                {
                    DateTime        time     = DateTime.Now;                       // Variable to be included in notification message
                    int             quantity = Convert.ToInt32(tbx_Quantity.Text); // validate INT input from user
                    int             notificationReturnValue;                       // Variable to hold return value from database insert
                    BusinessObjects _businessObject = new BusinessObjects();

                    // Get the catalog information for the item that needs to be ordered.  Some of the catalog item info
                    // will be populated into the notification message string
                    CatalogItem catalogItem = _businessObject.GetCatalogItemByCatalogItemId(new Guid(tbx_CatalogId.Text));

                    // Populate notification fields manually
                    Notification notification = new Notification();
                    notification.OrderId             = new Guid(tbx_OrderId.Text);
                    notification.NotificationId      = Guid.NewGuid();
                    notification.NotificationMessage = ("Please order inventory item --> Item Name: " +
                                                        catalogItem.ItemName.ToString() + ",  Manufacturer Name: " + catalogItem.Manufacturer.ToString() +
                                                        ",  Date: " + time.ToString() + ",  Quantity: " + quantity.ToString()) + ", Catalog ID: " +
                                                       catalogItem.CatalogItemId.ToString();
                    notification.NotificationType = NotificationType.RestockItem;
                    notification.IsRead           = false;
                    notification.PermissionScope  = Permission.StockClerk;

                    // Insert notification into database table
                    notificationReturnValue = _businessObject.InsertNotification(notification);

                    if (notificationReturnValue == 0)
                    {
                        // Database insert success message
                        MessageBox.Show("Your stock request was sent successfully.", "Stock Request",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                        tbx_OrderId.Clear();
                        tbx_CatalogId.Clear();
                        tbx_Quantity.Clear();
                    }
                    else
                    {
                        // Database insert failure message
                        MessageBox.Show("Your stock request failed.  Please try again", "Stock Request",
                                        MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        return;
                    }
                }
                catch (Exception)
                {
                    // Failure message
                    MessageBox.Show("Your stock request failed.  Please make sure that you filled out all request fields with appropriate information", "Stock Request",
                                    MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
            }

            else
            {
                // Error message due to empty fields in stock request form
                MessageBox.Show("Your stock request is not complete.  Please fill out all fields try again", "Stock Request",
                                MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }
        // MARK AS SOLD submit button click event
        private void btn_SubmitRequest_Click(object sender, EventArgs e)
        {
            int             updateReturnValue;
            int             notificationReturnValue;
            BusinessObjects _businessObjects = new BusinessObjects();

            // Verify that user enterd an order Id, and that they had an inventory item selected in the search result combobox
            if ((tbx_OrderSold.Text == null) || (cbx_ResultsList.SelectedItem == null))
            {
                MessageBox.Show("Invalid input.  Please make sure you have selected an inventory item & entered an Order ID and try again", "Invalid Stock Request",
                                MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }
            // Verify that the item that has been selected is not already marked as SOLD
            else if (inventoryItems[cbx_ResultsList.SelectedIndex].InventoryItemStatus != InventoryItemStatus.Stock)
            {
                MessageBox.Show("You have selected an inventory item that is not in stock.  Please try again", "Invalid Item Status",
                                MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }

            // If user input appears to be valid, continue
            else
            {
                try
                {
                    // Try to convert user input to a Guid
                    Order order = _businessObjects.GetOrder(new Guid(tbx_OrderSold.Text.ToString()));

                    // Verify that an Order was found
                    if (order == null)
                    {
                        MessageBox.Show("We were unable to find an order with the ID that you entered.  Please try again", "No Order Found",
                                        MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        return;
                    }

                    // Add order ID to inventory item
                    InventoryItem inventoryItem = inventoryItems[cbx_ResultsList.SelectedIndex];
                    inventoryItem.OrderId = order.OrderId;

                    // Change inventory item status to SOLD
                    inventoryItem.InventoryItemStatus = InventoryItemStatus.Sold;

                    //Update inventory and populate result value variable
                    updateReturnValue = _businessObjects.UpdateInventoryItem(inventoryItem);

                    // Display message based on success or failue of database update
                    if (updateReturnValue == 0)
                    {
                        BusinessObjects _notificationBusinessObject = new BusinessObjects();
                        // Populate notification fields manually
                        Notification notification = new Notification();
                        notification.OrderId             = order.OrderId;
                        notification.NotificationId      = Guid.NewGuid();
                        notification.NotificationMessage = ("Please pull inventory item : " +
                                                            inventoryItem.InventoryItemId.ToString());
                        notification.NotificationType = NotificationType.MediaPull;
                        notification.IsRead           = false;
                        notification.PermissionScope  = Permission.StockClerk;

                        // Insert notification into database table
                        notificationReturnValue = _notificationBusinessObject.InsertNotification(notification);

                        // Database insert success message
                        MessageBox.Show("Your inventory update request was successful.", "Inventory Update",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        // Database insert failure message
                        MessageBox.Show("Your inventory update request has failed, Please try again.", "Inventory Update",
                                        MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }

                    // After transaction is complete, re-run original search and refresh search results.
                    btn_SearchSubmit.PerformClick();
                    tbx_OrderSold.Text = "";
                }

                // Show error if user didn't enter an INT
                catch (Exception)
                {
                    MessageBox.Show("You entered an invalid order ID.  Please try again", "Invalid Number",
                                    MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return;
                }
            }
        }
Esempio n. 5
0
        // ORDER METHODS
        public static int UpdateOrderStatusWithNotification(Order order, Enumeration.Permission senderPermissionScope)
        {
            int returnValue = 1;

            BusinessObjects _businessObjects = new BusinessObjects();

            returnValue = _businessObjects.UpdateOrder(order);

            if (returnValue == 1)
            {
                return(returnValue);
            }

            Notification notification = new Notification
            {
                NotificationId = Guid.NewGuid(),
                IsRead         = false,
                OrderId        = order.OrderId
            };

            string message = "";

            switch (order.OrderStatus)
            {
            case Enumeration.OrderStatus.WorkComplete:
                message = "Order ID: " + order.OrderId.ToString() + " - STATUS CHANGE = Work Complete";
                notification.NotificationMessage = message;
                notification.NotificationType    = Enumeration.NotificationType.WorkComplete;
                notification.PermissionScope     = Enumeration.Permission.Manager;
                returnValue = _businessObjects.InsertNotification(notification);
                break;

            case Enumeration.OrderStatus.EnRoute:
                message = "Order ID: " + order.OrderId.ToString() + " - STATUS CHANGE = En Route";
                notification.NotificationMessage = message;
                notification.NotificationType    = Enumeration.NotificationType.EnRoute;
                notification.PermissionScope     = Enumeration.Permission.Manager;
                returnValue = _businessObjects.InsertNotification(notification);
                break;

            case Enumeration.OrderStatus.Delivered:
                if (senderPermissionScope == Enumeration.Permission.Customer)
                {
                    message = "Order ID: " + order.OrderId.ToString() + " - STATUS CHANGE = Delivered";
                    notification.NotificationMessage = message;
                    notification.NotificationType    = Enumeration.NotificationType.Delivered;
                    notification.PermissionScope     = Enumeration.Permission.Manager;
                    returnValue = _businessObjects.InsertNotification(notification);
                }
                else if (senderPermissionScope == Enumeration.Permission.Manager)
                {
                    message = "Order ID: " + order.OrderId.ToString() + " - STATUS CHANGE = Delivered";
                    notification.NotificationMessage = message;
                    notification.NotificationType    = Enumeration.NotificationType.Delivered;
                    notification.PermissionScope     = Enumeration.Permission.Manager;
                    returnValue = _businessObjects.InsertNotification(notification);
                }
                break;

            case Enumeration.OrderStatus.Complete:
                message = "Order ID: " + order.OrderId.ToString() + " - STATUS CHANGE = Order Complete";
                notification.NotificationMessage = message;
                notification.NotificationType    = Enumeration.NotificationType.OrderComplete;
                notification.PermissionScope     = Enumeration.Permission.Customer;
                returnValue = _businessObjects.InsertNotification(notification);
                break;

            case Enumeration.OrderStatus.FailedValidation:
                message = "Order ID: " + order.OrderId.ToString() + " - STATUS CHANGE = Failed Validation";
                notification.NotificationMessage = message;
                notification.NotificationType    = Enumeration.NotificationType.FailedQualityControl;
                notification.PermissionScope     = Enumeration.Permission.Manager;
                returnValue = _businessObjects.InsertNotification(notification);
                break;
            }

            return(returnValue);
        }
Esempio n. 6
0
        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);
                    }
                }
            }
        }