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 System.Data.SqlClient;

namespace Amozeshgah
{
    public partial class Main : Form
    {

        public Main()
        {
            InitializeComponent();
        }

        private void ShowNewForm(object sender, EventArgs e)
        {
            
            Form1 f1 = new Form1();
            f1.MdiParent = this;
            f1.Show();
        }

        private void OpenFile(object sender, EventArgs e)
        {
            DarsJadid dj = new DarsJadid();
            dj.MdiParent = this;
            dj.Show();
        }

        private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
        }

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

        private void CutToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void CopyToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void PasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void ToolBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            toolStrip.Visible = toolBarToolStripMenuItem.Checked;
        }

        private void StatusBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            statusStrip.Visible = statusBarToolStripMenuItem.Checked;
        }

        private void CascadeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.Cascade);
        }

        private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileVertical);
        }

        private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.ArrangeIcons);
        }

        private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form childForm in MdiChildren)
            {
                childForm.Close();
            }
        }

        private void saveToolStripButton_Click(object sender, EventArgs e)
        {
            LoginModir lm = new LoginModir();
            lm.MdiParent = this;
            lm.Show();
        }

        private void printToolStripButton_Click(object sender, EventArgs e)
        {
            SearchingKarbar SK = new SearchingKarbar();
            SK.MdiParent = this;
            SK.Show();
        }

        private void printPreviewToolStripButton_Click(object sender, EventArgs e)
        {
            SearchingDars SD = new SearchingDars();
            SD.MdiParent = this;
            SD.Show();
        }

        private void Main_Load(object sender, EventArgs e)
        {
            string strcon = @"Data Source=.\;Initial Catalog=dbAmozeshgah;Integrated Security=SSPI";
            SqlConnection Sql_Connection = new SqlConnection();
            Sql_Connection.ConnectionString = strcon;
            SqlCommand Sql_Command = new SqlCommand();
            Sql_Command.Connection = Sql_Connection;
            Sql_Command.CommandText = ("SELECT [ID],[Name],[Family],[CodeMeli],[TarikhTavalod],[Jensiyat],[Addres]FROM [tUsers]");
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = Sql_Command;
            DataTable dt = new DataTable();
            da.Fill(dt);
            Label1.Text = "تعداد کاربران:" + dt.Rows.Count;
            Sql_Connection.Close();
            //=====================================================>>>>+++<<<<
            string strcon01 = @"Data Source=.\;Initial Catalog=dbAmozeshgah;Integrated Security=SSPI";
            SqlConnection Sql_Connection01 = new SqlConnection();
            Sql_Connection01.ConnectionString = strcon01;
            SqlCommand Sql_Command01 = new SqlCommand();
            Sql_Command01.Connection = Sql_Connection01;
            Sql_Command01.CommandText = ("SELECT [ID],[NameDars],[Mozo],[TedadVahed],[NameOstad]FROM [tDoros]");
            SqlDataAdapter da01 = new SqlDataAdapter();
            da.SelectCommand = Sql_Command01;
            DataTable dt01 = new DataTable();
            da.Fill(dt01);
            Label2.Text = "تعداد کتابها:" + dt01.Rows.Count;
            Sql_Connection01.Close();
        }

        private void btnLoad_ButtonClick(object sender, EventArgs e)
        {
            Main_Load(sender, e);
        }

        private void dataRepeater1_CurrentItemIndexChanged(object sender, EventArgs e)
        {

        }

        private void دربارهماToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show("برنامه نویس : سعید عزیزی", "about");
        }
    }
}
