All pastes #548571 Raw Edit

Mine

public text v1 · immutable
·published 2007-06-07 19:40 UTC
rendered paste body
#region Using directives

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

#endregion

namespace Yops.Mobile.UI.Forms
{
    /// <summary>
    /// Summary description for Order.
    /// </summary>
    public class Order : System.Windows.Forms.Form
    {
        private int index;
        private MenuItem menuItem1;
        private MenuItem menuItem2;
        private Panel panel1;
        /// <summary>
        /// Main menu for the form.
        /// </summary>
        private System.Windows.Forms.MainMenu mainMenu1;

        public Order()
        {
            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.mainMenu1 = new System.Windows.Forms.MainMenu();
            this.menuItem1 = new System.Windows.Forms.MenuItem();
            this.menuItem2 = new System.Windows.Forms.MenuItem();
            this.panel1 = new System.Windows.Forms.Panel();
            // 
            // mainMenu1
            // 
            this.mainMenu1.MenuItems.Add(this.menuItem1);
            this.mainMenu1.MenuItems.Add(this.menuItem2);
            // 
            // menuItem1
            // 
            this.menuItem1.Text = "Confirm";
            this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
            // 
            // menuItem2
            // 
            this.menuItem2.Text = "Cancel";
            this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
            // 
            // panel1
            // 
            this.panel1.Location = new System.Drawing.Point(3, 3);
            this.panel1.Size = new System.Drawing.Size(170, 174);
            // 
            // Order
            // 
            this.ClientSize = new System.Drawing.Size(176, 180);
            this.Controls.Add(this.panel1);
            this.Menu = this.mainMenu1;
            this.Text = "Order";
            this.Load += new System.EventHandler(this.Order_Load);

        }

        #endregion

        private void menuItem1_Click(object sender, EventArgs e)
        {
            Forms.Confirm Confirm = new Forms.Confirm();
            for (int i = 0; i < this.panel1.Controls.Count -1; i++)
            {
                if (this.panel1.Controls[i] is Classes.TextBox)
                {
                    if (this.panel1.Controls[i].Text != "")
                    {
                        Classes.TextBox objT = (Classes.TextBox)this.panel1.Controls[i];
                        Confirm.Orders.Add(objT.TagString.ToString(), objT.Text.ToString());
                    }
                }
            }

            Confirm.ShowDialog();
        }

        private void menuItem2_Click(object sender, EventArgs e)
        {
            this.Close();
        }


        private void LoadProducts()
        {
            int currentY = 10;
            int heightOfControl = 30;
            int baseX = 10;
            Yops.Web.Service objService = new Yops.Web.Service();
   
            DataSet objDataSet = objService.GetProducts();;
            if (objDataSet.Tables[0].Rows.Count != 0)
            {
                foreach (DataRow objRow in objDataSet.Tables[0].Rows)
                {
                    Classes.Products p = new Classes.Products(baseX, currentY, objRow["ProductName"].ToString(), objRow["ProductID"].ToString());
                    foreach (Control c in p.ControlsToAdd)
                    {
                        this.panel1.Controls.Add(c);
                        if (c is TextBox)
                        {
                            c.GotFocus += new EventHandler(MyEditControl_GotFocus);
                        }
                    }
                    currentY += heightOfControl + 30;
                    this.panel1.Height += heightOfControl + 30;
                }
                index = 1;
                this.panel1.Controls[1].Focus();
            }
            else
            {
                Label objLabel = new Label();
                objLabel.Text = "No products";
                this.panel1.Controls.Add(objLabel);
            }
        }

        private void MyEditControl_GotFocus(object sender, EventArgs e)
        {
            TextBox objT = (TextBox)sender;
            this.panel1.Top = -objT.Location.Y + 30;
        }

        private void Order_Load(object sender, EventArgs e)
        {
    
            this.LoadProducts();
        }
    }
}