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;

namespace restooran
{
    public partial class list : Form
    {
        public list()
        {
            InitializeComponent();
        }

        private void list_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dataSet1.tbl_subfactor' table. You can move, or remove it, as needed.
            this.tbl_subfactorTableAdapter.Fill(this.dataSet1.tbl_subfactor);
            // TODO: This line of code loads data into the 'dataSet1.tbl_factor' table. You can move, or remove it, as needed.
            this.tbl_factorTableAdapter.Fill(this.dataSet1.tbl_factor);
            lbltotal.Text = tbl_factorTableAdapter.getsum().ToString();

        }

        private void buttonX1_Click(object sender, EventArgs e)
        {
            try
            {
                tbl_factorTableAdapter.FillBydate(dataSet1.tbl_factor, mskfrom.Text, mskto.Text);
                lbltotal.Text = tbl_factorTableAdapter.getbydate(mskfrom.Text, mskto.Text).ToString();
            }
            catch { MessageBox.Show("error"); }
            
        }

        private void groupPanel1_Click(object sender, EventArgs e)
        {

        }

        private void مشاهدهجزئیاتToolStripMenuItem_Click(object sender, EventArgs e)
        {
            sub f = new sub();
            f.txtshomare.Text = dataGridViewX1.CurrentRow.Cells[0].Value.ToString();
            f.txtmablagh.Text = dataGridViewX1.CurrentRow.Cells[2].Value.ToString();
            f.txttakhfif.Text = dataGridViewX1.CurrentRow.Cells[3].Value.ToString();
            f.txtpardahkt.Text = dataGridViewX1.CurrentRow.Cells[4].Value.ToString();
            f.Show();
        }

        private void صدورمجددToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("اطلاعات حذف شده قابل بازیابی نیست.آیا مطمئن هستید؟", "اخطار حذف", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                tbl_factorTableAdapter .mydelete (dataGridViewX1.CurrentRow .Cells [0].Value .ToString ());
                tbl_subfactorTableAdapter.mydelete(dataGridViewX1.CurrentRow.Cells[0].Value.ToString());
                this.tbl_factorTableAdapter.Fill(this.dataSet1.tbl_factor);
            }
            else
            {
            }
        }
    }
}
