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 DeleteStudent : Form
    {
        public DeleteStudent()
        {
            InitializeComponent();
        }

        public string STDNUM;
        Student Std = new Student();
        private void DeleteStudent_Load(object sender, EventArgs e)
        {
            SearchStudent FF = new SearchStudent();
            FF.ShowDialog();
            STDNUM = FF.STDNUM;
            if (STDNUM == "" || STDNUM == null) { return; }
            //----------------------------------------------
            StudentType Model = new StudentType();
            Model.ShowModels(txt_Student_Type);
            //----------------------------------------------
            Std.ShowInfo(STDNUM);
            txt_Student_ID.TEXT = Std.ID.ToString();
            txt_Cart_ID.TEXT = Std.CartID.ToString();
            txt_Student_Name.TEXT = Std.Name;
            txt_Student_Family.TEXT = Std.Family;
            txt_Student_Price.TEXT = Std.Price.ToString();
            txt_Student_Type.SelectedValue = Std.Type;
        }

        private void DeleteStudent_Activated(object sender, EventArgs e)
        {
            timer1.Enabled = true;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            if (STDNUM == "" || STDNUM == null) { this.Close(); return; }
        }

        private void btn_OK_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("آیا دانشجوی انتخاب شده، حذف شود ؟", "حذف دانشجو", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return;
            Std.DeleteStudent();
            MessageBox.Show("اطلاعات با موفقیت حذف شد", "حذف اطلاعات", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }

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