📄 loading.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using HardwareDistributor.Business;
using HardwareDistributor.Controls;
using HardwareDistributor.Properties;
using HardwareDistributor.Synchronization;
using Microsoft.VisualBasic;
namespace HardwareDistributor.UI
{
/// <summary>
/// UI layer that displays staged items to load
/// </summary>
public partial class Loading : Form
{
#region Members
Guid _orderId;
Loaded _loadedItemsForm;
GradientHeaders header;
#endregion
#region Constructors
/// <summary>
/// Pass in OrderId to constructor
/// </summary>
/// <param name="orderId"></param>
public Loading(Guid orderId)
{
InitializeComponent();
this._orderId = orderId;
_loadedItemsForm = new Loaded();
// Need to adjust the column width, so that we automatically adjust to different screen
// sizes and orientations.
this.columnHeaderHardware.Width = this.ItemsToLoadListView.Width - this.columnHeaderQty.Width - 4;
// 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();
}
#endregion
#region EventHandlers
/// <summary>
/// Cancel the Loading operation
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItemCancel_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
/// <summary>
/// View Items Loaded Clicked
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItemShowLoaded_Click(object sender, EventArgs e)
{
// Show the items loaded
_loadedItemsForm.Show();
}
/// <summary>
/// Handle the key down event for the listview, so that we can set focus to the next control
/// when we hit the first or last item in the list.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ItemsToLoadListView_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Up &&
(ItemsToLoadListView.Items.Count == 0 ||
(ItemsToLoadListView.SelectedIndices.Count > 0 && ItemsToLoadListView.SelectedIndices[0] == 0)))
{
e.Handled = true;
this.SelectNextControl(ItemsToLoadListView, false, true, false, true);
}
else if (e.KeyCode == Keys.Down &&
(ItemsToLoadListView.Items.Count == 0 ||
(ItemsToLoadListView.SelectedIndices.Count > 0 &&
(ItemsToLoadListView.SelectedIndices[0] == (ItemsToLoadListView.Items.Count - 1)))))
{
e.Handled = true;
this.SelectNextControl(ItemsToLoadListView, true, true, false, true);
}
}
/// <summary>
/// Launch Help
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void linkLabelHelp_Click(object sender, EventArgs e)
{
ShowHelpScreen();
}
/// Custom Handling for the back key
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BackKeyDown(object sender, KeyEventArgs e)
{
if ((e.KeyCode == System.Windows.Forms.Keys.Back))
{
// Back
// if the back key is hit, close this dialog
this.DialogResult = DialogResult.Cancel;
this.Close();
}
}
/// <summary>
/// Load the form
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Loading_Load(object sender, EventArgs e)
{
try
{
SetTruckInfo();
RefreshItemsToLoadList();
}
catch (Exception ex)
{
Business.Services.LogErrors(ex);
MessageBox.Show(Resources.InventoryDisplayError, Resources.SystemError);
}
}
/// <summary>
/// Add staged items to the loaded items listview
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItemLoad_Click(object sender, EventArgs e)
{
try
{
//Retrieve a collection of items from the list view control
ListView.ListViewItemCollection selectedItems = ItemsToLoadListView.Items;
//Iterate through the collection
foreach (ListViewItem item in selectedItems)
{
//Determine of item is selected
if (item.Selected)
{
int _quantity = int.Parse(item.SubItems[0].Text);
string _hardwareName = item.SubItems[1].Text;
int _inventoryId = int.Parse(item.SubItems[2].Text);
//Add item to Loaded Items List View
_loadedItemsForm.Add(_quantity, _hardwareName, _inventoryId);
//Remove item from list
ItemsToLoadListView.Items.Remove(item);
break;
}
}
}
catch (Exception ex)
{
Business.Services.LogErrors(ex);
MessageBox.Show(Resources.LoadingHardwareError, Resources.SystemError);
}
}
/// <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
labelStatusBar.Visible = true;
labelStatusBar.Text = statusText;
Application.DoEvents();
System.Threading.Thread.Sleep(timeout);
Application.DoEvents();
}
/// <summary>
/// clear the status of the form.
/// </summary>
private void ClearStatus()
{
labelStatusBar.Text = string.Empty;
labelStatusBar.Visible = false;
}
/// <summary>
/// Load Truck clicked
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItemFinish_Click(object sender, EventArgs e)
{
bool localDBUpdated = false;
//ensure all items for the order have been loaded
if (!AllItemsLoaded())
{
MessageBox.Show(Resources.LoadAllStagedMessage, Resources.LoadingError);
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -