Пример #1
0
        public void StartModuleTest()
        {
            Notifier _notif = new Notifier();

            // Eliminar archivo de email creado en prueba anteriores
            if (System.IO.File.Exists(Notifier.EmailFile))
            {
                System.IO.File.Delete(Notifier.EmailFile);
            }

            Assert.IsNull(_notif.SmtpClient);

            // Creando system config
            SystemConfigData syscfg = new SystemConfigData();

            syscfg.SMtpServer  = "smtp.test";
            syscfg.Source      = "*****@*****.**";
            syscfg.Destination = "*****@*****.**";
            syscfg.Password    = "******";

            _notif.ReceiveSystemConfig(new SendSystemConfig(syscfg));

            _notif.Start();

            Assert.IsNotNull(_notif.SmtpClient);
            Assert.IsTrue(System.IO.File.Exists(Notifier.EmailFile));

            _notif.Stop();

            if (System.IO.File.Exists(Notifier.EmailFile))
            {
                System.IO.File.Delete(Notifier.EmailFile);
            }
        }
Пример #2
0
 public static bool SendEmail(EmailModel email)
 {
     try
     {
         MailMessage mm = new MailMessage();
         mm.From = new MailAddress(SystemConfigData.GetSystemConfigData("MailAddress").DataValue, "Notes Marketplace");
         foreach (string address in email.EmailTo)
         {
             mm.To.Add(new MailAddress(address));
         }
         mm.Subject    = email.EmailSubject;
         mm.Body       = email.EmailBody;
         mm.IsBodyHtml = true;
         using (var smtp = new SmtpClient()
         {
             UseDefaultCredentials = false,
             Credentials = new NetworkCredential(mm.From.Address, SystemConfigData.GetSystemConfigData("MailPassword").DataValue)
         }
                )
         {
             smtp.Send(mm);
             return(true);
         }
     }catch (Exception e)
     {
         Debug.WriteLine(e);
         return(false);
     }
 }
        public ActionResult Report(ReportNoteModel Rm)
        {
            if (Session["UserID"] == null)
            {
                return(RedirectToAction("Login", "Authentication", new { ReturnUrl = @"/RegisteredUser/Downloads" }));
            }

            if (!ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest));
            }

            int UserID = Convert.ToInt32(User.Identity.Name);

            if (NotesRepository.SubmitNoteReport(Rm, UserID))
            {
                ViewBag.SellerName = Rm.SellerName;
                ViewBag.NoteName   = Rm.NoteTitle;
                ViewBag.BuyerName  = Session["FullName"];
                SendMail.SendEmail(new EmailModel()
                {
                    EmailTo      = SystemConfigData.GetSystemConfigData("AdminEmails").DataValue.Split(';'),
                    EmailSubject = Session["FullName"].ToString() + " reported an issue for " + Rm.NoteTitle,
                    EmailBody    = this.getHTMLViewAsString("~/Views/Email/ReportedNote.cshtml")
                });

                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.OK));
            }
            else
            {
                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.Forbidden));
            }
        }
    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)
                {
                    divSuccess.Visible = false;
                    divFail.Visible    = false;

                    config_data = new SystemConfig().getConfig();

                    academic_year         = config_data.AcademicYear;
                    txtACADEMIC_YEAR.Text = config_data.AcademicYear;
                    ddlSEMESTER.Items.FindByValue(config_data.Semester).Selected = true;
                }

                academic_year = txtACADEMIC_YEAR.Text;
                /*=============================*/
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }
Пример #5
0
    public SystemConfigData getConfig()
    {
        SystemConfigData config_data = new SystemConfigData();
        string           sql         = "";
        ConnectDB        db          = new ConnectDB();
        SqlDataSource    oracleObj   = db.ConnectionOracle();

        sql = "Select * From SYSTEM_CONFIG";

        try
        {
            oracleObj.SelectCommand = sql;
            DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty);
            foreach (DataRowView rowData in allData)
            {
                config_data.AcademicYear = rowData["ACADEMIC_YEAR"].ToString();
                config_data.Semester     = rowData["SEMESTER"].ToString();
            }
        }
        catch
        {
            HttpContext.Current.Session["response"] = "Unit Test:SystemConfig:getConfig" + " ไม่สามารถดำเนินการได้";
            HttpContext.Current.Response.Redirect("err_response.aspx");
        }


        return(config_data);
    }
Пример #6
0
    public string updateConfig(SystemConfigData config_data)
    {
        string        response  = "";
        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();
        string        sql       = "Update SYSTEM_CONFIG Set ACADEMIC_YEAR='" + config_data.AcademicYear + "',SEMESTER='" + config_data.Semester + "' ";

        try
        {
            oracleObj.UpdateCommand = sql;


            if (oracleObj.Update() == 1)
            {
                response = "OK";
            }
        }
        catch
        {
            HttpContext.Current.Session["response"] = "Unit Test:SystemConfig:updateConfig" + " ไม่สามารถดำเนินการได้";
            HttpContext.Current.Response.Redirect("err_response.aspx");
        }


        return(response);
    }
Пример #7
0
        public void In_RequestSystemData(RemReqSystemData request)
        {
            Console.WriteLine("Receive System Config from Remote Client.");

            SystemConfigData scfg = new SystemConfigData();

            scfg.ZyanServerName = "Servidor Remoto de Prueba WDAltMonitor";

            Out_SendSystemConfigData(new RemReplySystemData(scfg));
        }
Пример #8
0
        static internal void LaunchConsole()
        {
            Console.WriteLine("LaunchConsole");

            _dbHandler.OpenDatabase();

            // Mostrar contenido
            SystemConfigData scfg = _dbHandler._dbRoot.SystemConfig;

            Console.WriteLine("1- " + scfg.ZyanServerName + " " + scfg.ZyanServerPort);

            // Update externo config unica, sys
            scfg.ZyanServerName = "Modificado";
            scfg.ZyanServerPort = 20;
            _dbHandler.DbCommit();

            Console.WriteLine("2- " + scfg.ZyanServerName + " " + scfg.ZyanServerPort);


            // Update externo config multiple, client
            Dictionary <string, ClientData> clist = _dbHandler._dbRoot.ClientList;

            if (clist.Count == 0)
            {
                Console.WriteLine("No hay Clientes");
                UpdateClientes(clist);
                _dbHandler.DbCommit();
            }
            else
            {
                Console.WriteLine("Clientes: ");
                foreach (var item in clist.Values)
                {
                    Console.WriteLine(item.Name + "  " + item.Port);
                    Console.WriteLine("  HBs: ");

                    foreach (var hbs in item.HeartBeatList)
                    {
                        Console.WriteLine("       " + hbs);
                    }
                }
            }

            Console.WriteLine("Presione una tecla para terminar...");
            Console.ReadKey();
        }
Пример #9
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.lecturer))
            {
                // ======== Process ===========

                config_data = new SystemConfig().getConfig();

                prev_course = "";
                prev_sec    = 0;
                prev_subsec = 0;

                if (!Page.IsPostBack)
                {
                    divFail.Visible = false;

                    //อาจารย์
                    if (autro_obj.CheckGroupUser(login_data, group_var.lecturer))
                    {
                        LectuereInformationData lecturer_data = new Lecturer().getLecturer(login_data.Nation_ID);
                        ddlADVISOR.Items.Clear();
                        ddlADVISOR.Items.Insert(ddlADVISOR.Items.Count, new ListItem(lecturer_data.Lecturer_ShortName + " " + lecturer_data.First_ThaiName + " " + lecturer_data.Family_ThaiName, lecturer_data.Lecturer_ID));
                    }

                    btnSHOW_Click(null, null);
                }

                //=============================
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }
Пример #10
0
        internal void ExportData(string file)
        {
            StartDbHandler();

            Dictionary <string, ClientData> clDict = _dbHandler.ClientConfigDict;
            SystemConfigData sysConfig             = _dbHandler.SystemConfig;

            SystemPlusClientData        localData = new SystemPlusClientData(clDict, sysConfig);
            SystemPlusClientToSerialize toSer     = SystemPlusClientToSerialize.ToSerial(localData);

            XmlSerializer xmlSer = new XmlSerializer(typeof(SystemPlusClientToSerialize));

            StreamWriter myWriter = new StreamWriter(file);

            xmlSer.Serialize(myWriter, toSer);
            myWriter.Close();

            StopDbHandler();
        }
Пример #11
0
        public void SystemConfigurationSaveTest()
        {
            DbHandler _dbh = new DbHandler();

            // Eliminar archivo de datos serializados creado en prueba anteriores
            if (System.IO.File.Exists(_dbh.DbName))
            {
                System.IO.File.Delete(_dbh.DbName);
            }

            _dbh.Start();

            SystemConfigData _sysCfgData = _dbh.DbRoot.SystemConfig;

            int    expectedPort       = 8888;
            string expectedSMTPserver = "localhost";
            string expectedSource     = "*****@*****.**";
            string expectedPwd        = "monitor";
            int    expectedTimeout    = 3;

            _sysCfgData.UdpServerPort       = expectedPort;
            _sysCfgData.ZyanServerName      = Constants.ZyanServerName;
            _sysCfgData.SMtpServer          = expectedSMTPserver;
            _sysCfgData.Source              = expectedSource;
            _sysCfgData.Password            = expectedPwd;
            _sysCfgData.TimeoutStartRestart = expectedTimeout;

            _dbh.Stop();
            _dbh.Start();

            Assert.IsNotNull(_dbh.DbRoot);

            _sysCfgData = _dbh.DbRoot.SystemConfig;

            Assert.AreEqual(expectedPort, _sysCfgData.UdpServerPort);
            Assert.AreEqual(Constants.ZyanServerName, _sysCfgData.ZyanServerName);
            Assert.AreEqual(expectedSMTPserver, _sysCfgData.SMtpServer);
            Assert.AreEqual(expectedSource, _sysCfgData.Source);
            Assert.AreEqual(expectedPwd, _sysCfgData.Password);
            Assert.AreEqual(expectedTimeout, _sysCfgData.TimeoutStartRestart);

            _dbh.Stop();
        }
