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

                if (!Page.IsPostBack)
                {
                    officeData = officeObj.getOtherOffice(OfficeCode);

                    List <StatusData> status = new Status().getSystemStatus();
                    foreach (StatusData data in status)
                    {
                        ddlOfficeStatus.Items.Insert(ddlOfficeStatus.Items.Count, new ListItem(data.Status_Thai, data.Status_Code));
                    }

                    txtOfficeCode.Text      = officeData.OtherOffice_Code;
                    txtOfficeNameThai.Text  = officeData.OtherOffice_ThaiName;
                    txtOfficeNameEng.Text   = officeData.OtherOffice_EngName;
                    txtOfficeShortName.Text = officeData.OtherOffice_ShortName;

                    ddlOfficeStatus.ClearSelection();
                    ddlOfficeStatus.Items.FindByValue(officeData.OtherOffice_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) || autro_obj.CheckGroupUser(login_data, group_var.admin_department) || autro_obj.CheckGroupUser(login_data, group_var.admin_otherOffice))
            {
                /*=============================*/
                if (!Page.IsPostBack)
                {
                    if (autro_obj.CheckGroupUser(login_data, group_var.admin_university) || autro_obj.CheckGroupUser(login_data, group_var.admin_faculty))
                    {
                        rowAdd.Visible = true;
                    }
                    else
                    {
                        rowAdd.Visible = false;
                    }



                    if (autro_obj.CheckGroupUser(login_data, group_var.admin_university))
                    {
                        divFaculty.Visible = false;
                        divOffice.Visible  = false;
                    }
                    else if (autro_obj.CheckGroupUser(login_data, group_var.admin_faculty))
                    {
                        divFaculty.Visible = true;
                        divOffice.Visible  = false;
                    }
                    else if (autro_obj.CheckGroupUser(login_data, group_var.admin_department))
                    {
                        divFaculty.Visible = true;
                        divOffice.Visible  = false;
                    }
                    else if (autro_obj.CheckGroupUser(login_data, group_var.admin_otherOffice))
                    {
                        divFaculty.Visible = false;
                        divOffice.Visible  = true;
                    }

                    // admin มหาวิทยาลัย
                    if (autro_obj.CheckGroupUser(login_data, group_var.admin_university) || autro_obj.CheckGroupUser(login_data, group_var.admin_faculty))
                    {
                        // เลือกสังกัด
                        ddlDivision.Enabled = true;

                        // คณะ
                        ddlFaculty.Items.Clear();
                        facultyData = facultyObj.getFaculty();
                        ddlFaculty.Items.Insert(0, new ListItem("--- เลือกคณะ ---", "00"));
                        foreach (FacultyData data in facultyData)
                        {
                            ddlFaculty.Items.Insert(ddlFaculty.Items.Count, new ListItem(data.Faculty_Thai, data.Faculty_Code));
                        }
                    }
                    // admin คณะ
                    if (autro_obj.CheckGroupUser(login_data, group_var.admin_faculty))
                    {
                        // เลือกสังกัด
                        ddlDivision.Enabled = false;
                        ddlDivision.Items.Clear();
                        ddlDivision.Items.Insert(ddlDivision.Items.Count, new ListItem("คณะ/วิทยาลัย", "1"));

                        List <string> faculty_authorized = autro_obj.getFaculty_Authorized(login_data, group_var.admin_faculty);

                        // คณะ
                        ddlFaculty.Items.Clear();
                        facultyData = facultyObj.getFaculty(faculty_authorized);
                        ddlFaculty.Items.Insert(0, new ListItem("--- เลือกคณะ ---", "00"));
                        foreach (FacultyData data in facultyData)
                        {
                            ddlFaculty.Items.Insert(ddlFaculty.Items.Count, new ListItem(data.Faculty_Thai, data.Faculty_Code));
                        }
                    }
                    // admin ภาควิชา
                    if (autro_obj.CheckGroupUser(login_data, group_var.admin_department))
                    {
                        // เลือกสังกัด
                        ddlDivision.Enabled = false;
                        ddlDivision.Items.Clear();
                        ddlDivision.Items.Insert(ddlDivision.Items.Count, new ListItem("คณะ/วิทยาลัย", "1"));

                        List <string> department_authorized = autro_obj.getDepartment_Authorized(login_data, group_var.admin_department);
                        // ภาควิชา
                        ddlDepartment.Items.Clear();
                        departmentData = new Department().getDepartment(department_authorized);
                        foreach (DepartmentData data in departmentData)
                        {
                            ddlDepartment.Items.Insert(ddlDepartment.Items.Count, new ListItem(data.Department_Thai, data.Department_Code));
                        }

                        // คณะ
                        ddlFaculty.Enabled = false;
                        FacultyData faculty_data = new FacultyData();
                        faculty_data = new Faculty().getFaculty(ddlDepartment.SelectedValue.Substring(0, 2));
                        ddlFaculty.Items.Insert(ddlFaculty.Items.Count, new ListItem(faculty_data.Faculty_Thai, faculty_data.Faculty_Code));
                    }
                    // admin สำนักงาน
                    if (autro_obj.CheckGroupUser(login_data, group_var.admin_otherOffice))
                    {
                        // เลือกสังกัด
                        ddlDivision.Enabled = false;
                        ddlDivision.Items.Clear();
                        ddlDivision.Items.Insert(ddlDivision.Items.Count, new ListItem("สำนักงาน", "2"));

                        //สำนักงาน
                        List <string> otheroffice_authorized = autro_obj.getOtherOffice_Authorized(login_data, group_var.admin_otherOffice);
                        otherOfficeData = otherOfficeObj.getOtherOffice(otheroffice_authorized);
                        ddlOffice.Items.Clear();
                        ddlOffice.Items.Insert(0, new ListItem("--- เลือกสำนักงาน ---", "0000"));
                        foreach (OtherOfficeData data in otherOfficeData)
                        {
                            ddlOffice.Items.Insert(ddlOffice.Items.Count, new ListItem(data.OtherOffice_ThaiName, data.OtherOffice_Code));
                        }
                    }
                }     //end !Page.IsPostBack



                /*=============================*/
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }
Пример #3
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)
                {
                    //โหลดคำนำหน้าชื่อ
                    prefixData = prefixObj.getPrefix();
                    ddlTitleThai.Items.Clear();
                    ddlTitleEng.Items.Clear();

                    foreach (PrefixData prefix in prefixData)
                    {
                        ddlTitleThai.Items.Insert(ddlTitleThai.Items.Count, new ListItem(prefix.Prefix_Thai, prefix.Prefix_Code));
                        ddlTitleEng.Items.Insert(ddlTitleEng.Items.Count, new ListItem(prefix.Prefix_Eng, prefix.Prefix_Code));
                    }

                    //if (autro_obj.CheckGroupUser(login_data, group_var.admin_university))
                    //    {
                    //    facultyData = facultyObj.getFaculty();
                    //    ddlFaculty.Items.Clear();
                    //    ddlFaculty.Items.Insert(0, new ListItem("--- เลือกคณะ ---", "00"));
                    //    foreach (FacultyData data in facultyData)
                    //        {
                    //        ddlFaculty.Items.Insert(ddlFaculty.Items.Count, new ListItem(data.Faculty_Thai, data.Faculty_Code));
                    //        }
                    //    }

                    //โหลดคณะ
                    if (autro_obj.CheckGroupUser(login_data, group_var.admin_faculty))
                    {
                        List <string> faculty_authorized = autro_obj.getFaculty_Authorized(login_data, group_var.admin_faculty);

                        // คณะ
                        ddlFaculty.Items.Clear();
                        facultyData = facultyObj.getFaculty(faculty_authorized);
                        ddlFaculty.Items.Insert(0, new ListItem("--- เลือกคณะ ---", "00"));
                        foreach (FacultyData data in facultyData)
                        {
                            ddlFaculty.Items.Insert(ddlFaculty.Items.Count, new ListItem(data.Faculty_Thai, data.Faculty_Code));
                            if (data.Faculty_Code == "11")
                            {
                                ddlFaculty.Items.FindByValue(data.Faculty_Code).Selected = true;
                            }
                        }

                        //โหลดภาควิชา
                        Department            department     = new Department();
                        List <DepartmentData> departmentData = new List <DepartmentData>();

                        departmentData = department.getDepartmentWithFaculty(ddlFaculty.SelectedValue);
                        ddlDepartment.Items.Clear();
                        ddlDepartment.Items.Insert(0, new ListItem("-- ไม่ได้สังกัดภาควิชา --", "0000"));
                        foreach (DepartmentData data in departmentData)
                        {
                            ddlDepartment.Items.Insert(ddlDepartment.Items.Count, new ListItem(data.Department_Thai, data.Department_Code));
                        }
                    }


                    //สำนักงาน
                    otherOfficeData = otherOfficeObj.getOtherOffice();
                    ddlOffice.Items.Clear();
                    ddlOffice.Items.Insert(0, new ListItem("--- เลือกสำนักงาน ---", "0000"));
                    foreach (OtherOfficeData data in otherOfficeData)
                    {
                        ddlOffice.Items.Insert(ddlOffice.Items.Count, new ListItem(data.OtherOffice_ThaiName, data.OtherOffice_Code));
                    }

                    //ซ่อน ddl สังกัดไว้ตอน page load
                    divFaculty.Visible = true;
                    divOffice.Visible  = false;
                }
                /*=============================*/
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }
Пример #4
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))
            {
                /*=============================*/
                userId = Request.QueryString["Uid"];

                if (!Page.IsPostBack)
                {
                    userData = userObj.getUsers(userId);

                    txtUserName.Text  = userData.USERS_INFO_USER_ID;
                    txtNameThai.Text  = userData.USERS_INFO_FIRST_THAINAME;
                    txtLnameThai.Text = userData.USERS_INFO_FAMILY_THAINAME;
                    txtNameEng.Text   = userData.USERS_INFO_FIRST_ENGNAME;
                    txtLnameEng.Text  = userData.USERS_INFO_FAMILY_ENGNAME;
                    txtNationId.Text  = userData.USERS_INFO_NATIONAL_ID;
                    txtOfficId.Text   = userData.USERS_INFO_OFFICIAL_ID;
                    txtIntNumber.Text = userData.USERS_INFO_INTERNAL_PHONE;
                    txtExtNumber.Text = userData.USERS_INFO_EXTERNAL_PHONE;

                    //โหลดคำนำหน้าชื่อ
                    prefixData = prefixObj.getPrefix();
                    ddlTitleThai.Items.Clear();
                    ddlTitleEng.Items.Clear();
                    foreach (PrefixData prefix in prefixData)
                    {
                        ddlTitleThai.Items.Insert(ddlTitleThai.Items.Count, new ListItem(prefix.Prefix_Thai, prefix.Prefix_Code));
                        ddlTitleEng.Items.Insert(ddlTitleEng.Items.Count, new ListItem(prefix.Prefix_Eng, prefix.Prefix_Code));
                    }
                    ddlTitleThai.Items.FindByValue(userData.USERS_INFO_TITLE_THAINAME).Selected = true;
                    ddlTitleEng.Items.FindByValue(userData.USERS_INFO_TITLE_ENGNAME).Selected   = true;

                    List <string> faculty_authorized = autro_obj.getFaculty_Authorized(login_data, group_var.admin_faculty);

                    // คณะ
                    ddlFaculty.Items.Clear();
                    facultyData = facultyObj.getFaculty(faculty_authorized);
                    ddlFaculty.Items.Insert(0, new ListItem("--- เลือกคณะ ---", "00"));
                    foreach (FacultyData data in facultyData)
                    {
                        ddlFaculty.Items.Insert(ddlFaculty.Items.Count, new ListItem(data.Faculty_Thai, data.Faculty_Code));
                        if (data.Faculty_Code == "11")
                        {
                            ddlFaculty.Items.FindByValue(data.Faculty_Code).Selected = true;
                        }
                    }

                    //โหลดภาควิชา
                    Department            department     = new Department();
                    List <DepartmentData> departmentData = new List <DepartmentData>();

                    departmentData = department.getDepartmentWithFaculty(ddlFaculty.SelectedValue);
                    ddlDepartment.Items.Clear();
                    ddlDepartment.Items.Insert(0, new ListItem("-- ไม่ได้สังกัดภาควิชา --", "0000"));
                    foreach (DepartmentData data in departmentData)
                    {
                        ddlDepartment.Items.Insert(ddlDepartment.Items.Count, new ListItem(data.Department_Thai, data.Department_Code));
                    }

                    //สำนักงาน
                    otherOfficeData = otherOfficeObj.getOtherOffice();
                    ddlOffice.Items.Clear();
                    ddlOffice.Items.Insert(0, new ListItem("--- เลือกสำนักงาน ---", "0000"));
                    foreach (OtherOfficeData data in otherOfficeData)
                    {
                        ddlOffice.Items.Insert(ddlOffice.Items.Count, new ListItem(data.OtherOffice_ThaiName, data.OtherOffice_Code));
                    }


                    //โหลดค่า default สังกัด
                    // 1 = คณะ
                    if (userData.USERS_INFO_FACULTY_ID != "00" && userData.OTHEROFFICE_CODE == "0000")
                    {
                        ddlDivision.ClearSelection();
                        ddlDivision.Items.FindByValue("1").Selected = true;
                        ddlFaculty.ClearSelection();
                        ddlFaculty.Items.FindByValue(userData.USERS_INFO_FACULTY_ID).Selected = true;
                        ddlDepartment.ClearSelection();
                        ddlDepartment.Items.FindByValue(userData.USERS_INFO_DEPARTMENT_ID).Selected = true;

                        //ซ่อน ddl สังกัดไว้ตอน page load
                        divFaculty.Visible = true;
                        divOffice.Visible  = false;
                    }
                    // 2 = สำนักงาน
                    else if (userData.USERS_INFO_FACULTY_ID == "00" && userData.OTHEROFFICE_CODE != "0000")
                    {
                        ddlDivision.ClearSelection();
                        ddlDivision.Items.FindByValue("2").Selected = true;
                        ddlOffice.ClearSelection();
                        ddlOffice.Items.FindByValue(userData.OTHEROFFICE_CODE).Selected = true;

                        //ซ่อน ddl สังกัดไว้ตอน page load
                        divFaculty.Visible = false;
                        divOffice.Visible  = true;
                    }
                    else
                    {
                        ddlDivision.ClearSelection();
                        ddlDivision.Items.FindByValue("1").Selected = true;
                        ddlFaculty.ClearSelection();
                        ddlFaculty.Items.FindByValue(userData.USERS_INFO_FACULTY_ID).Selected = true;
                        ddlDepartment.ClearSelection();
                        ddlDepartment.Items.FindByValue(userData.USERS_INFO_DEPARTMENT_ID).Selected = true;

                        //ซ่อน ddl สังกัดไว้ตอน page load
                        divFaculty.Visible = true;
                        divOffice.Visible  = false;
                    }

                    divSuccess.Visible = false;
                    divFail.Visible    = false;
                }
                /*=============================*/
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }