📄 configuration.cs
字号:
this.configStatus = ConfigStatus.ConfigStart;
UpdateForm();
break;
/// Back
///
case ConfigStatus.ConfigSync:
this.configStatus = ConfigStatus.ConfigDriver;
UpdateForm();
break;
/// Quick Sync
///
case ConfigStatus.ConfigDone:
Cursor.ShowWaitCursor(true);
try
{
try
{
/// Execute the Quick Sync (for example, upload only).
///
this.dataIBuySpy.QuickSync();
}
finally
{
Cursor.ShowWaitCursor(false);
}
}
catch(SqlCeException err)
{
IBuySpyData.ShowErrors(err);
return;
}
catch (Exception err)
{
MessageBox.Show("Quick Sync: " + err.Message, "IBuySpy Delivery");
return;
}
this.cboDriverID.Enabled = false;
break;
}
}
/// This method controls the behavior of the Next button, which can also be the Finish button or
/// the Full Sync button. The Next button is active during configuration. The Finish button is
/// active at the final step in the configuration process. The Full Sync button is activated after
/// synchronization has occurred.
///
private void btnNextOrFull_Click(object sender, System.EventArgs e)
{
switch(this.configStatus)
{
/// Next
///
case ConfigStatus.ConfigStart:
if (0 == this.txtServerName.Text.Length)
{
MessageBox.Show("Enter server name first!", "IBuySpy Delivery");
return;
}
Cursor.ShowWaitCursor(true);
try
{
try
{
/// Loads the DriverID records.
///
LoadDriverIDs();
}
finally
{
Cursor.ShowWaitCursor(false);
}
}
catch(SqlCeException err)
{
IBuySpyData.ShowErrors(err);
return;
}
catch (Exception err)
{
MessageBox.Show("Load Driver IDs: " + err.Message, "IBuySpy Delivery");
return;
}
this.configStatus = ConfigStatus.ConfigDriver;
UpdateForm();
break;
/// Next
///
case ConfigStatus.ConfigDriver:
if (0 == this.cboDriverID.Text.Length)
{
MessageBox.Show("Select a driver ID!", "IBuySpy Delivery");
return;
}
this.configStatus = ConfigStatus.ConfigSync;
this.cboSyncMethod.SelectedIndex = 0;
UpdateForm();
break;
/// Finish
///
case ConfigStatus.ConfigSync:
if (0 == this.cboSyncMethod.Text.Length)
{
MessageBox.Show("Select a synchronize method!", "IBuySpy Delivery");
return;
}
this.dataIBuySpy.ServerName = this.txtServerName.Text;
this.dataIBuySpy.DriverID = Convert.ToInt32(this.cboDriverID.Text);
/// Determines which synchronization method to use (RDA or replication).
///
this.dataIBuySpy.SyncMethod = this.cboSyncMethod.Text.ToUpper() == "RDA" ? SyncType.Rda : SyncType.Replication;
Cursor.ShowWaitCursor(true);
try
{
try
{
/// Performs a Full Synchronization (bidirectional). The "true" parameter specifies that
/// this is the initial synchronization (for example, there is no local database or the local
/// database will be deleted if it exists).
///
this.dataIBuySpy.FullSync(SyncStatus.InitSync);
}
finally
{
Cursor.ShowWaitCursor(false);
}
}
catch(SqlCeException err)
{
IBuySpyData.ShowErrors(err);
return;
}
catch (Exception err)
{
MessageBox.Show("Full Sync: " + err.Message, "IBuySpy Delivery");
return;
}
this.configStatus = ConfigStatus.ConfigDone;
UpdateForm();
break;
/// Full Sync
///
case ConfigStatus.ConfigDone:
try
{
Cursor.ShowWaitCursor(true);
try
{
/// If the DriverID value is changed, a full synchronization automatically occurs in
/// the same manner as an initial synchronization (for example, the database is deleted).
///
if (this.cboDriverID.Text != this.dataIBuySpy.DriverID.ToString())
{
this.dataIBuySpy.DriverID = Convert.ToInt32(this.cboDriverID.Text);
this.dataIBuySpy.FullSync(SyncStatus.ReinitSync);
this.btnBackOrQuick.Enabled = true;
this.frmIBuySpy.UpdateForm(false);
}
/// The user caused a full synchronization to occur (without changing the DriverID).
///
else
{
this.dataIBuySpy.FullSync(SyncStatus.RegularSync);
}
}
finally
{
Cursor.ShowWaitCursor(false);
}
}
catch(SqlCeException err)
{
IBuySpyData.ShowErrors(err);
return;
}
catch (Exception err)
{
MessageBox.Show("Full Sync: " + err.Message, "IBuySpy Delivery");
return;
}
this.cboDriverID.Enabled = false;
break;
}
}
/// This method updates the user interface on the Configuration control based on the current status
/// (that is, which configuration step the user is currently performing).
///
private void UpdateForm()
{
switch(configStatus)
{
case ConfigStatus.ConfigStart:
this.txtServerName.Enabled = true;
this.lblDriverID.Hide();
this.cboDriverID.Hide();
this.lblSyncMethod.Hide();
this.cboSyncMethod.Hide();
this.btnReset.Hide();
this.btnChangeDriver.Hide();
this.btnBackOrQuick.Hide();
this.btnNextOrFull.Enabled = true;
this.btnNextOrFull.Text = "Next";
this.btnNextOrFull.Show();
this.frmIBuySpy.UpdateForm(true);
break;
case ConfigStatus.ConfigDriver:
this.txtServerName.Enabled = false;
this.lblDriverID.Show();
this.cboDriverID.Show();
this.cboDriverID.Enabled = true;
this.lblSyncMethod.Hide();
this.cboSyncMethod.Hide();
this.btnNextOrFull.Text = "Next";
this.btnBackOrQuick.Enabled = true;
this.btnBackOrQuick.Text = "Back";
this.btnBackOrQuick.Show();
break;
case ConfigStatus.ConfigSync:
this.cboDriverID.Enabled = false;
this.lblSyncMethod.Show();
this.cboSyncMethod.Show();
this.cboSyncMethod.Enabled = true;
this.btnNextOrFull.Text = "Finish";
break;
case ConfigStatus.ConfigDone:
this.txtServerName.Enabled = false;
this.lblDriverID.Show();
this.cboDriverID.Show();
this.cboDriverID.Enabled = false;
this.lblSyncMethod.Show();
this.cboSyncMethod.Show();
this.cboSyncMethod.Enabled = false;
this.btnReset.Show();
this.btnChangeDriver.Show();
this.btnBackOrQuick.Text = "Quick Sync";
this.btnBackOrQuick.Show();
this.btnNextOrFull.Text = "Full Sync";
this.btnNextOrFull.Show();
if (0 == this.dataIBuySpy.ServerName.Length)
{
this.btnChangeDriver.Enabled = false;
this.btnBackOrQuick.Enabled = false;
this.btnNextOrFull.Enabled = false;
}
else
{
this.btnChangeDriver.Enabled = true;
}
this.frmIBuySpy.UpdateForm(false);
break;
}
}
/// This method loads the DriverID records (through RDA) and binds the datatable to
/// the cobDriverID combo box.
///
private void LoadDriverIDs()
{
DataTable dtDriverIDs = null;
this.dataIBuySpy.ServerName = this.txtServerName.Text;
dtDriverIDs = dataIBuySpy.LoadDriverIDs();
if (null == dtDriverIDs)
{
throw (new Exception(@"Unable to load driver info."));
}
if (0 == dtDriverIDs.Rows.Count || 0 == dtDriverIDs.Columns.Count)
{
throw (new Exception(@"No driver data."));
}
this.cboDriverID.DataSource = dtDriverIDs;
this.cboDriverID.DisplayMember = "DriverID";
this.cboDriverID.ValueMember = "DriverID";
}
/// If the DriverID value is changed, a full synchronization is required; therefore, the Quick Sync
/// option is disabled.
///
private void cboDriverID_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (this.cboDriverID.Text != this.dataIBuySpy.DriverID.ToString() &&
ConfigStatus.ConfigDone == this.configStatus)
{
this.btnBackOrQuick.Enabled = false;
}
else
{
this.btnBackOrQuick.Enabled = true;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -