public int WithDraw(int money, string accountNo) { int totalMoney = GetTotalMoney(); int minMoney = GetMinWithDraw(accountNo); int currentMoney = GetCurrentMoney(accountNo); int requiredMoney = money; int thauChi = overDrawftBUL.GetThauChi(accountNo).Value; List <LogDTO> listLog = logDAL.GetLogToDay(accountNo); int soTienDaRut = 0; //So tien da rut trong ngay hom nay foreach (LogDTO item in listLog) { soTienDaRut += item.Amout; } if (money % 50000 != 0) { return(0); //So tien khong chia het cho 50000 } if (money > currentMoney + thauChi) { return(1); //So tien trong tai khoan khong du } if (soTienDaRut + requiredMoney > minMoney) { return(2); //Chi duoc rut toi da minMoney/1ngay } if (money > totalMoney) { return(3); //So tien trong cay ATM khong du } //So luong to tien cac loai int number20 = GetNumberOfMoney(20); int number50 = GetNumberOfMoney(50); int number100 = GetNumberOfMoney(100); int number200 = GetNumberOfMoney(200); int number500 = GetNumberOfMoney(500); if (money / 500000 > 0 && number500 > 0) { int soToTienTieuThu = money / 500000; if (soToTienTieuThu >= number500) { money = money - number500 * 500000; UpdateNumberOfMoney(500, 0); } else { number500 = number500 - soToTienTieuThu; money = money - soToTienTieuThu * 500000; UpdateNumberOfMoney(500, number500); } } if (money / 200000 > 0 && number200 > 0) { int soToTienTieuThu = money / 200000; if (soToTienTieuThu >= number200) { money = money - number200 * 200000; UpdateNumberOfMoney(200, 0); } else { number200 = number200 - soToTienTieuThu; money = money - soToTienTieuThu * 200000; UpdateNumberOfMoney(200, number200); } } if (money / 100000 > 0 && number100 > 0) { int soToTienTieuThu = money / 100000; if (soToTienTieuThu >= number100) { money = money - number100 * 100000; UpdateNumberOfMoney(100, 0); } else { number100 = number100 - soToTienTieuThu; money = money - soToTienTieuThu * 100000; UpdateNumberOfMoney(100, number100); } } if (money / 50000 > 0 && number50 > 0) { int soToTienTieuThu = money / 50000; if (soToTienTieuThu >= number50) { money = money - number50 * 50000; UpdateNumberOfMoney(50, 0); } else { number50 = number50 - soToTienTieuThu; money = money - soToTienTieuThu * 50000; UpdateNumberOfMoney(50, number50); } } if (money / 20000 > 0 && number20 > 0) { int soToTienTieuThu = money / 20000; if (soToTienTieuThu >= number50) { money = money - number20 * 20000; UpdateNumberOfMoney(20, 0); } else { number20 = number20 - soToTienTieuThu; money = money - soToTienTieuThu * 20000; UpdateNumberOfMoney(20, number20); } } UpdateMoney(currentMoney - requiredMoney - 1000 - 100, accountNo); string created_at = DateTime.Now.ToString(); int atm_id = 1; logBUL.StoreLog(atm_id, accountNo, created_at, requiredMoney, 1, "Rút tiền"); return(4); //Thanh cong }
public List <LogDTO> GetLogToDay(string stk) { return(logDAL.GetLogToDay(stk)); }