/// <summary> /// Ajouter Un Recue a Payer Par l'Etudiant /// </summary> /// <param name="myBill"></param> /// <returns>True pour Success</returns> public bool AddFeeReceipt(StudentBill myBill) { if (myBill.NetAmount < 0.0000001) { return(true); } if (FeeReceiptExist(myBill)) { return(true); } using (var db = new SchoolContext()) if (db.Students.Find(myBill.StudentGuid) == null) { throw new InvalidOperationException("STUDENT_REFERENCE_NOT_FOUND"); } using (var db = new EconomatContext()) { var newSchoolFee = new SchoolFee { SchoolFeeGuid = myBill.SchoolFeeGuid == Guid.Empty ? Guid.NewGuid() : myBill.SchoolFeeGuid, StudentGuid = myBill.StudentGuid, Designation = myBill.Designation, NetAmount = myBill.NetAmount, DueDate = myBill.DueDate, DateAdded = DateTime.Now, AddUserGuid = Guid.Empty, LastEditUserGuid = Guid.Empty }; db.SchoolFees.Add(newSchoolFee); return(db.SaveChanges() > 0); } }
public IActionResult Create(dynamic model) { var response = ResponseModelFactory.CreateInstance; if (model.SchoolUuid == null && AuthContextService.CurrentUser.SchoolGuid == null) { response.SetFailed("请登录学校账号"); return(Ok(response)); } using (_dbContext) { string idcard = model.idcardNum; string ordername = model.orderName; string serialNumber = model.serialNumber; string amountPayable = model.amountPayable; string orderMoney = model.orderMoney; var isserial = _dbContext.StudentBill.FirstOrDefault(x => x.SerialNumber == serialNumber); if (isserial != null) { response.SetFailed("该流水号已存在"); return(Ok(response)); } var iscard = _dbContext.StudentBill.FirstOrDefault(x => x.IdcardNum == idcard && x.OrderName == ordername); if (iscard != null) { response.SetFailed("该学生账单已存在"); return(Ok(response)); } var entity = new StudentBill(); entity.StudentBillUuid = Guid.NewGuid(); entity.SerialNumber = serialNumber; entity.StudentName = model.studentName; entity.IdcardNum = idcard; //string strSex = idcard.Substring(14, 3); //if (int.Parse(strSex) % 2 == 0)//性别代码为偶数是女性奇数为男性 //{ // entity.Sex = 2; //} //else //{ // entity.Sex = 1; //} entity.ClassName = model.className; entity.OrderName = ordername; entity.AmountPayable = model.amountPayable == null ? 0 : model.amountPayable; entity.OrderMoney = model.orderMoney == null ? 0 : model.orderMoney; entity.IsDeleted = 0; entity.SchoolUuid = AuthContextService.CurrentUser.SchoolGuid; _dbContext.StudentBill.Add(entity); _dbContext.SaveChanges(); response.SetSuccess("添加成功"); return(Ok(response)); } }
public ActionResult Trangection(StudentBill stbill) { Transcetion trns = new Transcetion(); trns.TransectionnDate = DateTime.Now; trns.StudentBillId = stbill.StudentBilId; db.Transcetions.Add(trns); db.SaveChanges(); return(RedirectToAction("Student_Bill")); }
/// <summary> /// Verifie L'existence d'un Recue /// </summary> /// <param name="myBill"></param> /// <returns>True pour oui</returns> protected internal static bool FeeReceiptExist(StudentBill myBill) { using (var db = new EconomatContext()) { if (db.SchoolFees.Find(myBill.SchoolFeeGuid) != null) { return(true); } return(db.SchoolFees.Any(r => r.StudentGuid == myBill.StudentGuid && r.Designation.Equals(myBill.Designation) && r.DueDate == myBill.DueDate && Math.Abs(r.NetAmount - myBill.NetAmount) < .00001)); } }