コード例 #1
0
ファイル: Program.cs プロジェクト: Plussa/BankDBapp
        private static void GUITransferAccount()
        {
            GUIShowCustomer();
            bool validResponse = false;
            int  response;
            int  response2;

            do
            {
                Console.WriteLine(@"

                           Select Customernumber to be transferred to another customer.

                        ");

                string guessInput = Console.ReadLine();

                // convert string to number
                validResponse = int.TryParse(guessInput, out response);
            } while (!validResponse);


            do
            {
                Console.WriteLine(@"

                           Select Customernumber of a new account holder.

                        ");

                string guessInput = Console.ReadLine();

                // convert string to number
                validResponse = int.TryParse(guessInput, out response2);
            } while (!validResponse);


            if (confirmInput())
            {
                accounts dummy = context.accounts.Find(response);
                dummy.customer_number = response2;
                context.SaveChanges();
                Console.WriteLine($"Account {response} has new customer...");
            }
            Console.ReadLine();

            /*                       Asiakas dummy = customerList.
             *
             *                         Find(x => x.customerNumber == response);
             *
             *                     Console.WriteLine($"Account {response} removed...");
             *                     customerList.Remove(dummy);
             *                 }
             */
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Plussa/BankDBapp
        private static void GUIChangeSaldo()
        {
            GUIShowAccount();


            bool    validResponse = false;
            int     response      = default;
            decimal response2     = default;

            do
            {
                Console.WriteLine(@"
                           Select Account?
            ");

                string guessInput = Console.ReadLine();

                // convert string to number
                validResponse = int.TryParse(guessInput, out response);
            } while (!validResponse);
            do
            {
                Console.WriteLine(@"

                           Initial change in saldo (negative for withdrawal)?

            ");

                string guessInput = Console.ReadLine();

                // convert string to number
                validResponse = decimal.TryParse(guessInput, out response2);
            } while (!validResponse);

            //---------------------------------------------------------------------------
            accounts dummy = context.accounts.Find(response);

            if (dummy.account_type.Equals(BankDefs.BankAccount))
            {
                dummy.account_saldo += response2;
                context.SaveChanges();
                Console.WriteLine($"Account {response} saldo changed...");
            }

            else
            {
                decimal?dummy2 = dummy.account_saldo + response2;

                if (dummy2 >= 0)
                {
                    dummy.account_saldo += response2;
                    context.SaveChanges();
                    Console.WriteLine($"Account {response} saldo changed...");
                }

                else if (dummy2 >= -dummy.credit_limit)
                {
                    dummy.account_saldo += response2;
                    context.SaveChanges();
                    Console.WriteLine($"Account uses now credit...");
                }

                else
                {
                    Console.WriteLine($"Account saldo cannot go that low...");
                }
            }
            Console.ReadLine();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Plussa/BankDBapp
        private static void GUICreateCreditAccount()
        {
            bool validResponse = false;
            //double response = default;
            //double response2 = default;
            int     accountType    = 2;
            int     customerNumber = default;
            decimal creditLimit    = default;
            decimal currentSaldo   = default;

            GUIShowCustomer();

            do
            {
                Console.WriteLine(@"

                        Who gets new credit account (customer number)?

                ");

                string guessInput = Console.ReadLine();

                // convert string to number
                validResponse = int.TryParse(guessInput, out customerNumber);
            } while (!validResponse);



            do
            {
                Console.WriteLine(@"

                        Credit Limit?

                ");

                string guessInput = Console.ReadLine();

                // convert string to number
                validResponse = decimal.TryParse(guessInput, out creditLimit);
            } while (!validResponse);



            do
            {
                Console.WriteLine(@"

                           Initial saldo?
            ");

                string guessInput = Console.ReadLine();

                // convert string to number
                validResponse = decimal.TryParse(guessInput, out currentSaldo);
            } while (!validResponse);



            /*            do
             *          {
             *              Console.WriteLine(@"
             *
             *                         Initial creditlimit (0 to inifinity)?
             *          ");
             *
             *              string guessInput = Console.ReadLine();
             *
             *              // convert string to number
             *              validResponse = double.TryParse(guessInput, out response2);
             *
             *          } while (!validResponse);
             */


            if (confirmInput())
            {
                var henkilö = context.customers.FirstOrDefault <customers>
                                  (x => x.customer_number.Equals(customerNumber));



                var newAccount = new accounts()
                {
                    account_name    = henkilö.customer_last_name,
                    account_type    = accountType,
                    account_saldo   = currentSaldo,
                    credit_limit    = creditLimit,
                    customer_number = customerNumber
                };

                context.accounts.Add(newAccount);
                context.SaveChanges();
            }


            /*
             *              if (confirmInput())
             *              {
             *                  LuottoTili newAccount = new LuottoTili(saldo: response, creditLimit: response2);
             *                 accountList.Add(newAccount);
             *            }
             */
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: Plussa/BankDBapp
        private static void GUICreateBankAccount()
        {
            bool    validResponse  = false;
            int     customerNumber = default;
            int     accountType    = 1;
            decimal creditLimit    = default;
            decimal currentSaldo   = default;

            GUIShowCustomer();

            do
            {
                Console.WriteLine(@"

                        Who gets new account (customer number)?

                ");

                string guessInput = Console.ReadLine();

                // convert string to number
                validResponse = int.TryParse(guessInput, out customerNumber);
            } while (!validResponse);

            /*           do
             *         {
             *
             *             Console.WriteLine(@"
             *
             *                     What is account type (1 = bank, 2 = credit)?
             *
             *             ");
             *
             *             string guessInput = Console.ReadLine();
             *
             *             // convert string to number
             *
             *             validResponse = int.TryParse(guessInput, out accountType);
             *
             *         } while (!validResponse);
             *
             *
             *
             *         if (accountType.Equals(2))
             *         {
             *             do
             *             {
             *                 Console.WriteLine(@"
             *
             *                     Credit Limit?
             *
             *             ");
             *
             *                 string guessInput = Console.ReadLine();
             *
             *                 // convert string to number
             *                 validResponse = decimal.TryParse(guessInput, out creditLimit);
             *
             *             } while (!validResponse);
             *
             *         }
             */


            do
            {
                Console.WriteLine(@"

                        Current saldo?

                ");

                string guessInput = Console.ReadLine();



                // convert string to number
                validResponse = decimal.TryParse(guessInput, out currentSaldo);
            } while (!validResponse);



            if (confirmInput())
            {
                var henkilö = context.customers.FirstOrDefault <customers>
                                  (x => x.customer_number.Equals(customerNumber));



                var newAccount = new accounts()
                {
                    account_name    = henkilö.customer_last_name,
                    account_type    = accountType,
                    account_saldo   = currentSaldo,
                    credit_limit    = creditLimit,
                    customer_number = customerNumber
                };

                context.accounts.Add(newAccount);
                context.SaveChanges();
            }
        }