using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using mgh;
using CommonLayer;

namespace Grocery
{
    public partial class FrmMain : Form
    {        
        public FrmMain()
        {
            InitializeComponent();
        }

        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 FrmMain_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)
            {
                FarsiMessagbox.Show(ex.Message, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }


            //System.IO.Stream MovieStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Grocery.button2.swf");
            //f_in_box__control1.PutMovieFromStream(MovieStream);

            //MovieStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Grocery.button.swf");
            //f_in_box__control2.PutMovieFromStream(MovieStream);

            //MovieStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Grocery.button3.swf");
            //f_in_box__control3.PutMovieFromStream(MovieStream);
        }

        
        private void btncustomers_Click(object sender, EventArgs e)
        {
            try
            {
                FrmCustomers customers = new FrmCustomers();
                customers.ShowDialog();
            }
            catch { }
        }

        private void btnkalas_Click(object sender, EventArgs e)
        {
            try
            {
                FrmKala kala = new FrmKala();
                kala.ShowDialog();
            }
            catch { }
        }

        private void btnsandoghs_Click(object sender, EventArgs e)
        {
            try
            {
                FrmSandogh sandogh = new FrmSandogh();
                sandogh.ShowDialog();
            }
            catch { }
        }

        private void btnchecks_Click(object sender, EventArgs e)
        {
            FrmChek check = new FrmChek();
            check.ShowDialog();
        }

        private void btnfrosh_Click(object sender, EventArgs e)
        {
            try
            {
                FrmFaktor faktor = new FrmFaktor(CommonLayer.FaktorMod.Frosh);
                faktor.ShowDialog();
            }
            catch { }
        }

        private void btnkharid_Click(object sender, EventArgs e)
        {
            try
            {
                FrmFaktor faktor = new FrmFaktor(CommonLayer.FaktorMod.Kharid);
                faktor.ShowDialog();
            }
            catch { }
        }

        private void btnbazgashtfrosh_Click(object sender, EventArgs e)
        {
            try
            {
                FrmFaktor faktor = new FrmFaktor(CommonLayer.FaktorMod.BazgashtFrosh);
                faktor.Show();
            }
            catch { }
        }

        private void btnbazgashtkharid_Click(object sender, EventArgs e)
        {
            try
            {
                FrmFaktor faktor = new FrmFaktor(CommonLayer.FaktorMod.BazgashtKharid);
                faktor.ShowDialog();
            }
            catch { }
        }

        private void btnsettings_Click(object sender, EventArgs e)
        {
            try
            {
                FrmSetting setting = new FrmSetting();
                setting.ShowDialog();
                LoadSettings();
            }
            catch { }
        }

        private void LoadSettings()
        {
            try
            {
                Settings.LoadSettings();
                 panelEx1.Text= Settings.Name;
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ex.Message, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }
        private void btnanbar_Click(object sender, EventArgs e)
        {
            FrmAnbar anbar = new FrmAnbar();
            anbar.ShowDialog();
        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void btnchangewallpaper_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                Image img = Image.FromFile(openFileDialog1.FileName);
                this.pictureBox3.Image = img;
                img = Image.FromFile(Application.StartupPath + "\\Untitled-2 copy.png");
                Graphics g= this.pictureBox4.CreateGraphics();
                Point p = new Point(pictureBox4.Left , pictureBox4.Top);
                g.DrawImage(img, p);
                
            }
        }        
    }
}
