Exemplo n.º 1
0
    /// <summary>
    /// Page_Load事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            ErrorMsgLabel.Text = "";
            ResultMsgLabel.Text = "";
            gvMsgLabel.Text = "";

            AuthorityControls(this);

            if (!IsPostBack)
            {
                //寫入首次載入Page TimeStamp
                PageTimeStamp.Value = string.Format("{0}{1}{2}{3}{4}{5}",
                                                    DateTime.Now.Year.ToString(),
                                                    DateTime.Now.Month.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Day.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Hour.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Minute.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Second.ToString().PadLeft(2, '0')
                                                    );
                //設定最後一次產生時間
                BCO.CreateStoreUniqueFile bco = new CreateStoreUniqueFile(ConntionDB);
                string workDate = bco.GetLastWorkTime();
                Lab_Date.Text = workDate;

                //設定GridView預設的狀態


                Initialization_Component();

                //設定ToolBar預設狀態


                ToolBarInit();


                //該頁面共有4種狀態


                //查詢 QUERY
                //檢視 VIEW
                //新增 INSERT
                //編輯 EDIT
                this.hid_PageStatus.Value = "QUERY";
                this.txt_PageStatus.Text = "QUERY";

                #region 預設系統功能鍵及Focus欄位

                this.Form.Attributes["onkeypress"] += "return STMCommon_WebForm_FireDefaultButton(event,'" + this.Btn_Query.ClientID + "');";

                BCO.STMCommon STMComm = new BCO.STMCommon();
                string s_ScriptManager_Script = STMComm.ToMakeUp_SetFocus_Script(CheckBox1.ClientID, false);
                ScriptManager.RegisterStartupScript(this.up_ErrorMsg, typeof(UpdatePanel), "STM031", s_ScriptManager_Script, true);

                #endregion

            }


        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
        }
        finally { Finally_Function(); }
    }