Esempio n. 1
0
        public ActionResult StudentRegistr(StudentRegModel model)
        {
            if (ModelState.IsValid)
            {
                var schoolList = new List<SelectListItem>();
                var schoolType = model.StudyType.Where(s => s.Value == model.SelectedStudyTypeId.ToString()).Select(t => t.Text).FirstOrDefault();

                var school = string.Empty;
                var schoolClass = string.Empty;
                var placeType = string.Empty;
                var schoolChosen = "Yes";

                if (model.SelectedStudyTypeId == 1)
                {
                    schoolList = RawSchoolList();
                    school = schoolList.Where(s => s.Text == model.SpecialSchool).Select(t => t.Text).FirstOrDefault();
                    schoolClass = model.SelectedKlass;
                }
                else
                {
                    schoolList = RawOtherList();
                    school = schoolList.Where(s => s.Text == model.SpecialSchool).Select(t => t.Text).FirstOrDefault();
                    schoolClass = model.SelectedKurss;
                }

                if (string.IsNullOrEmpty(school))
                {
                    school = model.SpecialSchool;
                    schoolChosen = "No";
                }

                var placeReq = model.PlaceRequired;
                if (placeReq != "Nē")
                {
                    placeType = model.PlaceRequiredType;
                }

                using (SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DataSourceConnectionString"].ConnectionString))
                {
                    con.Open();
                    string command = @"INSERT INTO Registration (Created, RegType, RegCode, Vards, Uzvards, Pilseta, Telefons, Email, Skolotajs, SkolasTips, SkolasNosaukums, SkolasKlase, Kopnite, KopnitesTips, IrIzveletaSkola)
                                     VALUES ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' ,N'" + model.RegType.ToString() + "', N'" + SpecialCode() + "',N'" + model.Name + "', N'" + model.Surname + "', N'" + model.City + "', N'" + model.Phone + "', N'" + model.Email + "', N'" + model.Advicer + "', N'" + schoolType + "', N'" + school + "', N'" + schoolClass + "', N'" + placeReq + "', N'" + placeType + "', N'" + schoolChosen + "')";

                    using (SqlCommand query = new SqlCommand(command, con))
                    {
                        query.ExecuteNonQuery();

                    }
                }

                return View("SuccessRegistr");
            }
            else
            {
                model.Sequrity = false;
                model.PlaceRequired = "Nē";
                return View(model);
            }
        }
Esempio n. 2
0
        //
        // GET: /Registr/
        public ActionResult StudentRegistr()
        {
            if (SiteConfiguration.EnableRegistration())
            {
                var model = new StudentRegModel();
                model.School = RawSchoolList();

                return View(model);
            }
            else
            {
                return RedirectToAction("Index", "Home");
            }
        }