using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Ajans
{
    public partial class Form5 : Form
    {
        String StrConn;
        String StrQury;
        public Form5()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (CodeMosafer.Text != "")
            {

                SqlDataAdapter myDA;
                DataSet myDS;

                StrConn = "SERVER=.;DATABASE=Havapeyma;Integrated Security=True";
                StrQury = "Select * From Mosafer Where CodeMosafer='" + CodeMosafer.Text + "'";
                myDA = new SqlDataAdapter(StrQury, StrConn);

                myDS = new DataSet();

                myDA.Fill(myDS, "Mosafer");

                this.dataGridView1.DataSource = myDS;
                this.dataGridView1.DataMember = "Mosafer";
                this.dataGridView1.AutoGenerateColumns = true;
                this.dataGridView1.RightToLeft = RightToLeft.Yes;
                this.dataGridView1.Refresh();

                myDA.Dispose();
                myDS.Dispose();
            }
        }

        private void Form5_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'havapeymaDataSet2.Mosafer' table. You can move, or remove it, as needed.
            this.mosaferTableAdapter.Fill(this.havapeymaDataSet2.Mosafer);

        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "" && textBox2.Text!="")
            {

                SqlDataAdapter myDA;
                DataSet myDS;

                StrConn = "SERVER=.;DATABASE=Havapeyma;Integrated Security=True";
                StrQury = "Select * From Mosafer Where Name='" + textBox1.Text  + "'";
                StrQury += " And Family='" + textBox2.Text + "'";
                myDA = new SqlDataAdapter(StrQury, StrConn);

                myDS = new DataSet();

                myDA.Fill(myDS, "Mosafer");

                this.dataGridView1.DataSource = myDS;
                this.dataGridView1.DataMember = "Mosafer";
                this.dataGridView1.AutoGenerateColumns = true;
                this.dataGridView1.RightToLeft = RightToLeft.Yes;
                this.dataGridView1.Refresh();

                myDA.Dispose();
                myDS.Dispose();
            }
        }
    }
}
