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 DevComponents.DotNetBar.Rendering;
using System.IO;
using System.Data.SqlClient;


namespace HotelProject
{
    public partial class FrmMain : Form
    {


        SqlConnection con;

        public FrmMain()
        {
            InitializeComponent();
        }

        private void BtnRoomTypes_Click(object sender, EventArgs e)
        {
            FrmRoomTypes Frt = new FrmRoomTypes();
            Frt.ShowDialog();
        }

        private void BtnRoomManagement_Click(object sender, EventArgs e)
        {
            FrmRoomManagement Frm = new FrmRoomManagement();
            Frm.ShowDialog();
        }

        private void buttonItem1_Click(object sender, EventArgs e)
        {

        }

        private void BtnOffice2007_Click(object sender, EventArgs e)
        {
            office2007StartButton1.Visible = true;
            styleManager1.ManagerStyle = eStyle.Office2007Blue;

            TextWriter tw = new StreamWriter(Application.StartupPath + "\\Style.Htl");
            tw.WriteLine("Office2007");
            tw.Close();
        }

        private void BtnOffice2010_Click(object sender, EventArgs e)
        {
            office2007StartButton1.Visible = false;
            styleManager1.ManagerStyle = eStyle.Office2010Blue;
            TextWriter tw = new StreamWriter(Application.StartupPath + "\\Style.Htl");
            tw.WriteLine("Office2010");
            tw.Close();
        }

        private void BtnWindows7_Click(object sender, EventArgs e)
        {
            office2007StartButton1.Visible = false;
            styleManager1.ManagerStyle = eStyle.Windows7Blue;
            TextWriter tw = new StreamWriter(Application.StartupPath + "\\Style.Htl");
            tw.WriteLine("Windows7");
            tw.Close();
        }

        private void FrmMain_Load(object sender, EventArgs e)
        {


            FrmLogin fl = new FrmLogin();
            fl.ShowDialog();

            if (fl.Result == false)
            {
                Application.Exit();
            }

            BtnRoomManagement.Enabled = fl.RoomManagement;
            BtnRoomTypes.Enabled = fl.Roomtypes;
            BtnSrv.Enabled = fl.service;
            BtnUsers.Enabled = fl.user;
            buttonItem4.Enabled = fl.Paziresh;
            BtnPazireshManagement.Enabled = fl.Paziresh;
            ribbonTabItem3.Enabled = fl.Reporting;
            ribbonTabItem4.Enabled = fl.BackUp;
            
            
            
            
            
            
            try
            {
                StreamReader sr = new StreamReader(Application.StartupPath + "\\Style.Htl");
                string StrStyle = sr.ReadLine().ToString();
                sr.Close();

                switch (StrStyle)
                {
                    case "Office2007":
                        {
                            styleManager1.ManagerStyle = eStyle.Office2007Blue;
                            office2007StartButton1.Visible = true;
                            break;
                        }

                    case "Office2010":
                        {
                            styleManager1.ManagerStyle = eStyle.Office2010Blue;
                            office2007StartButton1.Visible = false;
                            break;
                        }

                    case "Windows7":
                        {
                            styleManager1.ManagerStyle = eStyle.Windows7Blue;
                            office2007StartButton1.Visible = false;
                            break;
                        }
                }
            }
            catch
            {
                styleManager1.ManagerStyle = eStyle.Office2007Blue;
            }



        }

        private void buttonItem2_Click(object sender, EventArgs e)
        {

        }

        private void BtnSrv_Click(object sender, EventArgs e)
        {
            FrmServices fs = new FrmServices();
            fs.ShowDialog();
        }

        private void BtnUsers_Click(object sender, EventArgs e)
        {
            FrmAdmin fa = new FrmAdmin();
            fa.ShowDialog();
        }

        private void BtnClose_Click(object sender, EventArgs e)
        {
            FrmMessage Fm = new FrmMessage();
            Fm.LblText.Text = "آیا از خروج اطمینان دارید؟";
            Fm.PicClose.Visible = false;
            Fm.PicNO.Visible = true;
            Fm.PicYes.Visible = true;
            Fm.ShowDialog();

            if (Fm.Result == true)
                Application.Exit();
        }

        private void buttonItem4_Click(object sender, EventArgs e)
        {
            FrmPaziresh fp = new FrmPaziresh();
            fp.ShowDialog();
        }

        private void BtnPazireshManagement_Click(object sender, EventArgs e)
        {
            FrmPazireshManagement fpm = new FrmPazireshManagement();
            fpm.ShowDialog();
        }

        private void BtnReportPaziresh_Click(object sender, EventArgs e)
        {
            FrmReportPaziresh frp = new FrmReportPaziresh();
            frp.ShowDialog();

        }

        private void BtnReportKhoruji_Click(object sender, EventArgs e)
        {
            FrmReportKhoruji frk = new FrmReportKhoruji();
            frk.ShowDialog();
        }

        private void BtnReportRooms_Click(object sender, EventArgs e)
        {
            con = new SqlConnection("Server = . ; DataBase = DbHotel ; Integrated Security = True");
            SqlDataAdapter da = new SqlDataAdapter("ReportRooms", con);
            da.SelectCommand.CommandType = CommandType.StoredProcedure;
            DataTable DtResult = new DataTable();
            da.Fill(DtResult);

            stiReport1.Load("stiReportRooms.mrt");
            stiReport1.RegData(DtResult);
            stiReport1.Show();
        }

        private void BtnReportSevice_Click(object sender, EventArgs e)
        {
            con = new SqlConnection("Server = . ; DataBase = DbHotel ; Integrated Security = True");
            SqlDataAdapter da = new SqlDataAdapter("ReportService", con);
            da.SelectCommand.CommandType = CommandType.StoredProcedure;
            DataTable DtResult = new DataTable();
            da.Fill(DtResult);

            stiReport1.Load("stiReportService.mrt");
            stiReport1.RegData(DtResult);
            stiReport1.Show();
        }

        private void BtnBackUp_Click(object sender, EventArgs e)
        {
            FrmBackUp fb = new FrmBackUp();
            fb.ShowDialog();
        }

        private void BtnRestore_Click(object sender, EventArgs e)
        {
            FrmRestore fr = new FrmRestore();
            fr.ShowDialog();
        }
    }
}
