Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            string adminLogin    = "******";
            string adminPassword = "******";

            string[] familyArray = new string[] { "Single", "Married", "Divorced", "Widowed" };
            int      clientID    = 0;


            //! Dictionary example
            var dictionary = new Dictionary <string, int>();

            int choice;

            //bool working = true;

startCode:
            System.Console.Write(@"Welcome to AlifCreditHistory
                Are you client or admin? 
                1. User
                2. Admin
                Please type reference number: ");

            int userInput;

            if (int.TryParse(Console.ReadLine(), out userInput))
            {
                if (userInput == 1)
                {
                    goto userLogin;
                }
                else if (userInput == 2)
                {
                    goto adminLogin;
                }
                else
                {
                    goto startCode;
                }
            }



userLogin:
            System.Console.WriteLine("\t\t\t\tUser Panel");
            System.Console.Write(@"
                1. Register
                2. Login
                Please type referece number: ");
            int clientInput;

            if (int.TryParse(Console.ReadLine(), out clientInput))
            {
                if (clientInput == 1)
                {
                    goto userRegister;
                }
                else if (clientInput == 2)
                {
                    goto clientLogin;
                }
                else
                {
                    ConsoleShow.Red("\t\t\t\tIncorrect choice. Try Again");
                    goto userLogin;
                }
            }

clientLogin:
            System.Console.WriteLine("\t\t\t\tPlease type your login and password");
            System.Console.Write("\t\t\t\tLogin: "******"\t\t\t\tPassword: "******"
                What you can do:
                1. Credit application filling 
                2. Applications State View
                3. See graph of payment by Application ID
                4. Exit
                Please type reference number: ");
            int clientFunctionsChoice;

            if (int.TryParse(Console.ReadLine(), out clientFunctionsChoice))
            {
                if (clientFunctionsChoice == 1)
                {
                    goto creditApplicationFilling;
                }
                else if (clientFunctionsChoice == 2)
                {
                    goto clientApplicationView;
                }
                else if (clientFunctionsChoice == 3)
                {
                    goto graphPayment;
                }
                else if (clientFunctionsChoice == 4)
                {
                    goto startCode;
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    System.Console.WriteLine("\t\t\t\tError try again");
                    Console.ForegroundColor = ConsoleColor.White;
                    goto clientFunctions;
                }
            }

graphPayment:
            System.Console.Write("Type Application ID: ");
            int     id      = int.Parse(Console.ReadLine());
            Payment payment = new Payment(clientID, id);

            payment.showPaymentGraphByClientID();
            goto clientFunctions;


creditApplicationFilling:
            System.Console.WriteLine("\t\t\t\tThere a few questions to fill out: ");
creditAmountChecking:
            System.Console.Write("\t\t\t\tAmount of credit: ");
            double creditAmount;

            if (!double.TryParse(Console.ReadLine(), out creditAmount))
            {
                goto creditAmountChecking;
            }
creditTermChecking:
            System.Console.Write("\t\t\t\tTerm (1 Month, 2 Months.....)\nPlease enter number of months:");
            int creditTerm;

            if (!int.TryParse(Console.ReadLine(), out creditTerm))
            {
                goto creditTermChecking;
            }
creditGoalChecking:
            System.Console.WriteLine("\t\t\t\tChoose goal for getting credit:\n\t\t\t\t1.Home Equipment\n\t\t\t\t2.Fix\n\t\t\t\t3.Phones\n\t\t\t\t4.Other");
            System.Console.Write("\t\t\t\tPlease type reference number: ");
            int clientGoalChoice; string clientGoal;

            if (!int.TryParse(Console.ReadLine(), out clientGoalChoice))
            {
                System.Console.WriteLine("\t\t\t\tError: Try Again");
                goto creditGoalChecking;
            }
            else if (clientGoalChoice < 1 || clientGoalChoice > 4)
            {
                System.Console.WriteLine("\t\t\t\tError: Try Again");
                goto creditGoalChecking;
            }
            else
            {
                switch (clientGoalChoice)
                {
                case 1: clientGoal = "Home"; break;

                case 3: clientGoal = "Fix"; break;

                case 4: clientGoal = "Others"; break;

                default: clientGoal = "Phone"; break;
                }
            }
creditSalaryChecking:
            System.Console.Write("\t\t\t\tYour Salary:");
            double creditSalary;

            if (!double.TryParse(Console.ReadLine(), out creditSalary))
            {
                goto creditSalaryChecking;
            }
            System.Console.WriteLine(creditSalary);

            Applications application = new Applications(clientID, creditAmount, creditTerm, clientGoal, creditSalary);

            application.RegisterForCredit();
            goto clientFunctions;

clientApplicationView:
            Applications applications = new Applications(clientID);

            applications.creditStateView();
            goto clientFunctions;

userRegister:
            System.Console.WriteLine("\t\t\t\tPlease fill following information carefully!!!");
            System.Console.Write("\t\t\t\tEnter your Firstname: ");
            string tempFirstname = Console.ReadLine();

            System.Console.Write("\t\t\t\tEnter your Lastname: ");
            string tempSecondname = Console.ReadLine();

            System.Console.Write("\t\t\t\tEnter your Middlename: ");
            string tempMiddlename = Console.ReadLine();

loginPasswordChecking:
            System.Console.Write("\t\t\t\tEnter your new login: (Use phone numbers) ");
            string login = Console.ReadLine();

            System.Console.Write("\t\t\t\tEnter your new password: "******"\t\t\t\tEnter your birthday in format(dd/MM/yyyy): ");
            string   birthday = Console.ReadLine();
            DateTime birthdayDate;
            int      tempAge;

            if (DateTime.TryParse(birthday, out birthdayDate))
            {
                tempAge = GetAge(birthdayDate);
            }
            else
            {
                System.Console.WriteLine("\t\t\t\tError: try again");
                goto ageIntEntering;
            }

            //! Check whether matches or not
tempGenderChecking:
            System.Console.Write("\t\t\t\tEnter your Gender: M/F");
            string tempGender = Console.ReadLine();

            if (tempGender == "M")
            {
                tempGender = "Male";
            }
            else if (tempGender == "F")
            {
                tempGender = "Female";
            }
            else
            {
                System.Console.WriteLine("\t\t\t\tError try again ... ");
                goto tempGenderChecking;
            }

            //! Citizenship Checking
tempCitizenshipChecking:
            System.Console.Write("\t\t\t\tEnter your citizenship: Tajikistan/Other");
            string tempCitizenship = Console.ReadLine();

            if (tempCitizenship.ToLower() == "tajikistan")
            {
                tempCitizenship = "Tajikistan";
            }
            else if (tempCitizenship.ToLower() == "other")
            {
                tempCitizenship = "Other";
            }
            else
            {
                System.Console.WriteLine("Error try again ... ");
                goto tempCitizenshipChecking;
            }
            //! FamilyState Checking
tempFamilyChecking:
            bool isInFamilyArray = false;

            System.Console.Write("\t\t\t\tEnter your family state....\n\t\t\t\t1. Married\n\t\t\t\t2. Divorced\n\t\t\t\t3. Single\n\t\t\t\t4. Widowed\n\t\t\t\t4Type family state: ");
            string tempFamily = Console.ReadLine();

            foreach (var item in familyArray)
            {
                if (item.ToLower() == tempFamily.ToLower())
                {
                    isInFamilyArray = true;
                    tempFamily      = item;
                    break;
                }
            }
            if (!isInFamilyArray)
            {
                goto tempFamilyChecking;
            }
            System.Console.Write("Your City: ");
            string tempCity = Console.ReadLine();

            System.Console.Write("Your District (ex: Sino): ");
            string tempDistrict = Console.ReadLine();

            System.Console.Write("Your Street(ex: Shevchenko 23): ");
            string tempStreet = Console.ReadLine();

            System.Console.Write("Your apartment/house number: ");
            string tempHouse = Console.ReadLine();

ClientAdding:
            Client client = new Client(tempFirstname, tempSecondname, tempMiddlename, tempGender, tempAge, tempCitizenship, tempFamily, tempCity, tempDistrict, tempStreet, tempHouse);
            bool isAdded = client.AddClient();

            if (!isAdded)
            {
                goto ClientAdding;
            }
            Console.ForegroundColor = ConsoleColor.Green;
            System.Console.WriteLine("\t\t\t\tCongratulations..... You have done it\n Now you may Login");
            Console.ForegroundColor = ConsoleColor.White;
            goto userLogin;


            /// Admin Login
adminLogin:
            System.Console.WriteLine(@"                     Admin Panel:");
            System.Console.Write("Admin Login: "******"Admin Password: "******"Error: not found ");
                goto adminLogin;
            }

            /// Second Stage
adminDashboard:
            System.Console.Write(@"Admin Dashboard:
                1. Info about Client by ID
                2. Show All Clients with ID
                3. Register Admin
                4. Exit
                Type reference number: ");
            if (int.TryParse(Console.ReadLine(), out choice))
            {
                if (choice == 1 || choice == 2 || choice == 3 || choice == 4)
                {
                    goto adminFuntions;
                }
                else
                {
                    System.Console.WriteLine("Incorrect choice");
                    goto adminDashboard;
                }
            }
            else
            {
                System.Console.WriteLine("Incorrect choice");
                goto adminDashboard;
            }

adminFuntions:
            Client client1 = new Client();

            switch (choice)
            {
            case 1:
            {
                //! Choices Like CreditHistory, PaymentHistory, Client Info
                System.Console.Write("Enter client ID: ");
                int userClientId = int.Parse(Console.ReadLine());
                client1 = new Client(userClientId);
                client1.showByClientId(userClientId);
                goto adminDashboard;
            }
            break;

            case 2:
            {
                //! Choices Like Client Info
                System.Console.WriteLine();
                client1.showAllClients();
                goto adminDashboard;
            }
            break;

            case 3:
            {
                System.Console.WriteLine("Enter new Login and Password for new Admin");
                System.Console.Write("Login: "******"Password: "******"Admin Registered");
                    goto adminDashboard;
                }
                else
                {
                    System.Console.WriteLine("Error while Registering");
                    goto adminFuntions;
                }
            }
            break;

            case 4:
            {
                goto startCode;
            }
            break;
            }
        }
Ejemplo n.º 2
0
        public void showPaymentGraphByClientID()
        {
            int clientID     = this.ClientID;
            int appPaymentID = this.ID;

            if (IsPaymentIDExist() == true)
            {
                SqlConnection connection = new SqlConnection(Connection.connectionString);

                if (connection.State == ConnectionState.Open)
                {
                    connection.Close();
                }
                connection.Open();

                System.Console.WriteLine("ApplicationID\t\tPaymentDate\t\tAmount\t\tDelays");

                string commandText1 = $"Select PercentCredit, Goal from Applications where ID = {appPaymentID} and ClientID = {clientID}";

                SqlCommand    command1 = new SqlCommand(commandText1, connection);
                SqlDataReader reader1  = command1.ExecuteReader();
                string        percent  = "";
                string        goal     = "";
                while (reader1.Read())
                {
                    percent = reader1.GetValue(0).ToString();
                    goal    = reader1.GetValue(1).ToString();
                }
                reader1.Close();

                if (percent != "")
                {
                    percent = " With " + percent + "% per term";
                }
                if (goal != "")
                {
                    goal = " for " + goal;
                }
                string        commandText = $"Select ID, DatePayment, AmountShouldPay, Delays from Payment where ID = {appPaymentID}";
                SqlCommand    command     = new SqlCommand(commandText, connection);
                SqlDataReader reader      = command.ExecuteReader();

                double sumAmount = 0;

                while (reader.Read())
                {
                    string applicationID   = reader.GetValue(0).ToString();
                    string datePayment     = reader.GetValue(1).ToString().Substring(0, 10);
                    string amountShouldPay = reader.GetValue(2).ToString().Substring(0, 5);
                    string delays          = reader.GetValue(3).ToString();
                    sumAmount += double.Parse(amountShouldPay);
                    System.Console.Write(appPaymentID);

                    for (int i = 0; i < 13 - applicationID.Length; i++)
                    {
                        System.Console.Write(" ");
                    }
                    Console.Write("\t\t" + datePayment);
                    for (int i = 0; i < 3; i++)
                    {
                        System.Console.Write(" ");
                    }
                    Console.Write("\t\t" + amountShouldPay);
                    Console.Write("\t\t" + delays + "\n");
                }
                Console.WriteLine("\t\t\t\t\t\t" + sumAmount.ToString() + percent + goal);
                connection.Close();
                reader.Close();
            }
            else
            {
                ConsoleShow.Red("No such application found\n");
            }
        }