⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 formibuyspy.cs

📁 采用vc#.net和sqlce实现智能手机端和服务器数据交换
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlServerCe;

namespace Microsoft.Sql.SqlCe.Samples.Cs.IBuySpyDelivery.IBuySpyDevice
{
	/// <summary>
	/// Summary description for FormIBuySpy. The application consists of one form, FormIBuySpy, with multiple
	/// custom controls embedded into this single form. The form contains a global menu bar, a Begin button,
	/// which starts the preferred click through path, and a Driver ID label which displays the current Driver
	/// ID. The Driver ID is only displayed after the device has been configured (that is, there is a local SSCE
	/// database on the device). The menu options (other than Exit) and the Begin button are also disabled
	/// until synchronization has been completed (that is, a local SSCE database has been created).
	/// </summary>
	public class FormIBuySpy : System.Windows.Forms.Form
	{
        private System.Windows.Forms.MenuItem itemFile;
        private System.Windows.Forms.MenuItem itemExit;
        private System.Windows.Forms.MenuItem itemDelivery;
        private System.Windows.Forms.MenuItem itemCustomers;
        private System.Windows.Forms.MenuItem itemInventory;
        private System.Windows.Forms.MenuItem itemTools;
        private System.Windows.Forms.MenuItem itemConfiguration;
        private System.Windows.Forms.MainMenu menuIBuySpy;
        private System.Windows.Forms.Label lblDriver;
        private System.Windows.Forms.Label lblDriverID;
        private System.Windows.Forms.Button btnStart;

        private IBuySpyData dataIBuySpy;
        private Configuration configuration = null;
        private Customers customers = null;
        private Orders orders = null;
        private Inventory inventory = null;
        private Signature signature = null;

