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

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

        private void btnInsert_pic_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();
            
        }

        private void btnInsert_Click(object sender, EventArgs e)
        {
            if (txtName.Text == "" || txtFamily.Text == "" || txtFather.Text == "" || txtAddress.Text == ""
               || txtCode.Text == "" || txtEmail.Text == "" || txtMobile.Text == "" || txtShomare.Text == ""
               || txtTel.Text == "")
            {
                MessageBox.Show("اطلاعات وارد شده کامل نیست", "مدیریت آموزشگاه", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();
            DateTime dt = new DateTime();
            dt = DateTime.Now;
            Class_date cdate = new Class_date();
            string date = dt.Year.ToString() + "/" + dt.Month.ToString() + "/" + dt.Day.ToString();
            string date_T;
            date_T = cdate.Shamsi(date);
            string genus;
            if (rdoMale.Checked)
                genus = "مرد";
            else
                genus = "زن";
            string birth;
            birth = day.Text + ' ' + month.Text + " ماه " + year.Text;
            studentTableAdapter1.Insert(txtName.Text, txtFamily.Text, txtFather.Text, birth, txtCode.Text,
                txtEmail.Text, txtMobile.Text, txtAddress.Text, genus, txtShomare.Text, txtTel.Text, date_T);
            MessageBox.Show("اطلاعات با موفقیت ثبت شد", "مدیریت آموزشگاه", MessageBoxButtons.OK, MessageBoxIcon.Information);
            day.SelectedIndex = -1;
            month.SelectedIndex = -1;
            year.SelectedIndex = -1;
            txtName.Text = txtFamily.Text = txtFather.Text =
            txtMobile.Text = txtShomare.Text = txtEmail.Text = txtTel.Text = txtCode.Text = txtAddress.Text = string.Empty;
            txtName.Focus();
        }

       

       
    }
}