Пример #12
0
        /// <summary>
        /// Crea configuracion de prueba para los tests.
        /// Configuracion de sistema
        /// </summary>
        private SystemConfigData CreateSystemConfig()
        {
            // config system
            SystemConfigData tmpSys = new SystemConfigData();

            tmpSys.ServerIpAdr    = "127.0.0.1";
            tmpSys.UdpServerPort  = 8888;
            tmpSys.ZyanServerName = Constants.ZyanServerName;
            tmpSys.ZyanServerPort = Constants.ZyanServerPort;
            tmpSys.SMtpServer     = "localhost";

            tmpSys.Source              = "*****@*****.**";
            tmpSys.Password            = "******";
            tmpSys.Destination         = "[email protected], [email protected]";
            tmpSys.TimeoutStartRestart = 180;
            tmpSys.RestartAttemps      = 2;

            return(tmpSys);
        }
Пример #13
0
    public List <StudentGroupData> getStudentGroupByDepartment(string department_code, string degree_char)
    {
        string           tableName     = getTableName(degree_char);
        SystemConfigData system_config = new SystemConfigData();

        system_config = new SystemConfig().getConfig();
        Status_Variable         status_var   = new Status_Variable();
        List <StudentGroupData> studentGroup = new List <StudentGroupData>();

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        try
        {
            string sql = "Select CURR_CODE,STD_CATEGORY_CODE,STD_GROUP_CODE,SECTION_CODE  From " + tableName + " Where ACADEMIC_YEAR='" + system_config.AcademicYear + "' AND SEMESTER='" + system_config.Semester + "' AND STD_CATEGORY_CODE!='-'  Group By CURR_CODE, STD_CATEGORY_CODE,STD_GROUP_CODE,SECTION_CODE";


            oracleObj.SelectCommand = sql;
            DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty);
            foreach (DataRowView rowData in allData)
            {
                StudentGroupData student_group = new StudentGroupData();
                student_group.curri_code   = rowData["CURR_CODE"].ToString();
                student_group.std_category = rowData["STD_CATEGORY_CODE"].ToString();
                student_group.std_group    = rowData["STD_GROUP_CODE"].ToString();
                student_group.section      = rowData["SECTION_CODE"].ToString();
                string curr_department = new Curriculum().getCurriculum(student_group.curri_code).Department_Code;
                if (curr_department == department_code)
                {
                    studentGroup.Add(student_group);
                }
            }
        }
        catch
        {
            HttpContext.Current.Session["response"] = "Unit Test:StudentGroup:getStudentGroupByDepartment" + " ไม่สามารถดำเนินการได้";
            HttpContext.Current.Response.Redirect("err_response.aspx");
        }


        return(studentGroup);
    }
Пример #14
0
        public void SimplePropertiesTest()
        {
            // La clase SystemConfigData es un almacen de datos, sus propiedades son
            // simples {get set}.

            // arrange
            SystemConfigData syscfg = new SystemConfigData();

            string expectedSMtpServer = "SystemConfigData Test Value";
            string expectedPassword   = "******";
            int    expectedPort       = 56567;
            int    expectedServerPort = 556666;

            syscfg.SMtpServer     = expectedSMtpServer;
            syscfg.Password       = expectedPassword;
            syscfg.UdpServerPort  = expectedPort;
            syscfg.ZyanServerPort = expectedServerPort;

            Assert.AreEqual(expectedSMtpServer, syscfg.SMtpServer);
            Assert.AreEqual(expectedPassword, syscfg.Password);
            Assert.AreEqual(expectedPort, syscfg.UdpServerPort);
            Assert.AreEqual(expectedServerPort, syscfg.ZyanServerPort);
        }
Пример #15
0
        public void SimulatedMailTest()
        {
            Notifier _notif = new Notifier();

            // Eliminar archivo de email creado en prueba anteriores
            if (System.IO.File.Exists(Notifier.EmailFile))
            {
                System.IO.File.Delete(Notifier.EmailFile);
            }

            // Creando system config
            SystemConfigData syscfg = new SystemConfigData();

            syscfg.SMtpServer  = "smtp.test";
            syscfg.Source      = "*****@*****.**";
            syscfg.Destination = "*****@*****.**";
            syscfg.Password    = "******";

            _notif.ReceiveSystemConfig(new SendSystemConfig(syscfg));

            _notif.Start();

            RequestSendEmail req = new RequestSendEmail(EMessageAction.SysStart, DateTime.Now);

            _notif.SendEmail(req);

            Assert.IsNotNull(_notif.SmtpClient);
            Assert.IsTrue(System.IO.File.Exists(Notifier.EmailFile));

            _notif.Stop();

            if (System.IO.File.Exists(Notifier.EmailFile))
            {
                System.IO.File.Delete(Notifier.EmailFile);
            }
        }
Пример #16
0
        public ActionResult ContactUs(ContactUsModel cu)
        {
            if (Request.IsAuthenticated && Session["UserID"] == null)
            {
                return(RedirectToAction("Login", "Authentication"));
            }
            else if (Request.IsAuthenticated)
            {
                ViewBag.Authorized = true;
            }

            ViewBag.Title = "ContactUs";
            if (!ModelState.IsValid)
            {
                return(View(cu));
            }

            ViewBag.Name    = cu.FullName;
            ViewBag.Email   = cu.Email;
            ViewBag.Comment = cu.Comment;
            if (SendMail.SendEmail(new EmailModel()
            {
                EmailTo = SystemConfigData.GetSystemConfigData("AdminEmails").DataValue.Split(';'),
                EmailSubject = cu.Subject,
                EmailBody = this.getHTMLViewAsString("~/Views/Email/ContactUsMail.cshtml")
            }))
            {
                ViewBag.Message = "Thank you for contacting us, we will get back to you.";
                return(View(cu));
            }
            else
            {
                ViewBag.Message = "Something went wrong. Please try again.";
                return(View(cu));
            }
        }
Пример #17
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.lecturer))
            {
                // ======== Process ===========
                config_data   = new SystemConfig().getConfig();
                academic_year = config_data.AcademicYear;
                semester      = config_data.Semester;

                row1 = Request.QueryString["show_row"];


                if (Session["showCourse" + row1] == null)
                {
                    Response.Redirect("List_Course_Lecturer.aspx");
                }
                else
                {
                    LecturerTableData lectuere_data = new LecturerTableData();

                    lnkADD.NavigateUrl = "Extend_Student.aspx?show_row=" + row1;

                    lectuere_data = (LecturerTableData)Session["showCourse" + row1];

                    Session["Extend_Data"] = lectuere_data;

                    lec_info    = new Lecturer().getLecturer(lectuere_data.Lecturer);
                    course_info = new Course().getCourse(lectuere_data.Course_Code);


                    string course_type = "";
                    string course_sec  = "";

                    if (lectuere_data.Course_Type == "1")
                    {
                        course_type = "S.";
                    }
                    else if (lectuere_data.Course_Type == "2")
                    {
                        course_type = "L.";
                    }
                    else if (lectuere_data.Course_Type == "4")
                    {
                        course_type = "T.";
                    }
                    else if (lectuere_data.Course_Type == "5")
                    {
                        course_type = "M.";
                    }
                    else if (lectuere_data.Course_Type == "6")
                    {
                        course_type = "SP.";
                    }
                    else if (lectuere_data.Course_Type == "7")
                    {
                        course_type = "D.";
                    }

                    if (lectuere_data.SubSec_No != 0)
                    {
                        course_sec = lectuere_data.SubSec_No.ToString();
                    }
                    else
                    {
                        course_sec = lectuere_data.Sec_No.ToString();
                    }

                    lblLec.Text = lec_info.Lecturer_ShortName + " " + lec_info.First_ThaiName + " " + lec_info.Family_ThaiName;

                    lblHeader.Text = course_type + course_sec + " " + course_info.Course_Code + " " + course_info.Course_Thainame + " " + course_info.Course_Engname;

                    if (!Page.IsPostBack)
                    {
                        // Session.Remove("ApproveRegis");
                    }

                    try
                    {
                        List <RegistrationData> temp1 = new Student_Registration().getStudentRegistration(academic_year, semester, lectuere_data.Course_Code, lectuere_data.Sec_No, lectuere_data.SubSec_No);
                        // List<RegistrationData> temp2 = new Student_Registration().getStudentRegistration(academic_year, semester, lectuere_data.Course_Code, lectuere_data.Sec_No, lectuere_data.SubSec_No, "M");

                        foreach (RegistrationData reg in temp1)
                        {
                            studentRegisData.Add(reg);
                        }

                        //foreach (RegistrationData reg in temp2)
                        //{
                        //    studentRegisData.Add(reg);
                        //}

                        studentExtendData = new ExtendAvailableStudent().getExtendStudent(academic_year, semester, lectuere_data.Course_Code, lectuere_data.Sec_No, lectuere_data.SubSec_No);

                        int numrow  = 1;
                        int numrow2 = 1;

                        string[] ar  = { "ลำดับที่", "รหัสนักศึกษา", "ชื่อ-นามสกุล", "คณะ", "หลักสูตร", "ประเภท", "รอบ", "ห้อง", "อาจารย์ที่ปรึกษา อนุมัติ" };
                        string[] ar2 = { "ลำดับที่", "รหัสนักศึกษา", "ชื่อ-นามสกุล", "คณะ", "หลักสูตร", "ประเภท", "รอบ", "ห้อง", "อาจารย์ผู้ดำเนินการ", "ยกเลิก" };
                        Table    tb1 = new Table();
                        Table    tb2 = new Table();

                        tb1.Attributes.Add("class", "table table-bordered table-hover table-striped");
                        tb1.Attributes.Add("id", "dt_basic");
                        tb2.Attributes.Add("class", "table table-bordered table-hover table-striped");
                        tb2.Attributes.Add("id", "dt_basic");

                        TableHeaderRow tRowHead = new TableHeaderRow();
                        tRowHead.TableSection = TableRowSection.TableHeader;
                        TableHeaderRow tRowHead2 = new TableHeaderRow();
                        tRowHead2.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];
                            cellHead.Attributes.Add("class", "text-align-center");
                            tRowHead.Cells.Add(cellHead);
                        }
                        tb1.Rows.Add(tRowHead);

                        for (int cellCtr = 1; cellCtr <= ar2.Length; cellCtr++)
                        {
                            // Create a new cell and add it to the row.
                            TableHeaderCell cellHead = new TableHeaderCell();
                            cellHead.Text = ar2[cellCtr - 1];
                            cellHead.Attributes.Add("class", "text-align-center");
                            tRowHead2.Cells.Add(cellHead);
                        }
                        tb2.Rows.Add(tRowHead2);


                        foreach (RegistrationData data in studentRegisData)
                        {
                            TableRow tRowBody = new TableRow();
                            tRowBody.TableSection = TableRowSection.TableBody;

                            TableCell cellNum = new TableCell();
                            cellNum.Text = numrow.ToString();
                            cellNum.Attributes.Add("class", "text-align-center");
                            tRowBody.Cells.Add(cellNum);

                            TableCell cellStudent_ID = new TableCell();
                            cellStudent_ID.Text = data.Student_ID;
                            cellStudent_ID.Attributes.Add("class", "text-align-center");
                            tRowBody.Cells.Add(cellStudent_ID);

                            TableCell cellStudent_Name = new TableCell();
                            cellStudent_Name.Text = data.First_Thainame + " " + data.Family_Thainame;
                            cellStudent_Name.Attributes.Add("class", "text-align-center");
                            tRowBody.Cells.Add(cellStudent_Name);

                            TableCell cellFaculty = new TableCell();
                            cellFaculty.Text = new Faculty().getFaculty(data.Faculty_Code).Faculty_Thai;
                            cellFaculty.Attributes.Add("class", "text-align-center");
                            tRowBody.Cells.Add(cellFaculty);

                            TableCell cellCurri = new TableCell();
                            cellCurri.Text = data.Curr_Code.Substring(4) + " " + new Curriculum().getCurriculum(data.Curr_Code).Curr_ThaiName;
                            //cellCurri.Attributes.Add("class", "text-align-center");
                            tRowBody.Cells.Add(cellCurri);

                            Student student_data = new Student();
                            student_data = new Student().getStudent(data.Student_ID, new Curriculum().getCurriculum(data.Curr_Code).Degree_Char);

                            TableCell cellCategory = new TableCell();
                            cellCategory.Text = student_data.StdCategoryThai;
                            cellCategory.Attributes.Add("class", "text-align-center");
                            tRowBody.Cells.Add(cellCategory);

                            TableCell cellSection = new TableCell();
                            cellSection.Text = student_data.SectionThai;
                            cellSection.Attributes.Add("class", "text-align-center");
                            tRowBody.Cells.Add(cellSection);

                            TableCell cellGroup = new TableCell();
                            cellGroup.Text = student_data.StdGroupName;
                            cellGroup.Attributes.Add("class", "text-align-center");
                            tRowBody.Cells.Add(cellGroup);

                            TableCell cellApprove = new TableCell();
                            if (data.Approve_Status == "y")
                            {
                                cellApprove.Text = "อนุมัติ";
                                cellApprove.Attributes.Add("class", "txt-green-bold text-align-center");
                            }
                            else
                            {
                                cellApprove.Text = "รออนุมัติ";
                                cellApprove.Attributes.Add("class", "txt-red text-align-center");
                            }


                            tRowBody.Cells.Add(cellApprove);

                            tb1.Rows.Add(tRowBody);

                            numrow++;
                        }


                        TableRow  row  = new TableRow();
                        TableCell cell = new TableCell();
                        cell.Controls.Add(tb1);
                        row.Cells.Add(cell);
                        tblStudentAdvisor.Rows.Add(row);


                        foreach (ExtendAvailableStudentData data in studentExtendData)
                        {
                            Student student_data = new Student();
                            student_data = new Student().getStudent(data.Student_ID, new DegreeAdmission().getDegreeAdmissionChar(utlObj.getFactorFromStudentID(data.Student_ID, utlObj.stdID_Factor_DegreeAdmission)));

                            TableRow tRowBody = new TableRow();
                            tRowBody.TableSection = TableRowSection.TableBody;

                            TableCell cellNum = new TableCell();
                            cellNum.Text = numrow2.ToString();
                            cellNum.Attributes.Add("class", "text-align-center");
                            tRowBody.Cells.Add(cellNum);

                            TableCell cellStudent_ID = new TableCell();
                            cellStudent_ID.Text = data.Student_ID;
                            cellStudent_ID.Attributes.Add("class", "text-align-center");
                            tRowBody.Cells.Add(cellStudent_ID);

                            TableCell cellStudent_Name = new TableCell();
                            cellStudent_Name.Text = student_data.First_ThaiName + " " + student_data.Family_ThaiName;
                            cellStudent_Name.Attributes.Add("class", "text-align-center");
                            tRowBody.Cells.Add(cellStudent_Name);

                            TableCell cellFaculty = new TableCell();
                            cellFaculty.Text = student_data.FacultyThai;
                            cellFaculty.Attributes.Add("class", "text-align-center");
                            tRowBody.Cells.Add(cellFaculty);

                            TableCell cellCurri = new TableCell();
                            cellCurri.Text = student_data.Curri_Code.Substring(4) + " " + student_data.CurrThai;
                            //cellCurri.Text = "-";
                            tRowBody.Cells.Add(cellCurri);

                            TableCell cellCategory = new TableCell();
                            cellCategory.Text = student_data.StdCategoryThai;
                            cellCategory.Attributes.Add("class", "text-align-center");
                            tRowBody.Cells.Add(cellCategory);

                            TableCell cellSection = new TableCell();
                            cellSection.Text = student_data.SectionThai;
                            cellSection.Attributes.Add("class", "text-align-center");
                            tRowBody.Cells.Add(cellSection);

                            TableCell cellGroup = new TableCell();
                            cellGroup.Text = student_data.StdGroupName;
                            cellGroup.Attributes.Add("class", "text-align-center");
                            tRowBody.Cells.Add(cellGroup);

                            TableCell cellLecturerAdd = new TableCell();
                            cellLecturerAdd.Text = new Lecturer().getLecturer(data.LECTURER_ADD).Lecturer_ShortName;
                            cellLecturerAdd.Attributes.Add("class", "text-align-center");
                            tRowBody.Cells.Add(cellLecturerAdd);

                            TableCell cellApprove = new TableCell();
                            cellApprove.Text = "<a href='Cancel_Extend_Student.aspx?student_id=" + data.Student_ID + "&academic_year=" + data.AcademicYear + "&semester=" + data.Semester + "&course_code=" + data.Course_Code + "&sec=" + data.Sec_No + "&subsec=" + data.SubSec_No + "&lecturer_code=" + lectuere_data.Lecturer + "&show_row=" + row1 + "' title='Cancel' data-target='#deleteModal' data-toggle='modal'><h4><i class='fa fa-trash-o'></i></h4></a>";
                            cellApprove.Attributes.Add("class", "text-align-center");
                            tRowBody.Cells.Add(cellApprove);

                            tb2.Rows.Add(tRowBody);

                            numrow2++;
                        }

                        TableRow  row2  = new TableRow();
                        TableCell cell2 = new TableCell();
                        cell2.Controls.Add(tb2);
                        row2.Cells.Add(cell2);
                        tblExtendStudentAdvisor.Rows.Add(row2);
                    }
                    catch (Exception err)
                    {
                        HttpContext.Current.Session["response"] = "ไม่สามารถดำเนินการได้";
                        HttpContext.Current.Response.Redirect("err_response.aspx");
                    }
                }
                //=============================
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }
        public ActionResult AddNotes(NoteModel Nm, string SaveOrPublish)
        {
            ViewBag.Title                = "AddNotes";
            ViewBag.Authorized           = true;
            ViewBag.LoadValidationScript = true;

            if (Session["UserID"] == null)
            {
                return(RedirectToAction("Login", "Authentication", new { ReturnUrl = "/RegisteredUser/AddNotes" }));
            }

            SearchNotesModel FilterData = new SearchNotesModel();

            FilterData.Type     = NotesFilters.Types();
            FilterData.Category = NotesFilters.Categories();
            FilterData.Country  = NotesFilters.Countries();
            ViewBag.FilterData  = FilterData;


            //check uploaded files and their size
            if (Nm.PreviewFile != null && (Path.GetExtension(Nm.PreviewFile.FileName).ToLower() != ".pdf" || Nm.PreviewFile.ContentLength > 31457280))
            {
                ModelState.AddModelError("PreviewFile", "Only PDF files that are under 30MBs are allowed.");
            }

            long NoteSize = 0;

            foreach (HttpPostedFileBase file in Nm.NotesFiles)
            {
                if (file == null)
                {
                    ModelState.AddModelError("NotesFiles", "Make sure you have uploaded PDF file(s) that are under 30MBs");
                }
                else if (Path.GetExtension(file.FileName).ToLower() != ".pdf")
                {
                    ModelState.AddModelError("NotesFiles", "Only PDF file(s) are allowed.");
                }
                if (file != null)
                {
                    NoteSize += file.ContentLength;
                }
            }
            if (NoteSize > 31457280)
            {
                ModelState.AddModelError("NotesFiles", "Combine PDF(s) size should not exceeds 30MBs");
            }


            if (Nm.NotesCoverPage != null && !MimeMapping.GetMimeMapping(Nm.NotesCoverPage.FileName).ToLower().Contains("image"))
            {
                ModelState.AddModelError("NotesCoverPage", "Only Images are allowed.");
            }

            if (!ModelState.IsValid)
            {
                return(View(Nm));
            }


            //0 for draft 1 for submit for review
            if (SaveOrPublish == "Save")
            {
                Nm.Status = 0;
            }
            else if (SaveOrPublish == "Publish")
            {
                Nm.Status = 1;
            }
            else
            {
                ViewBag.Message = "Adding / Editing note didnt go as expected please try again.";
                return(View(Nm));
            }

            ViewBag.Title                = "AddNotes";
            ViewBag.Authorized           = true;
            ViewBag.LoadValidationScript = true;
            string UID = User.Identity.Name;

            int result = NotesRepository.AddNote(Nm, Convert.ToInt32(UID), Server.MapPath("~"));

            if (result < 1)
            {
                ViewBag.Message = "Adding/Editing note didnt go as expected please try again.";
                return(View(Nm));
            }
            if (SaveOrPublish == "Publish")
            {
                ViewBag.SellerName = Session["FullName"];
                ViewBag.NoteName   = Nm.Title;
                SendMail.SendEmail(new EmailModel()
                {
                    EmailTo      = SystemConfigData.GetSystemConfigData("AdminEmails").DataValue.Split(';'),
                    EmailSubject = Session["FullName"].ToString() + " sent his note for review.",
                    EmailBody    = this.getHTMLViewAsString("~/Views/Email/RequestToReview.cshtml")
                });
                TempData["Message"] = "Note has been submitted for review, we will send you mail when it gets approved.";
            }
            else
            {
                TempData["Message"] = "Note has been successfully saved in Drafts";
            }

            return(RedirectToAction("Dashboard", "RegisteredUser"));
        }
Пример #19
0
        static private void DoUpdateSystem(RequestUpdateSystem req)
        {
            Builder.Output(ClassName + ": Realizando actualizacion de la configuracion del sistema", TraceEventType.Information);

            bool RestartZyanServer = false;
            bool RestartHbReceiver = false;

            SystemConfigData newCfg = req.Data;

            // Config que afecta a HbReceiver.
            if (newCfg.UdpServerPort != _dbHandler.SystemData.UdpServerPort)
            {
                _dbHandler.SystemData.UdpServerPort = newCfg.UdpServerPort;
                RestartHbReceiver = true;
            }
            if (newCfg.ServerIpAdr != _dbHandler.SystemData.ServerIpAdr)
            {
                _dbHandler.SystemData.ServerIpAdr = newCfg.ServerIpAdr;
                RestartHbReceiver = true;
            }
            // Config que afecta a ZyanServer.
            if (newCfg.ZyanServerName != _dbHandler.SystemData.ZyanServerName)
            {
                _dbHandler.SystemData.ZyanServerName = newCfg.ZyanServerName;
                RestartZyanServer = true;
            }
            if (newCfg.ZyanServerPort != _dbHandler.SystemData.ZyanServerPort)
            {
                _dbHandler.SystemData.ZyanServerPort = newCfg.ZyanServerPort;
                RestartZyanServer = true;
            }
            // Config que afecta a Notifier.
            if (newCfg.Source != _dbHandler.SystemData.Source)
            {
                _dbHandler.SystemData.Source = newCfg.Source;
            }
            if (newCfg.Destination != _dbHandler.SystemData.Destination)
            {
                _dbHandler.SystemData.Destination = newCfg.Destination;
            }
            if (newCfg.Password != _dbHandler.SystemData.Password)
            {
                _dbHandler.SystemData.Password = newCfg.Password;
            }
            if (newCfg.SMtpServer != _dbHandler.SystemData.SMtpServer)
            {
                _dbHandler.SystemData.SMtpServer = newCfg.SMtpServer;
            }

            // Resto de la configuracion
            if (newCfg.TimeoutStartRestart != _dbHandler.SystemData.TimeoutStartRestart)
            {
                _dbHandler.SystemData.TimeoutStartRestart = newCfg.TimeoutStartRestart;
            }
            if (newCfg.RestartAttemps != _dbHandler.SystemData.RestartAttemps)
            {
                _dbHandler.SystemData.RestartAttemps = newCfg.RestartAttemps;
            }

            // guardar cambios
            MessageBus.Send(new RequestSaveConfig());

            // Registrando mensaje y controlador.
            MessageBus.Register <SendSystemConfig>(_clientManager.ReceiveSystemConfig);
            MessageBus.Register <SendSystemConfig>(_notifier.ReceiveSystemConfig);
            MessageBus.Register <SendSystemConfig>(_zyanServer.ReceiveSystemConfig);

            // Enviando msg.
            MessageBus.Send(new SendSystemConfig(_dbHandler.SystemData));

            // Quitando registro.
            MessageBus.Remove <SendSystemConfig>(_clientManager.ReceiveSystemConfig);
            MessageBus.Remove <SendSystemConfig>(_notifier.ReceiveSystemConfig);
            MessageBus.Remove <SendSystemConfig>(_zyanServer.ReceiveSystemConfig);

            // Actualizar componentes afectados:
            //  posibles implicados Notifier, ZyanServer, ClientManager (HB REceiver y timeouts)
            //  De ellos solo HB REceiver (pertenece a ClientManager) y ZyanServer se deben reiniciar si hay cambios
            //  los demas solo leen los valores de la configuracion.

            if (RestartHbReceiver)
            {
                MessageBus.Register <RequestStartHbServer>(_clientManager.DoRestartHbReceiver);
                MessageBus.Send(new RequestStartHbServer());
                MessageBus.Remove <RequestStartHbServer>(_clientManager.DoRestartHbReceiver);
            }

            if (RestartZyanServer)
            {
                MessageBus.Register <RequestStartZyanServer>(_zyanServer.DoRestart);
                MessageBus.Send(new RequestStartZyanServer());
                MessageBus.Remove <RequestStartZyanServer>(_zyanServer.DoRestart);
            }

            Builder.Output(ClassName + ": Terminada actualizacion de la configuracion del sistema", TraceEventType.Information);
        }
Пример #20
0
 internal void ReceiveSystemConfig(object sender, SystemConfigEventArgs e)
 {
     SystemData = e.Data;
 }
Пример #21
0
        public void ConfigurationImportExportTest()
        {
            DbHandler _dbh = new DbHandler();

            // Eliminar archivo de datos serializados creado en prueba anteriores
            if (System.IO.File.Exists(_dbh.DbName))
            {
                System.IO.File.Delete(_dbh.DbName);
            }

            string cfgFile = "impexptest.bsr";

            _dbh.Start();

            // System config.
            SystemConfigData _sysCfgData = _dbh.DbRoot.SystemConfig;

            int    expectedPort       = 8888;
            string expectedSMTPserver = "localhost";
            string expectedSource     = "*****@*****.**";
            string expectedPwd        = "monitor";
            int    expectedTimeout    = 3;

            _sysCfgData.UdpServerPort       = expectedPort;
            _sysCfgData.ZyanServerName      = Constants.ZyanServerName;
            _sysCfgData.SMtpServer          = expectedSMTPserver;
            _sysCfgData.Source              = expectedSource;
            _sysCfgData.Password            = expectedPwd;
            _sysCfgData.TimeoutStartRestart = expectedTimeout;

            // Client config.
            ClientDataManager cdm = _dbh.DbRoot.ClientManager;

            string id        = "ER$%^667";
            string name      = "TestClt";
            string appPath   = "TestClt\\qewqew \\qwerq\\qwer";
            string logPath   = "TestClt\\245\\vfd erw5\\wregerw";
            int    timeout   = 345;
            int    port      = 0;
            bool   mail      = false;
            bool   logAttach = true;
            int    queueSize = 56;

            ClientData client = cdm.CreateClient(ClientIdType.KeyByIdString,
                                                 id,
                                                 port,
                                                 name,
                                                 appPath,
                                                 logPath,
                                                 timeout,
                                                 mail,
                                                 logAttach,
                                                 queueSize);

            // export
            _dbh.ExportCfg(cfgFile);

            _dbh.Stop();
            // borrar salva de config creada al detener componente
            if (System.IO.File.Exists(_dbh.DbName))
            {
                System.IO.File.Delete(_dbh.DbName);
            }

            // se crea config por defecto al abrir
            _dbh.Start();

            Assert.IsNotNull(_dbh.DbRoot);
            Assert.IsNotNull(_dbh.DbRoot.ClientManager);
            Assert.IsNotNull(_dbh.DbRoot.SystemConfig);
            // Sin clientes
            Assert.AreEqual(0, _dbh.DbRoot.ClientManager.Count);

            // import
            _dbh.ImportCfg(cfgFile);

            Assert.IsNotNull(_dbh.DbRoot);
            Assert.IsNotNull(_dbh.DbRoot.ClientManager);
            Assert.IsNotNull(_dbh.DbRoot.SystemConfig);

            // Comprobaciones
            // System
            _sysCfgData = _dbh.DbRoot.SystemConfig;

            Assert.AreEqual(expectedPort, _sysCfgData.UdpServerPort);
            Assert.AreEqual(Constants.ZyanServerName, _sysCfgData.ZyanServerName);
            Assert.AreEqual(expectedSMTPserver, _sysCfgData.SMtpServer);
            Assert.AreEqual(expectedSource, _sysCfgData.Source);
            Assert.AreEqual(expectedPwd, _sysCfgData.Password);
            Assert.AreEqual(expectedTimeout, _sysCfgData.TimeoutStartRestart);

            // Clientes
            cdm = _dbh.DbRoot.ClientManager;;

            Assert.AreEqual(1, cdm.Count);

            client = cdm.GetClient(id);

            Assert.AreEqual(name, client.Name);
            Assert.AreEqual(appPath, client.AppFilePath);
            Assert.AreEqual(logPath, client.LogFilePath);
            Assert.AreEqual(timeout, client.Timeout);
            Assert.AreEqual(port, client.Port);
            Assert.AreEqual(mail, client.MailEnabled);
            Assert.AreEqual(logAttach, client.LogAttachEnabled);
            Assert.AreEqual(queueSize, client.QueueSize);

            _dbh.Stop();

            if (System.IO.File.Exists(cfgFile))
            {
                System.IO.File.Delete(cfgFile);
            }
        }
Пример #22
0
        internal void CreateTestConfig()
        {
            ClientDataManager cdm = new ClientDataManager();

            /*
             * Cliente con clave Id, puerto automatico
             *
             * client.Name = "WinClt01";
             * client.Id = "WC0001";
             * client.AppFilePath = "c:\\Tmp\\ClientUdp\\wcudp1.exe";
             * client.LogFilePath = "c:\\Tmp\\ClientUdp\\wcudp1.txt";
             * client.MailEnabled = true;
             * client.Timeout = 55;
             * client.Port = 0;
             * client.QueueSize = 12;
             */
            cdm.CreateClient(ClientIdType.KeyByIdString,
                             "WC0001",
                             0,
                             "WinClt01",
                             "c:\\Tmp\\ClientUdp\\wcudp1.exe",
                             "c:\\Tmp\\ClientUdp\\wcudp1.txt",
                             55, true, false, 12);

            /*
             * Cliente con clave Port, puerto 50100
             *
             * client = new ClientData();
             * client.Name = "WinClt02";
             * client.Id = "WC0002";
             * client.AppFilePath = "c:\\Tmp\\ClientUdp\\wcudp2.exe";
             * client.LogFilePath = "c:\\Tmp\\ClientUdp\\wcudp2.txt";
             * client.MailEnabled = true;
             * client.LogAttachEnabled = false;
             * client.Timeout = 65;
             * client.Port = 50100;
             * client.QueueSize = 24;
             */
            cdm.CreateClient(ClientIdType.KeyByUdpPort,
                             null,
                             50100,
                             "WinClt02",
                             "c:\\Tmp\\ClientUdp\\wcudp2.exe",
                             "c:\\Tmp\\ClientUdp\\wcudp2.txt",
                             65, true, false, 24);
            //// ... and again

            //client = new ClientData();
            //client.Name = "CConsole1";
            //client.Id = HeartBeat.DefaultClientID;
            //client.AppFilePath = "c:\\Tmp\\ClientUdp\\cudp.cmd";
            //client.LogFilePath = "c:\\Tmp\\ClientUdp\\cudp.txt";
            //client.MailEnabled = false;
            //client.LogAttachEnabled = false;
            //client.Timeout = 70;
            //client.Port = 50200;
            //client.QueueSize = 48;

            cdm.CreateClient(ClientIdType.KeyByUdpPort,
                             null,
                             50200,
                             "CConsole1",
                             "c:\\Tmp\\ClientUdp\\cudp.cmd",
                             "c:\\Tmp\\ClientUdp\\cudp.txt",
                             70, false, false, 48);

            // config system
            SystemConfigData tmpSys = new SystemConfigData();

            tmpSys.ServerIpAdr    = "127.0.0.1";
            tmpSys.UdpServerPort  = 8888;
            tmpSys.ZyanServerName = Constants.ZyanServerName;
            tmpSys.ZyanServerPort = Constants.ZyanServerPort;
            tmpSys.SMtpServer     = "localhost";

            tmpSys.Source              = "*****@*****.**";
            tmpSys.Password            = "******";
            tmpSys.Destination         = "[email protected], [email protected]";
            tmpSys.TimeoutStartRestart = 180;
            tmpSys.RestartAttemps      = 2;

            SystemPlusClientData tmpDb = new SystemPlusClientData(cdm, tmpSys);

            _dbRoot = tmpDb;

            CommitDatabase();
        }
Пример #23
0
        public ActionResult NoteDetails(string NoteId)
        {
            if (String.IsNullOrEmpty(NoteId))
            {
                return(new HttpNotFoundResult());
            }

            int UserID = 0;

            string[] UserRoles = null;

            if (Request.IsAuthenticated)
            {
                if (Session["UserID"] == null)
                {
                    return(RedirectToAction("Login", "Authentication"));
                }
                ViewBag.Authorized = true;

                UserID = Convert.ToInt32(User.Identity.Name);

                UserRoles = new RoleManager.NotesMarketPlaceRoleManager().GetRolesForUser(User.Identity.Name);
            }

            NoteModel Nm = NotesRepository.GetNoteDetailsById(Convert.ToInt32(NoteId));

            if (Nm == null)
            {
                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.NotFound));
            }

            //Only show note details when notes is published or being accessed by owner or admins
            if (Nm.Status != 3 && (Request.IsAuthenticated && !(Nm.SellerID == UserID || UserRoles.Contains("SuperAdmin") || UserRoles.Contains("SubAdmin"))))
            {
                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.NotFound));
            }

            List <string> ReviewerList = new List <string>();

            foreach (Review r in Nm.Reviews)
            {
                ReviewerList.Add(r.ReviwerProfilePicture);
            }


            /* We will use this list in content controller to give anonymous users, access to those user profiles
             * which are included in notes reviews.
             */

            Session["ReviewerList"] = ReviewerList;

            //Adding Full Name of Seller and contact number of support for popup model

            SystemConfigModel SupportContact = SystemConfigData.GetSystemConfigData("SupportContact");

            if (SupportContact != null)
            {
                ViewBag.SupportContact = SupportContact.DataValue;
            }
            else
            {
                ViewBag.SupportContact = "Not Available";
            }

            //Full Name of Seller
            UserProfileModel Seller = UserRepository.GetUserData(Nm.SellerID);

            if (Seller != null)
            {
                ViewBag.Seller = Seller.User.FirstName + " " + Seller.User.LastName;
            }
            else
            {
                ViewBag.Seller = "Anonymous User";
            }

            //TempData passed by GetNoteAttachments method to confirm buyer request submission
            if (TempData.ContainsKey("BuyerRequestSubmitted") && (bool)TempData["BuyerRequestSubmitted"])
            {
                ViewBag.BuyerRequestSubmitted = true;
            }

            ViewBag.Title = "NotesDetails";
            return(View(Nm));
        }
Пример #24
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.officer_faculty) || autro_obj.CheckGroupUser(login_data, group_var.officer_department))
            {
                // ======== Process ===========
                config_data = new SystemConfig().getConfig();

                degree_char = ddlDEGREE.SelectedValue;

                if (!Page.IsPostBack)
                {
                    divShow.Visible = false;
                    divFail.Visible = false;

                    txtACADEMIC_YEAR.Text = config_data.AcademicYear;
                    AcademicYear          = config_data.AcademicYear;
                    ddlSEMESTER.Items.FindByValue(config_data.Semester).Selected = true;

                    // ระดับการศึกษา
                    degreeLevel = new Degree().getDegreeChar();
                    foreach (DegreeData data in degreeLevel)
                    {
                        ddlDEGREE.Items.Insert(ddlDEGREE.Items.Count, new ListItem(data.Degree_Thai, data.Degree_Char));
                    }


                    //วิชาการคณะ
                    if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty))
                    {
                        List <string> faculty_authorized = autro_obj.getFaculty_Authorized(login_data, group_var.officer_faculty);

                        // คณะ
                        facultyData = new Faculty().getFaculty(faculty_authorized);
                        foreach (FacultyData data in facultyData)
                        {
                            ddlFACULTY.Items.Insert(ddlFACULTY.Items.Count, new ListItem(data.Faculty_Thai, data.Faculty_Code));
                        }

                        departmentData = new Department().getDepartmentWithFaculty(ddlFACULTY.SelectedValue);
                        ddlDepartment.Items.Clear();
                        foreach (DepartmentData data in departmentData)
                        {
                            ddlDepartment.Items.Insert(ddlDepartment.Items.Count, new ListItem(data.Department_Thai, data.Department_Code));
                        }
                    }
                    //วิชาการภาค
                    else if (autro_obj.CheckGroupUser(login_data, group_var.officer_department))
                    {
                        ddlFACULTY.Enabled   = false;
                        ddlFACULTY.BackColor = System.Drawing.ColorTranslator.FromHtml("#CCCCCC");
                        List <string> department_authorized = autro_obj.getDepartment_Authorized(login_data, group_var.officer_department);

                        // ภาควิชา
                        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));
                        }

                        // คณะ
                        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));
                    }

                    // อาจารย์
                    LecturerData = new Lecturer().getLecturerbyDepartment(ddlDepartment.SelectedValue);
                    ddlLecturer.Items.Clear();
                    if (LecturerData.Count.Equals(0))
                    {
                        ddlLecturer.Items.Insert(ddlLecturer.Items.Count, new ListItem("--- ไม่พบข้อมูลอาจารย์ ---", "00"));
                    }
                    else
                    {
                        foreach (LectuereInformationData data in LecturerData)
                        {
                            ddlLecturer.Items.Insert(ddlLecturer.Items.Count, new ListItem(data.Lecturer_ShortName + " " + data.First_ThaiName + " " + data.Family_ThaiName, data.Lecturer_ID));
                        }
                    }

                    // หลักสูตร
                    string Curr_LevelCode = "";
                    if (ddlDEGREE.SelectedValue == "U")
                    {
                        Curr_LevelCode = "01";
                    }
                    else if (ddlDEGREE.SelectedValue == "B")
                    {
                        Curr_LevelCode = "02";
                    }
                    else if (ddlDEGREE.SelectedValue == "P")
                    {
                        Curr_LevelCode = "05";
                    }
                    else if (ddlDEGREE.SelectedValue == "M")
                    {
                        Curr_LevelCode = "03";
                    }
                    else if (ddlDEGREE.SelectedValue == "D")
                    {
                        Curr_LevelCode = "04";
                    }

                    string faculty_code = ddlFACULTY.SelectedValue;

                    string curr_sql = "Select * From CURRICULUM Where FACULTYCODE='" + faculty_code + "' AND DEPARTMENTCODE = '" + ddlDepartment.SelectedValue + "' AND LEVELCODE='" + Curr_LevelCode + "' AND CURRCODE!='999999999'";
                    currData = new Curriculum().getManualCurriculum(curr_sql);

                    ddlCURRICULUM.Items.Clear();
                    if (currData.Count.Equals(0))
                    {
                        ddlCURRICULUM.Items.Insert(ddlCURRICULUM.Items.Count, new ListItem("--- เลือกหลักสูตร ---", "0"));
                    }
                    else
                    {
                        foreach (CurriculumGeneralData data in currData)
                        {
                            ddlCURRICULUM.Items.Insert(ddlCURRICULUM.Items.Count, new ListItem(data.Curr_Code + " " + data.Curr_ThaiName + " (" + data.Curr_Year + ")", data.Curr_Year + data.Curr_Code));
                        }
                    }


                    //กลุ่ม
                    stdgroupData = new StdGroup().getStdGroup();
                    ddlStdGruop.Items.Clear();
                    ddlStdGruop.Items.Insert(ddlStdGruop.Items.Count, new ListItem("--- เลือกรอบ ---", "0"));
                    foreach (StdGroupData data in stdgroupData)
                    {
                        ddlStdGruop.Items.Insert(ddlStdGruop.Items.Count, new ListItem(data.StdGroup_Thai, data.StdGroup_Code));
                    }

                    // ประเภทนักศึกษา
                    stdcatData = new StdCategory().getStdCategory();
                    ddlStdCategory.Items.Clear();
                    ddlStdCategory.Items.Insert(ddlStdCategory.Items.Count, new ListItem("--- เลือกประเภทนักศึกษา ---", "0"));
                    foreach (StdCategoryData data in stdcatData)
                    {
                        ddlStdCategory.Items.Insert(ddlStdCategory.Items.Count, new ListItem(data.StdCategory_Thai, data.StdCategory_Code));
                    }

                    // รอบ
                    secData = new Section().getSection();
                    ddlSection.Items.Clear();
                    ddlSection.Items.Insert(ddlSection.Items.Count, new ListItem("--- เลือกรอบ ---", "0"));
                    foreach (SectionData data in secData)
                    {
                        ddlSection.Items.Insert(ddlSection.Items.Count, new ListItem(data.Section_Thai, data.Section_Code));
                    }
                }

                AcademicYear = txtACADEMIC_YEAR.Text;
                // ==========================
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }
Пример #25
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.officer_faculty) || autro_obj.CheckGroupUser(login_data, group_var.officer_department))
            {
                // ======== Process ===========

                config_data = new SystemConfig().getConfig();

                row1 = Request.QueryString["show_row"];

                if (Session["showStudentAdvisor" + row1] == null)
                {
                    Response.Redirect("List_Segment_Advisor.aspx");
                }
                else
                {
                    student_data = (Student)Session["showStudentAdvisor" + row1];
                    degree_char  = student_data.Degree_Char;

                    lblHfaculty.Text      = new Faculty().getFaculty(student_data.Faculty_Code).Faculty_Thai;
                    lblHcurri.Text        = new Curriculum().getCurriculum(student_data.Curri_Code).Curr_ThaiName;
                    lblHstudentgroup.Text = "ห้อง/กลุ่มการเรียน " + new StdGroup().getStdGroup(student_data.StudentGruop).StdGroup_Thai;

                    StudentAdvisor = new Student().getStudentAdvisor(student_data.Faculty_Code, student_data.Curri_Code, student_data.Std_Category_Code, student_data.Section_Code, student_data.StudentGruop, student_data.Advisor_ID, degree_char);

                    if (!Page.IsPostBack)
                    {
                        divFail.Visible = false;

                        txtACADEMIC_YEAR.Text = config_data.AcademicYear;
                        AcademicYear          = config_data.AcademicYear;
                        ddlSEMESTER.Items.FindByValue(config_data.Semester).Selected = true;

                        //วิชาการคณะ
                        if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty))
                        {
                            List <string> faculty_authorized = autro_obj.getFaculty_Authorized(login_data, group_var.officer_faculty);

                            //อาจารย์
                            ddlLecturer.Items.Clear();
                            ddlLecturer.Items.Insert(ddlLecturer.Items.Count, new ListItem("--- เลือกอาจารย์ ---", "00"));

                            foreach (string fac in faculty_authorized)
                            {
                                LecturerData = new Lecturer().getLecturerbyFaculty(fac);
                                foreach (LectuereInformationData data in LecturerData)
                                {
                                    ddlLecturer.Items.Insert(ddlLecturer.Items.Count, new ListItem(data.Lecturer_ShortName + " " + data.First_ThaiName + " " + data.Family_ThaiName, data.Lecturer_ID));
                                }
                            }
                        }
                        //วิชาการภาค
                        else if (autro_obj.CheckGroupUser(login_data, group_var.officer_department))
                        {
                            List <string> department_authorized = autro_obj.getDepartment_Authorized(login_data, group_var.officer_department);
                            //อาจารย์
                            ddlLecturer.Items.Clear();
                            ddlLecturer.Items.Insert(ddlLecturer.Items.Count, new ListItem("--- เลือกอาจารย์ ---", "00"));

                            foreach (string dep in department_authorized)
                            {
                                LecturerData = new Lecturer().getLecturerbyDepartment(dep);
                                foreach (LectuereInformationData data in LecturerData)
                                {
                                    ddlLecturer.Items.Insert(ddlLecturer.Items.Count, new ListItem(data.Lecturer_ShortName + " " + data.First_ThaiName + " " + data.Family_ThaiName, data.Lecturer_ID));
                                }
                            }
                        }



                        Duallistbox.Items.Clear();
                        foreach (Student data in StudentAdvisor)
                        {
                            if (data.Advisor_ID != "")
                            {
                                Duallistbox.Items.Insert(Duallistbox.Items.Count, new ListItem(data.Student_ID + " " + data.First_ThaiName + " " + data.Family_ThaiName + " (" + new Lecturer().getLecturer(data.Advisor_ID).Lecturer_ShortName + ")", data.Student_ID));
                            }
                            else
                            {
                                Duallistbox.Items.Insert(Duallistbox.Items.Count, new ListItem(data.Student_ID + " " + data.First_ThaiName + " " + data.Family_ThaiName, data.Student_ID));
                            }
                        }
                    }
                }


                AcademicYear = txtACADEMIC_YEAR.Text;

                // ============================
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }
Пример #26
0
 public SystemConfigEventArgs(SystemConfigData data)
 {
     Data = data;
 }
