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

namespace projectcsharp
{
    public partial class frm_rep_fac : Form
    {
        public frm_rep_fac()
        {
            InitializeComponent();
        }
        SqlConnection con = new SqlConnection("server=. ; database=resturan ;Integrated Security=True");

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

        private void btn_search_Click(object sender, EventArgs e)
        {
            string str = "";
            bool bol = false;
            if (txt_family.Text != "")
            {
                if (bol == true)
                    str += "and custumer=N'" + txt_family.Text + "'";
                else
                    str += " customer=N'" + txt_family.Text + "'";
                bol=true;
            }
            if( txt_tarikh.Text != "")
            {
                if(bol == true)
                    str += "and tarikh=N'" + txt_tarikh.Text + "'";
                else
                    str += "tarikh=N'" + txt_tarikh.Text + "'";
                bol=true;
            }
            str = "select numberfac as [شماره فاکتور], customer as [نام خانوادگی],food as [نام غذا],count as 'تعداد',fullprice as [قیمت کل],tarikh as 'تاریخ' from tbl_fac where " + str;
            SqlDataAdapter da = new SqlDataAdapter(str, con);
            DataTable dt = new DataTable();
            da.Fill(dt);
            dataGridView1.DataSource = dt;
        }

        private void txt_family_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!((char.IsDigit(e.KeyChar) == false)))
            {
                e.Handled = true;
            }
        }

        private void txt_family_Enter(object sender, EventArgs e)
        {
            System.Globalization.CultureInfo fa;
            fa = InputLanguage.InstalledInputLanguages[1].Culture;
            InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(fa);
        }
    }
}
