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

namespace Self_Project
{
    public partial class Limit : Form
    {
        public Limit()
        {
            InitializeComponent();
        }
        Reserve R = new Reserve();
        private void Limit_Load(object sender, EventArgs e)
        {
            StudentType M = new StudentType();
            M.ShowModels(txt_StudentType);
        }

        private void LoadInformations()
        {
            //------------------------------------------
            if (!Functions.IsNumber(txt_StudentType.SelectedValue.ToString())) return;
            R.LoadLimits(Convert.ToInt16(txt_StudentType.SelectedValue));
            Ch11.Checked = R.Ch11;
            Ch12.Checked = R.Ch12;
            Ch13.Checked = R.Ch13;
            Ch21.Checked = R.Ch21;
            Ch22.Checked = R.Ch22;
            Ch23.Checked = R.Ch23;
            Ch31.Checked = R.Ch31;
            Ch32.Checked = R.Ch32;
            Ch33.Checked = R.Ch33;
            Ch41.Checked = R.Ch41;
            Ch42.Checked = R.Ch42;
            Ch43.Checked = R.Ch43;
            Ch51.Checked = R.Ch51;
            Ch52.Checked = R.Ch52;
            Ch53.Checked = R.Ch53;
            Ch61.Checked = R.Ch61;
            Ch62.Checked = R.Ch62;
            Ch63.Checked = R.Ch63;
            Ch71.Checked = R.Ch71;
            Ch72.Checked = R.Ch72;
            Ch73.Checked = R.Ch73;
        }

        private void T6_SelectedIndexChanged(object sender, EventArgs e)
        {
            LoadInformations();
        }

        private void Limit_Activated(object sender, EventArgs e)
        {
            LoadInformations();
        }

        private void btn_OK_Click(object sender, EventArgs e)
        {

            R.Ch11 = Ch11.Checked;
            R.Ch12 = Ch12.Checked;
            R.Ch13 = Ch13.Checked;
            R.Ch21 = Ch21.Checked;
            R.Ch22 = Ch22.Checked;
            R.Ch23 = Ch23.Checked;
            R.Ch31 = Ch31.Checked;
            R.Ch32 = Ch32.Checked;
            R.Ch33 = Ch33.Checked;
            R.Ch41 = Ch41.Checked;
            R.Ch42 = Ch42.Checked;
            R.Ch43 = Ch43.Checked;
            R.Ch51 = Ch51.Checked;
            R.Ch52 = Ch52.Checked;
            R.Ch53 = Ch53.Checked;
            R.Ch61 = Ch61.Checked;
            R.Ch62 = Ch62.Checked;
            R.Ch63 = Ch63.Checked;
            R.Ch71 = Ch71.Checked;
            R.Ch72 = Ch72.Checked;
            R.Ch73 = Ch73.Checked;
            R.SetLimits(Convert.ToInt16(txt_StudentType.SelectedValue));
            //-------------------
            MessageBox.Show("اطلاعات با موفقیت ثبت شد", "ایجاد محدودیت", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }

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