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 Form7.
	/// </summary>
	public class Form7 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.ComboBox comboBox1;
		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.DataGrid dataGrid1;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Panel panel2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.Label label7;
		private System.Windows.Forms.Label label8;
		private System.Windows.Forms.Label label9;
		private System.Windows.Forms.Label label10;
		private System.Windows.Forms.Label label11;
		private System.Windows.Forms.TextBox textBox2;
		private System.Windows.Forms.TextBox textBox3;
		private System.Windows.Forms.TextBox textBox4;
		private System.Windows.Forms.TextBox textBox5;
		private System.Windows.Forms.TextBox textBox6;
		private System.Windows.Forms.TextBox textBox7;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.Button button3;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.Button button4;
        string s1,s2,s3;
		public Form7()
		{
			//
			// 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(Form7));
            this.panel1 = new System.Windows.Forms.Panel();
            this.button4 = new System.Windows.Forms.Button();
            this.button3 = new System.Windows.Forms.Button();
            this.panel2 = new System.Windows.Forms.Panel();
            this.button2 = new System.Windows.Forms.Button();
            this.textBox7 = new System.Windows.Forms.TextBox();
            this.textBox6 = new System.Windows.Forms.TextBox();
            this.textBox5 = new System.Windows.Forms.TextBox();
            this.textBox4 = new System.Windows.Forms.TextBox();
            this.textBox3 = new System.Windows.Forms.TextBox();
            this.textBox2 = new System.Windows.Forms.TextBox();
            this.label8 = new System.Windows.Forms.Label();
            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.label3 = new System.Windows.Forms.Label();
            this.label9 = new System.Windows.Forms.Label();
            this.label10 = new System.Windows.Forms.Label();
            this.label11 = new System.Windows.Forms.Label();
            this.button1 = new System.Windows.Forms.Button();
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.comboBox1 = new System.Windows.Forms.ComboBox();
            this.label2 = new System.Windows.Forms.Label();
            this.label1 = new System.Windows.Forms.Label();
            this.dataGrid1 = new System.Windows.Forms.DataGrid();
            this.panel1.SuspendLayout();
            this.panel2.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
            this.SuspendLayout();
            // 
            // panel1
            // 
            this.panel1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panel1.BackgroundImage")));
            this.panel1.Controls.Add(this.button4);
            this.panel1.Controls.Add(this.button3);
            this.panel1.Controls.Add(this.panel2);
            this.panel1.Controls.Add(this.button1);
            this.panel1.Controls.Add(this.textBox1);
            this.panel1.Controls.Add(this.comboBox1);
            this.panel1.Controls.Add(this.label2);
            this.panel1.Controls.Add(this.label1);
            this.panel1.Controls.Add(this.dataGrid1);
            this.panel1.Location = new System.Drawing.Point(0, 0);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(672, 344);
            this.panel1.TabIndex = 0;
            // 
            // button4
            // 
            this.button4.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button4.Location = new System.Drawing.Point(488, 38);
            this.button4.Name = "button4";
            this.button4.Size = new System.Drawing.Size(75, 23);
            this.button4.TabIndex = 8;
            this.button4.Text = "جستجو";
            this.button4.Click += new System.EventHandler(this.button4_Click);
            // 
            // button3
            // 
            this.button3.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.button3.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button3.Location = new System.Drawing.Point(357, 168);
            this.button3.Name = "button3";
            this.button3.Size = new System.Drawing.Size(75, 23);
            this.button3.TabIndex = 7;
            this.button3.Text = "خروج";
            this.button3.Click += new System.EventHandler(this.button3_Click);
            // 
            // panel2
            // 
            this.panel2.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panel2.BackgroundImage")));
            this.panel2.Controls.Add(this.button2);
            this.panel2.Controls.Add(this.textBox7);
            this.panel2.Controls.Add(this.textBox6);
            this.panel2.Controls.Add(this.textBox5);
            this.panel2.Controls.Add(this.textBox4);
            this.panel2.Controls.Add(this.textBox3);
            this.panel2.Controls.Add(this.textBox2);
            this.panel2.Controls.Add(this.label8);
            this.panel2.Controls.Add(this.label7);
            this.panel2.Controls.Add(this.label6);
            this.panel2.Controls.Add(this.label5);
            this.panel2.Controls.Add(this.label4);
            this.panel2.Controls.Add(this.label3);
            this.panel2.Controls.Add(this.label9);
            this.panel2.Controls.Add(this.label10);
            this.panel2.Controls.Add(this.label11);
            this.panel2.Location = new System.Drawing.Point(12, 200);
            this.panel2.Name = "panel2";
            this.panel2.Size = new System.Drawing.Size(646, 136);
            this.panel2.TabIndex = 6;
            // 
            // button2
            // 
            this.button2.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.button2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button2.Location = new System.Drawing.Point(261, 110);
            this.button2.Name = "button2";
            this.button2.Size = new System.Drawing.Size(75, 23);
            this.button2.TabIndex = 12;
            this.button2.Text = "به روز رسانی";
            this.button2.Click += new System.EventHandler(this.button2_Click);
            // 
            // textBox7
            // 
            this.textBox7.Location = new System.Drawing.Point(109, 78);
            this.textBox7.Name = "textBox7";
            this.textBox7.Size = new System.Drawing.Size(100, 20);
            this.textBox7.TabIndex = 11;
            // 
            // textBox6
            // 
            this.textBox6.Location = new System.Drawing.Point(109, 46);
            this.textBox6.Name = "textBox6";
            this.textBox6.Size = new System.Drawing.Size(100, 20);
            this.textBox6.TabIndex = 10;
            // 
            // textBox5
            // 
            this.textBox5.Location = new System.Drawing.Point(109, 14);
            this.textBox5.Name = "textBox5";
            this.textBox5.Size = new System.Drawing.Size(100, 20);
            this.textBox5.TabIndex = 9;
            // 
            // textBox4
            // 
            this.textBox4.Location = new System.Drawing.Point(309, 78);
            this.textBox4.Name = "textBox4";
            this.textBox4.Size = new System.Drawing.Size(100, 20);
            this.textBox4.TabIndex = 8;
            // 
            // textBox3
            // 
            this.textBox3.Location = new System.Drawing.Point(309, 46);
            this.textBox3.Name = "textBox3";
            this.textBox3.Size = new System.Drawing.Size(100, 20);
            this.textBox3.TabIndex = 7;
            // 
            // textBox2
            // 
            this.textBox2.Location = new System.Drawing.Point(309, 14);
            this.textBox2.Name = "textBox2";
            this.textBox2.Size = new System.Drawing.Size(100, 20);
            this.textBox2.TabIndex = 6;
            // 
            // label8
            // 
            this.label8.Font = new System.Drawing.Font("Tahoma", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label8.Image = ((System.Drawing.Image)(resources.GetObject("label8.Image")));
            this.label8.Location = new System.Drawing.Point(213, 78);
            this.label8.Name = "label8";
            this.label8.Size = new System.Drawing.Size(100, 23);
            this.label8.TabIndex = 5;
            this.label8.Text = "قیمت فروش";
            this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // label7
            // 
            this.label7.Font = new System.Drawing.Font("Tahoma", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label7.Image = ((System.Drawing.Image)(resources.GetObject("label7.Image")));
            this.label7.Location = new System.Drawing.Point(213, 46);
            this.label7.Name = "label7";
            this.label7.Size = new System.Drawing.Size(100, 23);
            this.label7.TabIndex = 4;
            this.label7.Text = "قیمت خرید";
            this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // label6
            // 
            this.label6.Font = new System.Drawing.Font("Tahoma", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label6.Image = ((System.Drawing.Image)(resources.GetObject("label6.Image")));
            this.label6.Location = new System.Drawing.Point(213, 14);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(100, 23);
            this.label6.TabIndex = 3;
            this.label6.Text = "تاریخ خرید";
            this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // label5
            // 
            this.label5.Font = new System.Drawing.Font("Tahoma", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label5.Image = ((System.Drawing.Image)(resources.GetObject("label5.Image")));
            this.label5.Location = new System.Drawing.Point(413, 78);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(120, 23);
            this.label5.TabIndex = 2;
            this.label5.Text = "کارخانه سازنده";
            this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // label4
            // 
            this.label4.Font = new System.Drawing.Font("Tahoma", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label4.Image = ((System.Drawing.Image)(resources.GetObject("label4.Image")));
            this.label4.Location = new System.Drawing.Point(413, 46);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(120, 23);
            this.label4.TabIndex = 1;
            this.label4.Text = "تعداد کالا";
            this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // label3
            // 
            this.label3.Font = new System.Drawing.Font("Tahoma", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label3.Image = ((System.Drawing.Image)(resources.GetObject("label3.Image")));
            this.label3.Location = new System.Drawing.Point(413, 14);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(120, 23);
            this.label3.TabIndex = 0;
            this.label3.Text = "نام کالا";
            this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // label9
            // 
            this.label9.Font = new System.Drawing.Font("Tahoma", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label9.Location = new System.Drawing.Point(213, 78);
            this.label9.Name = "label9";
            this.label9.Size = new System.Drawing.Size(100, 23);
            this.label9.TabIndex = 5;
            this.label9.Text = "label8";
            this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // label10
            // 
            this.label10.Font = new System.Drawing.Font("Tahoma", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label10.Location = new System.Drawing.Point(213, 46);
            this.label10.Name = "label10";
            this.label10.Size = new System.Drawing.Size(100, 23);
            this.label10.TabIndex = 4;
            this.label10.Text = "label7";
            this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // label11
            // 
            this.label11.Font = new System.Drawing.Font("Tahoma", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label11.Location = new System.Drawing.Point(213, 14);
            this.label11.Name = "label11";
            this.label11.Size = new System.Drawing.Size(100, 23);
            this.label11.TabIndex = 3;
            this.label11.Text = "label6";
            this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // button1
            // 
            this.button1.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.button1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button1.Location = new System.Drawing.Point(245, 168);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(75, 23);
            this.button1.TabIndex = 5;
            this.button1.Text = "حذف";
            this.button1.Click += new System.EventHandler(this.button1_Click);
            // 
            // textBox1
            // 
            this.textBox1.Location = new System.Drawing.Point(192, 54);
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(104, 20);
            this.textBox1.TabIndex = 3;
            this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
            // 
            // comboBox1
            // 
            this.comboBox1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.comboBox1.Items.AddRange(new object[] {
            "نام کالا",
            "کد کالا",
            "تعداد کالا",
            "کارخانه سازنده",
            "تاریخ خرید",
            "قیمت خرید",
            "قیمت فروش",
            "شماره کارمند"});
            this.comboBox1.Location = new System.Drawing.Point(192, 22);
            this.comboBox1.Name = "comboBox1";
            this.comboBox1.Size = new System.Drawing.Size(104, 21);
            this.comboBox1.TabIndex = 2;
            this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
            // 
            // label2
            // 
            this.label2.Font = new System.Drawing.Font("Tahoma", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label2.Image = ((System.Drawing.Image)(resources.GetObject("label2.Image")));
            this.label2.Location = new System.Drawing.Point(320, 54);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(144, 23);
            this.label2.TabIndex = 1;
            this.label2.Text = "با مقدار";
            this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // label1
            // 
            this.label1.Font = new System.Drawing.Font("Tahoma", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label1.Image = ((System.Drawing.Image)(resources.GetObject("label1.Image")));
            this.label1.Location = new System.Drawing.Point(302, 22);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(162, 23);
            this.label1.TabIndex = 0;
            this.label1.Text = "جستوجو بر حسب";
            this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // dataGrid1
            // 
            this.dataGrid1.AlternatingBackColor = System.Drawing.Color.GhostWhite;
            this.dataGrid1.BackColor = System.Drawing.Color.GhostWhite;
            this.dataGrid1.BackgroundColor = System.Drawing.Color.Lavender;
            this.dataGrid1.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.dataGrid1.CaptionBackColor = System.Drawing.Color.RoyalBlue;
            this.dataGrid1.CaptionFont = new System.Drawing.Font("Microsoft Sans Serif", 8F);
            this.dataGrid1.CaptionForeColor = System.Drawing.Color.White;
            this.dataGrid1.DataMember = "";
            this.dataGrid1.FlatMode = true;
            this.dataGrid1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F);
            this.dataGrid1.ForeColor = System.Drawing.Color.MidnightBlue;
            this.dataGrid1.GridLineColor = System.Drawing.Color.RoyalBlue;
            this.dataGrid1.HeaderBackColor = System.Drawing.Color.MidnightBlue;
            this.dataGrid1.HeaderFont = new System.Drawing.Font("Microsoft Sans Serif", 8F);
            this.dataGrid1.HeaderForeColor = System.Drawing.Color.Lavender;
            this.dataGrid1.LinkColor = System.Drawing.Color.Teal;
            this.dataGrid1.Location = new System.Drawing.Point(8, 80);
            this.dataGrid1.Name = "dataGrid1";
            this.dataGrid1.ParentRowsBackColor = System.Drawing.Color.Lavender;
            this.dataGrid1.ParentRowsForeColor = System.Drawing.Color.MidnightBlue;
            this.dataGrid1.SelectionBackColor = System.Drawing.Color.Teal;
            this.dataGrid1.SelectionForeColor = System.Drawing.Color.PaleGreen;
            this.dataGrid1.Size = new System.Drawing.Size(661, 80);
            this.dataGrid1.TabIndex = 4;
            // 
            // Form7
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(670, 342);
            this.Controls.Add(this.panel1);
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.Name = "Form7";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "جستوجو کالا";
            this.panel1.ResumeLayout(false);
            this.panel1.PerformLayout();
            this.panel2.ResumeLayout(false);
            this.panel2.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
            this.ResumeLayout(false);

		}
		#endregion

		private void button3_Click(object sender, System.EventArgs e)
		{
			Close();
		}
        Form1 f1 = new Form1();
		private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			
		}

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

		private void button4_Click(object sender, System.EventArgs e)
		{
			
			
			if (comboBox1.SelectedIndex==0)
                s1 = "select name as ' نام کالا' ,codekala as ' کد کالا',number as ' تعداد',factor as 'فاکتور',date1 as ' تاریخ',pricebuy as ' قیمت خرید ',pricesell as ' قیمت فروش ',karmandid as ' شماره کارمند '  from kala where name='" + textBox1.Text + "'";
			if (comboBox1.SelectedIndex==1)
                s1 = "select name as ' نام کالا' ,codekala as ' کد کالا',number as ' تعداد',factor as 'فاکتور',date1 as ' تاریخ',pricebuy as ' قیمت خرید ',pricesell as ' قیمت فروش ',karmandid as ' شماره کارمند '  from kala where codekala='" + textBox1.Text + "'";
			if (comboBox1.SelectedIndex==2)
                s1 = "select name as ' نام کالا' ,codekala as ' کد کالا',number as ' تعداد',factor as 'فاکتور',date1 as ' تاریخ',pricebuy as ' قیمت خرید ',pricesell as ' قیمت فروش ',karmandid as ' شماره کارمند '  from kala where number='" + textBox1.Text + "'";
			if (comboBox1.SelectedIndex==3)
                s1 = "select name as ' نام کالا' ,codekala as ' کد کالا',number as ' تعداد',factor as 'فاکتور',date1 as ' تاریخ',pricebuy as ' قیمت خرید ',pricesell as ' قیمت فروش ',karmandid as ' شماره کارمند '  from kala where factor='" + textBox1.Text + "'";
			if (comboBox1.SelectedIndex==4)
                s1 = "select name as ' نام کالا' ,codekala as ' کد کالا',number as ' تعداد',factor as 'فاکتور',date1 as ' تاریخ',pricebuy as ' قیمت خرید ',pricesell as ' قیمت فروش ',karmandid as ' شماره کارمند '  from kala where date1='" + textBox1.Text + "'";
			if (comboBox1.SelectedIndex==5)
                s1 = "select name as ' نام کالا' ,codekala as ' کد کالا',number as ' تعداد',factor as 'فاکتور',date1 as ' تاریخ',pricebuy as ' قیمت خرید ',pricesell as ' قیمت فروش ',karmandid as ' شماره کارمند '  from kala where pricebuy='" + textBox1.Text + "'";
			if (comboBox1.SelectedIndex==6)
                s1 = "select name as ' نام کالا' ,codekala as ' کد کالا',number as ' تعداد',factor as 'فاکتور',date1 as ' تاریخ',pricebuy as ' قیمت خرید ',pricesell as ' قیمت فروش ',karmandid as ' شماره کارمند '  from kala where pricesell='" + textBox1.Text + "'";
			if (comboBox1.SelectedIndex==7)
                s1 = "select name as ' نام کالا' ,codekala as ' کد کالا',number as ' تعداد',factor as 'فاکتور',date1 as ' تاریخ',pricebuy as ' قیمت خرید ',pricesell as ' قیمت فروش ',karmandid as ' شماره کارمند '  from kala where karmandid='" + textBox1.Text + "'";
			f1.con.Open();
            SqlDataAdapter adp = new SqlDataAdapter(s1, f1.con);
			DataSet dst=new DataSet();
			adp.Fill(dst,"a1");
			dataGrid1.DataSource=dst.Tables["a1"];
			f1.con.Close();
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			
			
			if (comboBox1.SelectedIndex==0)
				s2="delete from kala where name='"+textBox1.Text+"'";
			if (comboBox1.SelectedIndex==1)
				s2="delete from kala where codekala='"+textBox1.Text+"'";
			if (comboBox1.SelectedIndex==2)
				s2="delete from kala where number='"+textBox1.Text+"'";
			if (comboBox1.SelectedIndex==3)
				s2="delete from kala where factor='"+textBox1.Text+"'";
			if (comboBox1.SelectedIndex==4)
				s2="delete from kala where date1='"+textBox1.Text+"'";
			if (comboBox1.SelectedIndex==5)
				s2="delete from kala where pricebuy='"+textBox1.Text+"'";
			if (comboBox1.SelectedIndex==6)
				s2="delete from kala where pricesell='"+textBox1.Text+"'";
			if (comboBox1.SelectedIndex==7)
				s2="delete from kala where karmandid='"+textBox1.Text+"'";
			f1.con.Open();
            SqlCommand com = new SqlCommand(s2, f1.con);
			com.ExecuteNonQuery();
            SqlDataAdapter adp = new SqlDataAdapter(s1, f1.con);
            DataSet dst = new DataSet();
            adp.Fill(dst, "a1");
            dataGrid1.DataSource = dst.Tables["a1"];
			f1.con.Close();
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			
			if (comboBox1.SelectedIndex==0)
			s3="update kala set name=@a1,number=@a2,factor=@a3,date1=@a4,pricebuy=@a5,pricesell=@a6 where name='"+textBox1.Text+"'";
			if (comboBox1.SelectedIndex==1)
				s3="update kala set name=@a1,number=@a2,factor=@a3,date1=@a4,pricebuy=@a5,pricesell=@a6 where codekala='"+textBox1.Text+"'";
			if (comboBox1.SelectedIndex==2)
				s3="update kala set name=@a1,number=@a2,factor=@a3,date1=@a4,pricebuy=@a5,pricesell=@a6 where number='"+textBox1.Text+"'";
			if (comboBox1.SelectedIndex==3)
				s3="update kala set name=@a1,number=@a2,factor=@a3,date1=@a4,pricebuy=@a5,pricesell=@a6 where factor='"+textBox1.Text+"'";
			if (comboBox1.SelectedIndex==4)
				s3="update kala set name=@a1,number=@a2,factor=@a3,date1=@a4,pricebuy=@a5,pricesell=@a6 where date1='"+textBox1.Text+"'";
			if (comboBox1.SelectedIndex==5)
				s3="update kala set name=@a1,number=@a2,factor=@a3,date1=@a4,pricebuy=@a5,pricesell=@a6 where pricebuy='"+textBox1.Text+"'";
			if (comboBox1.SelectedIndex==6)
				s3="update kala set name=@a1,number=@a2,factor=@a3,date1=@a4,pricebuy=@a5,pricesell=@a6 where pricesell='"+textBox1.Text+"'";
			if (comboBox1.SelectedIndex==7)
				s3="update kala set name=@a1,number=@a2,factor=@a3,date1=@a4,pricebuy=@a5,pricesell=@a6 where karmandid='"+textBox1.Text+"'";
            if ( (textBox2.Text != "") && (textBox3.Text != "") && (textBox4.Text != "") && (textBox5.Text != "") && (textBox6.Text != "") && (textBox7.Text != "") )
            {
                f1.con.Open();
                SqlCommand com = new SqlCommand(s3, f1.con);
                com.Parameters.AddWithValue("@a1", textBox2.Text);
                com.Parameters.AddWithValue("@a2", Convert.ToInt32(textBox3.Text));
                com.Parameters.AddWithValue("@a3", textBox4.Text);
                com.Parameters.AddWithValue("@a4", Convert.ToDateTime(textBox5.Text));
                com.Parameters.AddWithValue("@a5", Convert.ToInt32(textBox6.Text));
                com.Parameters.AddWithValue("@a6", Convert.ToInt32(textBox7.Text));
                com.ExecuteNonQuery();
                textBox2.Text = "";
                textBox3.Text = "";
                textBox4.Text = "";
                textBox5.Text = "";
                textBox6.Text = "";                            
                textBox7.Text = "";
                f1.con.Close();
            }
            else
            {
                DialogResult msg3;
                msg3 = MessageBox.Show(".اطلاعات را کامل وارد کنید", "اشکال", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
		}
	}
}