Пример #27
0
    protected void Page_Load(object sender, EventArgs e)
    {
        config_data   = new SystemConfig().getConfig();
        academic_year = config_data.AcademicYear;
        semester      = config_data.Semester;


        Student student_data = new Student();

        row1 = Request.QueryString["show_row"];

        if (Session["showRegCourse" + row1] == null)
        {
            Response.Redirect("List_StudentRegis_SecAdvisor.aspx");
        }
        else
        {
            student_data = (Student)Session["showRegCourse" + row1];

            lblStudentName.Text = student_data.Student_ID + " " + student_data.First_ThaiName + " " + student_data.Family_ThaiName;

            if (!Page.IsPostBack)
            {
                Session.Remove("ApproveRegis");
            }

            try
            {
                string          Lecturer_ID  = (string)Session["Lecturer_ID"];
                GradAdvisorData advisor_data = new GradAdvisorData();
                advisor_data = new Student().getAdvisorCoAdvisor(student_data.Student_ID);

                if (advisor_data.Advisor_ID == null)
                {
                    lblAlertAdvisor.Text = "";
                    if (Session["ApproveRegis"] != null)
                    {
                        btnApprove.Enabled = true;
                    }
                    else
                    {
                        btnApprove.Enabled = false;
                    }
                }
                else if (advisor_data.Advisor_ID == "0")
                {
                    lblAlertAdvisor.Text = "";
                    if (Session["ApproveRegis"] != null)
                    {
                        btnApprove.Enabled = true;
                    }
                    else
                    {
                        btnApprove.Enabled = false;
                    }
                }
                else
                {
                    if (Lecturer_ID == advisor_data.Advisor_ID)
                    {
                        lblAlertAdvisor.Text = "";
                        if (Session["ApproveRegis"] != null)
                        {
                            btnApprove.Enabled = true;
                        }
                        else
                        {
                            btnApprove.Enabled = false;
                        }
                    }
                    else
                    {
                        lblAlertAdvisor.Text = "นักศึกษาได้แต่งตั้งอาจารย์ที่ปรึกษาแล้ว";
                        btnApprove.Enabled   = false;
                    }
                }


                LectuereInformationData lecturer_data = new LectuereInformationData();
                lecturer_data = new Lecturer().getLecturer(student_data.Advisor_ID);

                degree_char = student_data.Degree_Char;

                studentRegisData = new Student_Registration().getRegistration(academic_year, semester, student_data.Student_ID, degree_char);

                int        numrow = 1;
                CheckBox[] chk    = new CheckBox[studentRegisData.Count];
                txtCredit = new TextBox[studentRegisData.Count];
                int i = 0;

                // Head Table
                //string[] ar = { "ตอนที่", "รหัสวิชา", "ชื่อวิชา", "ผู้สอน", "ห้องเรียน", "เวลาเรียน", "สอบกลางภาค", "สอบปลายภาค", "อนุมัติ" };
                string[] ar  = { "ตอนที่", "รหัสวิชา", "ชื่อวิชา", "ผู้สอน", "ห้องเรียน", "เวลาเรียน", "ประเภทการลงทะเบียน", "สถานะการลงทะเบียน", "สถานะการชำระเงิน", "จำนวนหน่วยกิต", "อนุมัติ" };
                Table    tb1 = new Table();
                tb1.Attributes.Add("class", "table table-bordered table-hover table-striped");
                tb1.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];
                    cellHead.Attributes.Add("class", "text-align-center");
                    tRowHead.Cells.Add(cellHead);
                }

                tb1.Rows.Add(tRowHead);

                List <RegistrationData> ApproveRegisData = new List <RegistrationData>();
                if (Session["ApproveRegis"] != null)
                {
                    ApproveRegisData = (List <RegistrationData>)Session["ApproveRegis"];
                }

                foreach (RegistrationData data in studentRegisData)
                {
                    teachingData = new TeachingTable().getSubTeachingTable(academic_year, semester, data.Course_Code, data.Sec_No, data.SubSec_No, degree_char);

                    lec_table = degree_char;

                    // กรณีวิชาที่เพิ่มโดยอาจารย์ผู้สอน เป็นวิชาที่อยู่คนละระดับการศึกษา
                    if (teachingData.Count <= 0)
                    {
                        if (degree_char == "U" || degree_char == "B")
                        {
                            teachingData = new TeachingTable().getSubTeachingTable(academic_year, semester, data.Course_Code, data.Sec_No, data.SubSec_No, "M");
                            lec_table    = "M";
                        }
                        else
                        {
                            teachingData = new TeachingTable().getSubTeachingTable(academic_year, semester, data.Course_Code, data.Sec_No, data.SubSec_No, "B");
                            lec_table    = "B";
                        }
                    }
                    //=======================

                    CourseData course_reg = new CourseData();
                    course_reg = new Course().getCourse(data.Course_Code);

                    TableRow tRowBody = new TableRow();
                    tRowBody.TableSection = TableRowSection.TableBody;

                    string course_type = "";
                    if (data.Course_Type == "1")
                    {
                        course_type = "S.";
                    }
                    else if (data.Course_Type == "2")
                    {
                        course_type = "L.";
                    }
                    else if (data.Course_Type == "4")
                    {
                        course_type = "T.";
                    }
                    else if (data.Course_Type == "5")
                    {
                        course_type = "M.";
                    }
                    else if (data.Course_Type == "6")
                    {
                        course_type = "SP.";
                    }
                    else if (data.Course_Type == "7")
                    {
                        course_type = "D.";
                    }

                    if (data.SubSec_No != 0)
                    {
                        course_type += data.SubSec_No;
                    }
                    else
                    {
                        course_type += data.Sec_No;
                    }

                    TableCell cellSec = new TableCell();
                    cellSec.Text = course_type;
                    cellSec.Attributes.Add("class", "text-align-center");
                    tRowBody.Cells.Add(cellSec);

                    TableCell cellCourseCode = new TableCell();
                    cellCourseCode.Text = course_reg.Course_Code;
                    cellCourseCode.Attributes.Add("class", "text-align-center");
                    tRowBody.Cells.Add(cellCourseCode);

                    TableCell cellCourse = new TableCell();
                    cellCourse.Text = course_reg.Course_Thainame;
                    tRowBody.Cells.Add(cellCourse);

                    TableCell cellLecturer = new TableCell();
                    string    lec_name     = "";
                    foreach (TeachingTableData teach in teachingData)
                    {
                        lecturerData = new LecturerTable().getLecturerTable(teach, lec_table);
                        foreach (LecturerTableData lec in lecturerData)
                        {
                            lec_name += new Lecturer().getLecturer(lec.Lecturer).Lecturer_ShortName + ",";
                        }

                        lec_name = lec_name.Substring(0, lec_name.Length - 1);

                        lec_name += "<br>";
                    }

                    cellLecturer.Text = lec_name;
                    tRowBody.Cells.Add(cellLecturer);
                    TableCell cellRoom = new TableCell();

                    foreach (TeachingTableData teach in teachingData)
                    {
                        cellRoom.Text += teach.Building_Code + "-" + teach.Room_Code;
                        if (teach.Campus_Code == "2")
                        {
                            cellRoom.Text += "*";
                        }
                        else if (teach.Campus_Code == "3")
                        {
                            cellRoom.Text += "**";
                        }

                        cellRoom.Text += "<br/>";
                    }
                    cellRoom.Attributes.Add("class", "text-align-center");

                    tRowBody.Cells.Add(cellRoom);

                    TableCell cellTeaching = new TableCell();
                    foreach (TeachingTableData teach in teachingData)
                    {
                        string day = "";

                        if (teach.Teaching_Day == "1")
                        {
                            day = "Mon";
                        }
                        else if (teach.Teaching_Day == "2")
                        {
                            day = "Tue";
                        }
                        if (teach.Teaching_Day == "3")
                        {
                            day = "Wed";
                        }
                        if (teach.Teaching_Day == "4")
                        {
                            day = "Thu";
                        }
                        if (teach.Teaching_Day == "5")
                        {
                            day = "Fri";
                        }
                        if (teach.Teaching_Day == "6")
                        {
                            day = "Sat";
                        }
                        if (teach.Teaching_Day == "7")
                        {
                            day = "Sun";
                        }

                        cellTeaching.Text += day + " " + teach.Teaching_Start_Time + " - " + teach.Teaching_End_Time + "<br>";
                        cellTeaching.Attributes.Add("class", "text-align-center");
                    }
                    tRowBody.Cells.Add(cellTeaching);

                    //TableCell cellMid = new TableCell();
                    //cellMid.Text = new utility().getThaiBirthDay(exam_data.ExamMid_Day) + " เวลา:" + exam_data.ExamMid_StartTime + "-" + exam_data.ExamMid_EndTime;
                    //tRowBody.Cells.Add(cellMid);

                    //TableCell cellFinal = new TableCell();
                    //cellFinal.Text = new utility().getThaiBirthDay(exam_data.ExamFinal_Day) + " เวลา:" + exam_data.ExamFinal_StartTime + "-" + exam_data.ExamFinal_EndTime;
                    //tRowBody.Cells.Add(cellFinal);

                    TableCell cellRegType = new TableCell();
                    cellRegType.Text = data.Reg_Type;
                    cellRegType.Attributes.Add("class", "text-align-center");
                    tRowBody.Cells.Add(cellRegType);

                    TableCell cellRegStatus = new TableCell();
                    cellRegStatus.Text = statusObj.getStatus(data.Status).Status_Thai;
                    cellRegStatus.Attributes.Add("class", "text-align-center");
                    tRowBody.Cells.Add(cellRegStatus);

                    TableCell cellPaymentStatus = new TableCell();
                    cellPaymentStatus.Text = statusObj.getStatus(new Student_Payment().getPaymentStatus(data.Payment_ID, degree_char)).Status_Thai;
                    cellPaymentStatus.Attributes.Add("class", "text-align-center");
                    tRowBody.Cells.Add(cellPaymentStatus);

                    TableCell cellCredit = new TableCell();
                    cellCredit.Attributes.Add("class", "text-align-center");

                    if ((data.Course_Type == "4") || (data.Course_Type == "5") || (data.Course_Type == "7"))
                    {
                        txtCredit[i]           = new TextBox();
                        txtCredit[i].ID        = "credit" + numrow.ToString();
                        txtCredit[i].MaxLength = 2;
                        txtCredit[i].Width     = 30;
                        txtCredit[i].Attributes.Add("class", "text-center");
                        txtCredit[i].Text = data.Credit.ToString();
                        if (data.Approve_Status == "y")
                        {
                            txtCredit[i].ReadOnly  = true;
                            txtCredit[i].BackColor = System.Drawing.ColorTranslator.FromHtml("#CCCCCC");
                        }
                        else
                        {
                            txtCredit[i].ReadOnly     = false;
                            txtCredit[i].AutoPostBack = true;
                            txtCredit[i].TextChanged += new EventHandler(txtCredit_TextChanged);
                        }
                        cellCredit.Controls.Add(txtCredit[i]);
                    }
                    else
                    {
                        cellCredit.Text = data.Credit.ToString();
                    }
                    tRowBody.Cells.Add(cellCredit);

                    TableCell cellchkApprove = new TableCell();

                    if (data.Approve_Status == "n")
                    {
                        chk[i] = new CheckBox();
                        chk[i].AutoPostBack = true;
                        chk[i].ID           = "approve" + numrow.ToString();

                        foreach (RegistrationData chkdata in ApproveRegisData)
                        {
                            if (data.Academic_Year == chkdata.Academic_Year && data.Semester == chkdata.Semester && data.Course_Code == chkdata.Course_Code && data.Sec_No == chkdata.Sec_No && data.SubSec_No == chkdata.SubSec_No)
                            {
                                chk[i].Checked = true;
                            }
                        }

                        chk[i].CheckedChanged += new EventHandler(chkApprove_CheckedChanged);
                        cellchkApprove.Controls.Add(chk[i]);
                        cellchkApprove.Attributes.Add("class", "text-align-center");
                    }
                    else
                    {
                        if (data.Approve_Status == "y")
                        {
                            cellchkApprove.Text = "อนุมัติ";
                            cellchkApprove.Attributes.Add("class", "txt-green-bold text-align-center");
                        }
                    }


                    tRowBody.Cells.Add(cellchkApprove);

                    numrow++;
                    i++;

                    tb1.Rows.Add(tRowBody);
                }



                TableRow  row  = new TableRow();
                TableCell cell = new TableCell();
                cell.Controls.Add(tb1);
                row.Cells.Add(cell);
                tblStudentAdvisor.Rows.Add(row);
            }
            catch (Exception err)
            {
                HttpContext.Current.Session["response"] = "ไม่สามารถดำเนินการได้" + err.ToString();
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }
Пример #28
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.officer_department) || autro_obj.CheckGroupUser(login_data, group_var.officer_faculty) || autro_obj.CheckGroupUser(login_data, group_var.lecturer))
            {
                /*=============================*/
                if (!Page.IsPostBack)
                {
                    config_data           = new SystemConfig().getConfig();
                    txtACADEMIC_YEAR.Text = config_data.AcademicYear;
                    academic_year         = config_data.AcademicYear;
                    ddlSEMESTER.Items.FindByValue(config_data.Semester).Selected = true;
                }
                academic_year = txtACADEMIC_YEAR.Text;

                // Head Table
                string[] ar  = { "ลำดับ", "ชื่ออาจารย์", "ตำแหน่ง", "ชั่วโมงสอนอ้างอิง", "หน่วยกิตรวม", "ภาระงานสอน ชั่วโมง/หน่วยกิต", "รายละเอียด" };
                Table    tb1 = new Table();
                tb1.Attributes.Add("class", "table table-bordered table-striped table-hover");
                tb1.Attributes.Add("id", "dt_basic");
                TableHeaderRow tRowHead = new TableHeaderRow();
                tRowHead.TableSection = TableRowSection.TableHeader;

                for (int cellCtr = 1; cellCtr <= ar.Length; cellCtr++)
                {
                    TableHeaderCell cellHead = new TableHeaderCell();
                    cellHead.Text = ar[cellCtr - 1];
                    cellHead.Attributes.Add("class", "text-center");
                    tRowHead.Cells.Add(cellHead);
                }
                tb1.Rows.Add(tRowHead);


                List <SysUser> lecturerALL = new List <SysUser>();

                if (autro_obj.CheckGroupUser(login_data, group_var.lecturer))
                {
                    SysUser lecturer = new SysUser().getSysUser(login_data.Nation_ID);
                    lecturerALL.Add(lecturer);
                }
                else
                {
                    lecturerALL = new SysUser().getSysUser();
                }



                int num = 1;
                foreach (SysUser lec in lecturerALL)
                {
                    TableRow tRowBody = new TableRow();
                    tRowBody.TableSection = TableRowSection.TableBody;

                    TableCell cellNum = new TableCell();
                    cellNum.Attributes.Add("class", "text-center");
                    cellNum.Text = num.ToString();
                    tRowBody.Cells.Add(cellNum);

                    TableCell cellName = new TableCell();
                    cellName.Text = new AcademicPosition().getAcademicPosition(lec.AcademicPositionCode).AcademicPositionThName + " " + lec.ThName + " " + lec.ThSurName;
                    tRowBody.Cells.Add(cellName);

                    TableCell cellPosition = new TableCell();
                    cellPosition.Attributes.Add("class", "text-center");
                    cellPosition.Text = new BoardPos().getBoardPos(lec.Position).Position_Thai;
                    tRowBody.Cells.Add(cellPosition);

                    TableCell cellHourRef = new TableCell();
                    cellHourRef.Attributes.Add("class", "text-center");
                    cellHourRef.Text = new WorkLoadCalculate().getHourRef(txtACADEMIC_YEAR.Text, ddlSEMESTER.SelectedValue, lec.IdCode).ToString();
                    tRowBody.Cells.Add(cellHourRef);

                    TableCell cellTotalCredit = new TableCell();
                    cellTotalCredit.Attributes.Add("class", "text-center");
                    cellTotalCredit.Text = new WorkLoadCalculate().getTotalCredit(txtACADEMIC_YEAR.Text, ddlSEMESTER.SelectedValue, lec.IdCode).ToString();
                    tRowBody.Cells.Add(cellTotalCredit);

                    Sysuser2 user2 = new Sysuser2();
                    user2 = new Sysuser2().getSysuser2(lec.IdCode);
                    WorkLoadConfigData workload = new WorkLoadConfigData();
                    workload = new WorkLoadConfig().getWorkLoadConfig(user2.Lecturer_Type, lec.Position);

                    TableCell cellLoad = new TableCell();
                    cellLoad.Attributes.Add("class", "text-center");
                    cellLoad.Text = workload.HourReference.ToString() + " / " + workload.TotalCredit.ToString();
                    tRowBody.Cells.Add(cellLoad);

                    TableCell cellDetail = new TableCell();
                    cellDetail.Attributes.Add("class", "text-center");

                    if (autro_obj.CheckGroupUser(login_data, group_var.lecturer))
                    {
                        if (login_data.Nation_ID == lec.IdCode)
                        {
                            string    urlDetail = "detail_WorkLoad.aspx?lecturer=" + lec.IdCode + "&year=" + txtACADEMIC_YEAR.Text + "&semester=" + ddlSEMESTER.SelectedValue;
                            HyperLink hypDetail = new HyperLink();
                            hypDetail.Text        = "<h4><i class='fa fa-search'></i></h4>";
                            hypDetail.NavigateUrl = urlDetail;
                            hypDetail.ToolTip     = "Detail";
                            hypDetail.Target      = "_Blank";
                            cellDetail.Controls.Add(hypDetail);
                        }
                        else
                        {
                            string    urlDetail = "#";
                            HyperLink hypDetail = new HyperLink();
                            hypDetail.Text        = "<h4><i class='fa fa-lock'></i></h4>";
                            hypDetail.NavigateUrl = urlDetail;
                            hypDetail.ToolTip     = "Detail";
                            hypDetail.Target      = "_Blank";
                            cellDetail.Controls.Add(hypDetail);
                        }
                    }
                    else if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty))
                    {
                        string    urlDetail = "detail_WorkLoad.aspx?lecturer=" + lec.IdCode + "&year=" + txtACADEMIC_YEAR.Text + "&semester=" + ddlSEMESTER.SelectedValue;
                        HyperLink hypDetail = new HyperLink();
                        hypDetail.Text        = "<h4><i class='fa fa-search'></i></h4>";
                        hypDetail.NavigateUrl = urlDetail;
                        hypDetail.ToolTip     = "Detail";
                        hypDetail.Target      = "_Blank";
                        cellDetail.Controls.Add(hypDetail);
                    }
                    else if (autro_obj.CheckGroupUser(login_data, group_var.officer_department))
                    {
                        bool          authorized            = false;
                        List <string> department_authorized = autro_obj.getDepartment_Authorized(login_data, group_var.officer_department);

                        foreach (string dep in department_authorized)
                        {
                            if (dep == lec.DepartmentCode)
                            {
                                authorized = true;
                                break;
                            }
                        }

                        if (authorized == true)
                        {
                            string    urlDetail = "detail_WorkLoad.aspx?lecturer=" + lec.IdCode + "&year=" + txtACADEMIC_YEAR.Text + "&semester=" + ddlSEMESTER.SelectedValue;
                            HyperLink hypDetail = new HyperLink();
                            hypDetail.Text        = "<h4><i class='fa fa-search'></i></h4>";
                            hypDetail.NavigateUrl = urlDetail;
                            hypDetail.ToolTip     = "Detail";
                            hypDetail.Target      = "_Blank";
                            cellDetail.Controls.Add(hypDetail);
                        }
                        else
                        {
                            string    urlDetail = "#";
                            HyperLink hypDetail = new HyperLink();
                            hypDetail.Text        = "<h4><i class='fa fa-lock'></i></h4>";
                            hypDetail.NavigateUrl = urlDetail;
                            hypDetail.ToolTip     = "Detail";
                            hypDetail.Target      = "_Blank";
                            cellDetail.Controls.Add(hypDetail);
                        }
                    }


                    tRowBody.Cells.Add(cellDetail);

                    tb1.Rows.Add(tRowBody);

                    num++;
                }

                TableRow  row  = new TableRow();
                TableCell cell = new TableCell();
                cell.Controls.Add(tb1);
                row.Cells.Add(cell);
                tblWorkLoad.Rows.Add(row);
                /*=============================*/
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }
Пример #29
0
    // V 1.0.0
    public string[] insertQualifiedSTD_BankData(BankHead bank_head, List <BankData> bankData)
    {
        string TableName = "";

        string[]         response      = new string[bankData.Count];
        string           comp_account  = new string(bank_head.CompAccount);
        string           comp_name     = new string(bank_head.CompName).Replace("'", "`");
        string           summary_date  = bank_head.Bank_SummaryDate;
        Status_Variable  status_var    = new Status_Variable();
        SystemConfigData system_config = new SystemConfigData();

        system_config = new SystemConfig().getConfig();


        int           i         = 0;
        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();


        foreach (BankData field in bankData)
        {
            TableName = getTableName(field.Degree_Char);
            int bank_amount = Convert.ToInt32(new string(field.Amount));
            bank_amount = bank_amount / 100;
            string regis_type = new Student_Payment().getPayment(field.Paymenty_ID, field.Degree_Char).Reg_Type;

            if (regis_type == "NW")
            {
                oracleObj.InsertCommand = "Insert Into " + TableName + " (PAYMENT_ID,PAYMENT_DATE,COMPANY_AC,COMPANY_NAME,BANK_CODE,BRANCH_CODE,TELLER_NO,NATION_PASSPORT_ID,STUDENT_NAME,ACADEMIC_YEAR,SEMESTER,AMOUNT,KIND_TRANSACTION,TRANSACTION_CODE,DUE_DATE,IMPORT_DATE,STATUS,PAYMENT_TIME,BANK_SUMDATE) Values('" + field.Paymenty_ID + "','" + field.Payment_Date + "','" + comp_account + "','" + comp_name + "','" + new string(field.BankCode) + "','" + new string(field.BranNo) + "','" + new string(field.TellerNo) + "','" + field.Student_ID + "','" + new string(field.CustomerName) + "','" + field.AcademicYear + "','" + field.Semester + "'," + Convert.ToSingle(bank_amount) + ",'" + new string(field.KindTranc) + "','" + new string(field.TrancCode) + "','" + field.DueDate + "','" + field.ImportDate + "','" + field.Status + "','" + new string(field.PayTime) + "','" + summary_date + "')";
            }
            else
            {
                oracleObj.InsertCommand = "Insert Into " + TableName + " (PAYMENT_ID,PAYMENT_DATE,COMPANY_AC,COMPANY_NAME,BANK_CODE,BRANCH_CODE,TELLER_NO,STUDENT_ID,STUDENT_NAME,ACADEMIC_YEAR,SEMESTER,AMOUNT,KIND_TRANSACTION,TRANSACTION_CODE,DUE_DATE,IMPORT_DATE,STATUS,PAYMENT_TIME,BANK_SUMDATE) Values('" + field.Paymenty_ID + "','" + field.Payment_Date + "','" + comp_account + "','" + comp_name + "','" + new string(field.BankCode) + "','" + new string(field.BranNo) + "','" + new string(field.TellerNo) + "','" + field.Student_ID + "','" + new string(field.CustomerName) + "','" + field.AcademicYear + "','" + field.Semester + "'," + Convert.ToSingle(bank_amount) + ",'" + new string(field.KindTranc) + "','" + new string(field.TrancCode) + "','" + field.DueDate + "','" + field.ImportDate + "','" + field.Status + "','" + new string(field.PayTime) + "','" + summary_date + "')";
            }

            try
            {
                if (oracleObj.Insert() == 1)
                {
                    response[i] = "OK";

                    // อัพเดทตาราง Payment
                    if ((field.Status == status_var.BankData_Accurate) || (field.Status == status_var.BankData_Accurate_OverPaid))
                    {
                        //นักศึกษาใหม่
                        if (regis_type == "NW")
                        {
                            Qualified_Student_Payment std_payment = new Qualified_Student_Payment();
                            string res_update = std_payment.updatePayment(field.Paymenty_ID, field.Payment_Date, status_var.QualifiedStudent_PaymentComplete, field.Degree_Char);

                            // Generate Student_ID
                            if (res_update == "OK")
                            {
                                GenStudentID gen_student_id = new GenStudentID();
                                PaymentData  payment_data   = std_payment.getPayment(field.Paymenty_ID, field.Degree_Char);
                                // List<StudentIDConfigData> configData = new List<StudentIDConfigData>();
                                Qualified_Student student_data = new Qualified_Student().getQualifiedStudent(payment_data.Academic_Year, payment_data.Semester, payment_data.Nation_ID, payment_data.Passport_ID, payment_data.Curr_Code, payment_data.Round_Paid, field.Degree_Char);

                                if (payment_data.Reg_Type == "NW")
                                {
                                    string academic_year   = student_data.Year_Admission.Substring(2, 2);
                                    string faculty_code    = student_data.Faculty_Code;
                                    string department_code = student_data.Department_Code_StudentID;
                                    string major_code      = student_data.Major_Code_StudentID;
                                    string degree_code     = student_data.Degree_Admission;
                                    string admission_type  = student_data.Admission_Type;
                                    string project_code    = student_data.Project_Code;


                                    string new_student_id = gen_student_id.getStudentID(student_data);

                                    if (new_student_id.Length == 13)
                                    {
                                        // Update Student ID ตารางนักศึกษาใหม่
                                        string update_status = new Qualified_Student().updateQualifiedStudent_ID(student_data.Year_Admission, student_data.Semester_Admission, student_data.Nation_ID, student_data.Passport_ID, student_data.Curri_Code, student_data.Round_Paid, new_student_id, field.Degree_Char);

                                        // Update ตารางลงทะเบียน
                                        new Qualified_Student_Registration().updateRegistrationStudentID(system_config.AcademicYear, system_config.Semester, student_data.Nation_ID, student_data.Passport_ID, student_data.Curri_Code, student_data.Project_Code, new_student_id, field.Degree_Char);
                                        // Update ตารางประวัติการลงทะเบียน
                                        new HistoryUpdate().update_HisRegistrationStudentID(system_config.AcademicYear, system_config.Semester, student_data.Nation_ID, student_data.Passport_ID, new_student_id, field.Degree_Char);

                                        // Update ตารางใบชำระเงิน
                                        std_payment.updatePayment_StudentID(field.Paymenty_ID, new_student_id, field.Degree_Char);
                                    }
                                }
                            }
                        }
                        // นักศึกษาปัจจุบันท์
                        else
                        {
                            Student_Payment std_payment = new Student_Payment();
                            string          res_update  = std_payment.updatePayment(field.Paymenty_ID, field.Payment_Date, status_var.PaymentComplete, field.Degree_Char);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                response[i] = e.Message.ToString();
            }

            i++;
        } // end foreach

        return(response);
    }
Пример #30
0
 public void In_GetSys(SystemConfigData cldat)
 {
     this.tbUdpPort.Text       = cldat.UdpServerPort.ToString();
     this.tbZyanComponent.Text = cldat.ZyanServerName;
     this.tbTcpPort.Text       = cldat.ZyanServerPort.ToString();
 }