using System;
using System.Windows.Forms;
//-------------------------------------
using System.Data;
using System.Data.SqlClient;

namespace _17_10
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            dataGridView1.SelectionMode =
               DataGridViewSelectionMode.FullRowSelect;

            dataGridView1.ColumnHeadersHeightSizeMode =
                           DataGridViewColumnHeadersHeightSizeMode.AutoSize;

            dataGridView1.ColumnHeadersDefaultCellStyle.Alignment =
                           DataGridViewContentAlignment.MiddleCenter;

            dataGridView1.DefaultCellStyle.Alignment =
                           DataGridViewContentAlignment.MiddleCenter;

            dataGridView1.RightToLeft = RightToLeft.Yes;
            
            string strConn = "Server=.;" + "DataBase=MyCompany;" +
                             "Integrated Security=True";
            
            SqlConnection sCon = new SqlConnection(strConn);
            SqlDataAdapter sda = new SqlDataAdapter("rptDiff", sCon);
            sda.SelectCommand.CommandType = CommandType.StoredProcedure;
            DataSet ds = new DataSet();
            sCon.Open();
            sda.Fill(ds, "table1");
            sCon.Close();
            
            dataGridView1.DataSource = ds;
            dataGridView1.DataMember = "table1";
            
            dataGridView1.Columns[0].HeaderText = "کد کالا";
            dataGridView1.Columns[1].HeaderText = "تعداد ورودی";
            dataGridView1.Columns[2].HeaderText = "تعداد فروش";
            dataGridView1.Columns[3].HeaderText = "تعداد باقیمانده";
        }
    }
}