示例#1
0
        public Form1()
        {
            InitializeComponent();
            timer1.Enabled = true;

            inital_DataTime();

            //DR開始 預設現在+2分鐘   ~~~DR結束 預設現在+3分鐘
            string current1TimeStr = DateTime.Now.AddMinutes(2).ToString("yyyy-MM-dd HH:mm:ss");
            string current2TimeStr = DateTime.Now.AddMinutes(3).ToString("yyyy-MM-dd HH:mm:ss");

            DateJob.getString1(current1TimeStr);
            dtp.Value     = Convert.ToDateTime(DateJob.getYMD());
            dtpTime.Value = Convert.ToDateTime(DateJob.getHMS());
            DateJob.getString1(current2TimeStr);
            dtp2.Value     = Convert.ToDateTime(DateJob.getYMD());
            dtpTime2.Value = Convert.ToDateTime(DateJob.getHMS());
        }
示例#2
0
        //判斷三段電價
        public double getFeeNum(string date1)
        {
            double price;

            DateJob.getString1(date1);
            string Year  = DateJob.getYear();
            string Month = DateJob.getMonth();
            string Day   = DateJob.getDay();
            string Hour  = DateJob.getHour();
            string Min   = DateJob.getMin();
            string Sec   = DateJob.getSec();

            /*
             * MessageBox.Show("年 : " + DateJob.getYear() + "\n" +"月 : " + DateJob.getMonth() + "\n" +"日 : " + DateJob.getDay() + "\n" +
             * "時 : " + DateJob.getHour() + "\n" +"分 : " + DateJob.getMin() + "\n" +"秒 : " + DateJob.getSec() + "\n");
             */
            DateTime dt = new DateTime(Convert.ToInt32(Year), Convert.ToInt32(Month), Convert.ToInt32(Day));

            //判斷夏月 做出 三段式電價表
            if (Month.Equals("06") || Month.Equals("07") || Month.Equals("08") || Month.Equals("09"))
            {
                //夏月
                if (GetDayName(dt).Equals("6") || GetDayName(dt).Equals("7"))
                {
                    price = 1.71;
                }                //假日_全日離峰
                else
                {
                    //非假日
                    if (Hour.Equals("10") || Hour.Equals("11") || Hour.Equals("13") ||
                        Hour.Equals("14") || Hour.Equals("15") || Hour.Equals("16"))
                    {
                        price = 5.84;
                    }                //夏日平日_尖峰10-11.59 +13-16.59
                    else if ((Hour.Equals("07") && (Convert.ToInt32(Min) >= 30)) ||
                             Hour.Equals("08") || Hour.Equals("09") || Hour.Equals("12") ||
                             Hour.Equals("17") || Hour.Equals("18") || Hour.Equals("19") ||
                             Hour.Equals("20") || Hour.Equals("21") ||
                             (Hour.Equals("22") && (Convert.ToInt32(Min) < 30)))
                    {
                        price = 3.85;
                    }                //夏日平日_半尖峰
                    else
                    {
                        price = 1.71;
                    }                     //夏日平日_離峰
                }
            }
            else
            {
                //非夏月
                if (GetDayName(dt).Equals("6") || GetDayName(dt).Equals("7"))
                {
                    price = 1.65;
                }                //假日_全日離峰
                else
                {
                    //非假日
                    if ((Hour.Equals("07") && (Convert.ToInt32(Min) < 30)) ||
                        Hour.Equals("00") || Hour.Equals("01") || Hour.Equals("02") ||
                        Hour.Equals("03") || Hour.Equals("04") || Hour.Equals("05") ||
                        Hour.Equals("06") || Hour.Equals("11") ||
                        (Hour.Equals("22") && (Convert.ToInt32(Min) >= 30)))
                    {
                        price = 1.65;
                    }                //非夏月平日_離峰0-7.30 + 22.30-24.00
                    else
                    {
                        price = 3.69;
                    }                //非夏月平日_半尖峰
                }
            }
            return(price);
        }