protected void Page_Load(object sender, EventArgs e)
    {
        ton.tonUtilities.pageaAuthorize(ton.config.Global_config.authtext_budgetor, ton.config.Global_config.warning_text);

        ManageCookie mgCookie = new ManageCookie();
        users        ck       = mgCookie.ReadCookies();

        if (ck != null)
        {
            // option 1 Call from Cookies
            sds_project_summary.SelectParameters["pj_id"].DefaultValue  = ck.pj_id;
            SqlDataSource1.SelectParameters["pj_id"].DefaultValue       = ck.pj_id;
            SqlDataSource2.SelectParameters["pj_id"].DefaultValue       = ck.pj_id;
            SqlDataSource3.SelectParameters["pj_id"].DefaultValue       = ck.pj_id;
            SqlDataSource4.SelectParameters["pj_id"].DefaultValue       = ck.pj_id;
            SqlDataSource5.SelectParameters["pj_id"].DefaultValue       = ck.pj_id;
            sds_factor_tamma.SelectParameters["pj_id"].DefaultValue     = ck.pj_id;
            sds_tamma_no_proceed.SelectParameters["pj_id"].DefaultValue = ck.pj_id;


            //// option 2 Call from Query String
            //// Option has problem with 128bit Encryption which contain '+' but URL.decode will replace '+' as ' '(space).
            //// The decoding process error will occur
            //// Solution: replace with 64 bit Enryption
            //string pj_id = Encryption.Decrypt(Request.QueryString["id"], ton.Encryption.keyword);
            //pj_id = tonUtilities.cleanQueryString(pj_id);
            //sds_project_summary.SelectParameters["pj_id"].DefaultValue = pj_id;
            //// End Option2

            // Copy from ProjectSummary.aspx which created by Narut

            DataView dv1 = (DataView)sds_project_summary.Select(DataSourceSelectArguments.Empty);

            foreach (DataRow dRow in dv1.Table.Rows)
            {
                lblDeptCode.Text               = dRow["mi_code"].ToString();
                lblDeptName.Text               = dRow["mi_name"].ToString();
                lblDivisionCode.Text           = dRow["d_code"].ToString();
                lblDivisionName.Text           = dRow["d_name"].ToString();
                lblProjectName.Text            = dRow["pj_name"].ToString();
                lblProjectCode.Text            = dRow["pj_code"].ToString();
                lblYutasard.Text               = dRow["yut_name"].ToString();
                lblIntegrateProject.Text       = dRow["pj_integrateProject"].ToString();
                lblRelateDept.Text             = dRow["pj_relateDept"].ToString();
                lblBudget.Text                 = dRow["pj_budget"].ToString();
                lblYear.Text                   = dRow["pj_year"].ToString();
                lit_approval.Text              = dRow["pj_approval_status"].ToString();
                lbl_pj_doc_no.Text             = dRow["pj_doc_number"].ToString();
                lbl_pj_date_doc_submitted.Text = dRow["pj_date_doc_submitted"].ToString().Substring(0, dRow["pj_date_doc_submitted"].ToString().IndexOf(" "));
            }

            // Show result in case its has value
            if ((lit_approval.Text == Global_config.pj_approval_status_value[1]) || string.IsNullOrEmpty(lit_approval.Text))
            {
                tbl_appr.Visible       = false;
                btn_goto_step3.Enabled = true;
            }
            else
            {
                tbl_appr.Visible       = true;
                btn_goto_step3.Enabled = false;
            }

            gUtilities gt = new gUtilities();
            litRisk1.Text  = gt.getReportTammaTotal(ck.pj_id);
            litRisk2.Text  = gt.getReportFactorRiskTotal(ck.pj_id);
            litRisk12.Text = gt.getReportTammaMainTotal(ck.pj_id);
            litRisk13.Text = gt.getReportTammaSubTotal(ck.pj_id);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        ton.tonUtilities.pageaAuthorize(ton.config.Global_config.authtext_budgetor, ton.config.Global_config.warning_text);

        ManageCookie mgCookie = new ManageCookie();
        users        ck       = mgCookie.ReadCookies();

        if (!Page.IsPostBack)
        {
            if (ck != null)
            {
                // Copy from ProjectSummary.aspx which created by Narut
                sds_project_summary.SelectParameters["pj_id"].DefaultValue = ck.pj_id;

                DataView dv1 = (DataView)sds_project_summary.Select(DataSourceSelectArguments.Empty);

                foreach (DataRow dRow in dv1.Table.Rows)
                {
                    lblDeptCode.Text               = dRow["mi_code"].ToString();
                    lblDeptName.Text               = dRow["mi_name"].ToString();
                    lblDivisionCode.Text           = dRow["d_code"].ToString();
                    lblDivisionName.Text           = dRow["d_name"].ToString();
                    lblProjectName.Text            = dRow["pj_name"].ToString();
                    lblProjectCode.Text            = dRow["pj_code"].ToString();
                    lblYutasard.Text               = dRow["yut_name"].ToString();
                    lblIntegrateProject.Text       = dRow["pj_integrateProject"].ToString();
                    lblRelateDept.Text             = dRow["pj_relateDept"].ToString();
                    lblBudget.Text                 = dRow["pj_budget"].ToString();
                    lblYear.Text                   = dRow["pj_year"].ToString();
                    lit_approval.Text              = dRow["pj_approval_status"].ToString();
                    lbl_pj_doc_no.Text             = dRow["pj_doc_number"].ToString();
                    lbl_pj_date_doc_submitted.Text = dRow["pj_date_doc_submitted"].ToString().Substring(0, dRow["pj_date_doc_submitted"].ToString().IndexOf(" "));
                }

                // Show result in case its has value
                if (String.IsNullOrEmpty(lit_approval.Text))
                {
                    tbl_appr.Visible = false;
                    //btn_goto_step3.Enabled = true;
                }
                else
                {
                    tbl_appr.Visible = true;
                    //btn_goto_step3.Enabled = false;
                }

                gUtilities gt = new gUtilities();
                litRisk1.Text  = gt.getReportTammaTotal(ck.pj_id);
                litRisk2.Text  = gt.getReportFactorRiskTotal(ck.pj_id);
                litRisk12.Text = gt.getReportTammaMainTotal(ck.pj_id);
                litRisk13.Text = gt.getReportTammaSubTotal(ck.pj_id);
            }

            // Below is an OLD code------------------------------------------------------------------

            // This page only allow เจ้าหน้าที่สำนักงบประมาณ role=2
            //if ((ck == null) || string.IsNullOrEmpty(ck.pj_id) || (ck.p_role_id != "2"))
            if ((ck == null) || string.IsNullOrEmpty(ck.pj_id))
            {
                //ton.JavaScript.MessageBox(" โปรเจค ว่างเปล่า กรุณาเข้าสู่ระบบ ");
                Response.Redirect(ton.config.Global_config.RootURL);
            }

            sds_project_approve_comment.SelectParameters["pj_id"].DefaultValue = ck.pj_id;
            DataView dv2 = (DataView)sds_project_approve_comment.Select(DataSourceSelectArguments.Empty);

            // Double check for prevention of re-approval

            string appr_text = dv2[0]["pj_approval_status"].ToString();

            // Pre DisAble การให้ความคิดเห็นเพิ่มเติมของเจ้าหน้าที่จัดทำงบประมาณ
            pnl_L0.Enabled   = false;
            btn_save.Enabled = false;

            if (string.IsNullOrEmpty(appr_text))
            {
                pnl_L0.Enabled   = true;
                btn_save.Enabled = true;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        ton.tonUtilities.pageaAuthorize(Global_config.authtext_23, ton.config.Global_config.warning_text);

        ManageCookie mgCookie = new ManageCookie();
        users        ck       = mgCookie.ReadCookies();

        if (!Page.IsPostBack)
        {
            intial_ApproveList();
            if (ck != null)
            {
                // Copy from ProjectSummary.aspx which created by Narut
                sds_project_summary.SelectParameters["pj_id"].DefaultValue = ck.pj_id;

                DataView dv1 = (DataView)sds_project_summary.Select(DataSourceSelectArguments.Empty);

                foreach (DataRow dRow in dv1.Table.Rows)
                {
                    lblDeptCode.Text               = dRow["mi_code"].ToString();
                    lblDeptName.Text               = dRow["mi_name"].ToString();
                    lblDivisionCode.Text           = dRow["d_code"].ToString();
                    lblDivisionName.Text           = dRow["d_name"].ToString();
                    lblProjectName.Text            = dRow["pj_name"].ToString();
                    lblProjectCode.Text            = dRow["pj_code"].ToString();
                    lblYutasard.Text               = dRow["yut_name"].ToString();
                    lblIntegrateProject.Text       = dRow["pj_integrateProject"].ToString();
                    lblRelateDept.Text             = dRow["pj_relateDept"].ToString();
                    lblBudget.Text                 = dRow["pj_budget"].ToString();
                    lblYear.Text                   = dRow["pj_year"].ToString();
                    lbl_pj_doc_no.Text             = dRow["pj_doc_number"].ToString();
                    lbl_pj_date_doc_submitted.Text = dRow["pj_date_doc_submitted"].ToString().Substring(0, dRow["pj_date_doc_submitted"].ToString().IndexOf(" "));
                    lit_approval.Text              = dRow["pj_approval_status"].ToString();
                }
                gUtilities gt = new gUtilities();
                litRisk1.Text  = gt.getReportTammaTotal(ck.pj_id);
                litRisk2.Text  = gt.getReportFactorRiskTotal(ck.pj_id);
                litRisk12.Text = gt.getReportTammaMainTotal(ck.pj_id);
                litRisk13.Text = gt.getReportTammaSubTotal(ck.pj_id);
            }

            // Below is an OLD code------------------------------------------------------------------

            // This page only allow เจ้าหน้าที่สำนักงบประมาณ role=2
            //if ((ck == null) || string.IsNullOrEmpty(ck.pj_id) || (ck.p_role_id != "2"))
            if ((ck == null) || string.IsNullOrEmpty(ck.pj_id))
            {
                //ton.JavaScript.MessageBox(" โปรเจค ว่างเปล่า กรุณาเข้าสู่ระบบ ");
                Response.Redirect(ton.config.Global_config.RootURL);
            }

            sds_project_approve_final.SelectParameters["pj_id"].DefaultValue = ck.pj_id;
            DataView dv2 = (DataView)sds_project_approve_final.Select(DataSourceSelectArguments.Empty);

            // Double check for prevention of re-approval

            string appr_text = dv2[0]["pj_approval_status"].ToString();

            // Pre DisAble การอนุมัติจากสภา
            pnl_parliament.Enabled    = false;
            pnl_parliament.Visible    = false;
            report_palia_link.Visible = false;
            // Allow ONLY สำนักงบประมาณ ( role id = 2 ) และ ต้องผ่านการให้ความเห็นมาแล้ว
            if ((appr_text == Global_config.pj_approval_status_value[1]) && (ck.p_role_id == ton.config.Global_config.authtext_budgetor))
            {
                rng_app_budget.MaximumValue = lblBudget.Text;
                //txt_approval_budget.Text = lblBudget.Text;
                pnl_parliament.Enabled = true;
                pnl_parliament.Visible = true;
            }
        }
    }