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 Amozeshgah
{
    public partial class Edit_Course : DevComponents.DotNetBar.Office2007Form
    {
        public Edit_Course()
        {
            InitializeComponent();
        }

        private void Edit_Course_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'amozeshgahDataSet1.Course' table. You can move, or remove it, as needed.
            this.courseTableAdapter.Fill(this.amozeshgahDataSet1.Course);
                 }

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

        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (dataGridViewX1.CurrentRow == null)
                return;
            DialogResult dr;
            dr = MessageBox.Show("آیا می خواهید سطر انتخاب شده را حذف کنید", "مدیریت آموزشگاه", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dr == DialogResult.No)
                return;
            int row = dataGridViewX1.CurrentRow.Index;
            string val = dataGridViewX1[0, row].Value.ToString();
            courseTableAdapter.Delete1(Int32.Parse(val));
            Edit_Course_Load(null, null);
        }

        private void btnShow_Click(object sender, EventArgs e)
        {
            this.courseTableAdapter.Fill(this.amozeshgahDataSet1.Course);

        }

        private void btnCode_Click(object sender, EventArgs e)
        {
            courseTableAdapter.SearchByTeacher(amozeshgahDataSet1.Course,txtCode.Text );
        }

        private void btnٰTerm_Click(object sender, EventArgs e)
        {
            courseTableAdapter.SearchByTerm(amozeshgahDataSet1.Course,  txtTitle.Text );
        }

        private void txtCode_TextChanged(object sender, EventArgs e)
        {
            courseTableAdapter.SearchByTeacher(amozeshgahDataSet1.Course, '%' + txtCode.Text + '%');
        }

        private void txtTitle_TextChanged(object sender, EventArgs e)
        {
            courseTableAdapter.SearchByTerm(amozeshgahDataSet1.Course, '%' + txtTitle.Text + '%');
        }
    }
}
