using System.Collections.Generic;
using System;
using System.Drawing;
using System.Diagnostics;
using System.Data;
using System.Collections;
using System.Windows.Forms;
using AR;
using System.Linq;

namespace vmsnet
{
    public partial class Frm_GraphSetup
    {

        public Frm_GraphSetup()
        {

            // 이 호출은 디자이너에 필요합니다.
            InitializeComponent();
        }
        public void Button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        public void Frm_GraphSetup_Load(object sender, EventArgs e)
        {
            dts.Value = PUB.TREND.graph_time_start;
            dte.Value = PUB.TREND.graph_time_end;
        }

        public void Button2_Click(object sender, EventArgs e)
        {
            PUB.TREND.graph_time_start = dts.Value;
            PUB.TREND.graph_time_end = dte.Value;
            PUB.CONFIG.Save();
            DialogResult = System.Windows.Forms.DialogResult.OK;
        }


        public void Frm_GraphSetup_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
                case Keys.Escape:
                    bt_cancel.PerformClick();
                    break;
                case Keys.Enter:
                    bt_ok.PerformClick();
                    break;
            }
        }


        private void button1_Click_1(object sender, EventArgs e)
        {
            var dates = PUB.DB.GetAvailableDates();
            if (dates.Any() == false)
            {
                UTIL.MsgE("가능한 날짜가 없습니다");
                return;
            }
            var lastmon = dates.Last();
            dte.Value = DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59"));
            dts.Value = dte.Value.AddMonths(-1).AddSeconds(1);
        }




        private void button2_Click_1(object sender, EventArgs e)
        {
            dte.Value = DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59"));
            dts.Value = dte.Value.AddDays(-7).AddSeconds(1);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            dts.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-01 00:00:00"));
            dte.Value = DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59"));
        }
    }
}
