📄 customers.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Data.SqlServerCe;
using System.Windows.Forms;
using System.Reflection;
namespace Microsoft.Sql.SqlCe.Samples.Cs.IBuySpyDelivery.IBuySpyDevice
{
/// <summary>
/// Summary description for the Customers control. This control displays customers information and is
/// read-only: Customer information can only be modified or created on the server.
/// </summary>
public class Customers : System.Windows.Forms.Control
{
private System.Windows.Forms.Label lblDriverValue;
private System.Windows.Forms.Label lblDriver;
private System.Windows.Forms.Button btnEditStatus;
private System.Windows.Forms.ListBox lstOrders;
private System.Windows.Forms.Button btnViewOrder;
private System.Windows.Forms.Label lblCompany;
private System.Windows.Forms.PictureBox pboIDegree;
private System.Windows.Forms.Label lblStatus;
private System.Windows.Forms.Label lblOrders;
private System.Windows.Forms.ComboBox cboCustomers;
private System.Windows.Forms.Label lblAddress;
private System.Windows.Forms.Label lblStatusValue;
private System.Windows.Forms.Label lblAddressValue1;
private System.Windows.Forms.Label lblAddressValue2;
private System.Windows.Forms.Label lblAddressValue3;
private FormIBuySpy formIBuySpy = null;
private IBuySpyData dataIBuySpy = null;
private DataTable dtCustomers = null;
private DataView dvOrders = null;
private int customerID = -1;
private int orderID = -1;
internal event ViewOrdersEventHandler OnViewOrders;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Customers(FormIBuySpy formIBuySpy)
{
this.formIBuySpy = formIBuySpy;
this.dataIBuySpy = IBuySpyData.GetInstance();
/// This call is required by the Windows.Forms Form Designer.
///
InitializeComponent();
this.pboIDegree.Image = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("IBuySpyDevice.idegree.gif"));
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lblDriverValue = new System.Windows.Forms.Label();
this.lblDriver = new System.Windows.Forms.Label();
this.btnEditStatus = new System.Windows.Forms.Button();
this.lblStatus = new System.Windows.Forms.Label();
this.lstOrders = new System.Windows.Forms.ListBox();
this.btnViewOrder = new System.Windows.Forms.Button();
this.lblOrders = new System.Windows.Forms.Label();
this.cboCustomers = new System.Windows.Forms.ComboBox();
this.lblAddress = new System.Windows.Forms.Label();
this.lblCompany = new System.Windows.Forms.Label();
this.pboIDegree = new System.Windows.Forms.PictureBox();
this.lblStatusValue = new System.Windows.Forms.Label();
this.lblAddressValue1 = new System.Windows.Forms.Label();
this.lblAddressValue2 = new System.Windows.Forms.Label();
this.lblAddressValue3 = new System.Windows.Forms.Label();
///
/// lblDriverValue
///
this.lblDriverValue.Location = new System.Drawing.Point(192, 248);
this.lblDriverValue.Size = new System.Drawing.Size(40, 16);
this.lblDriverValue.Text = "672";
///
/// lblDriver
///
this.lblDriver.Location = new System.Drawing.Point(144, 248);
this.lblDriver.Size = new System.Drawing.Size(40, 16);
this.lblDriver.Text = "Driver:";
///
/// btnEditStatus
///
this.btnEditStatus.Location = new System.Drawing.Point(132, 168);
this.btnEditStatus.Size = new System.Drawing.Size(100, 24);
this.btnEditStatus.Text = "Set Failed";
this.btnEditStatus.Click += new System.EventHandler(this.btnEditStatus_Click);
///
/// lblStatus
///
this.lblStatus.Location = new System.Drawing.Point(8, 143);
this.lblStatus.Size = new System.Drawing.Size(56, 16);
this.lblStatus.Text = "Status:";
///
/// lstOrders
///
this.lstOrders.Location = new System.Drawing.Point(72, 88);
this.lstOrders.Size = new System.Drawing.Size(160, 45);
this.lstOrders.SelectedIndexChanged += new System.EventHandler(this.lstOrders_SelectedIndexChanged);
///
/// btnViewOrder
///
this.btnViewOrder.Location = new System.Drawing.Point(132, 198);
this.btnViewOrder.Size = new System.Drawing.Size(100, 24);
this.btnViewOrder.Text = "View Order >>";
this.btnViewOrder.Click += new System.EventHandler(this.btnViewOrder_Click);
///
/// lblOrders
///
this.lblOrders.Location = new System.Drawing.Point(8, 86);
this.lblOrders.Size = new System.Drawing.Size(56, 16);
this.lblOrders.Text = "Orders:";
///
/// cboCustomers
///
this.cboCustomers.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboCustomers.Location = new System.Drawing.Point(72, 6);
this.cboCustomers.Size = new System.Drawing.Size(160, 21);
this.cboCustomers.SelectedIndexChanged += new System.EventHandler(this.cboCustomers_SelectedIndexChanged);
///
/// lblAddress
///
this.lblAddress.Location = new System.Drawing.Point(8, 32);
this.lblAddress.Size = new System.Drawing.Size(56, 16);
this.lblAddress.Text = "Address:";
///
/// lblCompany
///
this.lblCompany.Location = new System.Drawing.Point(7, 8);
this.lblCompany.Size = new System.Drawing.Size(56, 16);
this.lblCompany.Text = "Company:";
///
/// pboIDegree
///
this.pboIDegree.Location = new System.Drawing.Point(8, 168);
this.pboIDegree.Size = new System.Drawing.Size(120, 55);
///
/// lblStatusValue
///
this.lblStatusValue.Location = new System.Drawing.Point(72, 143);
this.lblStatusValue.Size = new System.Drawing.Size(160, 16);
this.lblStatusValue.Text = "";
///
/// lblAddressValue1
///
this.lblAddressValue1.Location = new System.Drawing.Point(72, 32);
this.lblAddressValue1.Size = new System.Drawing.Size(160, 16);
///
/// lblAddressValue2
///
this.lblAddressValue2.Location = new System.Drawing.Point(72, 48);
this.lblAddressValue2.Size = new System.Drawing.Size(160, 16);
///
/// lblAddressValue3
///
this.lblAddressValue3.Location = new System.Drawing.Point(72, 64);
this.lblAddressValue3.Size = new System.Drawing.Size(160, 16);
///
/// Customers
///
this.Controls.Add(this.lblAddressValue3);
this.Controls.Add(this.lblAddressValue2);
this.Controls.Add(this.lblAddressValue1);
this.Controls.Add(this.lblStatusValue);
this.Controls.Add(this.lblDriverValue);
this.Controls.Add(this.lblDriver);
this.Controls.Add(this.btnEditStatus);
this.Controls.Add(this.lblStatus);
this.Controls.Add(this.lstOrders);
this.Controls.Add(this.btnViewOrder);
this.Controls.Add(this.lblOrders);
this.Controls.Add(this.cboCustomers);
this.Controls.Add(this.lblAddress);
this.Controls.Add(this.lblCompany);
this.Controls.Add(this.pboIDegree);
this.Size = new System.Drawing.Size(240, 240);
}
#endregion
/// Loads data from the Customer and Orders tables and binds the data to the controls on the Customer control.
///
internal void InitCustomers()
{
DataTable dtOrders = null;
Cursor.ShowWaitCursor(true);
try
{
try
{
dtCustomers = dataIBuySpy.LoadCustomers();
dtOrders = dataIBuySpy.LoadOrders();
}
finally
{
Cursor.ShowWaitCursor(false);
}
}
catch(SqlCeException e)
{
IBuySpyData.ShowErrors(e);
return;
}
catch(Exception e)
{
MessageBox.Show("Init Customers: " + e.Message, "IBuySpy Delivery");
return;
}
if (null == dtCustomers)
{
MessageBox.Show("No customer data", "IBuySpy Delivery");
return;
}
if (null == dtOrders)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -