protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        //2017-10-25建立一個判斷星期的物件
        Lib.WorkWeek wk = new Lib.WorkWeek(e.Day.Date.Year);

        Calendar1.Visible = true;
        TaiwanCalendar tc = new TaiwanCalendar();
        CultureInfo    ci = new CultureInfo("zh-TW");

        ci.DateTimeFormat.Calendar          = tc;
        ci.DateTimeFormat.YearMonthPattern  = "民國yy年MM月";
        ci.DateTimeFormat.FirstDayOfWeek    = DayOfWeek.Sunday;
        Thread.CurrentThread.CurrentCulture = ci;
        if (Page.IsPostBack)
        {
            allow = Lib.SysSetting.getAllowedDates(this.cneterSel.SelectedValue);
            deny  = Lib.SysSetting.getDeniedDates(this.cneterSel.SelectedValue);
            //if (e.Day.IsWeekend)
            if (wk.DicWeek[e.Day.Date.DayOfWeek] == false)//2017-10-25新寫法
            {
                DateTime dt      = Lib.SysSetting.ToWorldDate(e.Day.Date.ToShortDateString());
                bool     _isOver = Lib.SysSetting.isOverTime(dt);
                if (_isOver == true)
                {
                    LiteralControl l = (LiteralControl)e.Cell.Controls[0];
                    e.Cell.Controls.RemoveAt(0);
                    e.Cell.Text = l.Text;
                }
                else
                {
                    if (dt.DayOfWeek == DayOfWeek.Friday)
                    {
                        e.Cell.BackColor = System.Drawing.Color.Red;
                        e.Cell.ForeColor = System.Drawing.Color.White;
                        LiteralControl l = (LiteralControl)e.Cell.Controls[0];
                        e.Cell.Controls.RemoveAt(0);
                        e.Cell.Text = l.Text;
                    }
                    else
                    {
                        int i = 0;
                        foreach (KeyValuePair <string, DateTime> s in allow)
                        {
                            if (e.Day.Date == s.Value)
                            {
                                e.Cell.BackColor = System.Drawing.Color.Green;
                                e.Cell.ForeColor = System.Drawing.Color.White;
                            }
                            else
                            {
                                i++;
                            }
                        }
                        if (i == allow.Count)
                        {
                            LiteralControl l = (LiteralControl)e.Cell.Controls[0];
                            e.Cell.Controls.RemoveAt(0);
                            e.Cell.Text = l.Text;
                        }
                    }
                }
            }
            //if (!e.Day.IsWeekend)
            if (wk.DicWeek[e.Day.Date.DayOfWeek] == true)//2017-10-25新寫法
            {
                DateTime dt      = Lib.SysSetting.ToWorldDate(e.Day.Date.ToShortDateString());
                bool     _isOver = Lib.SysSetting.isOverTime(dt);
                if (_isOver == true)
                {
                    LiteralControl l = (LiteralControl)e.Cell.Controls[0];
                    e.Cell.Controls.RemoveAt(0);
                    e.Cell.Text = l.Text;
                }
                else
                {
                    if (dt.DayOfWeek == DayOfWeek.Friday)
                    {
                        e.Cell.BackColor = System.Drawing.Color.Red;
                        e.Cell.ForeColor = System.Drawing.Color.White;
                        LiteralControl l = (LiteralControl)e.Cell.Controls[0];
                        e.Cell.Controls.RemoveAt(0);
                        e.Cell.Text = l.Text;
                    }
                    else
                    {
                        foreach (KeyValuePair <string, DateTime> d in deny)
                        {
                            if (e.Day.Date == d.Value)
                            {
                                e.Cell.BackColor = System.Drawing.Color.Red;
                                e.Cell.ForeColor = System.Drawing.Color.White;
                                LiteralControl l = (LiteralControl)e.Cell.Controls[0];
                                e.Cell.Controls.RemoveAt(0);
                                e.Cell.Text = l.Text;
                            }
                        }
                    }
                }
            }
        }
        Calendar1.Visible                   = true;
        ci.DateTimeFormat.Calendar          = tc;
        ci.DateTimeFormat.YearMonthPattern  = "民國yy年MM月";
        ci.DateTimeFormat.FirstDayOfWeek    = DayOfWeek.Sunday;
        Thread.CurrentThread.CurrentCulture = ci;
    }
Beispiel #2
0
    protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        //設定假日開放及平日關閉工能鍵
        //2017-10-25建立一個判斷星期的物件
        Lib.WorkWeek wk = new Lib.WorkWeek(e.Day.Date.Year);

        #region render center limit control
        Label label_limit = new Label();
        Dictionary <string, object> list = new Dictionary <string, object>();

        string   rocDate = e.Day.Date.ToShortDateString();
        string[] lines   = rocDate.Split(new string[] { @"/" }, StringSplitOptions.None);
        if (lines.Length > 0)
        {
            list.Add("date", (1911 + Convert.ToInt32(lines[0])).ToString() + "-" + lines[1] + "-" + lines[2]);
        }
        else
        {
            list.Add("date", DateTime.Now.ToShortDateString());
        }

        list.Add("center_code", Request.Params["center"]);
        DataTable dt_limit = new Lib.DataUtility().getDataTableBysp("Ex102_GetCenterLimit", list);
        label_limit.Text = dt_limit.Rows[0]["limit"].ToString();
        if (dt_limit.Rows[0]["limit"].ToString() != dt_limit.Rows[0]["default"].ToString())
        {
            label_limit.ForeColor = System.Drawing.Color.Red;
        }
        else
        {
            label_limit.ForeColor = System.Drawing.Color.Yellow;
        }
        e.Cell.Controls.Add(new LiteralControl("<br />"));


        #endregion
        allow = (Dictionary <string, DateTime>)Session["allow"];
        deny  = (Dictionary <string, DateTime>)Session["deny"];

        if (wk.isSetYear == true)                         //2017-10-25先判斷年份是否已開啟
        {
            if (wk.DicWeek[e.Day.Date.DayOfWeek] == true) //工作日
            {
                if (deny.Count > 0)
                {
                    foreach (KeyValuePair <string, DateTime> d in deny)
                    {
                        if (e.Day.Date == d.Value)//可是關閉
                        {
                            e.Cell.BackColor = System.Drawing.Color.Red;
                            e.Cell.ForeColor = System.Drawing.Color.White;
                            e.Cell.Controls.Remove(label_limit);
                            break;
                        }
                        else
                        {
                            e.Cell.Controls.Add(label_limit);
                        }
                    }
                }
                else
                {
                    e.Cell.Controls.Add(label_limit);
                }
            }

            else//非工作日
            {
                if (allow.Count > 0)
                {
                    foreach (KeyValuePair <string, DateTime> d in allow)
                    {
                        if (e.Day.Date == d.Value)//可是有開放
                        {
                            e.Cell.BackColor = System.Drawing.Color.Green;
                            e.Cell.ForeColor = System.Drawing.Color.White;
                            e.Cell.Controls.Add(label_limit);
                            break;
                        }
                        else
                        {
                            e.Cell.BackColor = System.Drawing.Color.DimGray;
                            e.Cell.Controls.Remove(label_limit);
                        }
                    }
                }
                else
                {
                }
            }
        }
        else
        {
            e.Cell.Visible = false;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Account a = (Account)Session["account"];

        if (a.Role != ((int)SysSetting.Role.admin_hq).ToString())
        {
            Response.Redirect("~/index.aspx");
        }
        else
        {
            //ch1 = cbl_WeekCheck.Items[0].Selected;
            //ch2 = cbl_WeekCheck.Items[1].Selected;
            //ch3 = cbl_WeekCheck.Items[2].Selected;
            //ch4 = cbl_WeekCheck.Items[3].Selected;
            //ch5 = cbl_WeekCheck.Items[4].Selected;
            //ch6 = cbl_WeekCheck.Items[5].Selected;
            //ch7 = cbl_WeekCheck.Items[6].Selected;
            ch1 = cb_Monday.Checked;
            ch2 = cb_Tuesday.Checked;
            ch3 = cb_Wednesday.Checked;
            ch4 = cb_Thursday.Checked;
            ch5 = cb_Friday.Checked;
            ch6 = cb_Saturday.Checked;
            ch7 = cb_Sunday.Checked;

            int year_addone = System.DateTime.Now.Year + 1 - 1911;
            year.Text = "民國" + year_addone.ToString() + "年度";
            Year      = System.DateTime.Now.Year + 1;//西元明年

            wk = new Lib.WorkWeek(System.DateTime.Now.Year + 1);
            lab_LastYear.Text = "(民國" + year_addone.ToString() + "年)";
            if (wk.isSetYear == true)
            {
                lab_SetStatus.Text        = "已設定";
                lab_SetStatus.ForeColor   = Color.Blue;
                btn_SetWorkWeek.Text      = "更新";
                btn_SetWorkWeek.ForeColor = Color.Blue;
                btn_SetWorkWeek.BackColor = Color.Aquamarine;
                //cbl_WeekCheck.Items[0].Selected = wk.DicWeek[DayOfWeek.Monday];
                //cbl_WeekCheck.Items[1].Selected = wk.DicWeek[DayOfWeek.Tuesday];
                //cbl_WeekCheck.Items[2].Selected = wk.DicWeek[DayOfWeek.Wednesday];
                //cbl_WeekCheck.Items[3].Selected = wk.DicWeek[DayOfWeek.Thursday];
                //cbl_WeekCheck.Items[4].Selected = wk.DicWeek[DayOfWeek.Friday];
                //cbl_WeekCheck.Items[5].Selected = wk.DicWeek[DayOfWeek.Saturday];
                //cbl_WeekCheck.Items[6].Selected = wk.DicWeek[DayOfWeek.Sunday];
                cb_Monday.Checked    = wk.DicWeek[DayOfWeek.Monday];
                cb_Tuesday.Checked   = wk.DicWeek[DayOfWeek.Tuesday];
                cb_Wednesday.Checked = wk.DicWeek[DayOfWeek.Wednesday];
                cb_Thursday.Checked  = wk.DicWeek[DayOfWeek.Thursday];
                cb_Friday.Checked    = wk.DicWeek[DayOfWeek.Friday];
                cb_Saturday.Checked  = wk.DicWeek[DayOfWeek.Saturday];
                cb_Sunday.Checked    = wk.DicWeek[DayOfWeek.Sunday];
            }
            else
            {
                lab_SetStatus.Text        = "未設定";
                lab_SetStatus.ForeColor   = Color.Red;
                btn_SetWorkWeek.Text      = "設定";
                btn_SetWorkWeek.ForeColor = Color.Red;
                btn_SetWorkWeek.BackColor = Color.Pink;
                //cbl_WeekCheck.Items[0].Selected = false;
                //cbl_WeekCheck.Items[1].Selected = false;
                //cbl_WeekCheck.Items[2].Selected = false;
                //cbl_WeekCheck.Items[3].Selected = false;
                //cbl_WeekCheck.Items[4].Selected = false;
                //cbl_WeekCheck.Items[5].Selected = false;
                //cbl_WeekCheck.Items[6].Selected = false;
                cb_Monday.Checked    = false;
                cb_Tuesday.Checked   = false;
                cb_Wednesday.Checked = false;
                cb_Thursday.Checked  = false;
                cb_Friday.Checked    = false;
                cb_Saturday.Checked  = false;
                cb_Sunday.Checked    = false;
            }



            Lib.DataUtility             du = new Lib.DataUtility();
            Dictionary <string, object> d  = new Dictionary <string, object>();
            d.Add("year", System.DateTime.Now.Year + 1);
            DataTable dt = du.getDataTableByText("select * from year where year = @year", d);
            if (dt.Rows.Count == 1)
            {
                if (Convert.ToBoolean(dt.Rows[0]["islock"]))
                {
                    year_status.Text      = "關閉報進";
                    year_status.ForeColor = Color.Red;
                    Button1.Text          = "開放";
                    Button1.ForeColor     = Color.Green;
                    Button1.BackColor     = Color.PaleGreen;
                    isopen = Convert.ToBoolean(dt.Rows[0]["islock"]);
                }
                else
                {
                    year_status.Text      = "開放報進";
                    year_status.ForeColor = Color.Green;
                    Button1.Text          = "關閉";
                    Button1.ForeColor     = Color.Red;
                    Button1.BackColor     = Color.Pink;
                    isopen = Convert.ToBoolean(dt.Rows[0]["islock"]);
                }
            }


            if (IsPostBack)
            {
                //int year_addone = System.DateTime.Now.Year + 1 - 1911;
                year.Text = "民國" + year_addone.ToString() + "年度";
                d.Clear();
                d.Add("year", System.DateTime.Now.Year + 1);
                dt = du.getDataTableByText("select * from year where year = @year", d);
                if (dt.Rows.Count == 1)
                {
                    if (Convert.ToBoolean(dt.Rows[0]["islock"]))
                    {
                        year_status.Text      = "關閉報進";
                        year_status.ForeColor = Color.Red;
                        Button1.Text          = "開放";
                        Button1.ForeColor     = Color.Green;
                        Button1.BackColor     = Color.PaleGreen;
                        isopen = Convert.ToBoolean(dt.Rows[0]["islock"]);
                    }
                    else
                    {
                        year_status.Text      = "開放報進";
                        year_status.ForeColor = Color.Green;
                        Button1.Text          = "關閉";
                        Button1.ForeColor     = Color.Red;
                        Button1.BackColor     = Color.Pink;
                        isopen = Convert.ToBoolean(dt.Rows[0]["islock"]);
                    }
                }
                //前端已經先關好站了,再來處理關站刪除
                if (HF_CheckDel.Value == "ok")
                {
                    HF_CheckDel.Value = "no";
                    //逐筆寄信後刪除
                    string date        = txb_InqDate.Text;
                    string center_name = DropDownList1.SelectedItem.Text;
                    string reason      = txb_Reason.Text;//關站原因
                    for (int i = 0; i < GridView2.Rows.Count; i++)
                    {
                        string sid  = GridView2.Rows[i].Cells[0].Text;
                        string id   = GridView2.Rows[i].Cells[2].Text;
                        string mail = GridView2.Rows[i].Cells[8].Text;


                        //檢查信箱欄位,有的才寄信
                        //信件文字檔案夾位置
                        string       dd = Server.MapPath(Request.ApplicationPath);
                        StreamReader _MailContentToUser = new StreamReader(dd + "\\Mail\\OffStation.txt");
                        //先寄信
                        if (!string.IsNullOrEmpty(mail) & mail != "&nbsp;")//表格空字串會變成「&nbsp;」
                        {
                            MailMessage _MailToUser = new MailMessage();
                            _MailToUser.Body = _MailContentToUser.ReadToEnd();
                            _MailToUser.Body = _MailToUser.Body.Replace("%reason%", reason);
                            _MailToUser.Body = _MailToUser.Body.Replace("%id%", (id.Substring(0, id.Length - 3) + "***"));
                            _MailToUser.Body = _MailToUser.Body.Replace("%date%", date);
                            _MailToUser.Body = _MailToUser.Body.Replace("%location%", center_name);
                            Lib.SysSetting.SaveLetter(mail + "@webmail.mil.tw", "國軍體能鑑測中心", _MailToUser.Body, "臨時關站取消報名通知信", "00");
                        }

                        //再刪報名
                        du.executeNonQueryBysp("Ex107_DelResultbySid", "sid", sid);
                    }
                    Lib.SysSetting.AddLog("臨時關站", "admin", "臨時關站取消報名 , 日期:" + date + " , 地點:" + center_name, System.DateTime.Now);
                    GridView2.DataSource = null;
                    GridView2.DataBind();
                    CloseEnter();
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('鑑測站已關閉,報名資料已刪除。');", true);

                    //重新整理網頁
                    //Response.Redirect(Request.FilePath);
                }
            }
        }
    }
Beispiel #4
0
    protected void Calendar1_SelectionChanged1(object sender, EventArgs e)
    {
        if (DateTime.Compare(Calendar1.SelectedDate, DateTime.Now.AddDays(-1)) > 0)//日期要大於今天
        {
            //查詢日期有沒有被設定,有的話就不作動作
            string center_code = Request.Params["center"];
            string Seldt       = Calendar1.SelectedDate.Year.ToString() + "/" + Calendar1.SelectedDate.Month.ToString() + "/" + Calendar1.SelectedDate.Day.ToString();
            Dictionary <string, object> list = new Dictionary <string, object>();
            list.Add("center_code", center_code);
            list.Add("date", Seldt);
            Lib.DataUtility du1 = new Lib.DataUtility();
            DataTable       dt1 = du1.getDataTableBysp("Ex107_GetWeekSetDay", list);
            if (dt1.Rows.Count == 0)//工作日表格沒設定值才動作
            {
                list.Clear();
                dt1.Dispose();
                //設定假日開放及平日關閉工能鍵
                //2017-10-25建立一個判斷星期的物件
                Lib.WorkWeek wk = new Lib.WorkWeek(Calendar1.SelectedDate.Year);
                date.Text = Calendar1.SelectedDate.ToShortDateString();

                if (string.IsNullOrEmpty(date.Text))
                {
                    list.Add("date", DateTime.Now.ToShortDateString());
                }
                else
                {
                    string   rocDate = date.Text;
                    string[] lines   = rocDate.Split(new string[] { @"/" }, StringSplitOptions.None);
                    if (lines.Length > 0)
                    {
                        list.Add("date", (1911 + Convert.ToInt32(lines[0])).ToString() + "-" + lines[1] + "-" + lines[2]);
                    }
                    else
                    {
                        list.Add("date", DateTime.Now.ToShortDateString());
                    }
                }
                list.Add("center_code", Request.Params["center"]);
                Lib.DataUtility du       = new Lib.DataUtility();
                DataTable       dt_limit = du.getDataTableBysp("Ex102_GetCenterLimit", list);
                //limit.Text = dt_limit.Rows[0]["default"].ToString();
                txtLimit.Text = dt_limit.Rows[0]["limit"].ToString();
                //2017-10-25更改工作日判斷方式
                //if (Calendar1.SelectedDate.DayOfWeek == DayOfWeek.Sunday || Calendar1.SelectedDate.DayOfWeek == DayOfWeek.Saturday)
                if (wk.isSetYear == true)
                {
                    if (wk.DicWeek[Calendar1.SelectedDate.DayOfWeek] == false)
                    {
                        selDate.Value = "week";
                        if (!Page.ClientScript.IsStartupScriptRegistered("clicktest"))
                        {
                            ScriptManager.RegisterStartupScript(Page, GetType(), "clicktest", "<script>clicktest('確認 「開放」?')</script>", false);
                        }
                    }
                    else
                    {
                        selDate.Value = "work";
                        if (!Page.ClientScript.IsStartupScriptRegistered("clicktest"))
                        {
                            ScriptManager.RegisterStartupScript(Page, GetType(), "clicktest", "<script>clicktest('確認 「關閉」?')</script>", false);
                        }
                    }
                }
            }
            else
            {
                list.Clear();
                dt1.Dispose();
                //設定假日開放及平日關閉工能鍵
                //2017-10-25建立一個判斷星期的物件
                Lib.WorkWeek wk = new Lib.WorkWeek(Calendar1.SelectedDate.Year);
                date.Text = Calendar1.SelectedDate.ToShortDateString();

                if (string.IsNullOrEmpty(date.Text))
                {
                    list.Add("date", DateTime.Now.ToShortDateString());
                }
                else
                {
                    string   rocDate = date.Text;
                    string[] lines   = rocDate.Split(new string[] { @"/" }, StringSplitOptions.None);
                    if (lines.Length > 0)
                    {
                        list.Add("date", (1911 + Convert.ToInt32(lines[0])).ToString() + "-" + lines[1] + "-" + lines[2]);
                    }
                    else
                    {
                        list.Add("date", DateTime.Now.ToShortDateString());
                    }
                }
                list.Add("center_code", Request.Params["center"]);
                Lib.DataUtility du       = new Lib.DataUtility();
                DataTable       dt_limit = du.getDataTableBysp("Ex102_GetCenterLimit", list);
                //limit.Text = dt_limit.Rows[0]["default"].ToString();
                txtLimit.Text = dt_limit.Rows[0]["limit"].ToString();
            }
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('無法變更當日之前之設定!!');", true);
        }
    }
Beispiel #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["account"] != null)
        {
            Account a = (Account)Session["account"];
            if (a.Role != ((int)SysSetting.Role.admin_hq).ToString())
            {
                Response.Redirect("~/index.aspx");
            }
            else
            {
                //顯示年度工作日
                ch1 = cb_Mon.Checked;
                ch2 = cb_Tue.Checked;
                ch3 = cb_Wed.Checked;
                ch4 = cb_Thu.Checked;
                ch5 = cb_Fri.Checked;
                ch6 = cb_Sat.Checked;
                ch7 = cb_Sun.Checked;

                int year_addone = System.DateTime.Now.Year + 1 - 1911;
                year.Text = "民國" + year_addone.ToString() + "年度";
                next_Year = System.DateTime.Now.Year + 1;                           //西元明年

                thisYear_wk       = new Lib.WorkWeek(System.DateTime.Now.Year);     //今年
                nextYear_wk       = new Lib.WorkWeek(System.DateTime.Now.Year + 1); //明年
                lab_ThisYear.Text = "民國" + (year_addone - 1).ToString() + "年";
                lab_NextYear.Text = "民國" + year_addone.ToString() + "年";
                //顯示今年資料
                if (thisYear_wk.isSetYear == true)
                {
                    if (thisYear_wk.DicWeek[DayOfWeek.Monday] == true)
                    {
                        lab_Mon.Text      = "ON";
                        lab_Mon.ForeColor = Color.Green;
                    }
                    else
                    {
                        lab_Mon.Text      = "OFF";
                        lab_Mon.ForeColor = Color.Red;
                    }
                    if (thisYear_wk.DicWeek[DayOfWeek.Tuesday] == true)
                    {
                        lab_Tue.Text      = "ON";
                        lab_Tue.ForeColor = Color.Green;
                    }
                    else
                    {
                        lab_Tue.Text      = "OFF";
                        lab_Tue.ForeColor = Color.Red;
                    }
                    if (thisYear_wk.DicWeek[DayOfWeek.Wednesday] == true)
                    {
                        lab_Wed.Text      = "ON";
                        lab_Wed.ForeColor = Color.Green;
                    }
                    else
                    {
                        lab_Wed.Text      = "OFF";
                        lab_Wed.ForeColor = Color.Red;
                    }
                    if (thisYear_wk.DicWeek[DayOfWeek.Thursday] == true)
                    {
                        lab_Thu.Text      = "ON";
                        lab_Thu.ForeColor = Color.Green;
                    }
                    else
                    {
                        lab_Thu.Text      = "OFF";
                        lab_Thu.ForeColor = Color.Red;
                    }
                    if (thisYear_wk.DicWeek[DayOfWeek.Friday] == true)
                    {
                        lab_Fri.Text      = "ON";
                        lab_Fri.ForeColor = Color.Green;
                    }
                    else
                    {
                        lab_Fri.Text      = "OFF";
                        lab_Fri.ForeColor = Color.Red;
                    }
                    if (thisYear_wk.DicWeek[DayOfWeek.Saturday] == true)
                    {
                        lab_Sat.Text      = "ON";
                        lab_Sat.ForeColor = Color.Green;
                    }
                    else
                    {
                        lab_Sat.Text      = "OFF";
                        lab_Sat.ForeColor = Color.Red;
                    }
                    if (thisYear_wk.DicWeek[DayOfWeek.Sunday] == true)
                    {
                        lab_Sun.Text      = "ON";
                        lab_Sun.ForeColor = Color.Green;
                    }
                    else
                    {
                        lab_Sun.Text      = "OFF";
                        lab_Sun.ForeColor = Color.Red;
                    }
                    //簡化版
                    //lab_Mon.Text = (wk.DicWeek[DayOfWeek.Monday] == true) ? "ON" : "OFF";
                    //lab_Tue.Text = (wk.DicWeek[DayOfWeek.Tuesday] == true) ? "ON" : "OFF";
                    //lab_Wed.Text = (wk.DicWeek[DayOfWeek.Wednesday] == true) ? "ON" : "OFF";
                    //lab_Thu.Text = (wk.DicWeek[DayOfWeek.Thursday] == true) ? "ON" : "OFF";
                    //lab_Fri.Text = (wk.DicWeek[DayOfWeek.Friday] == true) ? "ON" : "OFF";
                    //lab_Sat.Text = (wk.DicWeek[DayOfWeek.Saturday] == true) ? "ON" : "OFF";
                    //lab_Sun.Text = (wk.DicWeek[DayOfWeek.Sunday] == true) ? "ON" : "OFF";
                }
                else
                {
                    lab_Mon.Text = "未設定";
                    lab_Tue.Text = "未設定";
                    lab_Wed.Text = "未設定";
                    lab_Thu.Text = "未設定";
                    lab_Fri.Text = "未設定";
                    lab_Sat.Text = "未設定";
                    lab_Sun.Text = "未設定";
                }

                //顯示明年資料
                if (nextYear_wk.isSetYear == true)
                {
                    cb_Mon.Checked            = nextYear_wk.DicWeek[DayOfWeek.Monday];
                    cb_Tue.Checked            = nextYear_wk.DicWeek[DayOfWeek.Tuesday];
                    cb_Wed.Checked            = nextYear_wk.DicWeek[DayOfWeek.Wednesday];
                    cb_Thu.Checked            = nextYear_wk.DicWeek[DayOfWeek.Thursday];
                    cb_Fri.Checked            = nextYear_wk.DicWeek[DayOfWeek.Friday];
                    cb_Sat.Checked            = nextYear_wk.DicWeek[DayOfWeek.Saturday];
                    cb_Sun.Checked            = nextYear_wk.DicWeek[DayOfWeek.Sunday];
                    lab_Set_Status.Text       = "已設定";
                    lab_Set_Status.ForeColor  = Color.Blue;
                    btn_SetWorkWeek.Text      = "更新";
                    btn_SetWorkWeek.ForeColor = Color.Blue;
                    btn_SetWorkWeek.BackColor = Color.Aquamarine;
                }
                else
                {
                    cb_Mon.Checked            = false;
                    cb_Tue.Checked            = false;
                    cb_Wed.Checked            = false;
                    cb_Thu.Checked            = false;
                    cb_Fri.Checked            = false;
                    cb_Sat.Checked            = false;
                    cb_Sun.Checked            = false;
                    lab_Set_Status.Text       = "未設定";
                    lab_Set_Status.ForeColor  = Color.Red;
                    btn_SetWorkWeek.Text      = "設定";
                    btn_SetWorkWeek.ForeColor = Color.Red;
                    btn_SetWorkWeek.BackColor = Color.Pink;
                }


                Lib.DataUtility             du = new Lib.DataUtility();
                Dictionary <string, object> d  = new Dictionary <string, object>();
                d.Add("year", System.DateTime.Now.Year + 1);
                DataTable dt = du.getDataTableByText("select * from year where year = @year", d);
                if (dt.Rows.Count == 1)
                {
                    if (Convert.ToBoolean(dt.Rows[0][2]))
                    {
                        year_status.Text      = "關閉報進";
                        year_status.ForeColor = Color.Red;
                        Button1.Text          = "開放";
                        Button1.ForeColor     = Color.Green;
                        Button1.BackColor     = Color.PaleGreen;
                        isopen = Convert.ToBoolean(dt.Rows[0]["islock"]);
                        //原版
                        //year_status.Text = "關閉報進";
                        //Button1.Text = "開放";
                        //isopen = Convert.ToBoolean(dt.Rows[0][2]);
                    }
                    else
                    {
                        year_status.Text      = "開放報進";
                        year_status.ForeColor = Color.Green;
                        Button1.Text          = "關閉";
                        Button1.ForeColor     = Color.Red;
                        Button1.BackColor     = Color.Pink;
                        isopen = Convert.ToBoolean(dt.Rows[0]["islock"]);
                        //原版
                        //year_status.Text = "開放報進";
                        //Button1.Text = "關閉";
                        //isopen = Convert.ToBoolean(dt.Rows[0][2]);
                    }
                }


                if (IsPostBack)
                {
                    //int year_addone = System.DateTime.Now.Year + 1 - 1911;
                    year.Text = "民國" + year_addone.ToString() + "年度";
                    d.Clear();
                    d.Add("year", System.DateTime.Now.Year + 1);
                    dt = du.getDataTableByText("select * from year where year = @year", d);
                    if (dt.Rows.Count == 1)
                    {
                        if (Convert.ToBoolean(dt.Rows[0][2]))
                        {
                            year_status.Text = "開放報進";
                            Button1.Text     = "關閉";
                            isopen           = Convert.ToBoolean(dt.Rows[0][2]);
                        }
                        else
                        {
                            year_status.Text = "關閉報進";
                            Button1.Text     = "開放";
                            isopen           = Convert.ToBoolean(dt.Rows[0][2]);
                        }
                    }
                }
            }
        }
        else
        {
            Session.Clear();
            Response.Redirect("Login.aspx");
        }
    }