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

namespace amlakyar
{
    public partial class frmgozaresh_gholname_forush : 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 frmgozaresh_gholname_forush()
        {
            InitializeComponent();
        }

        
        private void frmgozaresh_gholname_forush_Load(object sender, EventArgs e)
        {
            da.SelectCommand.CommandText = "select name_family_fo,father_name_fo,tarikh_tavalod_fo,sn_shenasname_fo,sadere_fo,tel_fo,address_fo from gholname_forush order by name_family_fo";

            da.Fill(ds, "t1");

            dggholname1.DataSource = ds;
            dggholname1.DataMember = "t1";
            dggholname1.Columns[0].HeaderText = "نام و نام خانوادگی";
            dggholname1.Columns[1].HeaderText = "نام پدر";
            dggholname1.Columns[2].HeaderText = "تاریخ تولد";
            dggholname1.Columns[3].HeaderText = "شماره شناسنامه";
            dggholname1.Columns[4].HeaderText = "صادره از";
            dggholname1.Columns[5].HeaderText = "تلفن تماس";
            dggholname1.Columns[6].HeaderText = "آدرس";




            da.SelectCommand.CommandText = "select name_family_kh,father_name_kh,tarikh_tavalod_kh,sn_shenasname_kh,sadere_kh,tel_kh,address_kh  from gholname_forush order by name_family_kh";

            da.Fill(ds, "t2");

            dggholname2.DataSource = ds;
            dggholname2.DataMember = "t2";
            dggholname2.Columns[0].HeaderText = "نام و نام خانوادگی";
            dggholname2.Columns[1].HeaderText = "نام پدر";
            dggholname2.Columns[2].HeaderText = "تاریخ تولد";
            dggholname2.Columns[3].HeaderText = "شماره شناسنامه";
            dggholname2.Columns[4].HeaderText = "صادره از";
            dggholname2.Columns[5].HeaderText = "تلفن تماس";
            dggholname2.Columns[6].HeaderText = "آدرس";




            da.SelectCommand.CommandText = "select masahat_mo,sn_shenasname_melk_mo,sn_sabt_sanad_mo,tel_melk_mo,address_mo,tozihat_mo,price_melk_mo,tarikh_sabt_sanad_mo  from gholname_forush order by masahat_mo";

            da.Fill(ds, "t3");

            dggholname3.DataSource = ds;
            dggholname3.DataMember = "t3";
            dggholname3.Columns[0].HeaderText = "مساحت";
            dggholname3.Columns[1].HeaderText = "شماره شناسنامه ملک";
            dggholname3.Columns[2].HeaderText = "شماره ثبت سند";
            dggholname3.Columns[3].HeaderText = "شماره تلفن ملک";
            dggholname3.Columns[4].HeaderText = "آدرس";
            dggholname3.Columns[5].HeaderText = "توضیحات";
            dggholname3.Columns[6].HeaderText = "قیمت ملک";
            dggholname3.Columns[7].HeaderText = "تاریخ ثبت سند";





            da.SelectCommand.CommandText = "select * from gholname_forush order by name_family_fo";

            da.Fill(ds, "t4");

            dggholname4.DataSource = ds;
            dggholname4.DataMember = "t4";
            dggholname4.Columns[0].HeaderText = "نام و نام خانوادگی";
            dggholname4.Columns[1].HeaderText = "نام پدر";
            dggholname4.Columns[2].HeaderText = "تاریخ تولد";
            dggholname4.Columns[3].HeaderText = "شماره شناسنامه";
            dggholname4.Columns[4].HeaderText = "صادره از";
            dggholname4.Columns[5].HeaderText = "تلفن تماس";
            dggholname4.Columns[6].HeaderText = "آدرس";
            dggholname4.Columns[7].HeaderText = "نام و نام خانوادگی";
            dggholname4.Columns[8].HeaderText = "نام پدر";
            dggholname4.Columns[9].HeaderText = "تاریخ تولد";
            dggholname4.Columns[10].HeaderText = "شماره شناسنامه";
            dggholname4.Columns[11].HeaderText = "صادره از";
            dggholname4.Columns[12].HeaderText = "تلفن تماس";
            dggholname4.Columns[13].HeaderText = "آدرس";
            dggholname4.Columns[14].HeaderText = "مساحت";
            dggholname4.Columns[15].HeaderText = "شماره شناسنامه ملک";
            dggholname4.Columns[16].HeaderText = "شماره ثبت سند";
            dggholname4.Columns[17].HeaderText = "شماره تلفن ملک";
            dggholname4.Columns[18].HeaderText = "آدرس";
            dggholname4.Columns[19].HeaderText = "توضیحات";
            dggholname4.Columns[20].HeaderText = "قیمت ملک";
            dggholname4.Columns[21].HeaderText = "تاریخ ثبت سند";

            

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

        private void Button1_Click_1(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            DataGridViewPrinter.DGVPrinter printer = new DataGridViewPrinter.DGVPrinter();
            printer.CellAlignment = StringAlignment.Center;
            printer.CellFormatFlags = StringFormatFlags.DirectionRightToLeft;

            printer.HeaderCellAlignment = StringAlignment.Center;
            printer.HeaderCellFormatFlags = StringFormatFlags.DirectionRightToLeft;
            printer.PageNumberAlignment = StringAlignment.Near;
            printer.PageNumberInHeader = true;
            printer.PageNumberOnSeparateLine = true;
            printer.PageNumbers = true;
            printer.PorportionalColumns = true;

            printer.Title = "قولنامه فروش فروشنده";
            printer.TitleAlignment = StringAlignment.Center;
            printer.TitleColor = Color.Blue;
            printer.TitleFont = new Font("Arial", 14);
            printer.TitleFormatFlags = StringFormatFlags.DirectionRightToLeft;

            printer.SubTitle = " ";
            printer.SubTitleAlignment = StringAlignment.Center;
            printer.SubTitleColor = Color.Blue;
            printer.SubTitleFont = new Font("Arial", 14);
            printer.SubTitleFormatFlags = StringFormatFlags.DirectionRightToLeft;

            //printer.Footer = "Footer";
            //printer.FooterAlignment = StringAlignment.Center;
            //printer.FooterColor = Color.Blue;
            //printer.FooterFont = new Font("Arial", 14);
            //printer.FooterFormatFlags = StringFormatFlags.DirectionRightToLeft;
            //printer.FooterSpacing = 10;

            printer.PrintPreviewDataGridView(dggholname1);

            this.Cursor = Cursors.Default;
        }

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

        private void button3_Click_1(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            DataGridViewPrinter.DGVPrinter printer = new DataGridViewPrinter.DGVPrinter();
            printer.CellAlignment = StringAlignment.Center;
            printer.CellFormatFlags = StringFormatFlags.DirectionRightToLeft;

            printer.HeaderCellAlignment = StringAlignment.Center;
            printer.HeaderCellFormatFlags = StringFormatFlags.DirectionRightToLeft;
            printer.PageNumberAlignment = StringAlignment.Near;
            printer.PageNumberInHeader = true;
            printer.PageNumberOnSeparateLine = true;
            printer.PageNumbers = true;
            printer.PorportionalColumns = true;

            printer.Title = "قولنامه فروش خریدار";
            printer.TitleAlignment = StringAlignment.Center;
            printer.TitleColor = Color.Blue;
            printer.TitleFont = new Font("Arial", 14);
            printer.TitleFormatFlags = StringFormatFlags.DirectionRightToLeft;

            printer.SubTitle = " ";
            printer.SubTitleAlignment = StringAlignment.Center;
            printer.SubTitleColor = Color.Blue;
            printer.SubTitleFont = new Font("Arial", 14);
            printer.SubTitleFormatFlags = StringFormatFlags.DirectionRightToLeft;

            //printer.Footer = "Footer";
            //printer.FooterAlignment = StringAlignment.Center;
            //printer.FooterColor = Color.Blue;
            //printer.FooterFont = new Font("Arial", 14);
            //printer.FooterFormatFlags = StringFormatFlags.DirectionRightToLeft;
            //printer.FooterSpacing = 10;

            printer.PrintPreviewDataGridView(dggholname2);

            this.Cursor = Cursors.Default;
        }

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

        private void button5_Click_1(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            DataGridViewPrinter.DGVPrinter printer = new DataGridViewPrinter.DGVPrinter();
            printer.CellAlignment = StringAlignment.Center;
            printer.CellFormatFlags = StringFormatFlags.DirectionRightToLeft;

            printer.HeaderCellAlignment = StringAlignment.Center;
            printer.HeaderCellFormatFlags = StringFormatFlags.DirectionRightToLeft;
            printer.PageNumberAlignment = StringAlignment.Near;
            printer.PageNumberInHeader = true;
            printer.PageNumberOnSeparateLine = true;
            printer.PageNumbers = true;
            printer.PorportionalColumns = true;

            printer.Title = "قولنامه فروش مورد معامله";
            printer.TitleAlignment = StringAlignment.Center;
            printer.TitleColor = Color.Blue;
            printer.TitleFont = new Font("Arial", 14);
            printer.TitleFormatFlags = StringFormatFlags.DirectionRightToLeft;

            printer.SubTitle = " ";
            printer.SubTitleAlignment = StringAlignment.Center;
            printer.SubTitleColor = Color.Blue;
            printer.SubTitleFont = new Font("Arial", 14);
            printer.SubTitleFormatFlags = StringFormatFlags.DirectionRightToLeft;

            //printer.Footer = "Footer";
            //printer.FooterAlignment = StringAlignment.Center;
            //printer.FooterColor = Color.Blue;
            //printer.FooterFont = new Font("Arial", 14);
            //printer.FooterFormatFlags = StringFormatFlags.DirectionRightToLeft;
            //printer.FooterSpacing = 10;

            printer.PrintPreviewDataGridView(dggholname3);

            this.Cursor = Cursors.Default;
        }

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

        private void button7_Click_1(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            DataGridViewPrinter.DGVPrinter printer = new DataGridViewPrinter.DGVPrinter();
            printer.CellAlignment = StringAlignment.Center;
            printer.CellFormatFlags = StringFormatFlags.DirectionRightToLeft;

            printer.HeaderCellAlignment = StringAlignment.Center;
            printer.HeaderCellFormatFlags = StringFormatFlags.DirectionRightToLeft;
            printer.PageNumberAlignment = StringAlignment.Near;
            printer.PageNumberInHeader = true;
            printer.PageNumberOnSeparateLine = true;
            printer.PageNumbers = true;
            printer.PorportionalColumns = true;

            printer.Title = "قولنامه فروش";
            printer.TitleAlignment = StringAlignment.Center;
            printer.TitleColor = Color.Blue;
            printer.TitleFont = new Font("Arial", 14);
            printer.TitleFormatFlags = StringFormatFlags.DirectionRightToLeft;

            printer.SubTitle = " ";
            printer.SubTitleAlignment = StringAlignment.Center;
            printer.SubTitleColor = Color.Blue;
            printer.SubTitleFont = new Font("Arial", 14);
            printer.SubTitleFormatFlags = StringFormatFlags.DirectionRightToLeft;

            printer.Footer = "Footer";
            printer.FooterAlignment = StringAlignment.Center;
            printer.FooterColor = Color.Blue;
            printer.FooterFont = new Font("Arial", 14);
            printer.FooterFormatFlags = StringFormatFlags.DirectionRightToLeft;
            printer.FooterSpacing = 10;

            printer.PrintPreviewDataGridView(dggholname4);

            this.Cursor = Cursors.Default;
        }
    }
}