protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["login_data"] == null)
        {
            Response.Redirect("../index.aspx");
        }
        else
        {
            //ตรวจสอบสิทธิ์
            login_data = (UserLoginData)Session["login_data"];
            if (autro_obj.CheckGroupUser(login_data, group_var.admin_university) || autro_obj.CheckGroupUser(login_data, group_var.admin_faculty))
            {
                /*=============================*/
                code = Request.QueryString["token"];

                if (!Page.IsPostBack)
                {
                    data = obj.getAdmissionType(code);

                    txtADMISSIONTYPE_CODE.Text = data.AdmissionType_Code;
                    txtADMISSIONTYPE_THAI.Text = data.AdmissionType_Thai;
                    txtADMISSIONTYPE_ENG.Text  = data.AdmissionType_Eng;
                }
                /*=============================*/
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }
Example #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["login_data"] == null)
        {
            Response.Redirect("../index.aspx");
        }
        else
        {
            //ตรวจสอบสิทธิ์
            login_data = (UserLoginData)Session["login_data"];
            if (autro_obj.CheckGroupUser(login_data, group_var.admin_university) || autro_obj.CheckGroupUser(login_data, group_var.admin_faculty))
            {
                /*=============================*/
                if (!Page.IsPostBack)
                {
                    //โหลดสำนักงาน
                    Data = Obj.getAdmissionType();

                    // Head Table
                    string[] ar = { "รหัส", "วิธีการรับเข้า (Thai)", "วิธีการรับเข้า (English)", "แก้ไข", "ลบ" };
                    //Table tb1 = new Table();
                    tblAdminType.Attributes.Add("class", "table table-bordered table-striped table-hover");
                    tblAdminType.Attributes.Add("id", "dt_basic");
                    TableHeaderRow tRowHead = new TableHeaderRow();
                    tRowHead.TableSection = TableRowSection.TableHeader;
                    for (int cellCtr = 1; cellCtr <= ar.Length; cellCtr++)
                    {
                        // Create a new cell and add it to the row.
                        TableHeaderCell cellHead = new TableHeaderCell();
                        cellHead.Text = ar[cellCtr - 1];

                        if (cellCtr == 1 || cellCtr > 3)
                        {
                            cellHead.Width = 100;
                        }

                        tRowHead.Cells.Add(cellHead);
                    }

                    tblAdminType.Rows.Add(tRowHead);

                    foreach (AdmissionTypeData data in Data)
                    {
                        TableRow tRowBody = new TableRow();
                        tRowBody.TableSection = TableRowSection.TableBody;

                        TableCell cellCode = new TableCell();
                        cellCode.Text = data.AdmissionType_Code;
                        tRowBody.Cells.Add(cellCode);

                        TableCell cellThai = new TableCell();
                        cellThai.Text = data.AdmissionType_Thai;
                        tRowBody.Cells.Add(cellThai);

                        TableCell cellEng = new TableCell();
                        cellEng.Text = data.AdmissionType_Eng;
                        tRowBody.Cells.Add(cellEng);

                        TableCell cellEdit = new TableCell();
                        string    urlEdit  = "edit_Admission_Type.aspx?token=" + data.AdmissionType_Code;
                        HyperLink hypEdit  = new HyperLink();
                        hypEdit.Attributes.Add("data-target", "#editAdmission_Type");
                        hypEdit.Attributes.Add("data-toggle", "modal");
                        hypEdit.Text        = "<h4><i class='fa fa-edit'></i></h4>";
                        hypEdit.NavigateUrl = urlEdit;
                        hypEdit.ToolTip     = "Edit";
                        cellEdit.Controls.Add(hypEdit);
                        cellEdit.CssClass = "text-center";
                        tRowBody.Cells.Add(cellEdit);

                        TableCell cellDel = new TableCell();
                        //string urlDel = "#";
                        string    urlDel = "delete_Admission_Type.aspx?token=" + data.AdmissionType_Code;
                        HyperLink hypDel = new HyperLink();
                        hypDel.Attributes.Add("data-target", "#deleteAdmission_Type");
                        hypDel.Attributes.Add("data-toggle", "modal");
                        hypDel.Text        = "<h4><i class='fa fa-trash-o'></i></h4>";
                        hypDel.NavigateUrl = urlDel;
                        hypDel.ToolTip     = "Delete";
                        cellDel.Controls.Add(hypDel);
                        cellDel.CssClass = "text-center";
                        tRowBody.Cells.Add(cellDel);

                        tblAdminType.Rows.Add(tRowBody);
                    }
                }    //end !Page.IsPostBack
                /*=============================*/
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }