// 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);
            }
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        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();
        }
Esempio n. 4
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);
                    }
                }
            }
        }