public LoaiTietKiem GetLoaiTietKiemByID(int ID) { LoaiTietKiem astudent = null; try { astudent = dbContext.LoaiTietKiems.Where(x => x.ID == ID).SingleOrDefault(); } catch (Exception e) { astudent = null; } return(astudent); }
public HttpResponseMessage SaveLoaiTietKiem(LoaiTietKiem loaiTietKiem) { int result = 0; try { dbContext.LoaiTietKiems.Add(loaiTietKiem); dbContext.SaveChanges(); result = 1; } catch (Exception e) { result = 0; } return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public HttpResponseMessage UpdateLoaiTietKiem(LoaiTietKiem loaiTietKiem) { int result = 0; try { dbContext.LoaiTietKiems.Attach(loaiTietKiem); dbContext.Entry(loaiTietKiem).State = EntityState.Modified; dbContext.SaveChanges(); result = 1; } catch (Exception e) { result = 0; } return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public async Task <IActionResult> Create(LoaiTietKiemDto model) { var optionsBuilder = new DbContextOptions <DatabaseContext>(); using (var db = new DatabaseContext(optionsBuilder)) { var result = false; var loaiTietKiemMoi = new LoaiTietKiem() { TenLoaiTietKiem = model.TenLoaiTietKiem, LaiSuat = model.LaiSuat, KyHan = model.KyHan, NgayHieuLuc = model.NgayHieuLuc }; db.LoaiTietKiem.Add(loaiTietKiemMoi); result = db.SaveChanges() > 0; return(this.Ok(result)); } }
private bool AddChiTietSo(PhieuGuiRutTien phieuGuiTien, ChiTietSoTietKiem chitietSoTruoc, LoaiTietKiem loaitietkiem, LoaiTietKiem khongkyhan, string nghiepvu, SoTk soTietKiem) { var addChiTietSo = this.KhoiTaoChiTiet(phieuGuiTien, chitietSoTruoc, loaitietkiem, nghiepvu); addChiTietSo.NghiepVu = nghiepvu; int soNam = phieuGuiTien.Ngay.Value.Year - chitietSoTruoc.NgayGui.Value.Year; int soThang = 0; if (soNam > 0) { soThang = phieuGuiTien.Ngay.Value.Month + 12 - chitietSoTruoc.NgayGui.Value.Month; } else { soThang = phieuGuiTien.Ngay.Value.Month - chitietSoTruoc.NgayGui.Value.Month; } var soNgay = Math.Abs(phieuGuiTien.Ngay.Value.Day - chitietSoTruoc.NgayGui.Value.Day); if (soThang > 0 && nghiepvu != "DONG") { addChiTietSo.SoThangLaiSuat = soThang; addChiTietSo.LaiSuatThang = this.LaiThang(chitietSoTruoc.SoDuCuoiKy.Value, addChiTietSo.LaiSuat.Value / 100, (double)soThang); addChiTietSo.SoNgayLaiSuat = 0; addChiTietSo.LaiSuatNgay = 0; } if (soNgay > 0 && nghiepvu != "DONG") { addChiTietSo.SoNgayLaiSuat = (int)soNgay; addChiTietSo.LaiSuatNgay = this.LaiNgay(chitietSoTruoc.SoDuCuoiKy.Value, khongkyhan.LaiSuat / 100, (double)soThang, soNgay); } if (nghiepvu == "RUT") { addChiTietSo.SoThangLaiSuat = soThang; addChiTietSo.LaiSuatThang = this.LaiThang(chitietSoTruoc.SoDuCuoiKy.Value, addChiTietSo.LaiSuat.Value / 100, (double)soThang); addChiTietSo.SoNgayLaiSuat = 0; addChiTietSo.LaiSuatNgay = 0; } if (nghiepvu == "DONG") { addChiTietSo.SoThangLaiSuat = 0; addChiTietSo.LaiSuatThang = 0; addChiTietSo.SoNgayLaiSuat = 0; addChiTietSo.LaiSuatNgay = 0; } addChiTietSo.SoDuCuoiKy = addChiTietSo.SoDuDauKy + addChiTietSo.LaiSuatThang + addChiTietSo.LaiSuatNgay; context.ChiTietSoTietKiem.Add(addChiTietSo); soTietKiem.SoDu = addChiTietSo.SoDuCuoiKy; if (nghiepvu == "DONG") { soTietKiem.NgayDongSo = DateTime.Now; soTietKiem.SoDu = 0; } context.SoTk.Update(soTietKiem); return(context.SaveChanges() > 0); }
private bool GuiRutTien(ThemGuiRutTienRequest request, ChiTietSoTietKiem chitietSoTruoc, LoaiTietKiem loaitietkiem, LoaiTietKiem khongkyhan, string nghiepvu, SoTk soTietKiem) { var phieuGuiTien = this.TaoPhieuGuiRut(request); if (phieuGuiTien == null) { return(false); } var result = this.AddChiTietSo(phieuGuiTien, chitietSoTruoc, loaitietkiem, khongkyhan, nghiepvu, soTietKiem); return(result); }
public async Task <bool> ThemGuiRut(ThemGuiRutTienRequest request, SoTk soTietKiem, LoaiTietKiem loaiTietKiem, LoaiTietKiem khongKyHan, ChiTietSoTietKiem chitietSoTruoc) { if (request.Action == "GUI") { return(this.GuiRutTien(request, chitietSoTruoc, loaiTietKiem, khongKyHan, "GUI", soTietKiem)); } else if (request.Action == "RUT") { request.Action = double.Parse(request.SoTien.ToString()) == soTietKiem.SoDu ? "DONG" : "RUT"; request.SoTien = request.SoTien * -1; return(this.GuiRutTien(request, chitietSoTruoc, loaiTietKiem, khongKyHan, request.Action, soTietKiem)); } else { return(false); } }
private ChiTietSoTietKiem KhoiTaoChiTiet(PhieuGuiRutTien phieuGuiTien, ChiTietSoTietKiem chitietSoTruoc, LoaiTietKiem loaitietkiem, string nghiepvu) { var result = new ChiTietSoTietKiem { PhieuGuiRutTienId = phieuGuiTien.Id, Mskh = phieuGuiTien.Mskh, NgayGui = phieuGuiTien.Ngay, SoTienGui = phieuGuiTien.SoTien, LoaiTietKiemId = loaitietkiem.Id, LaiSuat = loaitietkiem.LaiSuat, }; if (nghiepvu == "RUT" || nghiepvu == "DONG") { result.SoTienGui = 0; result.NgayGui = null; result.SoTienRut = phieuGuiTien.SoTien; result.NgayRut = phieuGuiTien.Ngay; } result.SoDuDauKy = chitietSoTruoc.SoDuCuoiKy + phieuGuiTien.SoTien; return(result); }