public static int PayStudentFees(FeeCollections newFees) { using (VedantaEntities ve = new VedantaEntities()) { ve.AddToFeeCollections(newFees); return(ve.SaveChanges()); } }
public static int UpdateFeeCollection(FeeCollections newFee) { using (VedantaEntities ve = new VedantaEntities()) { FeeCollections oldFee = ve.FeeCollections.FirstOrDefault(st => st.Id == newFee.Id); if (oldFee == null) { return(-1);//Admission record not found. } newFee.AdmissionId = oldFee.AdmissionId; var updatedFee = ve.ApplyCurrentValues(oldFee.GetType().Name, newFee); return(ve.SaveChanges()); } }
public ActionResult EditFees(int id) { ViewData["PaymentHeads"] = Utilities.GetPaymentHeadsNameList(); ViewData["PaymentModes"] = Utilities.GetPaymentModesNameList(); FeeCollections feeColl = StudentModels.GetFeesCollectionById(id); ViewData.Model = feeColl; if (feeColl != null) { vw_Admissions admDeatails = StudentModels.GetAdmissionDetailsById(feeColl.AdmissionId); if (admDeatails != null) { ViewData["StudentDetails"] = admDeatails; } } return(View()); }
public static int UpdateAdmissionDetails(Admissions newAdmission) { using (VedantaEntities ve = new VedantaEntities()) { Admissions oldAdmission = ve.Admissions.FirstOrDefault(st => st.Id == newAdmission.Id); if (oldAdmission == null) { return(-1);//Admission record not found. } FeeCollections fee = ve.FeeCollections.FirstOrDefault(fe => fe.AdmissionId == newAdmission.Id && fe.ManualreceiptNumber.Equals(oldAdmission.ManualReceiptNumber, StringComparison.OrdinalIgnoreCase)); if (fee != null) { fee.Amount = newAdmission.DownPayment; fee.Description = newAdmission.Description; fee.TotalReceived = newAdmission.DownPayment; fee.PaymentDate = newAdmission.AdmissionDate; fee.PaymentHeadId = 1; fee.PaymentModeId = newAdmission.PaymentModeId; } newAdmission.StudentId = oldAdmission.StudentId; var updatedAdmission = ve.ApplyCurrentValues(oldAdmission.GetType().Name, newAdmission); return(ve.SaveChanges()); } }
public static int ProocessNewStudentAddmission(Students newStudent, Admissions newAdmission, FeeCollections newFeeCollection) { using (VedantaEntities ve = new VedantaEntities()) { Students oldStudent = ve.Students.FirstOrDefault(st => st.ID == newStudent.ID); int newStudentId = 0; int oldStudentId = 0; //Add A New Student Record in DataBase if that student does not exists if (oldStudent == null) { newStudent.CreatedDate = DateTime.Now.Date; ve.AddToStudents(newStudent); ve.SaveChanges(); newStudentId = newStudent.ID; } else { oldStudentId = oldStudent.ID; } //If Student is already enrolled with us then no need to add new record for same student if (newStudentId == 0 && oldStudentId > 0) { newStudentId = oldStudentId; } if (newStudentId > 0) { newAdmission.StudentId = newStudentId; Admissions oldAdmission = ve.Admissions.FirstOrDefault(ad => ad.StudentId == newStudentId && ad.CourseId == newAdmission.CourseId); if (oldAdmission == null) { ve.AddToAdmissions(newAdmission); int admResult = ve.SaveChanges(); return(admResult); //if (admResult > 0) //Admission of Student done successfully. //{ // newFeeCollection.AdmissionId = newAdmission.Id; // ve.AddToFeeCollections(newFeeCollection); // return ve.SaveChanges(); //Admission Fee Paid successfully. //} //else // return -2; } else { return(-2); //Student Record Entered but failed to take Admission of student. } } else { return(-1); //Student Record not entered; } } }
public ActionResult EditFees(FormCollection form, FeeCollections newFees) { ViewData["PaymentHeads"] = Utilities.GetPaymentHeadsNameList(); ViewData["PaymentModes"] = Utilities.GetPaymentModesNameList(); decimal?paidFeesAmount = 0; decimal?courseFee = 0; string regNumber = string.Empty; if (!ModelState.IsValid) { ApplicationMessages msg = new ApplicationMessages("Invalid entry.", MessageType.Error); ViewData["Message"] = msg; return(View()); } ViewData.Model = newFees; vw_Admissions admDeatails = StudentModels.GetAdmissionDetailsById(newFees.AdmissionId); if (admDeatails != null) { regNumber = admDeatails.RegistrationNumber; courseFee = admDeatails.CourseFees ?? 0; ViewData["StudentDetails"] = admDeatails; List <vw_FeeCollections> feeCollected = null; feeCollected = StudentModels.GetStudentsPaidFeesByReg_Number(regNumber); List <vw_FeeCollections> exceptThisFeelist = feeCollected.Where(fe => fe.Id != newFees.Id).ToList(); if (exceptThisFeelist != null && exceptThisFeelist.Count() > 0) { //ViewData["CollectedFees"] = feeCollected; paidFeesAmount = exceptThisFeelist.Sum(f => f.Amount); } if (courseFee >= paidFeesAmount + (newFees != null ? newFees.Amount : 0)) { if (admDeatails != null) { //newFees.AdmissionId = admDeatails.Id; if (newFees.Amount != null && newFees.Amount > 0) { newFees.TotalReceived = newFees.Amount; int result = StudentModels.UpdateFeeCollection(newFees); if (result > 0) { Session["CurrentFeeId"] = newFees.Id; // return RedirectToAction("FeeReceipt"); ApplicationMessages msg = new ApplicationMessages("Fees saved successfully.", MessageType.Success); ViewData["Message"] = msg; //ViewData["CollectedFees"] = StudentModels.GetStudentsPaidFeesByReg_Number(regNumber); } else { ApplicationMessages msg = new ApplicationMessages("Failed to save Fees. Please try again.", MessageType.Error); ViewData["Message"] = msg; } } else { ApplicationMessages msg = new ApplicationMessages("Fee Amount can not be zero or negative.", MessageType.Error); ViewData["Message"] = msg; } } else { ApplicationMessages msg = new ApplicationMessages("Failed to save Fees. Please try again.", MessageType.Error); ViewData["Message"] = msg; } } else { ApplicationMessages msg = new ApplicationMessages("Fee Amount can not exceed Total Installment Amount.", MessageType.Error); ViewData["Message"] = msg; } return(View()); } else { ApplicationMessages msg = new ApplicationMessages("Invalid Enquiry", MessageType.Error); ViewData["Message"] = msg; return(View()); } }
public ActionResult Fees(string Submit, FormCollection form, FeeCollections newFees) { ViewData["PaymentHeads"] = Utilities.GetPaymentHeadsNameList(); ViewData["PaymentModes"] = Utilities.GetPaymentModesNameList(); decimal?paidFeesAmount = 0; string regNumber = string.Empty; decimal?courseFee = 0; if (!string.IsNullOrEmpty(form["txtReg_Number"])) { regNumber = form["txtReg_Number"].ToString(); ViewData["RegistrationNumber"] = regNumber; List <vw_FeeCollections> feeCollected = null; feeCollected = StudentModels.GetStudentsPaidFeesByReg_Number(regNumber); if (feeCollected != null && feeCollected.Count() > 0) { ViewData["CollectedFees"] = feeCollected; paidFeesAmount = feeCollected.Sum(f => f.Amount); } vw_Admissions admDeatails = StudentModels.GetAdmissionDetailsByReg_Number(regNumber); if (admDeatails != null) { courseFee = admDeatails.CourseFees ?? 0; ViewData["StudentDetails"] = admDeatails; } else { ApplicationMessages msg = new ApplicationMessages("Invalid Registration Number.", MessageType.Error); ViewData["Message"] = msg; return(View()); } if (!string.IsNullOrEmpty(Submit)) { switch (Submit.ToLower()) { case "search": ModelState.Clear(); break; case "submit": if (!ModelState.IsValid) { ApplicationMessages msg = new ApplicationMessages("Invalid entry.", MessageType.Error); ViewData["Message"] = msg; return(View()); } if (courseFee >= paidFeesAmount + (newFees != null ? newFees.Amount : 0)) { if (admDeatails != null) { newFees.AdmissionId = admDeatails.Id; if (newFees.Amount != null && newFees.Amount > 0) { newFees.TotalReceived = newFees.Amount; int result = StudentModels.PayStudentFees(newFees); if (result > 0) { Session["CurrentFeeId"] = newFees.Id; return(RedirectToAction("FeeReceipt")); // ApplicationMessages msg = new ApplicationMessages("Fees paid successfully.", MessageType.Success); // ViewData["Message"] = msg; // ViewData["CollectedFees"] = StudentModels.GetStudentsPaidFeesByReg_Number(regNumber); } else { ApplicationMessages msg = new ApplicationMessages("Failed to Pay Fees. Please try again.", MessageType.Error); ViewData["Message"] = msg; } } else { ApplicationMessages msg = new ApplicationMessages("Fee Amount can not be zero or negative.", MessageType.Error); ViewData["Message"] = msg; } } else { ApplicationMessages msg = new ApplicationMessages("Failed to Pay Fees. Please try again.", MessageType.Error); ViewData["Message"] = msg; } } else { ApplicationMessages msg = new ApplicationMessages("Fee Amount can not exceed Total Installment Amount.", MessageType.Error); ViewData["Message"] = msg; } break; } } return(View()); } else { ApplicationMessages msg = new ApplicationMessages("Invalid Registration Number.", MessageType.Error); ViewData["Message"] = msg; return(View()); } }