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;

namespace Aram_CRM_Project.UIL
{
    public partial class frmDate : Form
    {
        public frmDate()
        {
            InitializeComponent();
        }

        private void frmDate_FormClosed(object sender, FormClosedEventArgs e)
        {
            Aram_CRM_Project.BLL.Entity.StaticVariable.FormDate_Shown = false;
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            Aram_CRM_Project.BLL.Entity.StaticVariable.FormDate_Shown = false;
            this.Dispose();
        }

        private void btnEnter_Click(object sender, EventArgs e)
        {
            Aram_CRM_Project.BLL.Entity.StaticVariable.SystemDate = nudYear.Value.ToString() + "/" + dudMonth.Text + "/" + dudDay.Text; ;
            ((frmParent)(this.MdiParent)).lblSystemDate.Text = nudYear.Value.ToString() + "/" + dudMonth.Text + "/" + dudDay.Text; ;

            Aram_CRM_Project.BLL.Entity.StaticVariable.FormDate_Shown = false;
            this.Dispose();
        }

        private void frmDate_Activated(object sender, EventArgs e)
        {
            string[] Date = Aram_CRM_Project.BLL.Entity.StaticVariable.SystemDate.Split('/');
            dudDay.Text = Date[2];
            dudMonth.Text = Date[1];
            nudYear.Value = int.Parse(Date[0]);
        }

        private void dudDay_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                btnEnter_Click(sender, e);
            if (!(e.KeyCode == Keys.Up || e.KeyCode == Keys.Down))
                e.SuppressKeyPress = true;
        }

        private void dudMonth_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                btnEnter_Click(sender, e);
            if (!(e.KeyCode == Keys.Up || e.KeyCode == Keys.Down))
                e.SuppressKeyPress = true;
        }

        private void nudYear_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                btnEnter_Click(sender, e);
            if (!(e.KeyCode == Keys.Up || e.KeyCode == Keys.Down))
                e.SuppressKeyPress = true;
        }
    }
}
