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.OleDb;

namespace shop
{
    public partial class gmotafareghe : Form
    {
        public gmotafareghe()
        {
            InitializeComponent();
        }

        void display()
        {
            OleDbConnection con1 = new OleDbConnection();
            con1.ConnectionString = "provider=microsoft.jet.oledb.4.0; data source=shoping.mdb";
            OleDbDataAdapter da = new OleDbDataAdapter("select * from motafareghe where tarikh between '" + maskedTextBox1.Text + "' and '" + maskedTextBox2.Text + "'", con1);
            DataSet ds = new DataSet();
            da.Fill(ds, "motafareghe");
            dataGridView1.DataSource = ds.Tables["motafareghe"].DefaultView;
            con1.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            display();
            decimal sum = 0;
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                sum += Convert.ToDecimal(dataGridView1.Rows[i].Cells["mablagh"].Value);
                dataGridView1.Rows[i].Cells["cod"].Value = i + 1;
            }
            lblfrush.Text = sum.ToString("###,###,###,###");
        }
    }
}
