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

namespace WindowsApplication1
{
	/// <summary>
	/// Summary description for Form11.
	/// </summary>
	public class Form11 : System.Windows.Forms.Form
	{
        private System.Windows.Forms.DataGrid dataGrid1;
        public TextBox textBox1;
		private System.Windows.Forms.Button button1;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form11()
		{
			//
			// 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.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form11));
            this.dataGrid1 = new System.Windows.Forms.DataGrid();
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.button1 = new System.Windows.Forms.Button();
            ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
            this.SuspendLayout();
            // 
            // dataGrid1
            // 
            this.dataGrid1.AlternatingBackColor = System.Drawing.Color.LightGoldenrodYellow;
            this.dataGrid1.BackColor = System.Drawing.Color.Tan;
            this.dataGrid1.BackgroundColor = System.Drawing.Color.LightGoldenrodYellow;
            this.dataGrid1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.dataGrid1.CaptionBackColor = System.Drawing.Color.LightGoldenrodYellow;
            this.dataGrid1.CaptionFont = new System.Drawing.Font("Microsoft Sans Serif", 8F);
            this.dataGrid1.CaptionForeColor = System.Drawing.Color.DarkSlateBlue;
            this.dataGrid1.DataMember = "";
            this.dataGrid1.FlatMode = true;
            this.dataGrid1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F);
            this.dataGrid1.ForeColor = System.Drawing.Color.DarkSlateBlue;
            this.dataGrid1.GridLineColor = System.Drawing.Color.Peru;
            this.dataGrid1.GridLineStyle = System.Windows.Forms.DataGridLineStyle.None;
            this.dataGrid1.HeaderBackColor = System.Drawing.Color.Maroon;
            this.dataGrid1.HeaderFont = new System.Drawing.Font("Microsoft Sans Serif", 8F);
            this.dataGrid1.HeaderForeColor = System.Drawing.Color.DeepSkyBlue;
            this.dataGrid1.LinkColor = System.Drawing.Color.Maroon;
            this.dataGrid1.Location = new System.Drawing.Point(12, 12);
            this.dataGrid1.Name = "dataGrid1";
            this.dataGrid1.ParentRowsBackColor = System.Drawing.Color.BurlyWood;
            this.dataGrid1.ParentRowsForeColor = System.Drawing.Color.DarkSlateBlue;
            this.dataGrid1.SelectionBackColor = System.Drawing.Color.DarkSlateBlue;
            this.dataGrid1.SelectionForeColor = System.Drawing.Color.GhostWhite;
            this.dataGrid1.Size = new System.Drawing.Size(709, 288);
            this.dataGrid1.TabIndex = 0;
            // 
            // textBox1
            // 
            this.textBox1.Location = new System.Drawing.Point(392, 323);
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(100, 21);
            this.textBox1.TabIndex = 1;
            this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(280, 323);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(75, 23);
            this.button1.TabIndex = 2;
            this.button1.Text = "گزارشگیری";
            this.button1.Click += new System.EventHandler(this.button1_Click);
            // 
            // Form11
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
            this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
            this.ClientSize = new System.Drawing.Size(733, 358);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.textBox1);
            this.Controls.Add(this.dataGrid1);
            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.Name = "Form11";
            this.Text = "گزارشگیری";
            this.Activated += new System.EventHandler(this.Form11_Activated);
            this.Load += new System.EventHandler(this.Form11_Load_1);
            ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

		}
		#endregion

		private void Form11_Load(object sender, System.EventArgs e)
		{
            
            
		}
        Form2 f2 = new Form2();
        Form1 f1 = new Form1();
        public int flag1;
		private void button1_Click(object sender, System.EventArgs e)
		{
			
			
			if (flag1==1)
			{
				f1.con.Open();
                SqlDataAdapter adp1 = new SqlDataAdapter("select name as ' نام کالا' ,codekala as ' کد کالا',number as ' تعداد',factor as 'فاکتور',date1 as ' تاریخ',pricebuy as ' قیمت خرید ',pricesell as ' قیمت فروش ',karmandid as ' شماره کارمند ' from kala ", f1.con);
				DataSet dst1=new DataSet();
				adp1.Fill(dst1,"t1");
				dataGrid1.DataSource=dst1.Tables["t1"];
               flag1 = 0;
			}
            if (flag1 == 2)
			{
				
				f1.con.Open();
                SqlDataAdapter adp2 = new SqlDataAdapter("select codekala as ' کد کالا',numberkala as ' تعداد کالا',datesell as ' تاریخ فروش',typesell as ' نوع فروش',customerid as ' شماره مشتری '  from sell ", f1.con);
				DataSet dst2=new DataSet();
				adp2.Fill(dst2,"t1");
				dataGrid1.DataSource=dst2.Tables["t1"];
                flag1 = 0;
			}
            if (flag1 == 3)
			{
				
				f1.con.Open();
                SqlDataAdapter adp3 = new SqlDataAdapter("select workername as ' نام کارمند' ,workerid as ' کد کارمند',dateinput as ' تاریخ استخدام',address as ' آدرس',tel as ' تلفن',dateburn as ' تاریخ تولد',type as ' جنسیت',numberchild as ' تعداد فرزندان',priceworkerfix as ' حقوق ثابت'  from worker ", f1.con);
				DataSet dst3=new DataSet();
				adp3.Fill(dst3,"t1");
				dataGrid1.DataSource=dst3.Tables["t1"];
                flag1 = 0;
			}
            if (flag1 == 4)
			{
				
				f1.con.Open();
                SqlDataAdapter adp4 = new SqlDataAdapter("select customername as ' نام مشتری' ,customerid as ' کد مشتری',address as ' آدرس',tel as ' تلفن',regular as ' میزان اعتبار'  from customer", f1.con);
				DataSet dst4=new DataSet();
				adp4.Fill(dst4,"t1");
				dataGrid1.DataSource=dst4.Tables["t1"];
                flag1 = 0;
			}
		}
        
        private void Form11_Activated(object sender, EventArgs e)
        {
            switch (flag1)
            {
                case 1:
                    {
                        textBox1.Text = "کالا";
                        break;
                    }
                case 2:
                    {
                        textBox1.Text = "فروش";
                        break;
                    }
                case 3:
                    {
                        textBox1.Text = "کارمند";
                        break;
                    }
                case 4:
                    {
                        textBox1.Text = "مشتری";
                        break;
                    }
            }
        }

        private void Form11_Load_1(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

	}
}
