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;
using CrystalDecisions.Shared;

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

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

            da.Fill(ds, "a");

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




        }
       
        

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

      

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

        private void button1_Click_2(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(dataGridView1);

            this.Cursor = Cursors.Default;
        }
    }
}