Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Power,EngineType,EngineName,VCNName,StationNumber,AOTypeID,CreationDate,KSID,Notes")] GPA gPA)
        {
            if (id != gPA.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    gPA.LastEditDate = DateTime.Now;

                    _context.Update(gPA);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GPAExists(gPA.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            ViewData["AOTypeID"] = gPA.AOTypeID;

            ViewData["KSID"] = new SelectList(_context.KSs, "ID", "Name", gPA.KSID);
            return(View(gPA));
        }
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            var emptyGPA = new GPA();

            await TryUpdateModelAsync <GPA>(
                emptyGPA,
                "gpa",    // Prefix for form value.
                s => s.GPAID,
                s => s.GPAValue,
                s => s.StudentID,
                s => s.SemesterID,
                s => s.SubjectModuleID,
                s => s.YearID
                );

            _context.GPA.Add(emptyGPA);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));

            /*
             * if (!ModelState.IsValid)
             * {
             *  return Page();
             * }
             *
             * _context.GPA.Add(GPA);
             * await _context.SaveChangesAsync();
             *
             * return RedirectToPage("./Index");
             */
        }
Exemple #3
0
        private async void InitializeContent(bool isRefresh)
        {
            // 获取GPA数据
            GPAData = await currentApp.client.QueryForData <GPA>(isRefresh : isRefresh);

            // 绑定数据
            DataContext      = GPAData;
            GradesCVS.Source = GPAData.Semesters;
        }
Exemple #4
0
 public void SetDataGridViewRow_GPA(int rownumber, GPA gpa)
 {
     this.DataGridView_GPA.Rows[rownumber].Cells["ID"].Value              = gpa.ID;
     this.DataGridView_GPA.Rows[rownumber].Cells["University"].Value      = gpa.Student.Faculty.University.Name;
     this.DataGridView_GPA.Rows[rownumber].Cells["Faculty"].Value         = gpa.Student.Faculty.Name;
     this.DataGridView_GPA.Rows[rownumber].Cells["StudentFullName"].Value = gpa.Student.GetStudentFullName();
     this.DataGridView_GPA.Rows[rownumber].Cells["Subject"].Value         = gpa.Subject.Name;
     this.DataGridView_GPA.Rows[rownumber].Cells["GPA"].Value             = ((uint)gpa.GradePointAverage).ToString();
 }
        public override string ToString()
        {
            string result = $"{FirstName} {LastName} ({SoonerID}) has s {GPA.ToString("N2")} GPA and owes {BursarBalance.ToString("C")}";

            if (IsOnProbation == true)
            {
                result += "\n Is on Probation.";
            }
            else
            {
                result += "\n Is not on Probation.";
            }

            return(result);
        }
Exemple #6
0
        public override string ToString()
        {
            string Output = $"{FirstName} {LastName} {SoonerID}";

            if (IsONProbation = true)
            {
                Output += " is on probation. \n";
            }
            else
            {
                Output += " is not on probation. \n";
            }
            Output += $"They have a {GPA.ToString("N2")} GPA and they owe {BursarBalance.ToString("C2")}";
            return(base.ToString());
        }
Exemple #7
0
        void ShowDataGridView_GPA(int page, int rowcount)
        {
            IMainView.Set_label_PageNumber(page);
            int DBRecordID = page * rowcount - rowcount;

            FillDataGridView_GPA(rowcount - 1);
            DBRecordCount = IModel.Get_DBRecordCount();
            int maxpage = Convert.ToInt32(Math.Ceiling((Convert.ToDouble(DBRecordCount)) / (Convert.ToDouble(rowcount))));// + 1;
            int maxrow  = DBRecordCount % rowcount;

            if (page != maxpage)
            {
                maxrow = rowcount;
            }
            else
            {
                if (maxrow == 0)
                {
                    maxrow = rowcount;
                }
            }
            for (int i = 0; i < maxrow; i++)
            {
                gpa = IModel.GetGPA(DBRecordID);
                DBRecordID++;
                IMainView.SetDataGridViewRow_GPA(i, gpa);
            }
            if (page == 1 && page != maxpage)
            {
                IMainView.SetNextButtonActive();
                IMainView.SetPrevButtonNotActive();
            }
            else if (page == 1 && page == maxpage)
            {
                IMainView.SetNextButtonNotActive();
                IMainView.SetPrevButtonNotActive();
            }
            else if (page != 1 && page == maxpage)
            {
                IMainView.SetNextButtonNotActive();
                IMainView.SetPrevButtonActive();
            }
            else
            {
                IMainView.SetNextButtonActive();
                IMainView.SetPrevButtonActive();
            }
        }
Exemple #8
0
        // <summary> Creates a string representation of our class
        public override string ToString()
        {
            string output = $"{FirstName} {LastName}";

            if (IsOnProbation == true)
            {
                output += "is on probation";
            }
            else
            {
                output += "is not on probation";
            }
            output += $"They have a {GPA.ToString("N2")} GPA +" +
                      $"and they owe {BursarBalance.ToString("C2")}";
            return(output);
        }
        public async Task <IActionResult> OnPostAsync(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            GPA = await _context.GPA.FindAsync(id);

            if (GPA != null)
            {
                _context.GPA.Remove(GPA);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnGetAsync(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            GPA = await _context.GPA
                  .Include(g => g.ApplicationUser)
                  .Include(g => g.Semester)
                  .Include(g => g.SubjectModule)
                  .Include(g => g.Year).FirstOrDefaultAsync(m => m.GPAID == id);

            if (GPA == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Exemple #11
0
        // SetGPA записывает данные о средней оценке в базу данных
        public void SetGPA(int id, GPA gpa)
        {
            university.Name = "ПНИПУ";

            faculty.Name       = "Юридический";
            faculty.University = university;

            student.Name       = "Петр";
            student.Surname    = "Иванов";
            student.Patronimic = "Андреевич";
            student.Faculty    = faculty;

            subject.Name = "История древнего мира";

            gpa.Student           = student;
            gpa.Student.Faculty   = faculty;
            gpa.Subject           = subject;
            gpa.GradePointAverage = GPA.gpa.great;
        }
Exemple #12
0
        public async Task <IActionResult> Create([Bind("ID,Name,Power,EngineType,EngineName,VCNName,StationNumber,KSID,AOTypeID,Notes")] GPA gPA)
        {
            ViewData["AOTypeID"] = new SelectList(_context.AOTypes, "ID", "Name", gPA.AOTypeID);

            ViewData["KSID"] = new SelectList(_context.KSs, "ID", "Name", gPA.KSID);

            //-------ЗАПИСЬ в БД
            if (ModelState.IsValid)
            {
                gPA.CreationDate = DateTime.Now;

                _context.Add(gPA);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            //------------------------


            return(View(gPA));
        }
        public async Task <IActionResult> OnGetAsync(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            GPA = await _context.GPA
                  .Include(g => g.ApplicationUser)
                  .Include(g => g.Semester)
                  .Include(g => g.SubjectModule)
                  .Include(g => g.Year).FirstOrDefaultAsync(m => m.GPAID == id);

            if (GPA == null)
            {
                return(NotFound());
            }
            ViewData["StudentID"]       = new SelectList(_context.Set <ApplicationUser>(), "Id", "Id");
            ViewData["SemesterID"]      = new SelectList(_context.Set <Semester>(), "SemesterID", "SemesterID");
            ViewData["SubjectModuleID"] = new SelectList(_context.Set <SubjectModule>(), "SubjectModuleID", "SubjectModuleID");
            ViewData["YearID"]          = new SelectList(_context.Set <Year>(), "YearID", "YearID");
            return(Page());
        }
 static void Main()
 {
    const char DELIM = ',';
    const string FILENAME = "StudentData.txt;
    Student stu = new Student();
    FileStream inFile = new FileStream(FILENAME, FileMode.Open, FileAccess.Read);
    StreamReader reader = new StreamReader(inFile);
    string recordIn;
    string[] fields;
    Console.WriteLine("\n{0,-5}{1,-12}{2,8}\n, "Num", "Name", "GPA"); 
    recordIn = reader.ReadLine();
    while(recordIn != null)
    {
       fields = recordIn.split(DELIM);
       stu.StuNum = Convert.ToInt32(fields[0]);
       stu.Name = fields[1];
       stu.Gpa = Convert.ToDouble(fields[2]);
       Console.WriteLine("{0,-5}{1,-12}{2,8}", stu.StuNum, stu.Name, stu.Gpa.ToString("F2"));
    }
    
    reader.Close();  
    inFile.Close();
 }
Exemple #15
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            List <ValidationResult> errors = new List <ValidationResult>();

            if (string.IsNullOrEmpty(FirstName))
            {
                errors.Add(new ValidationResult("The First Name field is required.", new[] { "FirstName" }));
            }
            if (string.IsNullOrEmpty(LastName))
            {
                errors.Add(new ValidationResult("The Last Name field is required.", new[] { "LastName" }));
            }
            if (string.IsNullOrEmpty(GPA.ToString()) || GPA > 5 || GPA < 0)
            {
                errors.Add(new ValidationResult("You must enter a GPA between 0 and 5.", new[] { "GPA" }));
            }
            if (string.IsNullOrEmpty(Major.ToString()))
            {
                errors.Add(new ValidationResult("The Major field is required.", new[] { "Major" }));
            }

            return(errors);
        }
        public override int GetHashCode()
        {
            unchecked
            {
                // Choose large primes to avoid hashing collisions
                const int HashingBase       = (int)2166136261;
                const int HashingMultiplier = 16777619;

                int hash = HashingBase;
                hash = (hash * HashingMultiplier) ^ (!Object.ReferenceEquals(null, DriverAge) ? DriverAge.GetHashCode() : 0);
                hash = (hash * HashingMultiplier) ^ (!Object.ReferenceEquals(null, Relationship) ? Relationship.GetHashCode() : 0);
                hash = (hash * HashingMultiplier) ^ (!Object.ReferenceEquals(null, StudentStatus) ? StudentStatus.GetHashCode() : 0);
                hash = (hash * HashingMultiplier) ^ (!Object.ReferenceEquals(null, ViolationStatus) ? ViolationStatus.GetHashCode() : 0);
                hash = (hash * HashingMultiplier) ^ (!Object.ReferenceEquals(null, GPA) ? GPA.GetHashCode() : 0);
                hash = (hash * HashingMultiplier) ^ (!Object.ReferenceEquals(null, MaritialStatus) ? MaritialStatus.GetHashCode() : 0);
                return(hash);
            }
        }