コード例 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ManageCookie mgCookie = new ManageCookie();
        users        ck       = mgCookie.ReadCookies();

        if (ck != null)
        {
            string strDocNo = Request.QueryString["docno"];
            string strDate  = Request.QueryString["datedoc"];

            projects pj = new projects();

            string strDocNumber = pj.getProjectInfo(ck.pj_id, "pj_doc_number");

            if (strDocNumber != string.Empty || strDocNumber.ToLower() != "null")
            {
                pj.updateDocNo_DocDate(ck.pj_id, strDocNo, strDate);
            }

            string strStatus = pj.getProjectInfo(ck.pj_id, "pj_complete_status");

            if (strStatus != "ส่งผลแล้ว")
            {
                pj.updateProjectCompleteStatus(ck.pj_id, "ส่งผลแล้ว");
                pj.updateReport_Submitted(ck.pj_id, ck.p_id);

                //gUtilities gt = new gUtilities();
                //gt.setFactorImpact(ck.pj_id); //ทำข้อมูลเพื่อแสดงสรุปผลการวิเคราะห์ควาทเสี่ยงภายใน ภายนอก
            }
        }
    }
コード例 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string mode = "";

        if (!String.IsNullOrEmpty(Request.QueryString["mode"]))
        {
            mode = Server.UrlEncode(Request.QueryString["mode"].Replace("'", ""));
        }

        string p = "";

        if (!String.IsNullOrEmpty(Request.QueryString["p"]))
        {
            p = Server.UrlEncode(Request.QueryString["p"].Replace("'", ""));
        }

        // Protect variable P which must be in the specific rage.
        int p_index;

        if ((int.TryParse(p, out p_index)) && (p_index > 0) && (p_index <= fm.Count()))
        {
            // -1 for adjusting to 0 started base.
            p_index = p_index - 1;
        }
        else
        {
            p_index = 0;
        }

        if (!Page.IsPostBack)
        {
            initializeComponent();
        }

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

        Control parent = pnl_fm_1.Parent;

        int max = ans_fact_sub.getMax_fm_id(ck.pj_id);

        if (max < 0)
        {
            max = 0;
        }

        if (max >= fm.Count())
        {
            //----In Edit Mode--
            // Edit Mode Enable when All questions must be completed. Protect User try to hack system.
            if (mode == "edit")
            {
                // load panel which specified by request.querstring[p]
                max = p_index;
            }
            else
            {
                projects pj = new projects();
                pj.updateProjectCompleteStatus(ck.pj_id, "กรอกสมบูรณ์");

                Response.Redirect("project_summary.aspx");
            }
        }
        else
        {
            if (mode == "edit")
            {
                ton.JavaScript.MessageBox("การแก้ไข ทำได้ต่อเมื่อทำชุดคำถามนี้ครบทุกข้อแล้ว เท่านั้น!", "project_edit.aspx");
            }
        }
        //---------------------------------------------------

        for (int i = 0; i < fm.Count(); i++)
        {
            // +1 for adjust from 0 based array to 1 based array
            int suffix = i + 1;

            Panel pnl_temp = parent.FindControl("pnl_fm_" + suffix.ToString()) as Panel;

            if (suffix == (max + 1))
            {
                pnl_temp.Visible = true;
                pnl_temp.Enabled = true;
            }
            else
            {
                pnl_temp.Visible = false;
                pnl_temp.Enabled = false;
            }
        }
        //------------------------------------------
    }
