⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 picking.cs

📁 微软的行业应用解决方案示例
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

using HardwareDistributor.Business;
using HardwareDistributor.Properties;
using HardwareDistributor.Controls;
using HardwareDistributor.Synchronization;

namespace HardwareDistributor.UI
{
    /// <summary>
    /// UI layer form that facilitate the picking of items
    /// </summary>
    public partial class Picking : Form
    {
        private Guid _orderId;
        private StagedItems _staged = null;
        private GradientHeaders header;
        private const string HELP_FILE = "Picking";

        /// <summary>
        /// The OrderId is passed into the constructor
        /// </summary>
        /// <param name="orderId"></param>
        public Picking(Guid orderId)
        {
            InitializeComponent();

            this._orderId = orderId;
            _staged = new StagedItems();

            // Need to adjust the column width, so that we automatically adjust to different screen
            // sizes and orientations.
            this.columnHeaderHardware.Width = this.pickedItemsListView.Width - this.columnHeaderStock.Width - this.columnHeaderQty.Width - 6;

            // We are removing both the Control Box and the Minimize Box, so that we don't
            // have to handle these in our code. This is not necessary in Windows Mobile Standard,
            // but we are writing this code so that it works on all platforms without any changes
            // or any recompiling.
            this.ControlBox = false;
            this.MinimizeBox = false;

            AttachHeader();
        }

        private void AttachHeader()
        {
            // Create instance of the gradient header
            header = new HardwareDistributor.Controls.GradientHeaders();
            // Attach it to the listview
            header.Attach(ref pickedItemsListView);
            this.Controls.Add(header);
        }


        /// <summary>
        /// Cancels picking operation
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuItemCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }


        /// <summary>
        /// Load the picking form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Picking_Load(object sender, EventArgs e)
        {
            RefreshPickedItemsList();

        }

        private void RefreshPickedItemsList()
        {
            try
            {
                //Retrieve order details
                List<OrderDetail> orderDetailsList = Services.GetOrderDetails(_orderId);

                //add each order detail into the list
                foreach (OrderDetail orderDetailsItem in orderDetailsList)
                {
                    //Add Quantity
                    ListViewItem lvi = new ListViewItem(orderDetailsItem.Quantity.ToString());

                    //Add Hardware Name
                    lvi.SubItems.Add(orderDetailsItem.Inventory.InventoryName.Trim());

                    //Add In Stock Amount
                    lvi.SubItems.Add(orderDetailsItem.Inventory.InStock.ToString());

                    //Add Bin Location
                    lvi.SubItems.Add("Bin #: " + orderDetailsItem.Inventory.Bin.ToString());

                    //Add Inventory Id
                    lvi.SubItems.Add(orderDetailsItem.InventoryId.ToString());

                    //Add ListView Items to ListView
                    pickedItemsListView.Items.Add(lvi);
                }
            }
            catch (Exception ex)
            {
                Business.Services.LogErrors(ex);
                MessageBox.Show(Resources.PickInventoryItemDisplayError, Resources.SystemError);
            }
        }

        /// <summary>
        /// Sagte Item Menu Item Clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuItemStage_Click(object sender, EventArgs e)
        {
            try
            {
                ListViewItem selectedItem = GetSelectedItemToStage();

                if (null != selectedItem)
                {
                    MoveToStagedItemsList(selectedItem);
                }

            }
            catch (Exception ex)
            {
                Business.Services.LogErrors(ex);
                MessageBox.Show(Resources.PickHardwareItemDisplayError, Resources.SystemError);
            }
        }

        /// <summary>
        /// update quantity of item and move to staged item list from picked item list
        /// </summary>
        /// <param name="selectedItem"></param>
        private void MoveToStagedItemsList(ListViewItem selectedItem)
        {
            int _quantity = int.Parse(selectedItem.SubItems[0].Text);
            string _hardwareName = selectedItem.SubItems[1].Text;
            int _inStock = int.Parse(selectedItem.SubItems[2].Text);
            int _inventoryId = int.Parse(selectedItem.SubItems[4].Text);

            //Update In Stock Amount
            int _newInStock = _inStock - _quantity;

            //Add item to Staged Items List View                        
            _staged.Add(_quantity, _hardwareName, _newInStock, _inventoryId);

            //Remove item from picked list
            pickedItemsListView.Items.Remove(selectedItem);

        }

        /// <summary>
        /// return the selected item to stage
        /// </summary>
        /// <returns></returns>
        private ListViewItem GetSelectedItemToStage()
        {
            ListViewItem selectedItem = null;
            //Retrieve a collection of items from the list view control
            ListView.ListViewItemCollection selectedItems = pickedItemsListView.Items;
            //Iterate through the collection
            foreach (ListViewItem item in selectedItems)
            {
                //Determine of item is selected
                if (item.Selected)
                {
                    selectedItem = item;
                    break;
                }
            }

            return selectedItem;
        }

        private void ShowNotification()
        {
			HtmlFormEx notificationsForm = new HtmlFormEx(Resources.Picking,
                        Resources.PickedOrder,
                        Resources.SyncAfterPickMessage,
                                                    string.Empty);
			notificationsForm.ShowDialog();
			notificationsForm.Dispose();

            //bring back focus
            this.Activate();
        }

        /// <summary>
        /// Display status in form. Wait for the specified timeout so that the user can see the message
        /// before returning
        /// </summary>
        /// <param name="statusText"></param>
        /// <param name="timeout"></param>
        private void DisplayStatus(string statusText, int timeout)
        {
            //Network isn't available
            statusBarLabel.Visible = true;
            statusBarLabel.Text = statusText;

            Application.DoEvents();
            System.Threading.Thread.Sleep(timeout);
            Application.DoEvents();

        }

        /// <summary>
        /// clear the status of the form.
        /// </summary>
        private void ClearStatus()
        {
            statusBarLabel.Text = string.Empty;
            statusBarLabel.Visible = false;
        }

        /// <summary>
        /// This menu completes the picking operation
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuItemFinish_Click(object sender, EventArgs e)
        {
            bool localDBUpdated = false;
            //ensure all picked items have beend staged
            if (!CheckAllItemsStaged())
            {
                MessageBox.Show(Resources.StageAllPickedMessage, Resources.PickingError);
                return;
            }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -