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

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

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

            da.Fill(ds, "t3");

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

            this.Cursor = Cursors.Default;
        }
    }
}