		public FormIBuySpy()
		{
            ///
			/// Required for Windows Form Designer support
			///
			InitializeComponent();
		}
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			base.Dispose( disposing );
		}
		#region Windows Form 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.menuIBuySpy = new System.Windows.Forms.MainMenu();
            this.itemFile = new System.Windows.Forms.MenuItem();
            this.itemExit = new System.Windows.Forms.MenuItem();
            this.itemDelivery = new System.Windows.Forms.MenuItem();
            this.itemCustomers = new System.Windows.Forms.MenuItem();
            this.itemInventory = new System.Windows.Forms.MenuItem();
            this.itemTools = new System.Windows.Forms.MenuItem();
            this.itemConfiguration = new System.Windows.Forms.MenuItem();
            this.lblDriver = new System.Windows.Forms.Label();
            this.lblDriverID = new System.Windows.Forms.Label();
            this.btnStart = new System.Windows.Forms.Button();
            // 
            // menuIBuySpy
            // 
            this.menuIBuySpy.MenuItems.Add(this.itemFile);
            this.menuIBuySpy.MenuItems.Add(this.itemDelivery);
            this.menuIBuySpy.MenuItems.Add(this.itemTools);
            // 
            // itemFile
            // 
            this.itemFile.MenuItems.Add(this.itemExit);
            this.itemFile.Text = "File";
            // 
            // itemExit
            // 
            this.itemExit.Text = "Exit";
            this.itemExit.Click += new System.EventHandler(this.menuItem2_Click);
            // 
            // itemDelivery
            // 
            this.itemDelivery.MenuItems.Add(this.itemCustomers);
            this.itemDelivery.MenuItems.Add(this.itemInventory);
            this.itemDelivery.Text = "Delivery";
            // 
            // itemCustomers
            // 
            this.itemCustomers.Text = "Customers";
            this.itemCustomers.Click += new System.EventHandler(this.itemCustomers_Click);
            // 
            // itemInventory
            // 
            this.itemInventory.Text = "Inventory";
            this.itemInventory.Click += new System.EventHandler(this.itemInventory_Click);
            // 
            // itemTools
            // 
            this.itemTools.MenuItems.Add(this.itemConfiguration);
            this.itemTools.Text = "Tools";
            // 
            // itemConfiguration
            // 
            this.itemConfiguration.Text = "Configuration";
            this.itemConfiguration.Click += new System.EventHandler(this.itemConfiguration_Click);
            // 
            // lblDriver
            // 
            this.lblDriver.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
            this.lblDriver.Location = new System.Drawing.Point(136, 247);
            this.lblDriver.Size = new System.Drawing.Size(48, 16);
            this.lblDriver.Text = "Driver:";
            // 
            // lblDriverID
            // 
            this.lblDriverID.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
            this.lblDriverID.Location = new System.Drawing.Point(184, 247);
            this.lblDriverID.Size = new System.Drawing.Size(40, 16);
            // 
            // btnStart
            // 
            this.btnStart.Location = new System.Drawing.Point(8, 241);
            this.btnStart.Size = new System.Drawing.Size(104, 24);
            this.btnStart.Text = "Begin >>";
            this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
            // 
            // FormIBuySpy
            // 
            this.ClientSize = new System.Drawing.Size(240, 267);
            this.Controls.Add(this.lblDriverID);
            this.Controls.Add(this.lblDriver);
            this.Controls.Add(this.btnStart);
            this.Menu = this.menuIBuySpy;
            this.MinimizeBox = false;
            this.Text = "IBuySpy Delivery";
            this.Load += new System.EventHandler(this.FormIBuySpyDelivery_Load);

        }
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>

		static void Main() 
		{
			Application.Run(new FormIBuySpy());
		}

        /// Loads the main form (FormIBuySpyDelivery).
        ///
        private void FormIBuySpyDelivery_Load(object sender, System.EventArgs e)
        {
            try
            {
                dataIBuySpy = IBuySpyData.GetInstance();
            }
            catch(Exception err)
            {
                MessageBox.Show(err.Message, "IBuySpy Delivery");
                Application.Exit();
                return;
            }
            
            ViewConfiguration();
        }

        /// This method displays the Configuration control. If the control does not exist, this method first creates
        /// a new instance of the Configuration control before displaying it.
        ///
        private void ViewConfiguration()
        {
            ///
            /// Configuration
            ///
            if (null == configuration)
            {
                configuration = new Configuration(this);
                this.Controls.Add(this.configuration);
            }
                    
			/// Make the Configuration control visible initially.
			///
            configuration.BringToFront();
            configuration.Visible = true;
        }

        /// This method displays the Customers control. If the control does not exist, this method first creates
        /// a new instance of the Customers control before displaying it.
        ///
        private void ViewCustomers(object sender, EventArgs e)
        {
            ///
            /// Customers
            ///
            if (null == customers)
            {
                this.customers = new Customers(this);
                this.Controls.Add(this.customers);
                this.customers.OnViewOrders += new ViewOrdersEventHandler(this.ViewOrders);

                this.customers.InitCustomers();
            }
			/// The Customers control must be reset (click "Reset" from the Configuration control) if the database is deleted.
			///
            else
            {
				this.customers.InitCustomers();
                this.customers.UpdateOrderStatus();
            }

			/// Make the Customers control visible initially.
			///
            customers.BringToFront();
            customers.Visible = true;
        }

        /// This method displays the Orders control. If the control does not exist, this method first creates
        /// a new instance of the Orders control before displaying it.
        ///
        private void ViewOrders(object sender, OrderEventArgs e)
        {
            ///
            /// Orders
            ///
            if (null == this.orders)
            {
                this.orders = new Orders(this);
                this.Controls.Add(this.orders);
                this.orders.OnViewInventory += new ViewInventoryEventHandler(ViewInventory);
                this.orders.OnViewSignature += new ViewSignatureEventHandler(ViewSignature);

				/// These are the initial values required by the Orders control. Users cannot navigate to the
				/// Orders control without first choosing the CustomerID, CustomerName, and OrderID values
				/// from the Customers control.
				///
                this.orders.CustomerID   = e.CustomerID;
                this.orders.CustomerName = e.CustomerName;
                this.orders.OrderID      = e.OrderID;
                this.orders.InitOrders();
            }
            else if (sender is Customers)
            {
				/// The following code updates the Orders control if the user changes the CustomerID or OrderID on the Customers control.
                ///
                if (this.orders.OrderID != e.OrderID || this.orders.CustomerID != e.CustomerID)
                {
                    this.orders.CustomerID   = e.CustomerID;
                    this.orders.CustomerName = e.CustomerName;
                    this.orders.OrderID      = e.OrderID;
                    this.orders.RefreshOrders();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -