using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using C1.Data;

namespace Calculations
{
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class MainForm : System.Windows.Forms.Form
    {
        private C1.Data.C1DataSet c1DataSet1;
        private System.Windows.Forms.TabControl tabControl1;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Button btnClose;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.Label label6;
        private System.Windows.Forms.TabPage tabPage2;
        private System.Windows.Forms.TabPage tabPage1;
        private System.Windows.Forms.TabPage tabPage3;
        private System.Windows.Forms.Label label7;
        private C1.Win.C1TrueDBGrid.C1TrueDBGrid gridSuppliers;
        private System.Windows.Forms.Label label8;
        private C1.Win.C1TrueDBGrid.C1TrueDBGrid gridProducts;
        private C1.Win.C1TrueDBGrid.C1TrueDBGrid gridOrderDetails;
        private C1.Win.C1TrueDBGrid.C1TrueDBGrid gridOrders;
        private C1.Win.C1TrueDBGrid.C1TrueDBGrid gridCustomers;
        private System.Windows.Forms.Button btnRefresh;
        private C1.Data.C1DataTableSource c1DataTableSource1;
        private System.Windows.Forms.Label label9;
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        public MainForm()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }

        /// <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 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()
        {
            System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MainForm));
            this.c1DataSet1 = new C1.Data.C1DataSet();
            this.tabControl1 = new System.Windows.Forms.TabControl();
            this.tabPage1 = new System.Windows.Forms.TabPage();
            this.label7 = new System.Windows.Forms.Label();
            this.label6 = new System.Windows.Forms.Label();
            this.label5 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.gridProducts = new C1.Win.C1TrueDBGrid.C1TrueDBGrid();
            this.tabPage2 = new System.Windows.Forms.TabPage();
            this.gridOrderDetails = new C1.Win.C1TrueDBGrid.C1TrueDBGrid();
            this.label3 = new System.Windows.Forms.Label();
            this.gridOrders = new C1.Win.C1TrueDBGrid.C1TrueDBGrid();
            this.label2 = new System.Windows.Forms.Label();
            this.label1 = new System.Windows.Forms.Label();
            this.gridCustomers = new C1.Win.C1TrueDBGrid.C1TrueDBGrid();
            this.tabPage3 = new System.Windows.Forms.TabPage();
            this.label9 = new System.Windows.Forms.Label();
            this.label8 = new System.Windows.Forms.Label();
            this.gridSuppliers = new C1.Win.C1TrueDBGrid.C1TrueDBGrid();
            this.c1DataTableSource1 = new C1.Data.C1DataTableSource();
            this.btnRefresh = new System.Windows.Forms.Button();
            this.btnClose = new System.Windows.Forms.Button();
            ((System.ComponentModel.ISupportInitialize)(this.c1DataSet1)).BeginInit();
            this.tabControl1.SuspendLayout();
            this.tabPage1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.gridProducts)).BeginInit();
            this.tabPage2.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.gridOrderDetails)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.gridOrders)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.gridCustomers)).BeginInit();
            this.tabPage3.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.gridSuppliers)).BeginInit();
            this.SuspendLayout();
            // 
            // c1DataSet1
            // 
            this.c1DataSet1.BindingContextCtrl = null;
            this.c1DataSet1.DataLibrary = "DataLibrary";
            this.c1DataSet1.DataLibraryUrl = "";
            this.c1DataSet1.DataSetDef = "DataSet1";
            this.c1DataSet1.Locale = new System.Globalization.CultureInfo("en-US");
            this.c1DataSet1.SchemaClassName = "DataLibrary.DataClass";
            this.c1DataSet1.SchemaDef = null;
            this.c1DataSet1.SuppressNotifications = false;
            // 
            // tabControl1
            // 
            this.tabControl1.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                                      this.tabPage1,
                                                                                      this.tabPage2,
                                                                                      this.tabPage3});
            this.tabControl1.Location = new System.Drawing.Point(8, 8);
            this.tabControl1.Name = "tabControl1";
            this.tabControl1.SelectedIndex = 0;
            this.tabControl1.Size = new System.Drawing.Size(560, 376);
            this.tabControl1.TabIndex = 0;
            // 
            // tabPage1
            // 
            this.tabPage1.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                                   this.label7,
                                                                                   this.label6,
                                                                                   this.label5,
                                                                                   this.label4,
                                                                                   this.gridProducts});
            this.tabPage1.Location = new System.Drawing.Point(4, 22);
            this.tabPage1.Name = "tabPage1";
            this.tabPage1.Size = new System.Drawing.Size(552, 350);
            this.tabPage1.TabIndex = 1;
            this.tabPage1.Text = "Simple Calculations";
            // 
            // label7
            // 
            this.label7.Location = new System.Drawing.Point(24, 84);
            this.label7.Name = "label7";
            this.label7.Size = new System.Drawing.Size(512, 16);
            this.label7.TabIndex = 4;
            this.label7.Text = "3. SurplusPercent = IIF(ReorderLevel>0,(UnitsInStock+UnitsOnOrder-ReorderLevel)/R" +
                "eorderLevel,0)";
            // 
            // label6
            // 
            this.label6.Location = new System.Drawing.Point(24, 60);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(328, 16);
            this.label6.TabIndex = 3;
            this.label6.Text = "2. OrderAndStockSum = SumInStock + UnitPrice*UnitsOnOrder";
            // 
            // label5
            // 
            this.label5.Location = new System.Drawing.Point(24, 36);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(212, 16);
            this.label5.TabIndex = 2;
            this.label5.Text = "1. SumInStock = UnitPrice*UnitsInStock";
            // 
            // label4
            // 
            this.label4.Location = new System.Drawing.Point(8, 12);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(256, 16);
            this.label4.TabIndex = 1;
            this.label4.Text = "The Products table with three calculated columns:";
            // 
            // gridProducts
            // 
            this.gridProducts.AllowFilter = true;
            this.gridProducts.AllowRowSizing = C1.Win.C1TrueDBGrid.RowSizingEnum.AllRows;
            this.gridProducts.AllowSort = true;
            this.gridProducts.CaptionHeight = 17;
            this.gridProducts.CollapseColor = System.Drawing.Color.Black;
            this.gridProducts.DataChanged = false;
            this.gridProducts.DataMember = "Products";
            this.gridProducts.DataSource = this.c1DataSet1;
            this.gridProducts.BackColor = System.Drawing.Color.Empty;
            this.gridProducts.ExpandColor = System.Drawing.Color.Black;
            this.gridProducts.Images.Add(((System.Drawing.Bitmap)(resources.GetObject("resource.Images"))));
            this.gridProducts.Location = new System.Drawing.Point(12, 108);
            this.gridProducts.MarqueeStyle = C1.Win.C1TrueDBGrid.MarqueeEnum.DottedCellBorder;
            this.gridProducts.Name = "gridProducts";
            this.gridProducts.PreviewInfo.Location = new System.Drawing.Point(0, 0);
            this.gridProducts.PreviewInfo.Size = new System.Drawing.Size(0, 0);
            this.gridProducts.PreviewInfo.ZoomFactor = 75;
            this.gridProducts.RecordSelectorWidth = 16;
            this.gridProducts.RowHeight = 15;
            this.gridProducts.RowSubDividerColor = System.Drawing.Color.DarkGray;
            this.gridProducts.ScrollTips = false;
            this.gridProducts.Size = new System.Drawing.Size(528, 229);
            this.gridProducts.TabIndex = 0;
            this.gridProducts.Text = "c1TrueDBGrid4";
            this.gridProducts.PropBag = ((string)(resources.GetObject("gridProducts.PropBag")));
            // 
            // tabPage2
            // 
            this.tabPage2.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                                   this.gridOrderDetails,
                                                                                   this.label3,
                                                                                   this.gridOrders,
                                                                                   this.label2,
                                                                                   this.label1,
                                                                                   this.gridCustomers});
            this.tabPage2.Location = new System.Drawing.Point(4, 22);
            this.tabPage2.Name = "tabPage2";
            this.tabPage2.Size = new System.Drawing.Size(552, 350);
            this.tabPage2.TabIndex = 0;
            this.tabPage2.Text = "Aggregate Functions";
            // 
            // gridOrderDetails
            // 
            this.gridOrderDetails.AllowFilter = true;
            this.gridOrderDetails.AllowRowSizing = C1.Win.C1TrueDBGrid.RowSizingEnum.AllRows;
            this.gridOrderDetails.AllowSort = true;
            this.gridOrderDetails.CaptionHeight = 17;
            this.gridOrderDetails.CollapseColor = System.Drawing.Color.Black;
            this.gridOrderDetails.DataChanged = false;
            this.gridOrderDetails.DataMember = "Order Details";
            this.gridOrderDetails.DataSource = this.c1DataSet1;
            this.gridOrderDetails.BackColor = System.Drawing.Color.Empty;
            this.gridOrderDetails.ExpandColor = System.Drawing.Color.Black;
            this.gridOrderDetails.Images.Add(((System.Drawing.Bitmap)(resources.GetObject("resource.Images1"))));
            this.gridOrderDetails.Location = new System.Drawing.Point(12, 252);
            this.gridOrderDetails.MarqueeStyle = C1.Win.C1TrueDBGrid.MarqueeEnum.DottedCellBorder;
            this.gridOrderDetails.Name = "gridOrderDetails";
            this.gridOrderDetails.PreviewInfo.Location = new System.Drawing.Point(0, 0);
            this.gridOrderDetails.PreviewInfo.Size = new System.Drawing.Size(0, 0);
            this.gridOrderDetails.PreviewInfo.ZoomFactor = 75;
            this.gridOrderDetails.RecordSelectorWidth = 16;
            this.gridOrderDetails.RowHeight = 15;
            this.gridOrderDetails.RowSubDividerColor = System.Drawing.Color.DarkGray;
            this.gridOrderDetails.ScrollTips = false;
            this.gridOrderDetails.Size = new System.Drawing.Size(528, 85);
            this.gridOrderDetails.TabIndex = 5;
            this.gridOrderDetails.Text = "c1TrueDBGrid3";
            this.gridOrderDetails.PropBag = ((string)(resources.GetObject("gridOrderDetails.PropBag")));
            // 
            // label3
            // 
            this.label3.Location = new System.Drawing.Point(16, 232);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(136, 16);
            this.label3.TabIndex = 4;
            this.label3.Text = "Order Details";
            // 
            // gridOrders
            // 
            this.gridOrders.AllowFilter = true;
            this.gridOrders.AllowRowSizing = C1.Win.C1TrueDBGrid.RowSizingEnum.AllRows;
            this.gridOrders.AllowSort = true;
            this.gridOrders.CaptionHeight = 17;
            this.gridOrders.CollapseColor = System.Drawing.Color.Black;
            this.gridOrders.DataChanged = false;
            this.gridOrders.DataMember = "Orders";
            this.gridOrders.DataSource = this.c1DataSet1;
            this.gridOrders.BackColor = System.Drawing.Color.Empty;
            this.gridOrders.ExpandColor = System.Drawing.Color.Black;
            this.gridOrders.Images.Add(((System.Drawing.Bitmap)(resources.GetObject("resource.Images2"))));
            this.gridOrders.Location = new System.Drawing.Point(12, 140);
            this.gridOrders.MarqueeStyle = C1.Win.C1TrueDBGrid.MarqueeEnum.DottedCellBorder;
            this.gridOrders.Name = "gridOrders";
            this.gridOrders.PreviewInfo.Location = new System.Drawing.Point(0, 0);
            this.gridOrders.PreviewInfo.Size = new System.Drawing.Size(0, 0);
            this.gridOrders.PreviewInfo.ZoomFactor = 75;
            this.gridOrders.RecordSelectorWidth = 16;
            this.gridOrders.RowHeight = 15;
            this.gridOrders.RowSubDividerColor = System.Drawing.Color.DarkGray;
            this.gridOrders.ScrollTips = false;
            this.gridOrders.Size = new System.Drawing.Size(528, 85);
            this.gridOrders.TabIndex = 3;
            this.gridOrders.Text = "c1TrueDBGrid2";
            this.gridOrders.PropBag = ((string)(resources.GetObject("gridOrders.PropBag")));
            // 
            // label2
            // 
            this.label2.Location = new System.Drawing.Point(16, 120);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(80, 16);
            this.label2.TabIndex = 2;
            this.label2.Text = "Orders";
            // 
            // label1
            // 
            this.label1.Location = new System.Drawing.Point(16, 8);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(100, 16);
            this.label1.TabIndex = 1;
            this.label1.Text = "Customers";
            // 
            // gridCustomers
            // 
            this.gridCustomers.AllowFilter = true;
            this.gridCustomers.AllowRowSizing = C1.Win.C1TrueDBGrid.RowSizingEnum.AllRows;
            this.gridCustomers.AllowSort = true;
            this.gridCustomers.CaptionHeight = 17;
            this.gridCustomers.CollapseColor = System.Drawing.Color.Black;
            this.gridCustomers.DataChanged = false;
            this.gridCustomers.DataMember = "Customers";
            this.gridCustomers.DataSource = this.c1DataSet1;
            this.gridCustomers.BackColor = System.Drawing.Color.Empty;
            this.gridCustomers.ExpandColor = System.Drawing.Color.Black;
            this.gridCustomers.Images.Add(((System.Drawing.Bitmap)(resources.GetObject("resource.Images3"))));
            this.gridCustomers.Location = new System.Drawing.Point(12, 28);
            this.gridCustomers.MarqueeStyle = C1.Win.C1TrueDBGrid.MarqueeEnum.DottedCellBorder;
            this.gridCustomers.Name = "gridCustomers";
            this.gridCustomers.PreviewInfo.Location = new System.Drawing.Point(0, 0);
            this.gridCustomers.PreviewInfo.Size = new System.Drawing.Size(0, 0);
            this.gridCustomers.PreviewInfo.ZoomFactor = 75;
            this.gridCustomers.RecordSelectorWidth = 16;
            this.gridCustomers.RowHeight = 15;
            this.gridCustomers.RowSubDividerColor = System.Drawing.Color.DarkGray;
            this.gridCustomers.ScrollTips = false;
            this.gridCustomers.Size = new System.Drawing.Size(528, 85);
            this.gridCustomers.TabIndex = 0;
            this.gridCustomers.Text = "c1TrueDBGrid1";
            this.gridCustomers.PropBag = ((string)(resources.GetObject("gridCustomers.PropBag")));
            // 
            // tabPage3
            // 
            this.tabPage3.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                                   this.label9,
                                                                                   this.label8,
                                                                                   this.gridSuppliers});
            this.tabPage3.Location = new System.Drawing.Point(4, 22);
            this.tabPage3.Name = "tabPage3";
            this.tabPage3.Size = new System.Drawing.Size(552, 350);
            this.tabPage3.TabIndex = 2;
            this.tabPage3.Text = "Special Functions";
            // 
            // label9
            // 
            this.label9.Location = new System.Drawing.Point(16, 14);
            this.label9.Name = "label9";
            this.label9.Size = new System.Drawing.Size(456, 16);
            this.label9.TabIndex = 5;
            this.label9.Text = "Try modifying ContactName and moving to another grid row.";
            // 
            // label8
            // 
            this.label8.Location = new System.Drawing.Point(20, 40);
            this.label8.Name = "label8";
            this.label8.Size = new System.Drawing.Size(484, 16);
            this.label8.TabIndex = 4;
            this.label8.Text = "We use Current and Original functions to check status of Suppliers.ContactName:";
            // 
            // gridSuppliers
            // 
            this.gridSuppliers.AllowFilter = true;
            this.gridSuppliers.AllowRowSizing = C1.Win.C1TrueDBGrid.RowSizingEnum.AllRows;
            this.gridSuppliers.AllowSort = true;
            this.gridSuppliers.CaptionHeight = 17;
            this.gridSuppliers.CollapseColor = System.Drawing.Color.Black;
            this.gridSuppliers.DataChanged = false;
            this.gridSuppliers.DataSource = this.c1DataTableSource1;
            this.gridSuppliers.BackColor = System.Drawing.Color.Empty;
            this.gridSuppliers.ExpandColor = System.Drawing.Color.Black;
            this.gridSuppliers.Images.Add(((System.Drawing.Bitmap)(resources.GetObject("resource.Images4"))));
            this.gridSuppliers.Location = new System.Drawing.Point(16, 64);
            this.gridSuppliers.MarqueeStyle = C1.Win.C1TrueDBGrid.MarqueeEnum.DottedCellBorder;
            this.gridSuppliers.Name = "gridSuppliers";
            this.gridSuppliers.PreviewInfo.Location = new System.Drawing.Point(0, 0);
            this.gridSuppliers.PreviewInfo.Size = new System.Drawing.Size(0, 0);
            this.gridSuppliers.PreviewInfo.ZoomFactor = 75;
            this.gridSuppliers.RecordSelectorWidth = 16;
            this.gridSuppliers.RowHeight = 15;
            this.gridSuppliers.RowSubDividerColor = System.Drawing.Color.DarkGray;
            this.gridSuppliers.ScrollTips = false;
            this.gridSuppliers.Size = new System.Drawing.Size(520, 264);
            this.gridSuppliers.TabIndex = 0;
            this.gridSuppliers.Text = "c1TrueDBGrid5";
            this.gridSuppliers.PropBag = ((string)(resources.GetObject("gridSuppliers.PropBag")));
            // 
            // c1DataTableSource1
            // 
            this.c1DataTableSource1.BindingContextCtrl = this;
            this.c1DataTableSource1.DataSet = this.c1DataSet1;
            this.c1DataTableSource1.TableView = "Suppliers";
            this.c1DataTableSource1.AfterEndEdit += new C1.Data.RowChangeEventHandler(this.c1DataTableSource1_AfterEndEdit);
            // 
            // btnRefresh
            // 
            this.btnRefresh.Location = new System.Drawing.Point(402, 392);
            this.btnRefresh.Name = "btnRefresh";
            this.btnRefresh.Size = new System.Drawing.Size(81, 23);
            this.btnRefresh.TabIndex = 1;
            this.btnRefresh.Text = "Refresh";
            this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click);
            // 
            // btnClose
            // 
            this.btnClose.Location = new System.Drawing.Point(492, 392);
            this.btnClose.Name = "btnClose";
            this.btnClose.TabIndex = 2;
            this.btnClose.Text = "Close";
            this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
            // 
            // MainForm
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
            this.ClientSize = new System.Drawing.Size(574, 423);
            this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                          this.btnClose,
                                                                          this.btnRefresh,
                                                                          this.tabControl1});
            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.MaximizeBox = false;
            this.Name = "MainForm";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Calculations";
            ((System.ComponentModel.ISupportInitialize)(this.c1DataSet1)).EndInit();
            this.tabControl1.ResumeLayout(false);
            this.tabPage1.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.gridProducts)).EndInit();
            this.tabPage2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.gridOrderDetails)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.gridOrders)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.gridCustomers)).EndInit();
            this.tabPage3.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.gridSuppliers)).EndInit();
            this.ResumeLayout(false);

        }
        #endregion

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }

        private void btnClose_Click(object sender, System.EventArgs e)
        {
            Close();
        }

        private void btnRefresh_Click(object sender, System.EventArgs e)
        {
            c1DataSet1.Fill();
        }

        private void c1DataTableSource1_AfterEndEdit(object sender, C1.Data.RowChangeEventArgs e)
        {
            e.Row.Refresh();
        }
    }
}
