// // GET: /Realization/Create public ActionResult OcenyStudenta(int id) { Storage model = new Storage(); return View(model.getGradeValues()); }
// // GET: /Grade/Edit/5 public ActionResult Edit(int id) { Storage m = new Storage(); Grade grade = m.getGradeById(id); Models.Grade.CreateModel model = new Models.Grade.CreateModel(); model.NewGrade = grade; model.Realizations = getRealisationSelectList(grade.RealisationID.ToString()); return View(model); }
public void testInit() { _storage = new Storage(); _student = new Student(); _group = new Group(); _semestr = new Semester(); _student.FirstName = "Testowy"; _student.LastName = "Test"; _student.IndexNo = "123456"; _group.Name = "TstwGrp$#^134"; _semestr.Name = "78Z"; }
public ActionResult Create(FormCollection collection) { try { // TODO: Add insert logic here string name = Convert.ToString(collection["NewGrade.Name"]); int realisation = Convert.ToInt32(collection["NewGrade.RealisationID"]); string maxValue = Convert.ToString(collection["NewGrade.MaxValue"]); Storage m = new Storage(); m.createGrade(realisation, name, maxValue); return RedirectToAction("Index"); } catch { return View(); } }
public override ValidationResult Validate(object value, CultureInfo cultureInfo) { Storage storage = new Storage(); if (((String)value).Length > Max) { MainWindowViewModel.GradeNameValid = false; return new ValidationResult(false, "Nazwa moze miec maksymalnie " + Max + " znakow"); } else if (SelReal == null && storage.isGradeName(Real.RealisationID, (String)value)) { MainWindowViewModel.GradeNameValid = false; return new ValidationResult(false, "Nazwa oceny musi byc unikalna w obrebie przedmiotu."); } else { MainWindowViewModel.GradeNameValid = true; return new ValidationResult(true, null); } }
public ActionResult EditGV(int id, FormCollection collection) { Storage m = new Storage(); GradeValue grade = m.getGradeValueById(id); int rid = m.getRegistrations().Find(r=>r.RegistrationID == grade.RegistrationID).StudentID; //int rid = m.getGradeValues().Find(o => o.R) try { string name = Convert.ToString(collection["Value"]); if (string.IsNullOrEmpty(name)) ModelState.AddModelError("nazwa", "Musisz podać nazwę oceny!"); if (ModelState.IsValid) { m.updateGV(id, name, DateTime.Today.ToString("dd-MM-yyyy"), grade.RegistrationID, grade.GradeID, grade.TimeStamp); } else { return View(grade); } } catch (EresDataContextException e) { handleException(e); } catch { } return RedirectToAction("OcenyStudenta", new {id = rid }); }
public ActionResult Edit(int id, FormCollection collection) { try { string name = Convert.ToString(collection["NewGrade.Name"]); int realisation = Convert.ToInt32(collection["NewGrade.RealisationID"]); string maxValue = Convert.ToString(collection["NewGrade.MaxValue"]); if (string.IsNullOrEmpty(name)) ModelState.AddModelError("nazwa", "Musisz podać nazwę oceny!"); if(string.IsNullOrEmpty(maxValue)) ModelState.AddModelError("max wartosc", "Musisz podać maksymalna wartos!"); if (ModelState.IsValid) { Storage m = new Storage(); Grade grade = m.getGradeById(id); m.updateGrade(id, name, maxValue, realisation, grade.TimeStamp); } else { Storage m = new Storage(); Grade grade = m.getGradeById(id); Models.Grade.CreateModel model = new Models.Grade.CreateModel(); model.NewGrade = grade; model.Realizations = getRealisationSelectList(grade.RealisationID.ToString()); return View(model); } } catch (EresDataContextException e) { handleException(e); } catch { } return RedirectToAction("Index"); }
private SelectList getRealisationSelectList(string realisation) { Storage m = new Storage(); var roles = m.getRealisations().Select(x => new SelectListItem { Value = x.RealisationID.ToString(), Text = x.ToString(), }); return new SelectList(roles, "Value", "Text", realisation); ; }
// // GET: /Grade/ public ActionResult Index() { Storage model = new Storage(); return View(model.getGrades()); }
public ActionResult Delete(int id, FormCollection collection) { try { Storage m = new Storage(); Grade grade = m.getGradeById(id); m.deleteGrade(grade); } catch(EresDataContextException e) { handleException(e); } return RedirectToAction("Index"); }
// // GET: /Grade/Delete/5 public ActionResult Delete(int id) { Storage m = new Storage(); Grade grade = m.getGradeById(id); return View(grade); }
// 1-FirstName, 2-LastName, 3-GroupName, 4-SubName, 5-Conspect, 6-Url, 7-SemName, 8-GradeName, 9-MaxValue, 10-GVDate public override ValidationResult Validate(object value, CultureInfo cultureInfo) { if (string.IsNullOrEmpty((string)value)) { if (Id == 3) //Groups { MainWindowViewModel.GNameValid = false; return new ValidationResult(false, "Nazwa nie moze byc pusta."); } if (Id == 7) //SemName { MainWindowViewModel.SemNameValid = false; return new ValidationResult(false, "Nazwa nie moze byc pusta."); } else return new ValidationResult(true, null); } else if (((String)value).Length > Max) { if (Id == 1) { MainWindowViewModel.NameValid = false; return new ValidationResult(false, "Nazwa moze miec maksymalnie " + Max + " znakow."); } else if (Id == 2) { MainWindowViewModel.SurnameValid = false; return new ValidationResult(false, "Nazwa moze miec maksymalnie " + Max + " znakow."); } else if (Id == 3) { MainWindowViewModel.GNameValid = false; return new ValidationResult(false, "Nazwa moze miec maksymalnie " + Max + " znakow."); } else if (Id == 4) { MainWindowViewModel.SubNameValid = false; return new ValidationResult(false, "Nazwa moze miec maksymalnie " + Max + " znakow."); } else if (Id == 5) { MainWindowViewModel.ConspectValid = false; return new ValidationResult(false, "Konspekt moze miec maksylanie " + Max + " znakow."); } else if (Id == 6) { MainWindowViewModel.UrlValid = false; return new ValidationResult(false, "Url moze miec maksymalnie " + Max + " znakow."); } else if (Id == 7) { MainWindowViewModel.SemNameValid = false; return new ValidationResult(false, "Nazwa moze miec maksymalnie " + Max + " znakow."); } else if (Id == 8) { MainWindowViewModel.GradeNameValid = false; return new ValidationResult(false, "Nazwa moze miec maksymalnie " + Max + " znakow."); } else if (Id == 9) { MainWindowViewModel.MaxValueValid = false; return new ValidationResult(false, "Maksymalnie wartosc moze miec maksymalnie " + Max + " wartosci."); } else if (Id == 10) { MainWindowViewModel.DateValid = false; return new ValidationResult(false, "Data sklada sie z " + Max + " cyfr."); } else if (Id == 11) { MainWindowViewModel.ValueValid = false; return new ValidationResult(false, "Maksymalna wartosc moze miec " + Max + " znakow."); } return new ValidationResult(false, "Maksymalnie " + Max + " znakow."); } else if (Id == 3) //GroupName { Storage storage = new Storage(); if (storage.isGroupName((String)value)) { MainWindowViewModel.GNameValid = false; return new ValidationResult(false, "Nazwa grupy musi byc unikalna."); } MainWindowViewModel.GNameValid = true; return new ValidationResult(true, null); } else if (Id == 4) //SubName { Storage storage = new Storage(); if (storage.isSubName((String)value)) { MainWindowViewModel.SubNameValid = false; return new ValidationResult(false, "Nazwa przedmiotu musi byc unikalna"); } MainWindowViewModel.SubNameValid = true; return new ValidationResult(true, null); } else if (Id == 7) //SemName { Storage storage = new Storage(); if (storage.isSemName((String)value)) { MainWindowViewModel.SemNameValid = false; return new ValidationResult(false, "Nazwa semestru musi byc unikalna."); } if(!Regex.IsMatch((String)value, @"^\d\d(Z|L)$")) { MainWindowViewModel.SemNameValid = false; return new ValidationResult(false, "Nieprawidlowy format semestru, poprawny format liczba(Z lub L), np. 12Z."); } MainWindowViewModel.SemNameValid = true; return new ValidationResult(true, null); } else if (Id == 9) //GradeMaxValue { string str = (String)value; str = str.Replace(" ", String.Empty); str = str.ToUpper(); if (!(Regex.IsMatch(str, @"^(\-?[0-9]+[;,])*\-?[0-9]+$") || Regex.IsMatch(str, @"^N[,;]?Z$") || Regex.IsMatch(str, @"^Z[,;]?N$"))) { MainWindowViewModel.MaxValueValid = false; return new ValidationResult(false, "Maksymalna wartosc moze byc liczba, lub lista liczb"); } MainWindowViewModel.MaxValueValid = true; return new ValidationResult(true, null); } else if (Id == 10) //Date { string str = (String)value; try { DateTime.Parse(str); } catch (FormatException) { MainWindowViewModel.DateValid = false; return new ValidationResult(false, "Zly format, poprawny: yyyy-mm-dd, np 1991-01-31"); } MainWindowViewModel.MaxValueValid = true; return new ValidationResult(true, null); } /*else if (Id == 11) //GradeValue { string str = ((string)value).ToUpper(); int m; if (int.TryParse(MainWindowViewModel.MV, out m)) //MaxValue to pojedyncza liczba { int n; if (int.TryParse(str, out n)) { if (n <= m) { MainWindowViewModel.ValueValid = true; return new ValidationResult(true, null); } else { MainWindowViewModel.ValueValid = false; return new ValidationResult(false, "Wrong grade value, check MaxValue."); } } else { MainWindowViewModel.ValueValid = false; return new ValidationResult(false, "Wrong grade value, check MaxValue."); } } else { str = str.Replace(" ", String.Empty); string temp = MainWindowViewModel.MV.Replace(" ", String.Empty); //string temp = MainWindowViewModel.MV.Replace(",", String.Empty); //temp = temp.Replace(";", String.Empty); if (temp.IndexOf(str) != -1 && str.IndexOf(",") == -1 && str.IndexOf(";") == -1 && !str.Equals("-")) { MainWindowViewModel.ValueValid = true; return new ValidationResult(true, null); } else { MainWindowViewModel.ValueValid = false; return new ValidationResult(false, "Wrong grade value, check MaxValue."); } } }*/ else { if (Id == 1) MainWindowViewModel.NameValid = true; if (Id == 2) MainWindowViewModel.SurnameValid = true; if (Id == 3) MainWindowViewModel.GNameValid = true; if (Id == 4) MainWindowViewModel.SubNameValid = true; if (Id == 5) MainWindowViewModel.ConspectValid = true; if (Id == 6) MainWindowViewModel.UrlValid = true; if (Id == 7) MainWindowViewModel.SemNameValid = true; if (Id == 8) MainWindowViewModel.GradeNameValid = true; if (Id == 9) MainWindowViewModel.MaxValueValid = true; if (Id == 10) MainWindowViewModel.DateValid = true; if (Id == 11) MainWindowViewModel.ValueValid = true; return new ValidationResult(true, null); } }
public MainWindowViewModel() { storage = new Storage(); Groups = storage.getGroups(); Students = storage.getStudents(); Subjects = storage.getSubjects(); Semesters = storage.getSemesters(); Realisations = storage.getRealisations(); Registrations = storage.getRegistrations(); Grades = storage.getGrades(); GradeValues = null; GVGrades = null; IndexValid = NameValid = SurnameValid = true; GNameValid = true; SubNameValid = UrlValid = ConspectValid = true; SemNameValid = true; GradeNameValid = MaxValueValid = true; DateValid = ValueValid = true; }
public ActionResult EditGV(int id) { Storage m = new Storage(); GradeValue g = m.getGradeValueById(id); return View(g); }
// // GET: /Realization/Details/5 public ActionResult Details(int id) { Storage model = new Storage(); return View(model.getRealisationStudents(id)); }
// // GET: /Realization/ public ActionResult Index() { Storage model = new Storage(); return View(model.getRealisations()); }