Пример #1
0
        // viết các câu lệnh xử lí phần rút tiền
        public bool HandleWithdrawal(double amount)
        {
            double balanceNew = userLogin.Balance - amount;

            if (model.UpdateBalanceWithdraw(balanceNew, userLogin.BankId))
            {
                History history = new History(StringGenerator.NumberGen(3), userLogin.BankId, "", amount, "Withdraw");
                model.InsertToTableHistory(history);
                userLogin = model.SelectByUsernameFromTableUser(userLogin.Username);
                return(true);
            }
            return(false);
        }
Пример #2
0
        // viết các câu lệnh xử lí phần chuyển khoản
        public bool HandleTransfers(double amount, string content)
        {
            double balanceSource        = userLogin.Balance - amount;
            double balanceBeneficiaries = userBeneficiaries.Balance + amount;

            if (model.Transactions(userLogin.BankId, userBeneficiaries.BankId, balanceSource, balanceBeneficiaries))
            {
                History history = new History(StringGenerator.NumberGen(3), userLogin.BankId, userBeneficiaries.BankId, amount, content);
                model.InsertToTableHistory(history);
                userLogin = model.SelectByUsernameFromTableUser(userLogin.Username);
                return(true);
            }

            return(false);
        }
Пример #3
0
        // Tạo form Signup .
        public void Signup()
        {
            Console.WriteLine("====================== SIGN UP =======================");
            Account account = new Account();
            User    user    = new User();

            while (true)
            {
                Console.WriteLine("Please Enter Username: "******"Please Enter Password: "******"Please Enter Fullname: ");
                string fullName          = Console.ReadLine();
                string validatedFullName = validate.ValidateFullname(fullName);
                if (validatedFullName == null)
                {
                    user.Fullname = fullName;
                    break;
                }
                else
                {
                    Console.WriteLine(validatedFullName);
                }
            }

            while (true)
            {
                Console.WriteLine("Please Enter BirthDay(dd/mm/yyyy): ");
                string DoB = Console.ReadLine();
                string validatedBirthday = validate.ValidateBirthday(DoB);
                if (validatedBirthday == null)
                {
                    user.Birthday = DoB;
                    break;
                }
                else
                {
                    Console.WriteLine(validatedBirthday);
                }
            }

            while (true)
            {
                Console.WriteLine("Please Enter Phone Number: ");
                string phoneNumber    = Console.ReadLine();
                string validatedPhone = validate.ValidatePhone(phoneNumber);
                if (validatedPhone == null)
                {
                    user.Phone = phoneNumber;
                    break;
                }
                else
                {
                    Console.WriteLine(validatedPhone);
                }
            }

            while (true)
            {
                Console.WriteLine("Please Enter Identity Card: ");
                string userId          = Console.ReadLine();
                string validatedUserId = validate.ValidateUserId(userId);
                if (validatedUserId == null)
                {
                    user.UserId = userId;
                    break;
                }
                else
                {
                    Console.WriteLine(validatedUserId);
                }
            }

            while (true)
            {
                Console.WriteLine("Please Enter Email: ");
                string email          = Console.ReadLine();
                string validatedEmail = validate.ValidateEmail(email);
                if (validatedEmail == null)
                {
                    user.Email = email;
                    break;
                }
                else
                {
                    Console.WriteLine(validatedEmail);
                }
            }

            while (true)
            {
                Console.WriteLine("Please Enter Gender (F(female)/M(male)/O(other)): ");
                string inputGender = Console.ReadLine();
                inputGender = inputGender.ToLower();
                Console.WriteLine("===" + inputGender);
                string validateGender = validate.ValidateGender(inputGender);
                int    gender         = 0;
                if (validateGender == null)
                {
                    switch (inputGender)
                    {
                    case "f":
                        gender = 0;
                        break;

                    case "m":
                        gender = 1;
                        break;

                    case "o":
                        gender = 2;
                        break;

                    default:
                        Console.WriteLine("Gender incorrect. Please re-enter gender.");
                        break;
                    }

                    user.Gender = gender;
                    break;
                }
                else
                {
                    Console.WriteLine(validateGender);
                }
            }

            user.BankId   = StringGenerator.NumberGen(6);
            user.CreateAt = longTime.CurrentTimeMillis();
            user.Balance  = 5000000;

            Console.WriteLine("Processing ......");

            if (controller.HandleSignup(account, user))
            {
                Console.WriteLine("Sign Up Success");
            }
            else
            {
                Console.WriteLine("Sign Up Failed. Please try again.");
            }

            Console.WriteLine("=========================================================");
        }