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;
		private System.Windows.Forms.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.Resources.ResourceManager resources = new System.Resources.ResourceManager(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(32, 24);
			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(456, 288);
			this.dataGrid1.TabIndex = 0;
			// 
			// textBox1
			// 
			this.textBox1.Location = new System.Drawing.Point(232, 328);
			this.textBox1.Name = "textBox1";
			this.textBox1.TabIndex = 1;
			this.textBox1.Text = "textBox1";
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(120, 328);
			this.button1.Name = "button1";
			this.button1.TabIndex = 2;
			this.button1.Text = "button1";
			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(528, 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, ((System.Byte)(0)));
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Name = "Form11";
			this.Text = "گزارشگیری";
			this.Load += new System.EventHandler(this.Form11_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void Form11_Load(object sender, System.EventArgs e)
		{
		
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			SqlConnection con=new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=abzar;Data Source=MAHDI-59CA33515\\WINCC");
			textBox1.Text=Convert.ToString(Form2.flag1);
			if (Form2.flag1==1)
			{
				con.Open();
				SqlDataAdapter adp1=new SqlDataAdapter("select * from kala ",con);
				DataSet dst1=new DataSet();
				adp1.Fill(dst1,"t1");
				dataGrid1.DataSource=dst1.Tables["t1"];
				Form2.flag1=0;
			}
			if (Form2.flag1==2)
			{
				
				con.Open();
				SqlDataAdapter adp2=new SqlDataAdapter("select * from sell ",con);
				DataSet dst2=new DataSet();
				adp2.Fill(dst2,"t1");
				dataGrid1.DataSource=dst2.Tables["t1"];
				Form2.flag1=0;
			}
			if (Form2.flag1==3)
			{
				
				con.Open();
				SqlDataAdapter adp3=new SqlDataAdapter("select * from worker ",con);
				DataSet dst3=new DataSet();
				adp3.Fill(dst3,"t1");
				dataGrid1.DataSource=dst3.Tables["t1"];
				Form2.flag1=0;
			}
			if (Form2.flag1==4)
			{
				
				con.Open();
				SqlDataAdapter adp4=new SqlDataAdapter("select * from customer",con);
				DataSet dst4=new DataSet();
				adp4.Fill(dst4,"t1");
				dataGrid1.DataSource=dst4.Tables["t1"];
				Form2.flag1=0;
			}
		}

	}
}
