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_kharid : 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_kharid()
        {
            InitializeComponent();
        }

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

            da.Fill(ds, "t2");

            dggozareshkharid.DataSource = ds;
            dggozareshkharid.DataMember = "t2";
            dggozareshkharid.Columns[0].HeaderText = "نوع ملک";
            dggozareshkharid.Columns[1].HeaderText = "حدود متراژ";
            dggozareshkharid.Columns[2].HeaderText = "نام خریدار";
            dggozareshkharid.Columns[3].HeaderText = "امکانات";
            dggozareshkharid.Columns[4].HeaderText = "توضیحات اضافه";
            dggozareshkharid.Columns[5].HeaderText = "مبلغ خرید";
            dggozareshkharid.Columns[6].HeaderText = "تعداد اتاق";
            dggozareshkharid.Columns[7].HeaderText = "منطقه";
            dggozareshkharid.Columns[8].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_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(dggozareshkharid);

            this.Cursor = Cursors.Default;
        }
    }
}