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.getStdCategory(code);

                    txtCATEGORY_CODE.Text     = data.StdCategory_Code;
                    txtCATEGORY_SHORT.Text    = data.StdCategory_Short;
                    txtCATEGORY_THAINAME.Text = data.StdCategory_Thai;
                    txtCATEGORY_ENGNAME.Text  = data.StdCategory_Eng;
                }
                /*=============================*/
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }
Пример #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.getStdCategory();

                    // Head Table
                    string[] ar = { "รหัส", "ชื่อย่อ", "ชื่อภาษาไทย", "ชื่อภาษาอังกฤษ", "แก้ไข", "ลบ" };
                    //Table tb1 = new Table();
                    tblCategory.Attributes.Add("class", "table table-bordered table-striped table-hover");
                    tblCategory.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 < 3 || cellCtr > 4)
                        {
                            cellHead.Width = 100;
                        }

                        tRowHead.Cells.Add(cellHead);
                    }

                    tblCategory.Rows.Add(tRowHead);

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

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

                        TableCell cellShort = new TableCell();
                        cellShort.Text = data.StdCategory_Short;
                        tRowBody.Cells.Add(cellShort);

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

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

                        TableCell cellEdit = new TableCell();
                        string    urlEdit  = "edit_Student_Category.aspx?token=" + data.StdCategory_Code;
                        HyperLink hypEdit  = new HyperLink();
                        hypEdit.Attributes.Add("data-target", "#editStudent_Category");
                        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_Student_Category.aspx?token=" + data.StdCategory_Code;
                        HyperLink hypDel = new HyperLink();
                        hypDel.Attributes.Add("data-target", "#deleteStudent_Category");
                        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);

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