コード例 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ManageCookie mgCookie = new ManageCookie();
        users        ck       = mgCookie.ReadCookies();

        if (ck != null)
        {
            String strPJid = ck.pj_id;

            StringBuilder strSQL = new StringBuilder();
            strSQL.Append("select * from projects p where p.pj_id = '" + strPJid + "'");

            SqlDataSource4.SelectCommand = strSQL.ToString();
            SqlDataSource4.DataBind();

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

            ListItem   ls1 = new ListItem();
            gUtilities ug  = new gUtilities();

            if (dv1.Table.Rows.Count > 0)
            {
                //redirect ไปที่หน้าที่ทำค้างไว้ กรณีที่ยังทำไม่ถึงคำถามชุด ก.
                projects pj     = new projects();
                string   strRet = pj.redirectToPendingProjectDetails(ck.pj_id);

                string strFM = string.Empty;

                if (Request.QueryString["fm"] != null)
                {
                    strFM = Request.QueryString["fm"].ToString();
                }

                if (strRet != string.Empty && !strRet.Contains("pickquestion.aspx") && strFM != "type")
                {
                    Response.Redirect(strRet);
                }

                foreach (DataRow dRow in dv1.Table.Rows)
                {
                    if (dRow["pj_type"].ToString() == "โครงการใหม่")
                    {
                        string strPending1 = ug.getPendingAnswerTotal(strPJid, "1");
                        string strPending2 = ug.getPendingAnswerTotal(strPJid, "2");
                        string strPending3 = ug.getPendingAnswerTotal(strPJid, "3");
                        string strPending4 = ug.getPendingAnswerTotal(strPJid, "4");

                        string strTotal1 = ug.getAnswerTotal("1");
                        string strTotal2 = ug.getAnswerTotal("2");
                        string strTotal3 = ug.getAnswerTotal("3");
                        string strTotal4 = ug.getAnswerTotal("4");

                        string strTotal6 = ug.getFactorRiskCount(ck.pj_id);

                        if (strPending1 == "0")
                        {
                            Lit1.Text = "(<span style='color:blue; font-weight:bold'>ยังไม่ได้ทำแบบประเมินชุดนี้</span> / <span style='color:green; font-weight:bold'>ทั้งหมดมี " + strTotal1 + " ข้อ</span>)";
                        }
                        else
                        {
                            Lit1.Text = "(<span style='color:blue; font-weight:bold'>ทำแล้ว " + strPending1 + " ข้อ</span> / <span style='color:green; font-weight:bold'>ทั้งหมดมี " + strTotal1 + " ข้อ</span>)";
                        }

                        if (strPending2 == "0")
                        {
                            Lit2.Text = "(<span style='color:blue; font-weight:bold'>ยังไม่ได้ทำแบบประเมินชุดนี้</span> / <span style='color:green; font-weight:bold'>ทั้งหมดมี " + strTotal2 + " ข้อ</span>)";
                        }
                        else
                        {
                            Lit2.Text = "(<span style='color:blue; font-weight:bold'>ทำแล้ว " + strPending2 + " ข้อ</span> / <span style='color:green; font-weight:bold'>ทั้งหมดมี " + strTotal2 + " ข้อ</span>)";
                        }

                        if (strPending3 == "0")
                        {
                            Lit3.Text = "(<span style='color:blue; font-weight:bold'>ยังไม่ได้ทำแบบประเมินชุดนี้</span> / <span style='color:green; font-weight:bold'>ทั้งหมดมี " + strTotal3 + " ข้อ</span>)";
                        }
                        else
                        {
                            Lit3.Text = "(<span style='color:blue; font-weight:bold'>ทำแล้ว " + strPending3 + " ข้อ</span> / <span style='color:green; font-weight:bold'>ทั้งหมดมี " + strTotal3 + " ข้อ</span>)";
                        }

                        if (strPending4 == "0")
                        {
                            Lit4.Text = "(<span style='color:blue; font-weight:bold'>ยังไม่ได้ทำแบบประเมินชุดนี้</span> / <span style='color:green; font-weight:bold'> ทั้งหมดมี " + strTotal4 + " ข้อ</span>)";
                        }
                        else
                        {
                            Lit4.Text = "(<span style='color:blue; font-weight:bold'>ทำแล้ว " + strPending4 + " ข้อ</span> / <span style='color:green; font-weight:bold'>ทั้งหมดมี " + strTotal4 + " ข้อ</span>)";
                        }

                        H1.Enabled = false;
                        H2.Enabled = false;
                        H3.Enabled = false;
                        H4.Enabled = false;

                        if (strPending1 != strTotal1)
                        {
                            H1.Enabled = true;
                            H2.Enabled = false;
                            H3.Enabled = false;
                            H4.Enabled = false;
                        }
                        else if (strPending2 != strTotal2)
                        {
                            H1.Enabled = false;
                            H2.Enabled = true;
                            H3.Enabled = false;
                            H4.Enabled = false;
                        }
                        else if (strPending3 != strTotal3)
                        {
                            H1.Enabled = false;
                            H2.Enabled = false;
                            H3.Enabled = true;
                            H4.Enabled = false;
                        }
                        else if (strPending4 != strTotal4)
                        {
                            H1.Enabled = false;
                            H2.Enabled = false;
                            H3.Enabled = false;
                            H4.Enabled = true;
                        }
                        else if ((strPending4 == strTotal4) && strTotal6 != "41")
                        {
                            HFactor.Enabled = true;
                        }
                        else if (strTotal6 != "41")
                        {
                            HFactor.Enabled = true;
                        }
                        else if (strTotal6 == "41")
                        {
                            //update pj_complete_status = 'กรอกสมบูรณ์'
                            pj.updateProjectCompleteStatus(ck.pj_id, "กรอกสมบูรณ์");

                            Response.Redirect("project_summary.aspx");
                        }

                        H5.Visible   = false;
                        Lit5.Visible = false;
                    }
                    else if (dRow["pj_type"].ToString() == "โครงการต่อเนื่องหรือโครงการขยายผล")
                    {
                        string strPending1 = ug.getPendingAnswerTotal(strPJid, "1");
                        string strPending2 = ug.getPendingAnswerTotal(strPJid, "2");
                        string strPending3 = ug.getPendingAnswerTotal(strPJid, "3");
                        string strPending4 = ug.getPendingAnswerTotal(strPJid, "4");
                        string strPending5 = ug.getPendingAnswerTotal(strPJid, "5");

                        string strTotal1 = ug.getAnswerTotal("1");
                        string strTotal2 = ug.getAnswerTotal("2");
                        string strTotal3 = ug.getAnswerTotal("3");
                        string strTotal4 = ug.getAnswerTotal("4");
                        string strTotal5 = ug.getAnswerTotal("5");

                        string strTotal6 = ug.getFactorRiskCount(ck.pj_id);

                        if (strPending1 == "0")
                        {
                            Lit1.Text = "(<span style='color:blue; font-weight:bold'>ยังไม่ได้ทำแบบประเมินชุดนี้</span> / <span style='color:green; font-weight:bold'> ทั้งหมดมี " + strTotal1 + " ข้อ</span>)";
                        }
                        else
                        {
                            Lit1.Text = "(<span style='color:blue; font-weight:bold'>ทำแล้ว " + strPending1 + " ข้อ</span> / <span style='color:green; font-weight:bold'>ทั้งหมดมี " + strTotal1 + " ข้อ</span>)";
                        }

                        if (strPending2 == "0")
                        {
                            Lit2.Text = "(<span style='color:blue; font-weight:bold'>ยังไม่ได้ทำแบบประเมินชุดนี้</span> / <span style='color:green; font-weight:bold'> ทั้งหมดมี " + strTotal2 + " ข้อ</span>)";
                        }
                        else
                        {
                            Lit2.Text = "(<span style='color:blue; font-weight:bold'>ทำแล้ว " + strPending2 + " ข้อ</span> / <span style='color:green; font-weight:bold'>ทั้งหมดมี " + strTotal2 + " ข้อ</span>)";
                        }

                        if (strPending3 == "0")
                        {
                            Lit3.Text = "(<span style='color:blue; font-weight:bold'>ยังไม่ได้ทำแบบประเมินชุดนี้</span> / <span style='color:green; font-weight:bold'> ทั้งหมดมี " + strTotal3 + " ข้อ</span>)";
                        }
                        else
                        {
                            Lit3.Text = "(<span style='color:blue; font-weight:bold'>ทำแล้ว " + strPending3 + " ข้อ</span> / <span style='color:green; font-weight:bold'>ทั้งหมดมี " + strTotal3 + " ข้อ</span>)";
                        }

                        if (strPending4 == "0")
                        {
                            Lit4.Text = "(<span style='color:blue; font-weight:bold'>ยังไม่ได้ทำแบบประเมินชุดนี้</span> / <span style='color:green; font-weight:bold'> ทั้งหมดมี " + strTotal4 + " ข้อ</span>)";
                        }
                        else
                        {
                            Lit4.Text = "(<span style='color:blue; font-weight:bold'>ทำแล้ว " + strPending4 + " ข้อ</span> / <span style='color:green; font-weight:bold'>ทั้งหมดมี " + strTotal4 + " ข้อ</span>)";
                        }

                        if (strPending5 == "0")
                        {
                            Lit5.Text = "(<span style='color:blue; font-weight:bold'>ยังไม่ได้ทำแบบประเมินชุดนี้</span> / <span style='color:green; font-weight:bold'> ทั้งหมดมี " + strTotal5 + " ข้อ</span>)";
                        }
                        else
                        {
                            Lit5.Text = "(<span style='color:blue; font-weight:bold'>ทำแล้ว " + strPending5 + " ข้อ</span> / <span style='color:green; font-weight:bold'>ทั้งหมดมี " + strTotal5 + " ข้อ</span>)";
                        }

                        H1.Enabled = false;
                        H2.Enabled = false;
                        H3.Enabled = false;
                        H4.Enabled = false;
                        H5.Enabled = false;

                        H5.Visible   = true;
                        Lit5.Visible = true;

                        if (strPending1 != strTotal1)
                        {
                            H1.Enabled = true;
                            H2.Enabled = false;
                            H3.Enabled = false;
                            H4.Enabled = false;
                            H5.Enabled = false;
                        }
                        else if (strPending2 != strTotal2)
                        {
                            H1.Enabled = false;
                            H2.Enabled = true;
                            H3.Enabled = false;
                            H4.Enabled = false;
                            H5.Enabled = false;
                        }
                        else if (strPending3 != strTotal3)
                        {
                            H1.Enabled = false;
                            H2.Enabled = false;
                            H3.Enabled = true;
                            H4.Enabled = false;
                            H5.Enabled = false;
                        }
                        else if (strPending4 != strTotal4)
                        {
                            H1.Enabled = false;
                            H2.Enabled = false;
                            H3.Enabled = false;
                            H4.Enabled = true;
                            H5.Enabled = false;
                        }
                        else if (strPending5 != strTotal5)
                        {
                            H1.Enabled = false;
                            H2.Enabled = false;
                            H3.Enabled = false;
                            H4.Enabled = false;
                            H5.Enabled = true;
                        }
                        else if ((strPending5 == strTotal5))
                        {
                            HFactor.Enabled = true;
                            H1.Enabled      = false;
                            H2.Enabled      = false;
                            H3.Enabled      = false;
                            H4.Enabled      = false;
                            H5.Enabled      = false;
                        }
                        else if (strTotal6 != "41")
                        {
                            HFactor.Enabled = true;
                            H1.Enabled      = false;
                            H2.Enabled      = false;
                            H3.Enabled      = false;
                            H4.Enabled      = false;
                            H5.Enabled      = false;
                        }
                        else if (strTotal6 == "41")
                        {
                            //update pj_complete_status = 'กรอกสมบูรณ์'
                            pj.updateProjectCompleteStatus(ck.pj_id, "กรอกสมบูรณ์");
                            Response.Redirect("project_summary.aspx");
                        }
                    }
                }
            }
        }
    }
コード例 #4
0
    protected void btnNext_Click(object sender, EventArgs e)
    {
        //save project code to cookie
        if (!Page.IsValid)
        {
            return;
        }
        else
        {
            ManageCookie mgCookie = new ManageCookie();
            users        ck       = mgCookie.ReadCookies();

            string strSQL2 = "SELECT count(*) from dbo.projects where pj_id = " + ck.pj_id;

            SqlDataSource1.SelectCommand = strSQL2;
            SqlDataSource1.DataBind();

            DataView dv2 = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);

            foreach (DataRow dRow in dv2.Table.Rows)
            {
                if (dRow[0].ToString() != "0")
                {
                    //save to database
                    SqlParameter pj_filter_q1 = new SqlParameter("@pj_filter_q1", SqlDbType.NVarChar, 10);
                    pj_filter_q1.Direction = ParameterDirection.Input;
                    pj_filter_q1.Value     = radQ1.SelectedValue;

                    SqlParameter pj_filter_q2 = new SqlParameter("@pj_filter_q2", SqlDbType.NVarChar, 10);
                    pj_filter_q2.Direction = ParameterDirection.Input;
                    pj_filter_q2.Value     = radQ2.SelectedValue;

                    SqlParameter pj_filter_q3 = new SqlParameter("@pj_filter_q3", SqlDbType.NVarChar, 10);
                    pj_filter_q3.Direction = ParameterDirection.Input;
                    pj_filter_q3.Value     = radQ3.SelectedValue;

                    SqlParameter pj_filter_q4 = new SqlParameter("@pj_filter_q4", SqlDbType.NVarChar, 10);
                    pj_filter_q4.Direction = ParameterDirection.Input;
                    pj_filter_q4.Value     = radQ4.SelectedValue;

                    SqlParameter pj_id = new SqlParameter("@pj_id", SqlDbType.Int);
                    pj_id.Direction = ParameterDirection.Input;
                    pj_id.Value     = ck.pj_id;

                    insertParameters.Add(pj_filter_q1);
                    insertParameters.Add(pj_filter_q2);
                    insertParameters.Add(pj_filter_q3);
                    insertParameters.Add(pj_filter_q4);
                    insertParameters.Add(pj_id);

                    try
                    {
                        SqlDataSource1.Update();
                    }
                    catch
                    {
                        //ELMA Log
                    }

                    if ((radQ1.SelectedIndex == 0 && radQ2.SelectedIndex == 0 && radQ3.SelectedIndex == 0) || (radQ4.SelectedIndex == 0))
                    {
                        lblResult.Visible       = true;
                        btnNext.Visible         = false;
                        btnNextPage.Visible     = true;
                        lblResult.Text          = "<span style='background-color:green;font-weight:bold'>เกณฑ์การประเมิน:  แผนงาน / โครงการ อยู่ในเกณฑ์ที่ต้องวิเคราะห์ความเสี่ยงตามหลักธรรมาภิบาล</span>";
                        lblPrintWarning.Visible = false;
                        btnPrint.Visible        = false;
                        radQ1.Enabled           = false;
                        radQ2.Enabled           = false;
                        radQ3.Enabled           = false;
                        radQ4.Enabled           = false;

                        projects pj = new projects();
                        pj.updateProjectCompleteStatus(ck.pj_id, "อยู่ในเกณฑ์การประเมิน");
                    }
                    else
                    {
                        lblResult.Visible       = true;
                        btnNext.Visible         = false;
                        btnPrint.Visible        = true;
                        lblResult.Text          = "<span style='background-color:red;font-weight:bold'>เกณฑ์การประเมิน: แผนงาน / โครงการ นี้ไม่อยู่ในเกณฑ์ที่ต้องวิเคราะห์ความเสี่ยงตามหลักธรรมาภิบาล</span>";
                        lblPrintWarning.Visible = true;
                        radQ1.Enabled           = false;
                        radQ2.Enabled           = false;
                        radQ3.Enabled           = false;
                        radQ4.Enabled           = false;
                        btnNextPage.Visible     = false;

                        projects pj = new projects();
                        pj.updateProjectCompleteStatus(ck.pj_id, "ไม่อยู่ในเกณฑ์การประเมิน/กรอกสมบูรณ์");
                    }
                }
                else
                {
                    //duplicate project code, not insert
                    if ((radQ1.SelectedIndex == 0 && radQ2.SelectedIndex == 0 && radQ3.SelectedIndex == 0) || (radQ4.SelectedIndex == 0))
                    {
                        lblResult.Visible       = true;
                        btnNext.Visible         = true;
                        btnNext.Text            = "โปรดดำเนินการต่อ";
                        lblResult.Text          = "<span style='background-color:green;font-weight:bold'>แผนงาน / โครงการ อยู่ในเกณฑ์ที่ต้องวิเคราะห์ความเสี่ยงตามหลักธรรมาภิบาล</span>";
                        lblPrintWarning.Visible = false;
                        btnPrint.Visible        = false;

                        projects pj = new projects();
                        pj.updateProjectCompleteStatus(ck.pj_id, "อยู่ในเกณฑ์การประเมิน");
                    }
                    else
                    {
                        lblResult.Visible       = true;
                        btnNext.Visible         = false;
                        btnPrint.Visible        = true;
                        lblResult.Text          = "<span style='background-color:red;font-weight:bold'>แผนงาน / โครงการ นี้ไม่อยู่ในเกณฑ์ที่ต้องวิเคราะห์ความเสี่ยงตามหลักธรรมาภิบาล</span>";
                        lblPrintWarning.Visible = true;

                        projects pj = new projects();
                        pj.updateProjectCompleteStatus(ck.pj_id, "ไม่อยู่ในเกณฑ์การประเมิน/กรอกสมบูรณ์");
                    }
                }
            }
        }
    }