Exemple #1
0
        public async Task <SchoolYear> PostSchoolYear(SchoolYear schoolYear)
        {
            _context.SchoolYears.Add(schoolYear);
            await _context.SaveChangesAsync();

            return(schoolYear);
        }
Exemple #2
0
        public string GetCurrentSy()
        {
            SchoolYearService sys = new SchoolYearService();
            SchoolYear        sy  = sys.GetCurrentSY();

            return(sy.SY);
        }
 public ResponseMessageWrap <int> Insert([FromBody] SchoolYear schoolYear)
 {
     return(new ResponseMessageWrap <int>
     {
         Body = SchoolYearService.Insert(schoolYear)
     });
 }
 public ResponseMessageWrap <int> Update([FromBody] SchoolYear schoolYear)
 {
     return(new ResponseMessageWrap <int>
     {
         Body = SchoolYearService.Update(schoolYear)
     });
 }
        protected IEnumerable <string> GetFieldsForView(SchoolYear schoolYear, string schema, string name)
        {
            var fieldsForView = new List <string>();

            using (var schoolYearContext = SchoolYearDbContextFactory.CreateWithParameter(schoolYear.EndYear))
            {
                var connection = schoolYearContext.Database.Connection;
                connection.Open();

                var queryCommand = connection.CreateCommand();
                queryCommand.CommandType = System.Data.CommandType.Text;
                queryCommand.CommandText =
                    @"SELECT COLUMN_NAME FROM information_schema.columns WHERE TABLE_SCHEMA=@schemaName and table_name = @viewName";

                queryCommand.Parameters.Add(new SqlParameter("@schemaName", schema));
                queryCommand.Parameters.Add(new SqlParameter("@viewName", name));

                using (var reader = queryCommand.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        fieldsForView.Add(reader["COLUMN_NAME"].ToString());
                    }
                }
            }

            return(fieldsForView);
        }
        public static async Task <List <SchoolYear> > GetSchoolYearsAsync()
        {
            List <SchoolYear> lstResults = new List <SchoolYear>();
            await Task.Run(() =>
            {
                using (var db = new dbSchoolAttendanceEntities())
                {
                    var dbresult = db.tblSchoolYear.ToList();
                    if (dbresult.Count > 0)
                    {
                        foreach (var year in dbresult)
                        {
                            SchoolYear exSchoolYear  = new SchoolYear();
                            exSchoolYear.ID          = year.ID;
                            exSchoolYear.YearEndDate = Convert.ToDateTime(year.YearStartDate);
                            exSchoolYear.YearEndDate = Convert.ToDateTime(year.YearEndDate);
                            exSchoolYear.Description = year.Description;
                            exSchoolYear.Notes       = year.Notes;

                            lstResults.Add(exSchoolYear);
                        }
                    }
                }
            });

            return(lstResults);
        }
Exemple #7
0
        private bool IsValidSchoolYear(SchoolYear schoolyear)
        {
            var db = DAL.DbContext.Create();

            //validate yearFrom if value is int
            int yearFrom;

            if (!int.TryParse(schoolyear.YearFrom, out yearFrom))
            {
                ModelState.AddModelError("", "Unable to save changes. Year To needs to be greater than 1 to Year From.");
                return(false);
            }
            //validate yearTo if value is int
            int yearTo;

            if (!int.TryParse(schoolyear.YearTo, out yearTo))
            {
                ModelState.AddModelError("", "Unable to save changes. Year To needs to be greater than 1 to Year From.");
                return(false);
            }
            //validte if dateTo is greater than dateFrom
            if (yearTo - yearFrom != 1)
            {
                ModelState.AddModelError("", "Unable to save changes. Year To needs to be greater than 1 to Year From.");
                return(false);
            }

            return(true);
        }
 public ActionResult AddNewSchoolYear(SchoolYear model)
 {
     ViewBag.AlreadyExists = false;
     if (ModelState.IsValid)
     {
         if (model.Id != 0)
         {
             bool IsUpdated = SchoolYear.Update(model.Id, model.Name);
             if (IsUpdated)
             {
                 return(RedirectToAction("Index"));
             }
         }
         else
         {
             bool isAdded = SchoolYear.AddNew(model.Name, ApplicationHelper.LoggedUserId);
             if (isAdded)
             {
                 return(RedirectToAction("Index"));
             }
         }
         ViewBag.AlreadyExists = true;
         return(View(model));
     }
     else
     {
         return(View(model));
     }
 }
Exemple #9
0
        public ActionResult Create(SchoolYear schoolyear)
        {
            var db = DAL.DbContext.Create();

            try
            {
                if (ModelState.IsValid)
                {
                    if (IsValidSchoolYear(schoolyear))
                    {
                        //var existStudent = db.Students.All().FirstOrDefault(s => s.StudentID == student.StudentID);
                        var existSchoolYearFrom = db.SchoolYears.All().FirstOrDefault(s => s.YearFrom == schoolyear.YearFrom);
                        var existSchoolYearTo   = db.SchoolYears.All().FirstOrDefault(s => s.YearTo == schoolyear.YearTo);
                        if (existSchoolYearFrom == null && existSchoolYearTo == null)
                        {
                            db.SchoolYears.Insert(schoolyear);
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            ModelState.AddModelError("", "Dupplicate School Year");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }
            return(View(schoolyear));
        }
        public static int Save(SchoolYear scYear)
        {
            var a = new SchoolYear
            {
                SchoolYearId      = scYear.SchoolYearId,
                SchoolYearName    = scYear.SchoolYearName,
                SchoolDescription = scYear.SchoolDescription,
                ModifiedBy        = scYear.ModifiedBy,
                ModifiedOn        = scYear.ModifiedOn
            };

            using (_d = new DataRepository <SchoolYear>())
            {
                if (scYear.SchoolYearId > 0)
                {
                    _d.Update(a);
                }
                else
                {
                    _d.Add(a);
                }
                _d.SaveChanges();
            }
            return(a.SchoolYearId);
        }
        public InternalSchoolYearRepository(string SQLConnectionString)
        {
            using (SqlConnection connection = new SqlConnection(SQLConnectionString))
            {
                using (SqlCommand sqlCommand = new SqlCommand())
                {
                    sqlCommand.Connection  = connection;
                    sqlCommand.CommandType = CommandType.Text;
                    sqlCommand.CommandText = sql;

                    sqlCommand.Connection.Open();
                    SqlDataReader dataReader = sqlCommand.ExecuteReader();

                    if (dataReader.HasRows)
                    {
                        while (dataReader.Read())
                        {
                            SchoolYear parsedSY = dataReaderToSchoolYear(dataReader);
                            if (parsedSY != null)
                            {
                                _cacheByID.Add(parsedSY.ID, parsedSY);
                            }
                        }
                    }
                    sqlCommand.Connection.Close();
                }
            }
        }
        public static SchoolYear ProjectTo(this AddSchoolYearRequest request, IMapper mapper)
        {
            SchoolYear item = mapper.Map <SchoolYear>(request);

            item.DateCreated = DateTime.Now;
            return(item);
        }
Exemple #13
0
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            Forms.FormSelectSchoolYear fssy = new Forms.FormSelectSchoolYear();
            fssy.ShowDialog();
            SchoolYear selectedSchoolYear = fssy.SelectedSchoolYear;

            decimal totalFact = 0;
            decimal totalForm = 0;

            foreach (Course c in bindingSource1)
            {
                foreach (CourseInWork ciw in c.CourseInWork)
                {
                    if (ciw.SchoolYear.ID == selectedSchoolYear.ID)
                    {
                        if (ciw.Fact == (short)WorkloadType.Формальная || ciw.Fact == (short)WorkloadType.Фактическая_и_формальная)
                        {
                            totalForm += (decimal)ciw.AllHours;
                        }
                        if (ciw.Fact == (short)WorkloadType.Фактическая || ciw.Fact == (short)WorkloadType.Фактическая_и_формальная)
                        {
                            totalFact += (decimal)ciw.AllHours;
                        }
                    }
                }
            }
            MessageBox.Show(String.Format("Общая нагрузка:\n" +
                                          "формальная - {0},\n" +
                                          "фактическая - {1}.", totalForm, totalFact));
        }
        public JsonResult SchoolYears_Read(int cspId)
        {
            if (cspId == -1) // Insert Mode
            {
                IQueryable <SchoolYear> items = SchoolYear.GetCurrent().AsQueryable();
                var result = from item in items
                             select new
                {
                    Id   = item.Id,
                    Name = item.Name
                };

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            else
            {
                IQueryable <SchoolYear> items = SchoolYear.GetByCSPId(cspId).AsQueryable();
                var result = from item in items
                             select new
                {
                    Id   = item.Id,
                    Name = item.Name
                };

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #15
0
        public async Task PutSchoolYear(Guid id, SchoolYear schoolYear)
        {
            if (id != schoolYear.Id)
            {
                return;
            }

            _context.Entry(schoolYear).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SchoolYearExists(id))
                {
                    return;
                }
                else
                {
                    throw;
                }
            }

            return;
        }
Exemple #16
0
        public void LoadSY()
        {
            gvSY.DataSource = null;
            ISchoolYearService syService = new SchoolYearService();
            string             message   = String.Empty;

            try
            {
                var sy = syService.GetAllSY();
                SYList          = new List <SchoolYear>(sy);
                gvSY.DataSource = SYList;
                gvSY.Refresh();

                if (gvSY.RowCount != 0)
                {
                    gvSY.Rows[0].IsSelected = true;
                }


                SYcurrent = SYList.Find(x => x.CurrentSY == true);
            }
            catch (Exception ex)
            {
                message = "Error Loading List of School Years";
                MessageBox.Show(ex.ToString());
            }
        }
        private GradebookViewModel()
        {
            GradebookModel _gradebook = GradebookDao.getGradebook();

            this.SchoolYears = new List <SchoolYearViewModel>();
            foreach (SchoolYear schoolYear in _gradebook.SchoolYears)
            {
                SchoolYearViewModel schoolYearVM = new SchoolYearViewModel(schoolYear);
                this.SchoolYears.Add(schoolYearVM);

                if (!schoolYearVM.isComplete)
                {
                    this.SchoolYear = schoolYearVM;
                }
            }

            if (this.SchoolYear == null)
            {
                this.SchoolYear = new SchoolYearViewModel();
                this.SchoolYears.Add(this.SchoolYear);
            }

            if (SchoolYear.CurrentGradingPeriod == null)
            {
                SchoolYear.CreateGradingPeriod();
            }

            GradingPeriod = SchoolYear.CurrentGradingPeriod;
        }
Exemple #18
0
        private void SaveSY()
        {
            try
            {
                Boolean ret     = false;
                string  message = String.Empty;

                int SYto = 0;
                SYto = int.Parse(txtSY.Text) + 1;

                ISchoolYearService syService  = new SchoolYearService();
                SchoolYear         schoolyear = new SchoolYear()
                {
                    SY        = txtSY.Text + "-" + SYto.ToString(),
                    CurrentSY = false
                };


                ret = syService.CreateSY(ref schoolyear, ref message);
                Log("C", "SchoolYear", schoolyear);
                MessageBox.Show("Saved Successfully!");
                LoadSY();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.ToString());
            }
        }
Exemple #19
0
        public async Task <IActionResult> PutSchoolYear(int id, SchoolYear schoolYear)
        {
            if (id != schoolYear.YearId)
            {
                return(BadRequest());
            }

            _context.Entry(schoolYear).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SchoolYearExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #20
0
        public async Task <ActionResult <SchoolYear> > PostSchoolYear(SchoolYear schoolYear)
        {
            _context.SchoolYears.Add(schoolYear);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSchoolYear", new { id = schoolYear.YearId }, schoolYear));
        }
        public Boolean UpdateSY(ref SchoolYear schoolyear, ref string message)
        {
            message = String.Empty;
            SchoolYearBDO syBDO = new SchoolYearBDO();

            TranslateSYDTOToSYBDO(schoolyear, syBDO);
            return(syLogic.UpdateSY(ref syBDO, ref message));
        }
Exemple #22
0
 public SLAbsenceRepository(string SQLConnectionString, SchoolYear schoolYear)
 {
     this.SQLConnectionString = SQLConnectionString;
     this._reasonRepo         = new SLAbsenceReasonRepository(SQLConnectionString);
     this._statusRepo         = new SLAbsenceStatusRepository(SQLConnectionString);
     this.schoolYear          = schoolYear ?? throw new InvalidSchoolYearException("School year cannot be null");
     _refreshCache();
 }
Exemple #23
0
        public ActionResult DeleteConfirmed(int id)
        {
            SchoolYear schoolYear = db.SchoolYears.Find(id);

            db.SchoolYears.Remove(schoolYear);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #24
0
        public void DeleteStudentSchoolYear(Guid studentId, SchoolYear studentSchoolYear)
        {
            if (studentId == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(studentId));
            }

            _context.SchoolYears.Remove(studentSchoolYear);
        }
 public static bool Delete(SchoolYear scYear)
 {
     using (_d = new DataRepository <SchoolYear>())
     {
         _d.Delete(scYear);
         _d.SaveChanges();
     }
     return(true);
 }
Exemple #26
0
        public void ChangeSchoolYear(int schoolYear)
        {
            if (SchoolYear.Equals(schoolYear))
            {
                return;
            }

            SchoolYear = schoolYear;
            EntityModified();
        }
Exemple #27
0
 public static SchoolYearClassesViewData Create(SchoolYear schoolYear, IList <Class> classes, School school)
 {
     return(new SchoolYearClassesViewData
     {
         SchoolYear = SchoolYearViewData.Create(schoolYear),
         Classes = classes.Select(ShortClassViewData.Create).ToList(),
         SchoolId = school.Id,
         SchoolName = school.Name
     });
 }
Exemple #28
0
        /* CREATE  */
        public static void Add_Year(int School_Year)
        {
            var client = ConnectNeo4J.Connection();

            var year = new SchoolYear {
                school_year = School_Year, isEnded = false, isDeleted = false
            };

            client.Cypher.Create("(:School_Year {year})").WithParam("year", year).ExecuteWithoutResultsAsync().Wait();
        }
        public SchoolYear GetSY(string schoolyear)
        {
            SchoolYearBDO SYbdo = new SchoolYearBDO();

            SYbdo = syLogic.GetSY(schoolyear);
            SchoolYear u = new SchoolYear();

            TranslateSYBDOToSYDTO(SYbdo, u);

            return(u);
        }
 private string GetSchoolYear()
 {
     if (SchoolYear.InvokeRequired)
     {
         return(SchoolYear.Invoke(new Func <string>(GetSchoolYear)).ToString());
     }
     else
     {
         return(SchoolYear.Text);
     }
 }
Exemple #31
0
        private void gvSY_SelectionChanged(object sender, EventArgs e)
        {
            int selectedIndex = gvSY.CurrentRow.Index;


            if (selectedIndex >= 0)
            {
                string tCode = gvSY.Rows[selectedIndex].Cells["SY"].Value.ToString();
                List<SchoolYear> item = new List<SchoolYear>();
                item = SYList.FindAll(x => x.SY.ToString() == tCode);

                SYSelected = new SchoolYear();
                SYSelected = (SchoolYear)item[0];

            }
        }
Exemple #32
0
        public void LoadSY()
        {
            gvSY.DataSource = null;
            SchoolYearServiceClient syService = new SchoolYearServiceClient();
            string message = String.Empty;
            try
            {
                var sy = syService.GetAllSY();
                SYList = new List<SchoolYear>(sy);
                gvSY.DataSource = SYList;
                gvSY.Refresh();

                if (gvSY.RowCount != 0)
                    gvSY.Rows[0].IsSelected = true;

                SYcurrent = SYList.Find(x => x.CurrentSY == true);
            }
            catch (Exception ex)
            {
                message = "Error Loading List of School Years";
                MessageBox.Show(ex.ToString());
            }
        }
Exemple #33
0
        private void UpdateCurrentSY(string szSY, bool bSY)
        {
            try
            {
                Boolean ret = false;
                string message = String.Empty;

                SchoolYearServiceClient syService = new SchoolYearServiceClient();
                SchoolYear schoolyear = new SchoolYear()
                {
                    SY = szSY,
                    CurrentSY = bSY
                };

                ret = syService.UpdateSY(ref schoolyear, ref message);
                schoolyear.CurrentSY = true;
                Log("U", "SchoolYear", schoolyear);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.ToString());
            }
        }
Exemple #34
0
        private void SaveSY()
        {
            try
            {
                Boolean ret = false;
                string message = String.Empty;

                int SYto = 0;
                SYto = int.Parse(txtSY.Text) + 1;
                                
                SchoolYearServiceClient syService = new SchoolYearServiceClient();
                SchoolYear schoolyear = new SchoolYear()
                {
                    SY = txtSY.Text + "-" + SYto.ToString(),
                    CurrentSY = false
                };

              
                    ret = syService.CreateSY(ref schoolyear, ref message);


                MessageBox.Show("Saved Successfully!");

                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.ToString());
            }
        }
Exemple #35
0
        private void AssessStudent_Load(object sender, EventArgs e)
        {
            RegistrationServiceClient registrationService = new RegistrationServiceClient();
            List<Fee> fees = new List<Fee>();
            ScholarshipServiceClient scholarshipService = new ScholarshipServiceClient();
            List<RegistrationServiceRef.ScholarshipDiscount> scholarships = new List<RegistrationServiceRef.ScholarshipDiscount>();

            currentSY = registrationService.GetCurrentSY();

            StudentAssessed = registrationService.GetStudentEnrolled(StudentId, currentSY.SY);
            txtGradeLevel.Text = StudentAssessed.GradeLevel;
            txtIDnum.Text = StudentAssessed.StudentId;
            txtName.Text = StudentAssessed.StudentName;
            txtSY.Text = currentSY.SY;

            //scholarshipDiscount = scholarshipService.GetAllScholarshipDiscount(StudentAssessed.DiscountId);
            //scholarshipDiscount = scholarshipService.GetAllScholarships();

            fees = new List<Fee>(registrationService.GetStudentFees(StudentAssessed));
            gvAssessment.DataSource = fees;
            fees.ToArray();

            scholarships = new List<RegistrationServiceRef.ScholarshipDiscount>(registrationService.GetScholarshipDiscounts());

            int scholarshipDiscountId = StudentAssessed.DiscountId;

            RegistrationServiceRef.ScholarshipDiscount sd = new RegistrationServiceRef.ScholarshipDiscount();

            sd = scholarships.Find(v => v.ScholarshipDiscountId == scholarshipDiscountId);

            amountTuition = (double)fees[0].Amount;
            enrollment = (double)fees[1].Amount;

            // Read Only TextBox
            tuitionFee.ReadOnly = true;
            discountPercent.ReadOnly = true;
            totalTuitionFee.ReadOnly = true;
            enrollmentFee.ReadOnly = true;
            enrTotalTuitionFee.ReadOnly = true;
            subTotal.ReadOnly = true;
            discountbyAmountSubTotal.ReadOnly = true;
            Total.ReadOnly = true;

            // Total Tuition Fee
            tuitionFee.Text = amountTuition.ToString("0.###");

            // Percent Discount
            double perc = 0;
            double percRound = 0;
            double percInitial = 0;

            perc = (double)sd.Discount;
            if (sd.Discount == null)
            {
                discountPercent.Enabled = false;
            }
            else
            {
                discountPercent.Text = perc.ToString("0.##");
                percRound = perc / 100;
                if (percRound == 1)
                {
                    percValue = amountTuition;
                    fullPaymentDisc.ReadOnly = true;
                } else {
                    percInitial = amountTuition * percRound;
                    percValue = amountTuition - percInitial;
                }
            }

               /* Operations */
            // Operation for Percent Discount if not null

            if (fullPaymentDisc != null)
            {
                finalPercentDisc = amountTuition - percValue - fullPaymentDiscount;
            }
            else
            {
                finalPercentDisc = amountTuition - percValue;
            }

            // Total Tuition Fee
            totalTuitionFee.Text = finalPercentDisc.ToString("0.##");

            // Enrollment Fee
            enrollmentFee.Text = enrollment.ToString();

            // Total Tuition Fee
            enrTotalTuitionFee.Text = finalPercentDisc.ToString("0.##");

            // Sub Total

            subTotalValue = enrollment + finalPercentDisc;
            subTotal.Text = subTotalValue.ToString("0.##");

            // Sub Total
            discountbyAmountSubTotal.Text = subTotalValue.ToString("0.##");

            // Discount by Amount
            double discByAmout = 0;
            //discByAmout = discountByAmount

            // Para ma assess og ma save sa db
            //var assessments = registrationService.AssessMe(StudentAssessed);

            //gvAssessment.DataSource = assessments;
        }