Esempio n. 1
0
 public ActionResult Edit(TB_APPLICATION_SCHOOL tb_application_school)
 {
     if (ModelState.IsValid)
     {
         var _updateSchool = db.TB_APPLICATION_SCHOOL.FirstOrDefault(f => f.SCHOOL_ID == tb_application_school.SCHOOL_ID);
         if (_updateSchool != null)
         {
             _updateSchool.SCHOOL_ADDR_PROVINCE = tb_application_school.SCHOOL_ADDR_PROVINCE;
             _updateSchool.SCHOOL_ADDR_AMPHUR   = tb_application_school.SCHOOL_ADDR_AMPHUR;
             _updateSchool.SCHOOL_ADDR_TOMBON   = tb_application_school.SCHOOL_ADDR_TOMBON;
             _updateSchool.SCHOOL_ZONE_EDU      = tb_application_school.SCHOOL_ZONE_EDU;
             _updateSchool.SCHOOL_ZONE          = tb_application_school.SCHOOL_ZONE;
             _updateSchool.SCHOOL_TYPE_OTHER    = tb_application_school.SCHOOL_TYPE_OTHER;
             _updateSchool.SCHOOL_ADDR          = tb_application_school.SCHOOL_ADDR;
             _updateSchool.SCHOOL_ADDR_SOI      = tb_application_school.SCHOOL_ADDR_SOI;
             _updateSchool.SCHOOL_ADDR_ROAD     = tb_application_school.SCHOOL_ADDR_ROAD;
             _updateSchool.SCHOOL_ADDR_ZIPCODE  = tb_application_school.SCHOOL_ADDR_ZIPCODE;
             _updateSchool.SCHOOL_ADDR_PHONE    = tb_application_school.SCHOOL_ADDR_PHONE;
             _updateSchool.SCHOOL_ADDR_FAX      = tb_application_school.SCHOOL_ADDR_FAX;
             _updateSchool.SCHOOL_NAME          = tb_application_school.SCHOOL_NAME;
             _updateSchool.SCHOOL_PROVINCE      = tb_application_school.SCHOOL_PROVINCE;
             _updateSchool.SCHOOL_PASSWORD      = tb_application_school.SCHOOL_PASSWORD;
             _updateSchool.SCHOOL_DOC_PATH      = tb_application_school.SCHOOL_DOC_PATH;
             _updateSchool.SCHOOL_REGISTER_DATE = tb_application_school.SCHOOL_REGISTER_DATE;
         }
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tb_application_school));
 }
        public JsonResult CheckLogin(string uname, string pwd)
        {
            bool result = true;



            ///* CHECK USER ACCOUNT */
            var _school = from s in db.TB_APPLICATION_SCHOOL where s.SCHOOL_EMAIL == uname && s.SCHOOL_PASSWORD == pwd select s;

            if (_school == null)
            {
                result = false;
            }
            else
            {
                TB_APPLICATION        application = db.TB_APPLICATION.FirstOrDefault();
                TB_APPLICATION_SCHOOL school      = _school.FirstOrDefault();
                if (school != null)
                {
                    result = true;
                    Session["Phet10School"]   = (TB_APPLICATION_SCHOOL)school;
                    Session["TB_APPLICATION"] = application;

                    FormsAuthentication.SetAuthCookie(school.SCHOOL_NAME + "  (" + uname + ")", true);
                }
                else
                {
                    result = false;
                }
            }

            return(Json(new { Success = result, responseText = "" }));
        }
        //
        // GET: /SchoolDocument/

        public ActionResult Index()
        {
            if (Session["Phet10School"] == null)
            {
                //FormsAuthentication.SignOut();
                return(RedirectToAction("../"));
            }
            TB_APPLICATION_SCHOOL school = (TB_APPLICATION_SCHOOL)Session["Phet10School"];

            return(View(db.TB_SCHOOL_DOCUMENT.Where(s => s.SCHOOL_ID == school.SCHOOL_ID).ToList()));
        }
Esempio n. 4
0
        //
        // GET: /School/Edit/5

        public ActionResult Edit(int id = 0)
        {
            if (Session["Phet10School"] != null)
            {
                TB_APPLICATION_SCHOOL school = (TB_APPLICATION_SCHOOL)Session["Phet10School"];
                id = Convert.ToInt32(school.SCHOOL_ID);
            }
            TB_APPLICATION_SCHOOL tb_application_school = db.TB_APPLICATION_SCHOOL.Single(t => t.SCHOOL_ID == id);

            if (tb_application_school == null)
            {
                return(HttpNotFound());
            }
            ViewBag.SCHOOL_ADDR_PROVINCE = new SelectList(db.TB_M_PROVINCE, "PROVINCE_ID", "PROVINCE_NAME", tb_application_school.SCHOOL_ADDR_PROVINCE);
            ViewBag.SCHOOL_ADDR_TOMBON   = new SelectList(db.TB_M_DISTRICT, "DISTRICT_ID", "DISTRICT_NAME", tb_application_school.SCHOOL_ADDR_TOMBON);
            ViewBag.SCHOOL_ADDR_AMPHUR   = new SelectList(db.TB_M_AMPHUR, "AMPHUR_ID", "AMPHUR_NAME", tb_application_school.SCHOOL_ADDR_AMPHUR);

            /*
             * SCHOOL TYPE
             */
            List <RadioButtonModel> list = new List <RadioButtonModel>();

            list.Add(new RadioButtonModel()
            {
                ID = 1, Name = Resources.Application.Application.SCHOOL_TYPE_01
            });                                                                                                  //สพฐ
            list.Add(new RadioButtonModel()
            {
                ID = 2, Name = Resources.Application.Application.SCHOOL_TYPE_02
            });                                                                                                  //เอกชน
            list.Add(new RadioButtonModel()
            {
                ID = 3, Name = Resources.Application.Application.SCHOOL_TYPE_03
            });                                                                                                  //กทม
            list.Add(new RadioButtonModel()
            {
                ID = 4, Name = Resources.Application.Application.SCHOOL_TYPE_04
            });                                                                                                  //อุดมศึกษา
            list.Add(new RadioButtonModel()
            {
                ID = 5, Name = Resources.Application.Application.SCHOOL_TYPE_OTHER
            });                                                                                                     //อื่น ๆ

            SelectList schoolTypes = new SelectList(list, "ID", "Name", tb_application_school.SCHOOL_TYPE);

            ViewBag.SCHOOL_TYPE     = schoolTypes;
            ViewBag.SCHOOL_PROVINCE = new SelectList(db.TB_M_PROVINCE, "PROVINCE_ID", "PROVINCE_NAME", tb_application_school.SCHOOL_PROVINCE);

            ViewBag.PrintComfirmDoc = false;
            return(View(tb_application_school));
        }
        public ActionResult SetEditLanguage(int id = 0)
        {
            if (Session["Phet10School"] == null)
            {
                FormsAuthentication.SignOut();
                return(RedirectToAction("../"));
            }
            TB_APPLICATION_SCHOOL tb_application_school = (TB_APPLICATION_SCHOOL)Session["Phet10School"];

            /*
             * SET INITIAL APPLICATION LANG
             */
            Session["PhetCulture"] = new CultureInfo((tb_application_school.SCHOOL_CULTURE == null) ? "th" : tb_application_school.SCHOOL_CULTURE);

            return(RedirectToAction("Edit"));
        }
Esempio n. 6
0
        //
        // GET: /School/
        public ActionResult Index()
        {
            if (Session["Phet10School"] == null)
            {
                FormsAuthentication.SignOut();
                return(RedirectToAction("../"));
            }
            TB_APPLICATION_SCHOOL school = (TB_APPLICATION_SCHOOL)Session["Phet10School"];

            var tb_application_school = from a in db.TB_APPLICATION_SCHOOL where a.SCHOOL_ID == school.SCHOOL_ID select a;

            //a.TB_M_STATUS.STATUS_NAME
            ViewBag.PageContent = "ตรวจสอบผลการสมัคร";

            return(View(tb_application_school.ToList()));
        }
Esempio n. 7
0
        public static void SendEmail(TB_APPLICATION_SCHOOL school, String registerdPassword, String culture)
        {
            try
            {
                String templateName = (culture.ToUpper().Equals("TH")) ? "AccountDetail_th.html" : "AccountDetail_en.html";
                String emailSubject = (culture.ToUpper().Equals("TH")) ? "การลงทะเบียนเข้าร่วมการแข่งขัน" : "การลงทะเบียนเข้าร่วมการแข่งขัน";
                String displanName  = (culture.ToUpper().Equals("TH")) ? "การแข่งขันภาษาจีนเพชรยอดมงกุฎ ครั้งที่ 12 (นานาชาติ)" : "การแข่งขันภาษาจีนเพชรยอดมงกุฎ ครั้งที่ 12  (นานาชาติ)";

                MailDefinition mailDefinition = new MailDefinition();
                mailDefinition.BodyFileName = "~/Utils/Email-Templates/" + templateName;
                mailDefinition.From         = EmailUser;



                //Create a key-value collection of all the tokens you want to replace in your template...
                ListDictionary ldReplacements = new ListDictionary();
                ldReplacements.Add("<%School Name%>", school.SCHOOL_NAME);
                ldReplacements.Add("<%User%>", school.SCHOOL_EMAIL.Trim());
                ldReplacements.Add("<%Password%>", registerdPassword.Trim());

                string      mailTo      = string.Format("{0} <{1}>", school.SCHOOL_NAME, school.SCHOOL_EMAIL);
                MailMessage mailMessage = mailDefinition.CreateMailMessage(mailTo, ldReplacements, new System.Web.UI.Control());
                mailMessage.From            = new MailAddress(EmailUser, displanName);
                mailMessage.IsBodyHtml      = true;
                mailMessage.Subject         = emailSubject;
                mailMessage.SubjectEncoding = System.Text.Encoding.UTF8;

                // smtp settings
                System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();
                {
                    smtpClient.Host           = Host;
                    smtpClient.Port           = Port;
                    smtpClient.EnableSsl      = true;
                    smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                    smtpClient.Credentials    = new NetworkCredential(EmailUser, EmailPassword);
                    smtpClient.Timeout        = 20000;
                }
                //SmtpClient smtpClient = new SmtpClient(ConfigurationManager.AppSettings["SMTPServer"].ToString(), 25);
                smtpClient.Send(mailMessage);
            }
            catch (Exception ex)
            {
                //throw ex;
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 8
0
        //
        // GET: /Upload/
        public ActionResult Index()
        {
            if (Session["Phet10School"] == null)
            {
                FormsAuthentication.SignOut();
                return(RedirectToAction("../"));
            }

            TB_APPLICATION_SCHOOL tb_application_school = (TB_APPLICATION_SCHOOL)Session["Phet10School"];

            ViewBag.PageContent = "ส่งเอกสารยืนยันการสมัคร";
            var model = new UploadModel
            {
                school = tb_application_school
            };

            return(View(model));
        }
        // GET: /SchoolRegister/
        public ActionResult Edit(int id = 0)
        {
            //Thread.Sleep(5000);

            /*
             * SCHOOL SESSION
             */
            if (Session["Phet10School"] == null)
            {
                return(HttpNotFound());
            }



            TB_APPLICATION_SCHOOL tbSchoolSession = (TB_APPLICATION_SCHOOL)Session["Phet10School"];

            id = Convert.ToInt32(tbSchoolSession.SCHOOL_ID);
            TB_APPLICATION_SCHOOL tb_application_school = db.TB_APPLICATION_SCHOOL.Single(t => t.SCHOOL_ID == id);

            /*
             * TITLE PROVINCE
             */
            IList <TB_M_PROVINCE>        mProvinceLists = db.TB_M_PROVINCE.ToList <TB_M_PROVINCE>();
            IEnumerable <SelectListItem> provinceLists  =
                from s in mProvinceLists
                select new SelectListItem
            {
                Text  = s.PROVINCE_NAME,
                Value = s.PROVINCE_ID.ToString()
            };

            /*
             * TITLE AMPHUR
             */
            IList <TB_M_AMPHUR>          mAmphur    = db.TB_M_AMPHUR.ToList <TB_M_AMPHUR>();
            IEnumerable <SelectListItem> amPhurList =
                from s in mAmphur
                select new SelectListItem
            {
                Text  = s.AMPHUR_NAME,
                Value = s.AMPHUR_ID.ToString()
            };

            /*
             * TITLE TUMBON
             */
            IList <TB_M_DISTRICT>        mTumbon     = db.TB_M_DISTRICT.ToList <TB_M_DISTRICT>();
            IEnumerable <SelectListItem> tumbonLists =
                from s in mTumbon
                select new SelectListItem
            {
                Text  = s.DISTRICT_NAME,
                Value = s.DISTRICT_ID.ToString()
            };

            /*
             * SCHOOL TYPE
             */
            List <RadioButtonModel> list = new List <RadioButtonModel>();

            list.Add(new RadioButtonModel()
            {
                ID = 1, Name = Resources.Application.Application.SCHOOL_TYPE_01
            });                                                                                                  //สพฐ
            list.Add(new RadioButtonModel()
            {
                ID = 2, Name = Resources.Application.Application.SCHOOL_TYPE_02
            });                                                                                                  //เอกชน
            list.Add(new RadioButtonModel()
            {
                ID = 3, Name = Resources.Application.Application.SCHOOL_TYPE_03
            });                                                                                                  //กทม
            list.Add(new RadioButtonModel()
            {
                ID = 4, Name = Resources.Application.Application.SCHOOL_TYPE_04
            });                                                                                                  //กทม
            list.Add(new RadioButtonModel()
            {
                ID = 5, Name = Resources.Application.Application.SCHOOL_TYPE_OTHER
            });                                                                                                     //กทม
            SelectList schoolTypes = new SelectList(list, "ID", "Name");

            /*
             * STAFF
             */
            var tb_application_staff = from a in db.TB_APPLICATION_STAFF where a.STAFF_SCHOOL_ID == id select a;

            /*
             * STUDENT
             */
            var tb_application_student = from a in db.TB_APPLICATION_STUDENT where a.STD_SCHOOL_ID == id select a;

            var model = new ApplicationModel()
            {
                idSelectedSchoolType = tb_application_school.SCHOOL_TYPE + "",
                SCHOOL_ADDR_PROVINCE = tb_application_school.SCHOOL_ADDR_PROVINCE + "",
                SCHOOL_ADDR_AMPHUR   = tb_application_school.SCHOOL_ADDR_AMPHUR + "",
                SCHOOL_ADDR_TOMBON   = tb_application_school.SCHOOL_ADDR_TOMBON + "",
                provinceLists        = provinceLists,
                tumbonLists          = tumbonLists,
                amphurLists          = amPhurList,
                rSchoolTypes         = schoolTypes,
                school   = tb_application_school,
                Staffs   = tb_application_staff.ToList(),
                Students = tb_application_student.ToList()
            };

            return(View(model));
        }