📄 warehouse.cs
字号:
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace HardwareDistributor.UI
{
/// <summary>
/// UI layer form that displays order to pick and load
/// </summary>
public partial class Warehouse : Form
{
public Warehouse()
{
InitializeComponent();
}
/// <summary>
/// Cancel operation
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItemExit_Click(object sender, EventArgs e)
{
//Close form
this.Close();
}
/// <summary>
/// Replicate with SQL Server 2005
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItemSync_Click(object sender, EventArgs e)
{
Application.DoEvents();
Cursor.Current = Cursors.WaitCursor;
Application.DoEvents();
try
{
//Test to see if Network is available
Application.DoEvents();
statusBar1.Text = "Checking network connectivity...";
Application.DoEvents();
if (Business.Services.GetConnectionStatus())
{
//Test to see if Replication URL is reachable
Application.DoEvents();
statusBar1.Text = "Testing IIS server...";
Application.DoEvents();
if (Business.Services.CheckReplicationUrl())
{
//Log Application and Device Metrics
Business.Services.LogAppState();
//Synchronize database changes
Application.DoEvents();
statusBar1.Text = "Synchronizing database...";
Application.DoEvents();
Business.Services.SyncWithDataSource();
FillListView();
}
else
{
//Replication URL isn't reachable
Application.DoEvents();
statusBar1.Text = "IIS server isn't available...";
Application.DoEvents();
System.Threading.Thread.Sleep(1000);
}
}
else
{
//Network isn't available
Application.DoEvents();
statusBar1.Text = "Network isn't available...";
Application.DoEvents();
System.Threading.Thread.Sleep(1000);
}
}
catch (Exception ex)
{
Business.Services.LogErrors(ex);
MessageBox.Show("Error synchronizing database", "System Error");
}
Application.DoEvents();
statusBar1.Text = "";
Cursor.Current = Cursors.Default;
Application.DoEvents();
}
/// <summary>
/// Fill Orders to Pick listview and
/// Order to Load combo box
/// </summary>
private void FillListView()
{
//Retrieve OrderCollection of Orders to Pick
Business.OrderCollection _orders = Business.Services.GetOrders(true, Business.OrderState.Placed);
//Retrieve OrderCollection of Orders to Load
Business.OrderCollection _pickedOrders = Business.Services.GetOrders(false, Business.OrderState.Picked);
//Databind Orders to Load to combo box
cboPicked.DisplayMember = "OrderId";
cboPicked.ValueMember = "OrderId";
cboPicked.DataSource = _pickedOrders;
//Fill listview with Orders to Load
listView1.Items.Clear();
//Iterate through OrderCollection
foreach (Business.Order orderItem in _orders)
{
//Add OrderId
ListViewItem lvi = new ListViewItem(orderItem.OrderId.ToString());
//Add CustomerId
lvi.SubItems.Add(orderItem.CustomerName);
//Add Delivery Date
lvi.SubItems.Add(orderItem.DeliveryDate.ToShortDateString());
//Add Order State
lvi.SubItems.Add(orderItem.OrderState);
//Add ListView Items to ListView
listView1.Items.Add(lvi);
}
}
/// <summary>
/// Loads Warehouse form
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Warehouse_Load(object sender, EventArgs e)
{
try
{
//Fill the listview and combo box controls
FillListView();
}
catch (Exception ex)
{
Business.Services.LogErrors(ex);
MessageBox.Show("Error displaying orders", "System Error");
}
}
/// <summary>
/// Check an Order to Pick
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItemPick_Click(object sender, EventArgs e)
{
try
{
//Retrieve a collection of items from the list view control
ListView.ListViewItemCollection checkedItems = listView1.Items;
//Iterate through the collection
foreach (ListViewItem item in checkedItems)
{
//Determine of item is checked
if (item.Checked)
{
//Get OrderId and pass to Picking Screen
int _orderId = int.Parse(item.SubItems[0].Text);
Picking picking = new Picking(_orderId);
picking.ShowDialog();
//Refill listview and combo box when
//Picking screen is closed
FillListView();
//Release Picking screen's resources
picking.Dispose();
break;
}
}
}
catch (Exception ex)
{
Business.Services.LogErrors(ex);
MessageBox.Show("Error loading Picking screen", "System Error");
}
}
/// <summary>
/// Launches the Loading screen
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItemLoad_Click(object sender, EventArgs e)
{
try
{
//Ensure combo box isn't empty
if (cboPicked.Items.Count > 0)
{
//Get OrderId from combo selection
int _orderId = (int)cboPicked.SelectedValue;
//Load the Loading screen and pass in the OrderId
Loading loading = new Loading(_orderId);
loading.ShowDialog();
//Refill listview and combo box when
//Loading screen is closed
FillListView();
//Release Loading screen's resources
loading.Dispose();
}
}
catch (Exception ex)
{
Business.Services.LogErrors(ex);
MessageBox.Show("Error launching the Loading screen", "System Error");
}
}
/// <summary>
/// Launch Help
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void linkLabelHelp_Click_1(object sender, EventArgs e)
{
try
{
//Show Warehouse Help
Help.ShowHelp(this, @Business.GlobalCache.Instance.AppPath + "HardwareHelp.htm#warehouse");
}
catch (Exception ex)
{
Business.Services.LogErrors(ex);
MessageBox.Show("Error displaying Help", "System Error");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -