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 Transport.BLL;
using System.Globalization;

namespace Transport
{
    public partial class masterform : Office2007Form
    {
        public masterform()
        {
            InitializeComponent();
        }

        /// <summary>
        /// متد ایجاد تاریخ شمسی به همراه زمان با فرمت کامل
        /// </summary>
        /// <returns></returns>
        public static string PersianDatetime()
        {
            PersianCalendar pcDate = new PersianCalendar();
            int persianYear = pcDate.GetYear(DateTime.Now);
            int persianMonth = pcDate.GetMonth(DateTime.Now);
            int persianDay = pcDate.GetDayOfMonth(DateTime.Now);

            string CurrentTime = DateTime.Now.ToString("hh-mm-ss");

            string fullPersianDate = persianYear.ToString() + "-" + persianMonth.ToString() + "-" + persianDay.ToString() + "-" + CurrentTime;
            return fullPersianDate;
        }

        public static string PersianDatetime(string DateType)
        {
            PersianCalendar pcDate = new PersianCalendar();
            int persianYear = pcDate.GetYear(DateTime.Now);
            int persianMonth = pcDate.GetMonth(DateTime.Now);
            int persianDay = pcDate.GetDayOfMonth(DateTime.Now);

            string DayName = "";
            switch (DateTime.Now.DayOfWeek)
            {
                case DayOfWeek.Saturday:
                    DayName = " شنبه ";
                    break;
                case DayOfWeek.Sunday:
                    DayName = " یکشنبه ";
                    break;
                case DayOfWeek.Monday:
                    DayName = " دوشنبه ";
                    break;
                case DayOfWeek.Tuesday:
                    DayName = " سه شنبه ";
                    break;
                case DayOfWeek.Wednesday:
                    DayName = " چهارشنبه ";
                    break;
                case DayOfWeek.Thursday:
                    DayName = " پنج شنبه ";
                    break;
                case DayOfWeek.Friday:
                    DayName = " جمـــعه ";
                    break;
            }
            

            string fullPersianDate =" امـــــروز   "+DayName+"  "+ persianYear.ToString() + "/" + persianMonth.ToString("D2") + "/" + persianDay.ToString("D2")  ;
            return fullPersianDate;
        }

      

        // متد تهیه بک آپ از بانک اطلاعاتی - در اصل یک کپی از فایل اکسس را به مسیر تعیین شده در تنظیمات برنامه را انتقال می دهد
        public static void Backup()
        {
            // ----------------------------------- 
            // -- CREATE FILE BACKUP 
            // ----------------------------------- 

            string src = Application.StartupPath + @"\transportdb.mdb";
            string dst = "";

            System.Data.DataTable settingsDT = bll_settings.Select_App_Settings();
            if (settingsDT.Rows.Count > 0)
            {

                string backup_path = settingsDT.Rows[0].ItemArray[2].ToString();

                if (backup_path == "")
                {
                    dst = "c:/";
                }
                else
                {
                    dst = backup_path;
                }
                dst = dst + "\\" + "transportdb-" + PersianDatetime() + ".mdb";

            }

            try
            {

                System.IO.File.Copy(src, dst, true);

            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.ToString());
            }


        }

        private void masterform_Load(object sender, EventArgs e)
        {
            lbl_shamsiDate.Text = PersianDatetime("ForMainForm");
            InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(System.Globalization.CultureInfo.CreateSpecificCulture("fa-IR"));
        }

        private void button1_Click(object sender, EventArgs e)
        {
            cost_group frm_cost_group = new cost_group();
            frm_cost_group.ShowDialog();
        }

        private void buttonItem15_Click(object sender, EventArgs e)
        {
            settings frm_settings = new settings();
            frm_settings.ShowDialog();
        }

        private void btn_add_transport_in_Click(object sender, EventArgs e)
        {
            transport_in_edit frm_transport_in_edit = new transport_in_edit();
            frm_transport_in_edit.ShowDialog();
        }

        private void btn_add_transport_out_Click(object sender, EventArgs e)
        {
            transport_out_edit frm_transport_out_edit = new transport_out_edit();
            frm_transport_out_edit.ShowDialog();
        }

        private void btn_all_transport_in_Click(object sender, EventArgs e)
        {
            transport_in frm_transport_in = new transport_in();
            frm_transport_in.ShowDialog();
        }

        private void btn_all_transport_out_Click(object sender, EventArgs e)
        {
            transport_out frm_transport_out = new transport_out();
            frm_transport_out.ShowDialog();
        }

        private void btn_transport_report_Click(object sender, EventArgs e)
        {
            main frm_main = new main();
            frm_main.ShowDialog();
        }

        private void btn_add_company_Click(object sender, EventArgs e)
        {
            edit_company frm_edit_company = new edit_company();
            frm_edit_company.ShowDialog();
        }

        private void btn_all_company_Click(object sender, EventArgs e)
        {
            company frm_compony = new company();
            frm_compony.ShowDialog();
        }

        private void btn_all_city_Click(object sender, EventArgs e)
        {
            city frm_city = new city();
            frm_city.ShowDialog();
        }

        private void btn_add_city_Click(object sender, EventArgs e)
        {
            edit_city frm_edit_city = new edit_city();
            frm_edit_city.ShowDialog();
        }

        private void masterform_FormClosing(object sender, FormClosingEventArgs e)
        {
            Application.Exit();
        }

        private void btn_add_cost_group_Click(object sender, EventArgs e)
        {
            edit_cost_group frm_edit_cost_group = new edit_cost_group();
            frm_edit_cost_group.ShowDialog();
        }

        private void btn_all_cost_group_Click(object sender, EventArgs e)
        {
            cost_group frm_cost_group = new cost_group();
            frm_cost_group.ShowDialog();
        }

        private void btn_add_cost_Click(object sender, EventArgs e)
        {
            edit_cost frm_edit_cost = new edit_cost();
            frm_edit_cost.ShowDialog();
        }

        private void btn_all_cost_Click(object sender, EventArgs e)
        {
            cost frm_cost = new cost();
            frm_cost.ShowDialog();
        }

        private void btn_about_Click(object sender, EventArgs e)
        {
            about frm_about = new about();
            frm_about.ShowDialog();
        }

        private void img_transport_in_Click(object sender, EventArgs e)
        {
            transport_in_edit frm_transport_in_edit = new transport_in_edit();
            frm_transport_in_edit.ShowDialog();
        }

        private void img_transport_out_Click(object sender, EventArgs e)
        {
            transport_out_edit frm_transport_out_edit = new transport_out_edit();
            frm_transport_out_edit.ShowDialog();
        }

        private void img_transport_in_all_Click(object sender, EventArgs e)
        {
            transport_in frm_transport_in = new transport_in();
            frm_transport_in.ShowDialog();
        }

        private void img_transport_out_all_Click(object sender, EventArgs e)
        {
            transport_out frm_transport_out = new transport_out();
            frm_transport_out.ShowDialog();
        }

        private void img_company_Click(object sender, EventArgs e)
        {
            edit_company frm_edit_company = new edit_company();
            frm_edit_company.ShowDialog();
        }

        private void img_company_all_Click(object sender, EventArgs e)
        {
            company frm_compony = new company();
            frm_compony.ShowDialog();
        }

        private void img_city_Click(object sender, EventArgs e)
        {
            edit_city frm_edit_city = new edit_city();
            frm_edit_city.ShowDialog();
        }

        private void img_city_all_Click(object sender, EventArgs e)
        {
            city frm_city = new city();
            frm_city.ShowDialog();
        }

        private void img_cost_Click(object sender, EventArgs e)
        {
            edit_cost frm_edit_cost = new edit_cost();
            frm_edit_cost.ShowDialog();
        }

        private void img_cost_all_Click(object sender, EventArgs e)
        {
            cost frm_cost = new cost();
            frm_cost.ShowDialog();
        }

        private void img_cost_group_Click(object sender, EventArgs e)
        {
            edit_cost_group frm_edit_cost_group = new edit_cost_group();
            frm_edit_cost_group.ShowDialog();
        }

        private void img_cost_group_all_Click(object sender, EventArgs e)
        {
            cost_group frm_cost_group = new cost_group();
            frm_cost_group.ShowDialog();
        }

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

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

        private void lbl_transport_in_Click(object sender, EventArgs e)
        {
            transport_in_edit frm_transport_in_edit = new transport_in_edit();
            frm_transport_in_edit.ShowDialog();
        }

        private void lbl_transport_out_Click(object sender, EventArgs e)
        {
            transport_out_edit frm_transport_out_edit = new transport_out_edit();
            frm_transport_out_edit.ShowDialog();
        }

        private void lbl_company_Click(object sender, EventArgs e)
        {
            edit_company frm_edit_company = new edit_company();
            frm_edit_company.ShowDialog();
        }

        private void lbl_city_Click(object sender, EventArgs e)
        {
            edit_city frm_edit_city = new edit_city();
            frm_edit_city.ShowDialog();
        }

        private void lbl_cost_Click(object sender, EventArgs e)
        {
            edit_cost frm_edit_cost = new edit_cost();
            frm_edit_cost.ShowDialog();
        }

        private void lbl_cost_group_Click(object sender, EventArgs e)
        {
            edit_cost_group frm_edit_cost_group = new edit_cost_group();
            frm_edit_cost_group.ShowDialog();
        }

        private void lbl_transport_in_all_Click(object sender, EventArgs e)
        {
            transport_in frm_transport_in = new transport_in();
            frm_transport_in.ShowDialog();
        }

        private void lbl_transport_out_all_Click(object sender, EventArgs e)
        {
            transport_out frm_transport_out = new transport_out();
            frm_transport_out.ShowDialog();
        }

        private void lbl_company_all_Click(object sender, EventArgs e)
        {
            company frm_compony = new company();
            frm_compony.ShowDialog();
        }

        private void lbl_city_all_Click(object sender, EventArgs e)
        {
            city frm_city = new city();
            frm_city.ShowDialog();
        }

        private void lbl_cost_all_Click(object sender, EventArgs e)
        {
            cost frm_cost = new cost();
            frm_cost.ShowDialog();
        }

        private void lbl_cost_group_all_Click(object sender, EventArgs e)
        {
            cost_group frm_cost_group = new cost_group();
            frm_cost_group.ShowDialog();
        }
    }
}
