Пример #1
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))
            {
                /*=============================*/
                code = Request.QueryString["token"];

                if (!Page.IsPostBack)
                {
                    string sql = "Select * From SPECIAL_FIELD Where SPEC_FIELD_CODE='" + code + "'";
                    SpecialFieldData = SpecialFieldObj.getSpecialFieldManual(sql);

                    txtSPEC_FIELD_CODE.Text      = SpecialFieldData[0].SpecialField_Code;
                    txtSPEC_FIELD_ENGNAME.Text   = SpecialFieldData[0].SpecialField_Eng;
                    txtSPEC_FIELD_SHORTNAME.Text = SpecialFieldData[0].SpecialField_ShortName;
                    //ddlSPEC_FIELD_STATUS.Items.FindByValue(data.SpecialField_Status).Selected = true;
                    txtSPEC_FIELD_THAINAME.Text = SpecialFieldData[0].SpecialField_Thai;

                    facultyData = facultyObj.getFaculty();
                    foreach (FacultyData d in facultyData)
                    {
                        ddlFACULTY.Items.Insert(ddlFACULTY.Items.Count, new ListItem(d.Faculty_Thai, d.Faculty_Code));
                    }
                    ddlFACULTY.Items.FindByValue(SpecialFieldData[0].SpecialField_FacultyCode).Selected = true;

                    statusData = statusObj.getSystemStatus();
                    foreach (StatusData data in statusData)
                    {
                        ddlSPEC_FIELD_STATUS.Items.Insert(ddlSPEC_FIELD_STATUS.Items.Count, new ListItem(data.Status_Thai, data.Status_Code));
                    }
                    ddlSPEC_FIELD_STATUS.Items.FindByValue(SpecialFieldData[0].SpecialField_Status).Selected = true;
                }
                /*=============================*/
            }
            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)
                {
                    //โหลดแขนงวิชา
                    string sql = "Select * From SPECIAL_FIELD Order By SPEC_FIELD_CODE";
                    specialFData = specialFObj.getSpecialFieldManual(sql);

                    // Head Table
                    string[] ar = { "รหัส", "ชื่อย่อ", "ชื่อแขนงวิชา (thai)", "ชื่อแขนงวิชา (English)", "คณะ", "สถานะ", "แก้ไข", "ลบ" };
                    //Table tb1 = new Table();
                    tblSpecialField.Attributes.Add("class", "table table-bordered table-striped table-hover");
                    tblSpecialField.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];
                        tRowHead.Cells.Add(cellHead);
                    }

                    tblSpecialField.Rows.Add(tRowHead);

                    foreach (SpecialFieldData data in specialFData)
                    {
                        //ตรวจสอบสถานะการใช้งานของคณะ
                        if (new Faculty().getFaculty(data.SpecialField_FacultyCode).Faculty_Status != "0001")
                        {
                            continue;
                        }
                        else
                        {
                            TableRow tRowBody = new TableRow();
                            tRowBody.TableSection = TableRowSection.TableBody;

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

                            TableCell cellShortName = new TableCell();
                            cellShortName.Text = data.SpecialField_ShortName;
                            tRowBody.Cells.Add(cellShortName);

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

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

                            TableCell   cellFaculty = new TableCell();
                            FacultyData fac         = new Faculty().getFaculty(data.SpecialField_FacultyCode);
                            cellFaculty.Text = fac.Faculty_Thai;
                            tRowBody.Cells.Add(cellFaculty);

                            TableCell cellStatus = new TableCell();
                            //0001 = ใช้งาน
                            if (data.SpecialField_Status == "0001")
                            {
                                cellStatus.Text    = "<h4 class='txt-color-green'><i class='fa fa-check'></i></h4>";
                                cellStatus.ToolTip = "ใช้งาน";
                            }
                            //0002 = ไม่ใช้งาน
                            if (data.SpecialField_Status == "0002")
                            {
                                cellStatus.Text    = "<h4 class='txt-color-red'><i class='fa fa-times'></i></h4>";
                                cellStatus.ToolTip = "ไม่ใช้งาน";
                            }
                            cellStatus.CssClass = "text-center";
                            tRowBody.Cells.Add(cellStatus);

                            TableCell cellEdit = new TableCell();
                            string    urlEdit  = "edit_Special_Field.aspx?token=" + data.SpecialField_Code;
                            HyperLink hypEdit  = new HyperLink();
                            hypEdit.Attributes.Add("data-target", "#editSpecial_Field");
                            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_Special_Field.aspx?token=" + data.SpecialField_Code;
                            HyperLink hypDel = new HyperLink();
                            hypDel.Attributes.Add("data-target", "#deleteSpecial_Field");
                            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);

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