📄 picking.cs
字号:
try
{
//prepare user for a wait
Cursor.Current = Cursors.WaitCursor;
//Update the Orders table to reflect a new Order State of Picked (2)
DisplayStatus(Resources.UpdateOrderMsg, 0);
UpdateOrder();
Application.DoEvents();
localDBUpdated = true;
//check if we have network connectivity
DisplayStatus(Resources.CheckNetworkMessage, 0);
bool networkAvailable = Business.Services.GetConnectionStatus();
Application.DoEvents();
//try to sync only if network is available
if (networkAvailable)
{
//Test to see if Replication URL is reachable
DisplayStatus(Resources.checkIisMessage, 0); ;
bool replicationAvailable = Business.Services.CheckSynchronizationUrl();
Application.DoEvents();
if (replicationAvailable)
{
//send changes down to server DB
DisplayStatus(Resources.SyncDbMessage, 0);
Application.DoEvents();
Synchronize();
Application.DoEvents();
//send notification to next role in workflow
DisplayStatus(Resources.SendingNotificationMessage, 0);
Application.DoEvents();
SendNotification();
Application.DoEvents();
}
else
{
//Replication URL isn't reachable
DisplayStatus(Resources.IisUnavailableMessage, 1000);
}
}
else
{
DisplayStatus(Resources.NetworkUnavailableMessage, 1000);
}
}
catch (Utilities.WrapperException wex)
{
Cursor.Current = Cursors.Default;
//log and display error
Business.Services.LogErrors(wex.InnerException);
MessageBox.Show(wex.UserDisplayMessage, Resources.SystemError);
}
catch (Exception ex)
{
Cursor.Current = Cursors.Default;
Business.Services.LogErrors(ex);
MessageBox.Show(ex.Message, Resources.SystemError);
}
finally
{
Cursor.Current = Cursors.Default;
ClearStatus();
if (localDBUpdated)
this.Close();
}
}
/// <summary>
/// Synchronizes local db with server DB
/// </summary>
private void Synchronize()
{
try
{
Business.Services.SyncWithDataSource();
}
catch (Exception ex)
{
throw new Utilities.WrapperException(Resources.SyncDbError, ex);
}
}
/// <summary>
/// sends notification to the warehouse role that the order has been placed
/// </summary>
private void SendNotification()
{
try
{
Business.Services.SendNotification("Warehouse");
}
catch (Exception ex)
{
throw new Utilities.WrapperException(Resources.NotificationError, ex);
}
}
/// <summary>
/// update the state of the order to picked
/// </summary>
private void UpdateOrder()
{
try
{
Order order = Business.Services.GetOrder(_orderId);
//update state to picked
order.OrderState = OrderState.Picked;
Business.Services.SaveOrder(order);
//reflect change in inventory items quantity
ListView.ListViewItemCollection items = _staged.Items;
foreach (ListViewItem item in items)
{
int inStock = int.Parse(item.SubItems[2].Text);
int inventoryId = int.Parse(item.SubItems[3].Text);
Business.Services.UpdateInStockAmount(inventoryId, inStock);
}
}
catch (Exception ex)
{
throw new Utilities.WrapperException(Resources.UpdateOrderError, ex);
}
}
/// <summary>
/// indicates if all the inventory items for the order have been staged
/// </summary>
/// <returns></returns>
private bool CheckAllItemsStaged()
{
return pickedItemsListView.Items.Count == 0 && _staged.Count > 0;
}
/// <summary>
/// displays the stages item list
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItemShowStaged_Click(object sender, EventArgs e)
{
_staged.Show();
}
/// <summary>
/// Launch Help
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void linkLabelHelp_Click(object sender, EventArgs e)
{
ShowHelpScreen();
}
private void ShowHelpScreen()
{
try
{
//Show Picking Help
OnlineHelper myHelp = new OnlineHelper(HELP_FILE);
myHelp.ShowDialog();
//Free the resources of the help form
myHelp.Dispose();
//bring back focus
this.Activate();
}
catch (Exception ex)
{
Business.Services.LogErrors(ex);
MessageBox.Show(Resources.HelpDisplayError, Resources.SystemError);
}
}
/// <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 pickedItemsListView_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Up &&
(pickedItemsListView.Items.Count == 0 ||
(pickedItemsListView.SelectedIndices.Count > 0 && pickedItemsListView.SelectedIndices[0] == 0)))
{
e.Handled = true;
this.SelectNextControl(pickedItemsListView, false, true, false, true);
}
else if (e.KeyCode == Keys.Down &&
(pickedItemsListView.Items.Count == 0 ||
(pickedItemsListView.SelectedIndices.Count > 0 &&
(pickedItemsListView.SelectedIndices[0] == (pickedItemsListView.Items.Count - 1)))))
{
e.Handled = true;
this.SelectNextControl(pickedItemsListView, true, true, false, true);
}
}
// <summary>
/// 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.Close();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -