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.OleDb;
using System.IO;

namespace car
{
    public partial class menu : Form
    {
        public menu()
        {
            InitializeComponent();
        }
        private void buttonX1_Click(object sender, EventArgs e)
        {
            Form objform = new add_car();
            objform.ShowDialog();
        }


        private void menu_Load(object sender, EventArgs e)
        {
            try
            {
                System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar();
                lbldate.Text = p.GetYear(DateTime.Now).ToString() + "/" + p.GetMonth(DateTime.Now).ToString("0#") + "/" + p.GetDayOfMonth(DateTime.Now).ToString("0#");
                // Language.ChangeCurrentLanguage("fa");
                //sideBarPanelItem2.Expanded = true;
                switch (DateTime.Now.DayOfWeek)
                {
                    case DayOfWeek.Friday:
                        lblday.Text = "جمعه";
                        break;
                    case DayOfWeek.Monday:
                        lblday.Text = "دوشنبه";
                        break;
                    case DayOfWeek.Saturday:
                        lblday.Text = "شنبه";
                        break;
                    case DayOfWeek.Sunday:
                        lblday.Text = "یکشنبه";
                        break;
                    case DayOfWeek.Thursday:
                        lblday.Text = "پنجشنبه";
                        break;
                    case DayOfWeek.Tuesday:
                        lblday.Text = "سه شنبه";
                        break;
                    case DayOfWeek.Wednesday:
                        lblday.Text = "چهارشنبه";
                        break;
                }
                //LoadSettings();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "خطا");
            }
            
            
            if (variable.i == 2)
            {
                labelX1.Text = "کاربر فعلی : کاربر عادی";
                buttonX3.Enabled = false;
            }
            else
                labelX1.Text = "کاربر فعلی : کاربر مدیر";
        }

        private void buttonX2_Click(object sender, EventArgs e)
        {
            Form objform = new add_edit_sale();
            objform.ShowDialog();
        }

        private void buttonX6_Click(object sender, EventArgs e)
        {
            Form objform = new add_edit_customer();
            objform.ShowDialog();
        }

        private void buttonX7_Click(object sender, EventArgs e)
        {

        }

        private void buttonX8_Click(object sender, EventArgs e)
        {

        }

        private void buttonX9_Click(object sender, EventArgs e)
        {
            string PathToRestoreDB = Environment.CurrentDirectory + @"\cardb.mdb";

            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Text file (*.bk)|*.bk";

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                string Filetorestore = ofd.FileName;
                File.Copy(Filetorestore, PathToRestoreDB, true);
                MessageBox.Show("پشتیبان با موفقیت بازگردانی شد", "بازگرداندن پشتیبان");
            }  
        }

        private void buttonX5_Click(object sender, EventArgs e)
        {

        }

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

        private void buttonX11_Click(object sender, EventArgs e)
        {

        }

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

        private void buttonX3_Click(object sender, EventArgs e)
        {
            Form objform = new userfrm();
            objform.ShowDialog();
        }

        private void buttonX4_Click(object sender, EventArgs e)
        {
            string CurrentDatabasePath = Environment.CurrentDirectory + @"\cardb.mdb";

            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                string PathtobackUp = fbd.SelectedPath.ToString();
                File.Copy(CurrentDatabasePath, PathtobackUp + @"\CarBackUp.bk", true);
                MessageBox.Show("پشتیبان گیری با موفقیت انجام شد", "ایجاد پشتیبان");
            }
        }

        private void buttonX5_Click_1(object sender, EventArgs e)
        {
            Form objform = new chek();
            objform.ShowDialog();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            lbltime.Text = DateTime.Now.Hour.ToString("0#");
            lbltime.Text += " : ";
            lbltime.Text += DateTime.Now.Minute.ToString("0#");
            lbltime.Text += " : ";
            lbltime.Text += DateTime.Now.Second.ToString("0#");
        }

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

        private void buttonX7_Click_1(object sender, EventArgs e)
        {
            Form objform = new Form1();
            objform.ShowDialog();
        }

     }
}
