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;
using DevComponents.DotNetBar;
using System.Globalization;
using Stimulsoft.Report.Dictionary;
using Stimulsoft.Report;
using System.Data.SqlClient;


namespace academy
{
    public partial class main : DevComponents.DotNetBar.OfficeForm
    {
        public main()
        {
            InitializeComponent();
        }


        SqlConnection con = new SqlConnection("server=(local);database=school;integrated security=true");

        private void btn_student_Click(object sender, EventArgs e)
        {
            student s = new student();
            s.Show();
            this.Hide();
            
        }

        private void btn_fstudent_Click(object sender, EventArgs e)
        {
            fstudent fs = new fstudent();
            fs.Show();
            this.Hide();
        }

        private void buttonItem15_Click(object sender, EventArgs e)
        {
            master ms = new master();
            ms.Show();
            this.Hide();
        }

        private void buttonItem14_Click(object sender, EventArgs e)
        {
            karmand kr = new karmand();
            kr.Show();
            this.Hide();
        }

        private void buttonItem16_Click(object sender, EventArgs e)
        {
            dars dr = new dars();
            dr.Show();
            this.Hide();
        }

        private void buttonItem17_Click(object sender, EventArgs e)
        {
            kelas k = new kelas();
            k.Show();
            this.Hide();
        }

        private void buttonItem18_Click(object sender, EventArgs e)
        {
            pricekelas p = new pricekelas();
            p.Show();
            this.Hide();
        }

        private void buttonItem19_Click(object sender, EventArgs e)
        {
            shahriyeh sh = new shahriyeh();
            sh.Show();
            this.Hide();
        }

        private void buttonItem20_Click(object sender, EventArgs e)
        {
            fshahriyeh fsh = new fshahriyeh();
            fsh.Show();
            this.Hide();
        }

        private void buttonItem22_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void buttonItem23_Click(object sender, EventArgs e)
        {
            paymentstudent pst = new paymentstudent();
            pst.Show();
            this.Hide();
        }

        private void buttonItem2_Click(object sender, EventArgs e)
        {
            paymentfstudent fst = new paymentfstudent();
            fst.Show();
            this.Hide();
        }

        private void buttonItem3_Click(object sender, EventArgs e)
        {
            mastersalary msts = new mastersalary();
            msts.Show();
            this.Hide();
        }

        private void buttonItem4_Click(object sender, EventArgs e)
        {
            karmandsalary kst = new karmandsalary();
            kst.Show();
            this.Hide();
        }

        private void buttonItem5_Click(object sender, EventArgs e)
        {

            PersianCalendar pc = new PersianCalendar();
            string ShamsiDate = pc.GetYear(DateTime.Now).ToString()
            + "/" +
            pc.GetMonth(DateTime.Now).ToString()
            + "/" +
            pc.GetDayOfMonth(DateTime.Now).ToString();
            StiVariable sv = new StiVariable("Date", "ShamsiDate", typeof(string), ShamsiDate, false);
            rptstudent.Dictionary.Variables.Add(sv); 
            rptstudent.Show();

        }

        private void buttonItem6_Click(object sender, EventArgs e)
        {
            PersianCalendar pc = new PersianCalendar();
            string ShamsiDate = pc.GetYear(DateTime.Now).ToString()
            + "/" +
            pc.GetMonth(DateTime.Now).ToString()
            + "/" +
            pc.GetDayOfMonth(DateTime.Now).ToString();
            StiVariable sv = new StiVariable("Date", "ShamsiDate", typeof(string), ShamsiDate, false);
            rptfstudent.Dictionary.Variables.Add(sv);
            rptfstudent.Show();
        }

        private void buttonItem7_Click(object sender, EventArgs e)
        {
            PersianCalendar pc = new PersianCalendar();
            string ShamsiDate = pc.GetYear(DateTime.Now).ToString()
            + "/" +
            pc.GetMonth(DateTime.Now).ToString()
            + "/" +
            pc.GetDayOfMonth(DateTime.Now).ToString();
            StiVariable sv = new StiVariable("Date", "ShamsiDate", typeof(string), ShamsiDate, false);
            rptteacher.Dictionary.Variables.Add(sv);
            rptteacher.Show();
        }

        private void buttonItem8_Click(object sender, EventArgs e)
        {
            PersianCalendar pc = new PersianCalendar();
            string ShamsiDate = pc.GetYear(DateTime.Now).ToString()
            + "/" +
            pc.GetMonth(DateTime.Now).ToString()
            + "/" +
            pc.GetDayOfMonth(DateTime.Now).ToString();
            StiVariable sv = new StiVariable("Date", "ShamsiDate", typeof(string), ShamsiDate, false);
            rptkarmand.Dictionary.Variables.Add(sv);
            rptkarmand.Show();
        }

        private void buttonItem9_Click(object sender, EventArgs e)
        {
            PersianCalendar pc = new PersianCalendar();
            string ShamsiDate = pc.GetYear(DateTime.Now).ToString()
            + "/" +
            pc.GetMonth(DateTime.Now).ToString()
            + "/" +
            pc.GetDayOfMonth(DateTime.Now).ToString();
            StiVariable sv = new StiVariable("Date", "ShamsiDate", typeof(string), ShamsiDate, false);
            rptshman.Dictionary.Variables.Add(sv);
            rptshman.Show();
        }

        private void buttonItem10_Click(object sender, EventArgs e)
        {
            PersianCalendar pc = new PersianCalendar();
            string ShamsiDate = pc.GetYear(DateTime.Now).ToString()
            + "/" +
            pc.GetMonth(DateTime.Now).ToString()
            + "/" +
            pc.GetDayOfMonth(DateTime.Now).ToString();
            StiVariable sv = new StiVariable("Date", "ShamsiDate", typeof(string), ShamsiDate, false);
            rptshwoman.Dictionary.Variables.Add(sv);
            rptshwoman.Show();
        }

        private void buttonItem11_Click(object sender, EventArgs e)
        {
            PersianCalendar pc = new PersianCalendar();
            string ShamsiDate = pc.GetYear(DateTime.Now).ToString()
            + "/" +
            pc.GetMonth(DateTime.Now).ToString()
            + "/" +
            pc.GetDayOfMonth(DateTime.Now).ToString();
            StiVariable sv = new StiVariable("Date", "ShamsiDate", typeof(string), ShamsiDate, false);
            rptteachersalary.Dictionary.Variables.Add(sv);
            rptteachersalary.Show();
        }

        private void buttonItem12_Click(object sender, EventArgs e)
        {
            PersianCalendar pc = new PersianCalendar();
            string ShamsiDate = pc.GetYear(DateTime.Now).ToString()
            + "/" +
            pc.GetMonth(DateTime.Now).ToString()
            + "/" +
            pc.GetDayOfMonth(DateTime.Now).ToString();
            StiVariable sv = new StiVariable("Date", "ShamsiDate", typeof(string), ShamsiDate, false);
            rptkarmandsalary.Dictionary.Variables.Add(sv);
            rptkarmandsalary.Show();
        }

        private void buttonItem25_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("calc");
        }

        private void buttonItem24_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("notepad");
        }

        private void buttonItem13_Click(object sender, EventArgs e)
        {
            user us = new user();
            us.Show();
            this.Hide();
        }

        private void main_Load(object sender, EventArgs e)
        {
            if (variable.i == 2)
            {
                lbluser.Text = "کاربر عادی";
                btn_hazinehkelas.Enabled = false;
                btn_teacher_salary.Enabled = false;
                btn_karmand_salary.Enabled = false;
                btn_rpt_teacher.Enabled = false;
                btn_rpt_karmand.Enabled = false;
                btn_rpt_payteacher.Enabled = false;
                btn_rpt_paykarmand.Enabled = false;
                btn_karbaran.Enabled = false;
            }

            else
            
                lbluser.Text = "مدیر";

          
               
                SqlCommand sqlCmd1 = new SqlCommand("SELECT COUNT(*) FROM student", con);
                con.Open();
                lblstudent.Text = Convert.ToString((int)sqlCmd1.ExecuteScalar()) + "";
                con.Close();
            
            
                SqlCommand sqlCmd2 = new SqlCommand("SELECT COUNT(*) FROM fstudent", con);
                con.Open();
                lblfstudent.Text = Convert.ToString((int)sqlCmd2.ExecuteScalar()) + "";
                con.Close();


                SqlCommand sqlCmd3 = new SqlCommand("SELECT COUNT(*) FROM teacher", con);
                con.Open();
                lblteacher.Text = Convert.ToString((int)sqlCmd3.ExecuteScalar()) + "";
                con.Close();

                SqlCommand sqlCmd4 = new SqlCommand("SELECT COUNT(*) FROM karmand", con);
                con.Open();
                lblkarmand.Text = Convert.ToString((int)sqlCmd4.ExecuteScalar()) + "";
                con.Close();
        }

        private void btn_backup_Click(object sender, EventArgs e)
        {
            backup bku = new backup();
            bku.Show();
            this.Hide();
        }

        private void btn_restore_Click(object sender, EventArgs e)
        {
            restore res = new restore();
            res.Show();
            this.Hide();
        }

        private void btn_about_Click(object sender, EventArgs e)
        {
            About ab = new About();
            ab.Show();
            this.Hide();
        }
    }
}
