?? controlorders.cs
字號:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Data.SqlServerCe;
namespace Microsoft.Sql.SqlCe.Samples.Cs.NorthwindCe {
/// <summary>
/// Summary description for ControlOrders.
/// </summary>
public class ControlOrders : System.Windows.Forms.Control {
private System.Windows.Forms.ListView listViewOrders;
private System.Windows.Forms.ColumnHeader columnHeaderID;
private System.Windows.Forms.ColumnHeader columnHeaderDate;
private System.Windows.Forms.ColumnHeader columnHeaderNeedDate;
private System.Windows.Forms.ColumnHeader columnHeaderShipDate;
private System.Windows.Forms.ColumnHeader columnHeaderShipVia;
private System.Windows.Forms.ListView listViewProducts;
private System.Windows.Forms.ColumnHeader columnHeaderProduct;
private System.Windows.Forms.ColumnHeader columnHeaderUnitPrice;
private System.Windows.Forms.ColumnHeader columnHeaderQuantity;
private System.Windows.Forms.ColumnHeader columnHeaderDiscount;
private System.Windows.Forms.ComboBox comboBoxCustomers;
private System.Windows.Forms.Label labelCustomer;
private string selectedCustomerID = "";
private bool refreshOrders = false;
SqlCeDataAdapter daCustomers = null;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public ControlOrders() {
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
}
/// <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.listViewOrders = new System.Windows.Forms.ListView();
this.columnHeaderID = new System.Windows.Forms.ColumnHeader();
this.columnHeaderDate = new System.Windows.Forms.ColumnHeader();
this.columnHeaderNeedDate = new System.Windows.Forms.ColumnHeader();
this.columnHeaderShipDate = new System.Windows.Forms.ColumnHeader();
this.columnHeaderShipVia = new System.Windows.Forms.ColumnHeader();
this.listViewProducts = new System.Windows.Forms.ListView();
this.columnHeaderProduct = new System.Windows.Forms.ColumnHeader();
this.columnHeaderUnitPrice = new System.Windows.Forms.ColumnHeader();
this.columnHeaderQuantity = new System.Windows.Forms.ColumnHeader();
this.columnHeaderDiscount = new System.Windows.Forms.ColumnHeader();
this.comboBoxCustomers = new System.Windows.Forms.ComboBox();
this.labelCustomer = new System.Windows.Forms.Label();
//
// listViewOrders
//
this.listViewOrders.Columns.Add(this.columnHeaderID);
this.listViewOrders.Columns.Add(this.columnHeaderDate);
this.listViewOrders.Columns.Add(this.columnHeaderNeedDate);
this.listViewOrders.Columns.Add(this.columnHeaderShipDate);
this.listViewOrders.Columns.Add(this.columnHeaderShipVia);
this.listViewOrders.FullRowSelect = true;
this.listViewOrders.Location = new System.Drawing.Point(16, 40);
this.listViewOrders.Size = new System.Drawing.Size(216, 120);
this.listViewOrders.View = System.Windows.Forms.View.Details;
this.listViewOrders.SelectedIndexChanged += new System.EventHandler(this.listViewOrders_SelectedIndexChanged);
//
// columnHeaderID
//
this.columnHeaderID.Text = "ID";
this.columnHeaderID.Width = 50;
//
// columnHeaderDate
//
this.columnHeaderDate.Text = "Date";
this.columnHeaderDate.Width = 80;
//
// columnHeaderNeedDate
//
this.columnHeaderNeedDate.Text = "Need Date";
this.columnHeaderNeedDate.Width = 80;
//
// columnHeaderShipDate
//
this.columnHeaderShipDate.Text = "Ship Date";
this.columnHeaderShipDate.Width = 70;
//
// columnHeaderShipVia
//
this.columnHeaderShipVia.Text = "Shipper";
this.columnHeaderShipVia.Width = 120;
//
// listViewProducts
//
this.listViewProducts.Columns.Add(this.columnHeaderProduct);
this.listViewProducts.Columns.Add(this.columnHeaderUnitPrice);
this.listViewProducts.Columns.Add(this.columnHeaderQuantity);
this.listViewProducts.Columns.Add(this.columnHeaderDiscount);
this.listViewProducts.FullRowSelect = true;
this.listViewProducts.Location = new System.Drawing.Point(16, 160);
this.listViewProducts.Size = new System.Drawing.Size(216, 104);
this.listViewProducts.View = System.Windows.Forms.View.Details;
//
// columnHeader6
//
this.columnHeaderProduct.Text = "Product";
this.columnHeaderProduct.Width = 80;
//
// columnHeader7
//
this.columnHeaderUnitPrice.Text = "Unit Price";
this.columnHeaderUnitPrice.Width = 80;
//
// columnHeader8
//
this.columnHeaderQuantity.Text = "Quantity";
this.columnHeaderQuantity.Width = 80;
//
// columnHeader9
//
this.columnHeaderDiscount.Text = "Discount";
this.columnHeaderDiscount.Width = 80;
//
// comboBoxCustomers
//
this.comboBoxCustomers.Location = new System.Drawing.Point(72, 16);
this.comboBoxCustomers.Size = new System.Drawing.Size(160, 21);
this.comboBoxCustomers.SelectedIndexChanged += new System.EventHandler(this.comboBoxCustomers_SelectedIndexChanged);
//
// labelCustomer
//
this.labelCustomer.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold);
this.labelCustomer.Location = new System.Drawing.Point(8, 16);
this.labelCustomer.Size = new System.Drawing.Size(72, 16);
this.labelCustomer.Text = "Customer:";
//
// UserControl3
//
this.Controls.Add(this.listViewOrders);
this.Controls.Add(this.listViewProducts);
this.Controls.Add(this.comboBoxCustomers);
this.Controls.Add(this.labelCustomer);
this.Size = new System.Drawing.Size(246, 302);
}
#endregion
// This function initializes or refreshes the Customers DataSet for Orders information.
//
public void InitOrders() {
// Starts the cursor icon since this function may take some time.
//
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
SqlCeConnection cnNorthwind = NorthwindData.GetInstance().NorthwindConnection;
DataSet dsNorthwind = NorthwindData.GetInstance().NorthwindDataSet;
DataTable dtCustomers = null;
try {
// This will execute only the first time the InitOrders method is called.
//
if (null == daCustomers)
daCustomers = new SqlCeDataAdapter(@"SELECT CustomerID, CompanyName FROM Customers ORDER BY CompanyName", cnNorthwind);
// Note, the DataTable has been named "CustomerOrders" as to not be confused with the "Customers" DataTable in the ControlCustomers control.
//
dtCustomers = dsNorthwind.Tables["CustomerOrders"];
// Initialize the Customers DataSet
//
if (null == dtCustomers) {
daCustomers.Fill(dsNorthwind, "CustomerOrders");
dtCustomers = dsNorthwind.Tables["CustomerOrders"];
// Binds the database values to the controls
//
comboBoxCustomers.DataSource = dtCustomers;
comboBoxCustomers.DisplayMember = "CompanyName";
comboBoxCustomers.ValueMember = "CustomerID";
}
// Refresh the Customers DataSet
//
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -