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

namespace LibraryMembers
{
    public partial class frmBazgashteketab1 : Form
    {
        public frmBazgashteketab1()
        {
            InitializeComponent();
        }

        private void frmBazgashteketab1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'libraryMembersDataSet2.MeberNameSname' table. You can move, or remove it, as needed.
            this.meberNameSnameTableAdapter.Fill(this.libraryMembersDataSet2.MeberNameSname);
            // TODO: This line of code loads data into the 'libraryMembersDataSet1.Books' table. You can move, or remove it, as needed.
            this.booksTableAdapter.Fill(this.libraryMembersDataSet1.Books);
            // TODO: This line of code loads data into the 'libraryMembersDataSet.BookH' table. You can move, or remove it, as needed.
            this.bookHTableAdapter.Fill(this.libraryMembersDataSet.BookH);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox2.Text == "")
            {
                MessageBox.Show("مقادیر تمامی فیلدها بایستی وارد شوند");
            }
            else
            {
                this.bookHTableAdapter.Update(libraryMembersDataSet.BookH);
                dataGridView1.Refresh(); 
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox2.Text == "")
            {
                MessageBox.Show("مقادیر تمامی فیلدها بایستی وارد شوند");
            }
            else
            {
                this.bookHTableAdapter.Update(libraryMembersDataSet.BookH);
                dataGridView1.Refresh();
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.bookHTableAdapter.Delete(comboBox1.SelectedValue.ToString(), comboBox2.SelectedValue.ToString(), textBox2.Text);

            this.meberNameSnameTableAdapter.Fill(this.libraryMembersDataSet2.MeberNameSname);
            // TODO: This line of code loads data into the 'libraryMembersDataSet1.Books' table. You can move, or remove it, as needed.
            this.booksTableAdapter.Fill(this.libraryMembersDataSet1.Books);
            // TODO: This line of code loads data into the 'libraryMembersDataSet.BookH' table. You can move, or remove it, as needed.
            this.bookHTableAdapter.Fill(this.libraryMembersDataSet.BookH);

        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (textBox3.Text != "")
            {
                this.bookHTableAdapter.FillBy(libraryMembersDataSet.BookH, textBox3.Text.Trim());
            }
            else
            {
                MessageBox.Show("کد کتاب وارد نشده است");
            }
        }
    }
}