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

namespace amlakyar
{
    public partial class search : Form
    {
        static SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\amlak.mdf;integrated security=true;User Instance=True");
        SqlDataAdapter da = new SqlDataAdapter("", con);
        DataSet ds = new DataSet();
        public search()
        {
            InitializeComponent();
        }

        private void label4_Click(object sender, EventArgs e)
        {

        }

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

        private void button4_Click(object sender, EventArgs e)
        {
          
        }

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

        private void button1_Click(object sender, EventArgs e)
        {
            
            





        }

        private void button2_Click(object sender, EventArgs e)
        {
            
        }

        private void button5_Click(object sender, EventArgs e)
        {
            
        }

        private void button6_Click(object sender, EventArgs e)
        {
           
        }

        private void button8_Click(object sender, EventArgs e)
        {
           
        }

        private void button9_Click(object sender, EventArgs e)
        {
           
        }

        private void button10_Click(object sender, EventArgs e)
        {
           
        }

        private void dgshow1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void search_Load(object sender, EventArgs e)
        {
           
            da.SelectCommand.CommandText = "select * from forosh order by type";

            da.Fill(ds, "t1");

            dgshow1.DataSource = ds;
            dgshow1.DataMember = "t1";
            dgshow1.Columns[0].HeaderText = "نوع";
            dgshow1.Columns[1].HeaderText = "ملك";
            dgshow1.Columns[2].HeaderText = "تعداد طبقه";
            dgshow1.Columns[3].HeaderText = "قدمت";
            dgshow1.Columns[4].HeaderText = "تعداد واحد";
            dgshow1.Columns[5].HeaderText = "متراژ";
            dgshow1.Columns[6].HeaderText = "آدرس";
            dgshow1.Columns[7].HeaderText = "امکانات";
            dgshow1.Columns[8].HeaderText = "امکانات اضافه";
            dgshow1.Columns[9].HeaderText = "نما";
            dgshow1.Columns[10].HeaderText = "منطقه";
            dgshow1.Columns[11].HeaderText = "تعداد اتاق";
            dgshow1.Columns[12].HeaderText = "قیمت";
            dgshow1.Columns[13].HeaderText = "نام مالک";
            dgshow1.Columns[14].HeaderText = "سقف";
            dgshow1.Columns[15].HeaderText = "شکل زمین";
            dgshow1.Columns[16].HeaderText = "نوع کوچه";
            dgshow1.Columns[17].HeaderText = "وضعیت";


            
            da.SelectCommand.CommandText = "select * from darkhast_kharid order by typemelk";

            da.Fill(ds, "t2");

            dgshow2.DataSource = ds;
            dgshow2.DataMember = "t2";
            dgshow2.Columns[0].HeaderText = "نوع ملک";
            dgshow2.Columns[1].HeaderText = "حدود متراژ";
            dgshow2.Columns[2].HeaderText = "نام خریدار";
            dgshow2.Columns[3].HeaderText = "امکانات";
            dgshow2.Columns[4].HeaderText = "توضیحات اضافه";
            dgshow2.Columns[5].HeaderText = "مبلغ خرید";
            dgshow2.Columns[6].HeaderText = "تعداد اتاق";
            dgshow2.Columns[7].HeaderText = "منطقه";
            dgshow2.Columns[8].HeaderText = "قدمت";



            da.SelectCommand.CommandText = "select * from darkhast_rahn_ejare order by type";

            da.Fill(ds, "t3");

            dgshow3.DataSource = ds;
            dgshow3.DataMember = "t3";
            dgshow3.Columns[0].HeaderText = "نوع درخواست";
            dgshow3.Columns[1].HeaderText = "ملک";
            dgshow3.Columns[2].HeaderText = "درخواست کننده";
            dgshow3.Columns[3].HeaderText = "حداکثر مبلغ رهن";
            dgshow3.Columns[4].HeaderText = "حداکثر مبلغ اجاره";
            dgshow3.Columns[5].HeaderText = "منطقه";
            dgshow3.Columns[6].HeaderText = "تاسیس شغل";
            dgshow3.Columns[7].HeaderText = "تعداد نفرات";
            dgshow3.Columns[8].HeaderText = "حدود متراژ";
            dgshow3.Columns[9].HeaderText = "تعداد اتاق";
            dgshow3.Columns[10].HeaderText = "قدمت";
            dgshow3.Columns[11].HeaderText = "سایر موارد";

            
            


        }

        private void button11_Click(object sender, EventArgs e)
        {
            
        }

        private void button12_Click(object sender, EventArgs e)
        {
           
            
        }

        private void button13_Click(object sender, EventArgs e)
        {
           


        }

        private void button11_Click_1(object sender, EventArgs e)
        {
            ds.Clear();
            da.SelectCommand.CommandText = "select * from forosh order by type";

            da.Fill(ds, "t1");

            dgshow1.DataSource = ds;
            dgshow1.DataMember = "t1";
            dgshow1.Columns[0].HeaderText = "نوع";
            dgshow1.Columns[1].HeaderText = "ملك";
            dgshow1.Columns[2].HeaderText = "تعداد طبقه";
            dgshow1.Columns[3].HeaderText = "قدمت";
            dgshow1.Columns[4].HeaderText = "تعداد واحد";
            dgshow1.Columns[5].HeaderText = "متراژ";
            dgshow1.Columns[6].HeaderText = "آدرس";
            dgshow1.Columns[7].HeaderText = "امکانات";
            dgshow1.Columns[8].HeaderText = "امکانات اضافه";
            dgshow1.Columns[9].HeaderText = "نما";
            dgshow1.Columns[10].HeaderText = "منطقه";
            dgshow1.Columns[11].HeaderText = "تعداد اتاق";
            dgshow1.Columns[12].HeaderText = "قیمت";
            dgshow1.Columns[13].HeaderText = "نام مالک";
            dgshow1.Columns[14].HeaderText = "سقف";
            dgshow1.Columns[15].HeaderText = "شکل زمین";
            dgshow1.Columns[16].HeaderText = "نوع کوچه";
            dgshow1.Columns[17].HeaderText = "وضعیت";
        }

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

        private void button5_Click_1(object sender, EventArgs e)
        {
            string s;
            ds.Clear();
            s = "select * from darkhast_kharid where mablaghkharid between'" + txtazgheymat2.Text + "' and '" + txttagheymat2.Text + "'   ";
            da.SelectCommand.CommandText = s;
            da.Fill(ds, "t2");
            dgshow2.DataSource = ds;
            dgshow2.DataMember = "t2";
        }

        private void button6_Click_1(object sender, EventArgs e)
        {
            string s;
            ds.Clear();
            s = "select * from darkhast_kharid where hododmetraj between'" + txtazmetraj2.Text + "' and '" + txttametraj2.Text + "'   ";
            da.SelectCommand.CommandText = s;
            da.Fill(ds, "t2");
            dgshow2.DataSource = ds;
            dgshow2.DataMember = "t2";
        }

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

        private void Button1_Click_1(object sender, EventArgs e)
        {
            string s;
            ds.Clear();
            s = "select * from forosh where type='" + comtype.Text + "' and price between '" + txtazgheymat.Text + "' and '" + txttagheymat.Text + "'   ";
            da.SelectCommand.CommandText = s;
            da.Fill(ds, "t1");
            dgshow1.DataSource = ds;
            dgshow1.DataMember = "t1";
        }

        private void Button2_Click_1(object sender, EventArgs e)
        {
            string i;
            ds.Clear();
            i = "select * from forosh where type='" + comtype.Text + "' and metraj between '" + txtazmetraj.Text + "' and '" + txttametraj.Text + "'   ";
            da.SelectCommand.CommandText = i;
            da.Fill(ds, "t1");
            dgshow1.DataSource = ds;
            dgshow1.DataMember = "t1";
        }

        private void button12_Click_1(object sender, EventArgs e)
        {
            ds.Clear();
            da.SelectCommand.CommandText = "select * from darkhast_kharid order by typemelk";

            da.Fill(ds, "t2");

            dgshow2.DataSource = ds;
            dgshow2.DataMember = "t2";
            dgshow2.Columns[0].HeaderText = "نوع ملک";
            dgshow2.Columns[1].HeaderText = "حدود متراژ";
            dgshow2.Columns[2].HeaderText = "نام خریدار";
            dgshow2.Columns[3].HeaderText = "امکانات";
            dgshow2.Columns[4].HeaderText = "توضیحات اضافه";
            dgshow2.Columns[5].HeaderText = "مبلغ خرید";
            dgshow2.Columns[6].HeaderText = "تعداد اتاق";
            dgshow2.Columns[7].HeaderText = "منطقه";
            dgshow2.Columns[8].HeaderText = "قدمت";
        }

        private void button13_Click_1(object sender, EventArgs e)
        {
            ds.Clear();
            da.SelectCommand.CommandText = "select * from darkhast_rahn_ejare order by type";

            da.Fill(ds, "t3");

            dgshow3.DataSource = ds;
            dgshow3.DataMember = "t3";
            dgshow3.Columns[0].HeaderText = "نوع درخواست";
            dgshow3.Columns[1].HeaderText = "ملک";
            dgshow3.Columns[2].HeaderText = "درخواست کننده";
            dgshow3.Columns[3].HeaderText = "حداکثر مبلغ رهن";
            dgshow3.Columns[4].HeaderText = "حداکثر مبلغ اجاره";
            dgshow3.Columns[5].HeaderText = "منطقه";
            dgshow3.Columns[6].HeaderText = "تاسیس شغل";
            dgshow3.Columns[7].HeaderText = "تعداد نفرات";
            dgshow3.Columns[8].HeaderText = "حدود متراژ";
            dgshow3.Columns[9].HeaderText = "تعداد اتاق";
            dgshow3.Columns[10].HeaderText = "قدمت";
            dgshow3.Columns[11].HeaderText = "سایر موارد";
        }

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

        private void button8_Click_1(object sender, EventArgs e)
        {
            string p;
            ds.Clear();
            p = "select * from darkhast_rahn_ejare where max_mablagh_ejare between'" + txtazgheymatejare.Text + "' and '" + txttagheymatejare.Text + "'   ";
            da.SelectCommand.CommandText = p;
            da.Fill(ds, "t3");
            dgshow3.DataSource = ds;
            dgshow3.DataMember = "t3";
        }

        private void button9_Click_1(object sender, EventArgs e)
        {
            string p;
            ds.Clear();
            p = "select * from darkhast_rahn_ejare where max_mablagh_rahn between'" + txtazgheymatrahn.Text + "' and '" + txttagheymatrahn.Text + "'   ";
            da.SelectCommand.CommandText = p;
            da.Fill(ds, "t3");
            dgshow3.DataSource = ds;
            dgshow3.DataMember = "t3";
        }

        private void button10_Click_1(object sender, EventArgs e)
        {
            string h;
            ds.Clear();
            h = "select * from darkhast_rahn_ejare where hodod_metraj between'" + txtazmetraj3.Text + "' and '" + txttametraj3.Text + "'   ";
            da.SelectCommand.CommandText = h;
            da.Fill(ds, "t3");
            dgshow3.DataSource = ds;
            dgshow3.DataMember = "t3";
        }

        

       
    }
}