예제 #1
0
        public static int DeleteLoanById(int id)
        {
            int iSuccess = 0;
            int uSuccess = 0;

            BorrowORLoanInfo loanInfo = LoanDAL.GetLoanById(id);
            UserInfo         userInfo = UserDAL.GetUserByName(loanInfo.Lender);

            LoanDAL.DeleteLoanById(id, out iSuccess);

            if (iSuccess > 0)
            {
                if (loanInfo.BorrowORLoanType == 2)
                {
                    CardInfo cardInfo   = CardDAL.GetCardByCardNumber(loanInfo.Lender, userInfo.Id);
                    float    amount     = cardInfo.Amount - loanInfo.Amount;
                    float    LoanAmount = cardInfo.LoanAmount - loanInfo.Amount;
                    CardDAL.UpdateCardAmount(amount, LoanAmount, cardInfo.Id, 4, out uSuccess);
                }
            }
            if (iSuccess > 0 && ((loanInfo.BorrowORLoanType == 2 && uSuccess > 0) || (loanInfo.BorrowORLoanType != 2 && uSuccess == 0)))
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
예제 #2
0
        public static int DeleteBorrowedById(int id)
        {
            int iSuccess = 0;
            int uSuccess = 0;

            BorrowORLoanInfo borrowInfo = BorrowDAL.GetBorrowById(id);
            UserInfo         userInfo   = UserDAL.GetUserByName(borrowInfo.Borrower);

            BorrowDAL.DeleteBorrowed(id, out iSuccess);

            if (iSuccess > 0)
            {
                if (borrowInfo.BorrowORLoanType == 2)
                {
                    CardInfo cardInfo     = CardDAL.GetCardByCardNumber(borrowInfo.BorrowedAccount, userInfo.Id);
                    float    amount       = cardInfo.Amount - borrowInfo.Amount;
                    float    borrowAmount = cardInfo.BorrowAmount - borrowInfo.Amount;
                    CardDAL.UpdateCardAmount(amount, borrowAmount, cardInfo.Id, 3, out uSuccess);
                }
            }
            if (iSuccess > 0 && ((borrowInfo.BorrowORLoanType == 2 && uSuccess > 0) || (borrowInfo.BorrowORLoanType != 2 && uSuccess == 0)))
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
예제 #3
0
        public static int InsertOrUpdatetoLoan(BorrowORLoanInfo info)
        {
            int iSuccess = 0;
            int uSuccess = 0;
            BorrowORLoanInfo loanInfo = new BorrowORLoanInfo();
            UserInfo         userInfo = UserDAL.GetUserByName(info.Lender);
            CardInfo         cardInfo = CardDAL.GetCardByCardNumber(info.LoanAccount, userInfo.Id);

            if (info.Id > 0)
            {
                loanInfo = LoanDAL.GetLoanById(info.Id);
            }
            LoanDAL.InsertOrUpdatetoLoan(info, out iSuccess);
            if (iSuccess > 0 && info.BorrowORLoanType == 2)
            {
                float amount     = 0;
                float loanAmount = 0;
                if (info.Id > 0)
                {
                    amount     = cardInfo.Amount + (info.Amount - loanInfo.Amount);
                    loanAmount = cardInfo.Amount + (info.Amount - loanInfo.Amount);
                }
                else
                {
                    amount     = cardInfo.Amount + info.Amount;
                    loanAmount = cardInfo.Amount + info.Amount;
                }
                CardDAL.UpdateCardAmount(amount, loanAmount, cardInfo.Id, 4, out uSuccess);
            }

            if ((iSuccess > 0 && info.Id > 0) && ((info.BorrowORLoanType == 2 && uSuccess > 0) || (info.BorrowORLoanType != 2 && uSuccess == 0)))
            {
                return(2);
            }
            else if ((iSuccess > 0 && info.Id == 0) && ((info.BorrowORLoanType == 2 && uSuccess > 0) || (info.BorrowORLoanType != 2 && uSuccess == 0)))
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
예제 #4
0
        public static int InsertOrUpdatetoBorrowed(BorrowORLoanInfo info)
        {
            int iSuccess = 0;
            int uSuccess = 0;
            BorrowORLoanInfo borrowInfo = new BorrowORLoanInfo();
            UserInfo         userInfo   = UserDAL.GetUserByName(info.Borrower);
            CardInfo         cardInfo   = CardDAL.GetCardByCardNumber(info.BorrowedAccount, userInfo.Id);

            if (info.Id > 0)
            {
                borrowInfo = BorrowDAL.GetBorrowById(info.Id);
            }
            BorrowDAL.InsertOrUpdatetoBorrowed(info, out iSuccess);
            if (iSuccess > 0 && info.BorrowORLoanType == 2)
            {
                float amount       = 0;
                float borrowAmount = 0;
                if (info.Id > 0)
                {
                    amount       = cardInfo.Amount + (info.Amount - borrowInfo.Amount);
                    borrowAmount = cardInfo.BorrowAmount + (info.Amount - borrowInfo.Amount);
                }
                else
                {
                    amount       = cardInfo.Amount + info.Amount;
                    borrowAmount = cardInfo.BorrowAmount + info.Amount;
                }
                CardDAL.UpdateCardAmount(amount, borrowAmount, cardInfo.Id, 3, out uSuccess);
            }

            if ((iSuccess > 0 && info.Id > 0) && ((info.BorrowORLoanType == 2 && uSuccess > 0) || (info.BorrowORLoanType != 2 && uSuccess == 0)))
            {
                return(2);
            }
            else if ((iSuccess > 0 && info.Id == 0) && ((info.BorrowORLoanType == 2 && uSuccess > 0) || (info.BorrowORLoanType != 2 && uSuccess == 0)))
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
예제 #5
0
 public static CardInfo GetCardByCardNumber(string cardNumber, int ownerId)
 {
     return(CardDAL.GetCardByCardNumber(cardNumber, ownerId));
 }