📄 formibuyspy.cs
字号:
}
/// The Orders control is updated in case the Status field is changed in the Customers control.
///
else
{
this.orders.UpdateControls();
}
}
else if (sender is Inventory)
{
/// If the user adds more items through the Inventory control, the subtotal and total values on
/// the Orders control must be updated.
///
this.orders.UpdateSubTotal();
this.orders.UpdateTotal();
}
else if (sender is Signature)
{
/// The Orders control is updated in case the Status field is changed in the Signature control.
///
this.orders.UpdateControls();
}
/// Make the Orders control visible initially.
///
orders.BringToFront();
orders.Visible = true;
}
/// This method displays the Inventory control. If the control does not exist, this method first creates
/// a new instance of the Inventory control before displaying it.
///
private void ViewInventory(object sender, InventoryEventArgs e)
{
///
/// Inventory
///
if (null == inventory)
{
this.inventory = new Inventory(this);
this.Controls.Add(this.inventory);
this.inventory.OnViewOrders += new ViewOrdersEventHandler(ViewOrders);
this.inventory.OrderID = e.OrderID;
if (!this.inventory.InitInventory())
{
return;
}
}
/// The Inventory control must be reinitialized if the database is deleted (by clicking Reset from
/// the Configuration control) or if the inventory is changed (by changing the status of an order).
/// Products are categorized as inventory if they belong to an order that has a Status of "Failed".
/// "Pending" and "Completed" orders are NOT categorized as inventory.
///
else if (!dataIBuySpy.HasInventoryDataTable() || dataIBuySpy.InventoryChanged)
{
this.inventory.OrderID = e.OrderID;
if (!this.inventory.InitInventory())
{
return;
}
}
/// Users can navigate to the Inventory control from the menu and
/// from the Orders control. The buttons on the Inventory control must be enabled or disabled
/// depending on how the user navigates to the control. If the user navigates to the Inventory control
/// using the menu option, there is no OrderID associated with the user; therefore, they
/// cannot add products (because there is no order to which they can be added). So the buttons on the
/// Inventory control must be disabled.
///
/// If the user arrives at the Inventory control from the Orders control, there is an OrderID associated
/// with the user, and they will be allowed to add available inventory; therefore, the buttons on the
/// Inventory control are enabled. Products added to an order are no longer available to be added to other
/// orders, so the values on the Inventory control must be updated.
///
else
{
this.inventory.OrderID = e.OrderID;
if (!this.inventory.RefreshInventory())
{
return;
}
}
/// Make the Configuration control visible initially.
///
this.inventory.BringToFront();
this.inventory.Visible = true;
}
/// This method displays the Signature control. If the control does not exist, this method first creates
/// a new instance of the Signature control before displaying it.
///
private void ViewSignature(object sender, SignatureEventArgs e)
{
///
/// Signature
///
if (null == signature)
{
this.signature = new Signature();
this.Controls.Add(this.signature);
this.signature.OnViewCustomers += new ViewCustomerEventHandler(this.ViewCustomers);
this.signature.OnViewOrders += new ViewOrdersEventHandler(this.ViewOrders);
}
///
/// Make Signature Control Visible initially.
///
this.signature.OrderID = e.OrderID;
this.signature.Status = e.Status;
this.signature.LoadSignature();
this.signature.BringToFront();
this.signature.Visible = true;
}
/// This method updates the Driver ID label. The DriverID value can be changed from the Configuration
/// control.
///
internal void UpdateDriver(int driverID)
{
if (-1 == driverID)
{
this.lblDriver.Hide();
this.lblDriverID.Hide();
}
else
{
this.lblDriverID.Text = driverID.ToString();
this.lblDriver.Show();
this.lblDriverID.Show();
}
this.Update();
}
/// This method updates the menu options (Delivery and Tools) and Begin button. All menu options
/// (other than Exit) and the Begin button must be disabled until synchronization has been
/// completed (that is, a local SSCE database has been created).
///
internal void UpdateForm(bool init)
{
if (init)
{
this.itemDelivery.Enabled = false;
this.itemTools.Enabled = false;
this.btnStart.Enabled = false;
UpdateDriver(-1);
}
else
{
this.itemDelivery.Enabled = true;
this.itemTools.Enabled = true;
this.btnStart.Enabled = true;
UpdateDriver(this.dataIBuySpy.DriverID);
}
this.Update();
}
/// This method exits the application. If the user modified an order, all changes are
/// discarded. All order modifications are made in memory; the order is persisted to the database only after it has been signed for
/// on the Signature control.
///
private void Exit()
{
if (dataIBuySpy.HasChanges())
{
if (DialogResult.OK != MessageBox.Show(String.Format("You have modified an order. Exiting will discard all changes."),
"IBuySpy Delivery",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Asterisk,
MessageBoxDefaultButton.Button1))
{
return;
}
}
if (ConnectionState.Open == this.dataIBuySpy.IBuySpyConnection.State)
{
this.dataIBuySpy.IBuySpyConnection.Close();
}
this.Close();
Application.Exit();
}
/// This method begins the preferred click through path for the application. The preferred path starts
/// on the Customers control and goes to the Orders control, the Inventory control, and finally
/// the Signature control. If the user has already made changes to the current order, clicking Begin
/// discards all changes.
///
private void btnStart_Click(object sender, System.EventArgs e)
{
if (this.dataIBuySpy.HasChanges())
{
if (DialogResult.OK != MessageBox.Show("You have modified the current order. Continuing will discard all changes.",
"IBuySpy Delivery",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Asterisk,
MessageBoxDefaultButton.Button1))
{
return;
}
try
{
this.dataIBuySpy.ResetOrderDetails();
}
catch(SqlCeException err)
{
IBuySpyData.ShowErrors(err);
return;
}
catch(Exception err)
{
MessageBox.Show("Begin: " + err.Message, "IBuySpy Delivery");
return;
}
}
ViewCustomers(this, new EventArgs());
}
/// Clicking the Delivery->Customers menu option.
///
private void itemCustomers_Click(object sender, System.EventArgs e)
{
ViewCustomers(this, new EventArgs());
}
/// Clicking the Delivery->Inventory menu option. An OrderID of -1 is passed in to designate that no
/// order has been assigned to the user at this time.
///
private void itemInventory_Click(object sender, System.EventArgs e)
{
InventoryEventArgs args = new InventoryEventArgs(-1);
ViewInventory(this, args);
}
/// Clicking the Tools->Configuration menu option.
///
private void itemConfiguration_Click(object sender, System.EventArgs e)
{
ViewConfiguration();
}
/// Clicking the File->Exit menu option.
///
private void menuItem2_Click(object sender, System.EventArgs e)
{
Exit();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -