//



        protected void Timer1_Timer(object sender, EventArgs e)
        {
            this.txtTIME.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            //TextField1.Text = WIDTH.Text;
            //TextField2.Text = HIGHT.Text;
            //this.txtWEEK.Text = HIGHT.Text;
            TaskManager1.Enabled = false;
            TaskManager1.StopAll();
            int i = 0;

            if (HIGHT.Text != "")
            {
                i = Convert.ToInt16(HIGHT.Text);
            }
            i = i - 144;
            if (i < 420)
            {
                i = 420;
            }
            grdBED_LIST.Height = i;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                //TextField1.Hidden = true;
                //TextField2.Hidden = true;

                DBMysql db = new DBMysql();

                try
                {
                    string sPAD_HEAD = "Styles/mark1.png";
                    //string sPAD_HEAD = "";
                    DataTable dtPAD_HEAD = db.Query("SELECT *  FROM general_setup WHERE  genst_code='IPAD_HEAD'");
                    if (dtPAD_HEAD.Rows.Count > 0)
                    {
                        sPAD_HEAD = dtPAD_HEAD.Rows[0]["genst_desc"].ToString();
                        //sPAD_HEAD = Server.MapPath(sPAD_HEAD);
                        Image2.ImageUrl = sPAD_HEAD;
                    }
                }
                catch (Exception ex)
                {
                    //_ErrorMsgShow(ex.Message.ToString());
                }

                DateTime now = DateTime.Now;
                //this.txtDATE.Text = now.ToString("yyyy-MM-dd");

                this.txtTIME.Text  = now.ToString("yyyy-MM-dd HH:mm:ss");
                this.txtTIME1.Text = now.ToString("yyyy-MM-dd");

                //sDATE.Text = this.txtDATE.Text;
                sDATE.Text = this.txtTIME.Text.Substring(0, 10);
                //this.txtWEEK.Text = now.ToString("ddd");
                if (Session["PAD_TIME"] == null)
                {
                    int Hm = int.Parse(now.ToString("HHmm"));
                    if (1 <= Hm && Hm <= 1159)
                    {
                        sTIME.Text = "001";
                        cboTIME.Select(sTIME.Text);
                    }
                    else if (1200 <= Hm && Hm <= 1759)
                    {
                        sTIME.Text = "002";
                        cboTIME.Select(sTIME.Text);
                    }
                    else if (1800 <= Hm && Hm <= 2400)
                    {
                        sTIME.Text = "003";
                        cboTIME.Select(sTIME.Text);
                    }
                }
                else
                {
                    sTIME.Text = Session["PAD_TIME"].ToString();
                    cboTIME.Select(sTIME.Text);
                }

                GET_WEEK();


                this.WYEAR.Text       = now.ToString("yyyy");
                this.WMON.Text        = now.ToString("MM");
                this.cboYEAR.Disabled = false;
                YEAR_CHECK(this.WYEAR.Text);
                MON_CHECK(this.WMON.Text);


                if (dtAREA == null)
                {
                    dtAREA = db.Query("SELECT distinct mac_flr, mac_sec FROM mac_setup WHERE 1=1 ORDER BY mac_flr, mac_sec ");
                }
                if (dtAREA.Rows.Count > 0)
                {
                    if (Session["PAD_FLOOR"] == null)
                    {
                        sFLOOR.Text = dtAREA.Rows[0]["mac_flr"].ToString();
                    }
                    else
                    {
                        sFLOOR.Text = Session["PAD_FLOOR"].ToString();
                    }
                    if (Session["PAD_AREA"] == null)
                    {
                        sAREA.Text = dtAREA.Rows[0]["mac_sec"].ToString();
                    }
                    else
                    {
                        sAREA.Text = Session["PAD_AREA"].ToString();
                    }
                }
                System.Data.DataTable dtFLOOR = db.Query("SELECT distinct mac_flr FROM mac_setup WHERE 1=1 ORDER BY mac_flr ");
                for (int i = 0; i < dtFLOOR.Rows.Count; i++)
                {
                    Ext.Net.ListItem litem;
                    litem = new Ext.Net.ListItem(dtFLOOR.Rows[i]["mac_flr"].ToString() + "楼", dtFLOOR.Rows[i]["mac_flr"].ToString());
                    this.cboFLOOR.Items.Add(litem);
                }
                this.cboFLOOR.GetStore().DataBind();
                if (dtFLOOR.Rows.Count > 0)
                {
                    this.cboFLOOR.Disabled = false;
                    this.cboFLOOR.Select(sFLOOR.Text);
                    //SetComboBoxValue(this.cboFLOOR, "05楼", false);
                    FILL_AREA(sFLOOR.Text, sAREA.Text);
                    WFLOOR.Text = sFLOOR.Text;
                    WAREA.Text  = sAREA.Text;

                    //Column9.Text = WFLOOR.Text + "楼";
                    //Column11.Text = WAREA.Text + "區";
                    //FILL_BED();
                    //FILL_BEDN();
                }
                else
                {
                    this.cboFLOOR.Disabled = true;
                    this.cboAREA.Disabled  = true;
                }
                //Timer1.Enabled = true;
                //TaskManager1.Enabled = true;
                TaskManager1.StopTask("servertime");


                //2015.03.25 姓名 Andy
                System.Data.DataTable dtName = db.Query("select DISTINCT apptst_patrefid from appointment_setup order by apptst_patrefid");
                for (int i = 0; i < dtName.Rows.Count; i++)
                {
                    Ext.Net.ListItem litem1;
                    litem1 = new Ext.Net.ListItem(dtName.Rows[i]["apptst_patrefid"].ToString(), dtName.Rows[i]["apptst_patrefid"].ToString());
                    this.SelectBox1.Items.Add(litem1);
                }
                this.SelectBox1.GetStore().DataBind();
                if (dtName.Rows.Count > 0)
                {
                    this.SelectBox1.Disabled = false;
                    this.SelectBox1.Select(sNAME.Text);
                    //FILL_AREA(sFLOOR.Text, sAREA.Text);
                    //FILL_BED();
                }
                else
                {
                    //this.cboFLOOR.Disabled = true;
                    //this.cboAREA.Disabled = true;
                }
                //

                //2015.03.25 GP 身分證號 Andy
                System.Data.DataTable dtpatic = db.Query("select DISTINCT apptst_patic from appointment_setup order by apptst_patic");
                for (int i = 0; i < dtpatic.Rows.Count; i++)
                {
                    Ext.Net.ListItem litem2;
                    litem2 = new Ext.Net.ListItem(dtpatic.Rows[i]["apptst_patic"].ToString(), dtpatic.Rows[i]["apptst_patic"].ToString());
                    this.SelectBox2.Items.Add(litem2);
                }
                this.SelectBox2.GetStore().DataBind();
                if (dtpatic.Rows.Count > 0)
                {
                    this.SelectBox2.Disabled = false;
                    this.SelectBox2.Select(spatic.Text);
                }
                else
                {
                }
                //
            }
        }