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 video_club
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            updatefill();
        }

        private void updatefill()
        {
// TODO: This line of code loads data into the 'dataSet1.tblmoshtari' table. You can move, or remove it, as needed.
            this.tblmoshtariTableAdapter.Fill(this.dataSet1.tblmoshtari);
            // TODO: This line of code loads data into the 'dataSet1.tblfilm' table. You can move, or remove it, as needed.
            this.tblfilmTableAdapter.Fill(this.dataSet1.tblfilm);
        }

        private void commandBarButton1_Click(object sender, EventArgs e)
        {
            frmaddmoshtari r = new frmaddmoshtari();
            r.Show();
        }

        private void radGridView2_CommandCellClick(object sender, EventArgs e)
        {
          

        }

        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                int a = int.Parse(radGridView2.SelectedRows[0].Cells[4].Value.ToString());


                if (MessageBox.Show("آیا می خواهید حذف کنید؟", "اخطار", MessageBoxButtons.YesNoCancel) == System.Windows.Forms.DialogResult.Yes)
                {

                    tblfilmTableAdapter.DeleteQuery(a);
                    updatefill();
                }
                else
                {
                    updatefill();

                }
            }

            catch
            {
                MessageBox.Show(".فیلدی برای حذف کردن یافت نشد", "اخطار", MessageBoxButtons.OK);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            frmaddfilm w = new frmaddfilm();
            w.Show();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            frmeditfilm f = new frmeditfilm();
            f.txtnam.Text = radGridView2.SelectedRows[0].Cells[0].Value.ToString();
            f.txtcontry.Text = radGridView2.SelectedRows[0].Cells[1].Value.ToString();

            f.txtyear.Text = radGridView2.SelectedRows[0].Cells[3].Value.ToString();
            f.txtfid.Text = radGridView2.SelectedRows[0].Cells[4].Value.ToString();
            f.txtcount.Text = radGridView2.SelectedRows[0].Cells[5].Value.ToString();
            f.Show();
        }

        private void commandBarButton2_Click(object sender, EventArgs e)
        {
            frmreport q = new frmreport();
            q.ShowDialog();
        }

        private void commandBarButton4_Click(object sender, EventArgs e)
        {
            frmbargasht g = new frmbargasht();
            g.ShowDialog();
        }

        private void commandBarButton3_Click(object sender, EventArgs e)
        {
            frmkeraye c = new frmkeraye();
            c.ShowDialog();
        }

        private void commandBarButton6_Click(object sender, EventArgs e)
        {
            frmdaramad d = new frmdaramad();


            d.Show();

        }

        private void commandBarButton5_Click(object sender, EventArgs e)
        {
            frmdaramad d = new frmdaramad();


            d.Show();

        }

        private void button6_Click(object sender, EventArgs e)
        {
            frmaddmoshtari r = new frmaddmoshtari();
            r.Show();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                int b = int.Parse(radGridView3.SelectedRows[0].Cells[3].Value.ToString());
                DialogResult dr = (MessageBox.Show("آیا می خواهید حذف کنید؟", "اخطار", MessageBoxButtons.YesNoCancel));
                if (dr == DialogResult.Yes)
                {
                    tblmoshtariTableAdapter.DeleteQuery(b);
                    updatefill();
                }
                else if (dr == DialogResult.No)
                {
                    updatefill();
                }
                else
                {
                }
            }
            catch
            {
                MessageBox.Show(".فیلدی برای حذف کردن یافت نشد", "اخطار", MessageBoxButtons.OK);

            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            frmeditmoshtari f = new frmeditmoshtari();
            f.txtnamemoshtari.Text = radGridView3.SelectedRows[0].Cells[0].Value.ToString();
            f.txtfamilymoshtari.Text = radGridView3.SelectedRows[0].Cells[1].Value.ToString();
            f.txttellmoshtari.Text = radGridView3.SelectedRows[0].Cells[2].Value.ToString();
            f.txtmid.Text = radGridView3.SelectedRows[0].Cells[3].Value.ToString();

            f.Show();
        }
    }
}
