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

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

        }

        private void btnCode_Click(object sender, EventArgs e)
        {
            if (Int32.Parse(txtCode.Text) < 9000)
            {
                MessageBox.Show("شماره فراگیر نادرست است ", "مدیریت آموزشگاه",MessageBoxButtons.OK,MessageBoxIcon.Error);
                return;
            }
            Student std = new Student();
            std.ID = Int32.Parse(txtCode.Text);
            std.GetOne();
            lblID.Text = std.ID.ToString();
            lblCode.Text = std.code;
            lblFamily.Text = std.family;
            lblName.Text = std.name;
            unit_SelectTableAdapter.Select_Unit(amozeshgahDataSet1.Unit_Select,Int32.Parse(txtCode.Text));
        }

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

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

        private void btnEdit_Click(object sender, EventArgs e)
        {

            if (dataGridViewX1.CurrentRow == null)
                return;
            int row = dataGridViewX1.CurrentRow.Index;
            string val = dataGridViewX1[0, row].Value.ToString();
            unit_SelectTableAdapter.New(Int32.Parse(val), 301, Int32.Parse(lblID.Text));
            unit_SelectTableAdapter.Select_Unit(amozeshgahDataSet1.Unit_Select, Int32.Parse(txtCode.Text));   

        }

        
    }
}
