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

namespace lavazem_behdashti
{
    public partial class froosh_rpt : Form
    {
        public froosh_rpt()
        {
            InitializeComponent();
        }

        SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=lavazem behdashti;Integrated Security=True");
        SqlCommand cmd = new SqlCommand();

        void display()
        {

            DataSet ds = new DataSet();
            SqlDataAdapter adp = new SqlDataAdapter();
            adp.SelectCommand = new SqlCommand();
            adp.SelectCommand.Connection = con;
            adp.SelectCommand.CommandText = "select * from factor_froosh";
            adp.Fill(ds, "t1");
            dataGridViewX1.DataSource = ds;
            dataGridViewX1.DataMember = "t1";
        }

        private void textBoxX3_TextChanged(object sender, EventArgs e)
        {
            try
            {
                DataSet ds = new DataSet();
                SqlDataAdapter adp = new SqlDataAdapter();
                adp.SelectCommand = new SqlCommand();
                adp.SelectCommand.Connection = con;
                adp.SelectCommand.CommandText = "select * from factor_froosh where name_mahsol like @N";
                adp.SelectCommand.Parameters.AddWithValue("@N", textBoxX3.Text + "%");
                adp.Fill(ds, "t1");
                dataGridViewX1.DataSource = ds;
                dataGridViewX1.DataMember = "t1";
            }
            catch { }
        }

        private void froosh_rpt_Load(object sender, EventArgs e)
        {
            InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(System.Globalization.CultureInfo.CreateSpecificCulture("fa-IR"));

            display();

            dataGridViewX1.Columns[0].HeaderText = "کد محصول";
            dataGridViewX1.Columns[1].HeaderText = "نام محصول";
            dataGridViewX1.Columns[2].HeaderText = "قیمت";
            dataGridViewX1.Columns[3].HeaderText = "تعداد";
            dataGridViewX1.Columns[4].HeaderText = "قیمت کل";
            dataGridViewX1.Columns[5].HeaderText = "کد فاکتور";
            dataGridViewX1.Columns[6].HeaderText = "توضیحات";
            dataGridViewX1.Columns[7].HeaderText = "تاریخ";
            dataGridViewX1.Columns[8].HeaderText = "نام مشتری";
            dataGridViewX1.Columns[9].HeaderText = "تلفن";
        }
    }
}
