Beispiel #1
0
        public static void Transfer(int asd)
        {
            int NoRek = asd;

            Console.WriteLine("1. Transfer Between Account");
            Console.WriteLine("2. Transfer Between Bank ");
            Console.WriteLine("3. Back to Menu");
            Console.WriteLine();
            Console.Write("Input : ");
            int choice = Convert.ToInt32(Console.ReadLine());

            switch (choice)
            {
            default:
                Console.WriteLine("Please input 1-3");
                break;

            case 1:
                TransferRek(NoRek);
                break;

            case 2:
                TransferBank(NoRek);
                break;

            case 3:
                MasterMenuUser.User(NoRek);
                break;
            }
        }
Beispiel #2
0
        public static void TransferBank(int asd)
        {
            int num = new Random().Next(1000, 99999);

            string[] line_detect;
            string[] line_specific;
            int      linenumber;
            int      rek_pengirim   = asd;
            var      data           = new object[20];
            var      data_trf       = new object[5];
            var      rmv_empty_line = File.ReadAllLines(path + "UserData.txt").Where(arg => !string.IsNullOrWhiteSpace(arg));

            File.WriteAllLines(path + "UserData.txt", rmv_empty_line);
            bool a = true;

            while (a)
            {
                linenumber = 0;
                Console.WriteLine("Enter Bank Code");
                data_trf[3] = Console.ReadLine();
                Console.WriteLine("Enter Account Destination :");
                data_trf[0] = Console.ReadLine();
                Console.WriteLine("Enter Total Transfer");
                data_trf[1] = Console.ReadLine();
                Console.WriteLine("Enter Description :");
                data_trf[2] = Console.ReadLine();
                string nama_other_bank = "";
                foreach (string line in File.ReadLines(path + "kodebank.txt"))
                {
                    data = line.Split(',');
                    linenumber++;
                    if (data_trf[3].Equals(data[0]))
                    {
                        nama_other_bank = Convert.ToString(data[0]);
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
                Console.Clear();
                Console.WriteLine("Bank Destination : " + data[1]);

                foreach (string line in File.ReadLines(path + "UserData.txt"))
                {
                    data = line.Split('#');
                    linenumber++;
                    if (data_trf[0].Equals(data[11]))
                    {
                        break;
                    }
                }
                Console.WriteLine("Account Destination : " + data_trf[0]);
                Console.WriteLine("Account Name Destination : " + data[1]);
                Console.WriteLine("Total Transfer : " + data_trf[1]);
                Console.WriteLine("Are you sure? (y/n)");
                Console.Write("Enter : ");
                string input = Console.ReadLine().ToLower();
                if (input == "y")
                {
                    if (true)
                    {
                        foreach (string line in File.ReadLines(path + "UserData.txt"))
                        {
                            data = line.Split('#');
                            if (rek_pengirim.Equals(Convert.ToInt32(data[11])))
                            {
                                break;
                            }
                            else
                            {
                                continue;
                            }
                        }
                        if (Convert.ToInt32(data_trf[1]) + 6500 > Convert.ToInt32(data[13]))
                        {
                            Console.Clear();
                            Console.WriteLine("Transaction Failed!!");
                            Console.WriteLine("Not Enought Balance");
                        }
                        else
                        {
                            foreach (string line in File.ReadLines(path + "bank-" + data_trf[3] + ".txt"))
                            {
                                data = line.Split('#');
                                if (data_trf[0].Equals(data[11]))
                                {
                                    break;
                                }
                                else
                                {
                                    continue;
                                }
                            }
                            if (!data_trf[0].Equals(data[11]))
                            {
                                Console.Clear();
                                Console.WriteLine(data_trf[0]);
                                Console.WriteLine(data[11]);
                                Console.WriteLine("Transaction Failed!!");
                                Console.WriteLine("Data Not Found");
                            }
                            else
                            {
                                Console.Clear();
                                Console.WriteLine("Transaction Success!");
                                Console.WriteLine("Ref : " + "TRX" + num);
                                Console.WriteLine("Bank Destination : " + nama_other_bank);
                                Console.WriteLine("Account Destination : " + data_trf[0]);
                                Console.WriteLine("Total Transfer : " + data_trf[1]);
                                Console.WriteLine("Time : " + DateTime.Now);
                                linenumber = 0;
                                foreach (string line in File.ReadLines(path + "UserData.txt"))
                                {
                                    data = line.Split('#');
                                    linenumber++;
                                    if (rek_pengirim.Equals(Convert.ToInt32(data[11])))
                                    {
                                        break;
                                    }
                                }
                                line_detect   = File.ReadAllLines(path + "UserData.txt");
                                line_specific = line_detect[linenumber - 1].Split('#');
                                File.WriteAllText(path + "UserData.txt", File.ReadAllText(path + "UserData.txt").Replace(line_detect[linenumber - 1], line_detect[linenumber - 1].Replace(line_specific[13], Convert.ToString((Convert.ToInt32(data[13]) - Convert.ToInt32(data_trf[1]))))));


                                using (var sw = new StreamWriter(path + ("mutasi-" + data[11] + ".txt"), true))
                                {
                                    sw.WriteLine(DateTime.Now + "," + "TRX" + num + "," + rek_pengirim + "," + data_trf[3] + "+" + data_trf[0] + "," + "C" + "," + data_trf[1] + "," + Convert.ToString((Convert.ToInt32(data[13]) - Convert.ToInt32(data_trf[1]))) + "," + data_trf[2]);
                                }
                            }
                        }
                    }
                    Console.Write("Do you want to Transaction Again? (y/n) : ");
                    string ask_2 = Console.ReadLine().ToLower();
                    if (ask_2 == "y")
                    {
                        Console.Clear();
                    }
                    if (ask_2 == "n")
                    {
                        Console.Clear();
                        MasterMenuUser.User(asd);
                    }
                }
                else
                {
                    Console.Clear();
                }
            }
        }
Beispiel #3
0
        public static void CashDeposit(int a)
        {
            Console.Clear();
            int    NoRek      = a;
            var    dbUserData = File.ReadAllLines(path + "UserData.txt");
            int    packet;
            double nominal = 0;
            bool   chk;

            do
            {
                chk = false;
                Console.WriteLine("////////////////////////////////////////////////////////////////////////////////////////////////////////////////////");
                Console.WriteLine("\t//\t\t\t\t SELECT THE NOMIMAL OF PACKAGE DEPOSITS \t\t\t\t//");
                Console.WriteLine("\t//\t\t\t\t\t\t\t\t\t\t\t\t\t//");
                Console.WriteLine("\t//\t\t\t 1 <= 50.000 \t\t\t 6 <= 750.000   \t\t\t\t//");
                Console.WriteLine("\t//\t\t\t 2 <= 100.000 \t\t\t 7 <= 1.000.000 \t\t\t\t//");
                Console.WriteLine("\t//\t\t\t 3 <= 150.000 \t\t\t 8 <= 1.500.000 \t\t\t\t//");
                Console.WriteLine("\t//\t\t\t 4 <= 250.000 \t\t\t 9 <= 2.000.000 \t\t\t\t//");
                Console.WriteLine("\t//\t\t\t 5 <= 500.000 \t\t\t 10 <= Adjust Nominal\t\t\t\t//");
                Console.WriteLine("\t//\t\t\t              \t\t\t 11 <= Back To Menu\t\t\t\t//");
                Console.WriteLine("////////////////////////////////////////////////////////////////////////////////////////////////////////////////////");
                packet = Convert.ToInt32(Console.ReadLine());
                switch (packet)
                {
                default:
                    Console.WriteLine("Please input 1-10");
                    Console.ReadKey();
                    Console.Clear();
                    CashDeposit(NoRek);
                    break;

                case 1:
                    nominal = 50000;
                    break;

                case 2:
                    nominal = 100000;
                    break;

                case 3:
                    nominal = 150000;
                    break;

                case 4:
                    nominal = 250000;
                    break;

                case 5:
                    nominal = 500000;
                    break;

                case 6:
                    nominal = 750000;
                    break;

                case 7:
                    nominal = 1000000;
                    break;

                case 8:
                    nominal = 1500000;
                    break;

                case 9:
                    nominal = 2000000;
                    break;

                case 10:
                    do
                    {
                        Console.WriteLine("Please Enter The Nominal");
                        nominal = Convert.ToDouble(Console.ReadLine());
                        chk     = false;
                        if (((nominal % 50000) != 0) || (nominal > 5000000) || nominal < 50000)
                        {
                            Console.WriteLine("Please enter nominal multiples of Rp50.000 AND minimum nominal is Rp50.000 AND maximum nominal is Rp5.000.000");
                            Console.ReadKey();
                            chk = true;
                        }
                    } while (chk);
                    break;

                case 11:
                    MasterMenuUser.User(NoRek);
                    Console.Clear();
                    break;
                }
                ScanMoney(nominal, NoRek);
            } while (chk);
        }
Beispiel #4
0
        public static void ChangePIN(int asd)
        {
            var data         = new object[20];
            var data_input   = new object[4];
            int rek_pengirim = asd;
            int linenumber   = 0;

            string[] line_detect;
            string[] line_specific;
            foreach (string line in File.ReadLines(path + "UserData.txt"))
            {
                data = line.Split('#');
                linenumber++;
                if (rek_pengirim.Equals(Convert.ToInt32(data[11])))
                {
                    break;
                }
            }
            Console.WriteLine("Enter Old PIN");
            data_input[0] = Console.ReadLine();
            Console.WriteLine("Enter New PIN");
            data_input[1] = Console.ReadLine();
            Console.WriteLine("Confirm New PIN");
            data_input[2] = Console.ReadLine();
            if (true)
            {
                if (!data_input[0].Equals(data[12]))
                {
                    Console.WriteLine("Wrong Old PIN");
                    Console.ReadKey();
                    Console.Clear();
                    ChangePIN(rek_pengirim);
                }
                else
                {
                    if (!data_input[1].Equals(data_input[2]))
                    {
                        Console.WriteLine("Confirmation PIN Not Valid");
                        Console.ReadKey();
                        Console.Clear();
                        ChangePIN(rek_pengirim);
                    }
                    else if ((Convert.ToInt32(data_input[1]) > 100000) && (Convert.ToInt32(data_input[1]) < 999999))
                    {
                        Console.WriteLine("Must be 6 digits");
                        Console.ReadKey();
                        Console.Clear();
                        ChangePIN(rek_pengirim);
                    }
                    else
                    {
                        line_detect   = File.ReadAllLines(path + "UserData.txt");
                        line_specific = line_detect[linenumber - 1].Split('#');
                        File.WriteAllText(path + "UserData.txt", File.ReadAllText(path + "UserData.txt").Replace(line_detect[linenumber - 1], line_detect[linenumber - 1].Replace(line_specific[12], Convert.ToString(data_input[1]))));
                        Console.WriteLine("Change PIN Successfuly, Please press any key to continue");
                        Console.ReadKey();
                        Console.Clear();
                        MasterMenuUser.User(rek_pengirim);
                    }
                }
            }
        }
Beispiel #5
0
        public static void Mutation(int asd)
        {
            int NoRek = asd;

            Console.Clear();
            bool     chk = false;
            Random   rnd = new Random();
            int      choice = 0, diff = 0;
            DateTime now   = System.DateTime.Now;
            DateTime dateF = System.DateTime.Now;
            DateTime dateT = System.DateTime.Now;

            Console.WriteLine("\n\t\t\t\t\t~~~~~~~~     Mutation       ~~~~~~~~");
            Console.WriteLine("\t\t\t\t\t~~~~~~~~                    ~~~~~~~~");
            Console.WriteLine("\t\t\t\t\t~~~~~~~~  1 <= Last 30 days ~~~~~~~~");
            Console.WriteLine("\t\t\t\t\t~~~~~~~~  2 <= Last 7 days  ~~~~~~~~");
            Console.WriteLine("\t\t\t\t\t~~~~~~~~  3 <= Last today  ~~~~~~~~");
            Console.WriteLine("\t\t\t\t\t~~~~~~~~  4 <= Adjust date  ~~~~~~~~");
            Console.WriteLine("\t\t\t\t\t~~~~~~~~  5 <= Back To Menu  ~~~~~~~~");
            choice = Convert.ToInt32(Console.ReadLine());

            switch (choice)
            {
            default:
                Console.WriteLine("Please input 1-4");
                Console.ReadKey();
                Console.Clear();
                Mutation(NoRek);
                break;

            case 1:
                dateF = Convert.ToDateTime((now.AddDays(diff = -30)));
                break;

            case 2:
                dateF = Convert.ToDateTime((now.AddDays(diff = -7)));
                break;

            case 3:
                dateF = Convert.ToDateTime((now.AddDays(diff = -1)));
                break;

            case 4:
                do
                {
                    try
                    {
                        Console.Clear();
                        Console.WriteLine("Enter date form in the format dd-mm-yyyy");
                        Console.WriteLine("Example 02 March 2018 = 02-04-2018");
                        dateF = DateTime.Parse(Console.ReadLine());
                        Console.WriteLine("Enter date to in the format dd-mm-yyyy");
                        Console.WriteLine("Example 02 March 2018 = 02-04-2018");
                        dateT = DateTime.Parse(Console.ReadLine()).AddHours(23.9999);
                        diff  = (dateT - dateF).Days;
                    }
                    catch
                    {
                        Console.WriteLine("Your date input does not match the format, Please Enter The Date Again ");
                        chk = true;
                        Console.ReadKey();
                    }
                    if (((now - dateF).Days > 30) || ((now - dateT).Days > 30))
                    {
                        Console.WriteLine("Please enter a maximum of the last 30 days");
                        chk = true;
                        Console.ReadKey();
                    }
                    else if (diff < 0)
                    {
                        Console.WriteLine("Input your date reversed, Please Check And Enter Your The Date Again ");
                        Math.Abs(diff);
                        chk = true;
                        Console.ReadKey();
                    }
                } while (chk);
                break;

            case 5:
                MasterMenuUser.User(NoRek);
                Console.Clear();
                break;
            }


            Console.Clear();
            ProgramMain.Emphasis(@"
                                                           IOIOIOIOIOIOIOIOIOIOIOIO
                                IOIOIOIOIOIOIOIOIOIOIOIOIOIO   MUTATION REPORTS   IOIOIOIOIOIOIOIOIOIOIOIOIOIO
                                                           IOIOIOIOIOIOIOIOIOIOIOIO ");
            Console.WriteLine("Date\t: {0} \nTime\t: {1} \nMachine\t: {2} \n", now.ToShortDateString(), now.ToLongTimeString(), Environment.MachineName + "#" + rnd.Next(100, 999));
            Console.WriteLine("Account Number\t:" + NoRek + "\n");
            Console.SetWindowSize(150, 30);
            var table = new ConsoleTable("TransID", "Date", "Acc Recipient", "Acc Sender", "Nominal", "D/C", "Balance", "Information");

            foreach (string line in File.ReadLines(path + "mutasi-" + NoRek + ".txt"))
            {
                var data = line.Split(',');

                if (Convert.ToDateTime(data[0]) > dateF && Convert.ToDateTime(data[0]) <= dateT)
                {
                    table.AddRow(data[1], data[0], data[3], data[2], data[5], data[4], data[6], data[7]);
                }
            }
            table.Write();
            Console.WriteLine();
            Console.ReadKey();
        }
Beispiel #6
0
        public static void CashWithdraw(int b)
        {
            int NoRek = b;

            Console.Clear();
            GetTID(NoRek);
            StringBuilder newfile    = new StringBuilder();
            var           dbUserData = File.ReadAllLines(path + "UserData.txt");
            int           packet;
            double        nominal = 0;
            double        remain  = 0;
            bool          chk;

            do
            {
                chk = false;
                Console.WriteLine("////////////////////////////////////////////////////////////////////////////////////////////////////////////////////");
                Console.WriteLine("\t//\t\t\t\t   SELECT THE NUMBER OF CASH PACKETS \t\t\t\t\t//");
                Console.WriteLine("\t//\t\t\t\t\t\t\t\t\t\t\t\t\t//");
                Console.WriteLine("\t//\t\t\t 1 <= 50.000 \t\t\t 6 <= 750.000 \t\t\t\t\t//");
                Console.WriteLine("\t//\t\t\t 2 <= 100.000 \t\t\t 7 <= 1.000.000 \t\t\t\t//");
                Console.WriteLine("\t//\t\t\t 3 <= 150.000 \t\t\t 8 <= 1.500.000 \t\t\t\t//");
                Console.WriteLine("\t//\t\t\t 4 <= 250.000 \t\t\t 9 <= 2.000.000 \t\t\t\t//");
                Console.WriteLine("\t//\t\t\t 5 <= 500.000 \t\t\t 10 <= Random\t\t\t\t\t//");
                Console.WriteLine("\t//\t\t\t              \t\t\t 11 <= Back To Menu\t\t\t\t//");
                Console.WriteLine("////////////////////////////////////////////////////////////////////////////////////////////////////////////////////");
                packet = Convert.ToInt32(Console.ReadLine());
                switch (packet)
                {
                default:
                    Console.WriteLine("Please input 1-10");
                    Console.ReadKey();
                    Console.Clear();
                    CashWithdraw(NoRek);
                    break;

                case 1:
                    nominal = 50000;
                    break;

                case 2:
                    nominal = 100000;
                    break;

                case 3:
                    nominal = 150000;
                    break;

                case 4:
                    nominal = 250000;
                    break;

                case 5:
                    nominal = 500000;
                    break;

                case 6:
                    nominal = 750000;
                    break;

                case 7:
                    nominal = 1000000;
                    break;

                case 8:
                    nominal = 1500000;
                    break;

                case 9:
                    nominal = 2000000;
                    break;

                case 10:
                    do
                    {
                        Console.WriteLine("Please Enter The Nominal");
                        nominal = Convert.ToDouble(Console.ReadLine());
                        chk     = false;
                        if (((nominal % 50000) != 0) || (nominal > 5000000) || (nominal < 50000))
                        {
                            Console.WriteLine("Please enter nominal multiples of Rp50.000 AND minimum nominal is Rp50.000 AND maximum nominal is Rp5.000.000");
                            Console.ReadKey();
                            chk = true;
                        }
                        foreach (string line in dbUserData)
                        {
                            var data = line.Split('#');
                            if (long.Parse(data[11]).Equals(NoRek))
                            {
                                remain = Convert.ToDouble(data[13]) - nominal;
                                if (remain < Convert.ToDouble(data[14]))
                                {
                                    Console.WriteLine("Your saldo is Rp{0} \nPlease Leave Rp{1} balance", data[13], data[14]);
                                    Console.ReadKey();
                                    chk = true;
                                    break;
                                }
                            }
                        }
                    } while (chk);
                    break;

                case 11:
                    MasterMenuUser.User(NoRek);
                    Console.Clear();
                    break;
                }
                foreach (string line in dbUserData)
                {
                    var    data = line.Split('#');
                    string temp = "";
                    if (long.Parse(data[11]).Equals(NoRek))
                    {
                        remain = Convert.ToDouble(data[13]) - nominal;
                        if (remain < Convert.ToDouble(data[14]))
                        {
                            Console.WriteLine("Your saldo is Rp{0} \nPlease Leave Rp{1} balance", data[13], data[14]);
                            Console.ReadKey();
                            chk = true;
                            CashWithdraw(NoRek);
                            break;
                        }
                        else
                        {
                            temp = line.Replace(Convert.ToString(data[13]), Convert.ToString(remain));
                            newfile.Append(temp + "\r\n");
                            continue;
                        }
                    }
                    newfile.Append(line + "\r\n");
                }
                File.WriteAllText(@"UserData.txt", newfile.ToString());
                FileStream   fs = new FileStream(path + "mutasi-" + NoRek + ".txt.", FileMode.Append, FileAccess.Write);
                StreamWriter sw = new StreamWriter(fs);

                sw.WriteLine(DateTime.Now + "," + TID + "," + NoRek + "," + NoRek + "," + "C" + "," + nominal + "," + remain + "," + "Cash Withdraw");
                sw.Flush();
                sw.Close();
                fs.Close();
            } while (chk);
            Console.Clear();
            Console.WriteLine("\n\t\t\t\t\t~~~~~~~~  Transaction Success  ~~~~~~~~");
            Console.WriteLine("\t\t\t\t\t~~~~~~~~                       ~~~~~~~~");
            Console.WriteLine("\t\t\t\t\t~~~~~~~~ Please Take The Money ~~~~~~~~");
            Console.ReadKey();
        }
Beispiel #7
0
        public static void User(int asd)
        {
            int NoRek = asd;
            int choice;

            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("============== M E N U  U S E R ==============");
            Console.WriteLine("=========     1. Check Balance      ==========");
            Console.WriteLine("=========     2. Transfer Cash      ==========");
            Console.WriteLine("=========     3. Cash Withdraw      ==========");
            Console.WriteLine("=========     4. Cash Deposit       ==========");
            Console.WriteLine("=========     5. Mutation           ==========");
            Console.WriteLine("=========     6. Change PIN         ==========");
            Console.WriteLine("=========     7. Exit               ==========");
            Console.WriteLine("==============================================\n");
            Console.WriteLine("== Choice Number 1 / 2 / 3 / 4 / 5 / 6 / 7  ==");
            choice = Convert.ToInt32(Console.ReadLine());
            switch (choice)
            {
            case 1:
                Console.Clear();
                ProgramUser.CheckBalance(NoRek);
                Console.Clear();
                MasterMenuUser.User(NoRek);
                break;

            case 2:
                Console.Clear();
                ProgramUser.Transfer(NoRek);
                Console.Clear();
                MasterMenuUser.User(NoRek);
                break;

            case 3:
                Console.Clear();
                ProgramUser.CashWithdraw(NoRek);
                Console.Clear();
                MasterMenuUser.User(NoRek);
                break;

            case 4:
                Console.Clear();
                ProgramUser.CashDeposit(NoRek);
                Console.Clear();
                MasterMenuUser.User(NoRek);
                break;

            case 5:
                Console.Clear();
                ProgramUser.Mutation(NoRek);
                Console.Clear();
                MasterMenuUser.User(NoRek);
                break;

            case 6:
                Console.Clear();
                ProgramUser.ChangePIN(NoRek);
                MasterMenuUser.User(NoRek);
                break;

            case 7:
                Environment.Exit(0);
                break;

            default:
                Console.WriteLine("\nInvalid Choice");
                Console.ReadKey();
                Console.Clear();
                MasterMenuUser.User(NoRek);
                break;
            }
            Console.ReadKey();
            Console.Clear();
        }
        static void Main()
        {
            Console.Title          = "ATM Console Simulation";
            Console.OutputEncoding = System.Text.Encoding.UTF8;
            bool a = true;

            while (a)
            {
                Console.WriteLine("Waiting for card swipe...");
                if (string.IsNullOrWhiteSpace(nokartu))
                {
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    nokartu = Console.ReadLine();
                    Console.ResetColor();
                }
                Console.Clear();
                Console.WriteLine("Input PIN");
                string         pin = "";
                ConsoleKeyInfo key;
                do
                {
                    key = Console.ReadKey(true);
                    if (key.Key != ConsoleKey.Backspace && key.Key != ConsoleKey.Enter)
                    {
                        pin += key.KeyChar;
                        Console.ForegroundColor = ConsoleColor.DarkYellow;
                        Console.Write("*");
                        Console.ResetColor();
                    }
                    else
                    {
                        if (key.Key == ConsoleKey.Backspace && pin.Length > 0)
                        {
                            pin = pin.Substring(0, (pin.Length - 1));
                            Console.Write("\b \b");
                        }
                    }
                }while (key.Key != ConsoleKey.Enter);
                var data = new object[20];
                foreach (string line in File.ReadLines(path + "UserData.txt"))
                {
                    data = line.Split('#');
                    if (nokartu.Equals(data[16]))
                    {
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
                if (nokartu.Equals(data[16]) && pin.Equals(data[12]))
                {
                    int NoRek = Convert.ToInt32(data[11]);
                    a = false;
                    if (data[15].Equals("user"))
                    {
                        Console.Clear();
                        MasterMenuUser.User(NoRek);
                    }
                    else
                    {
                        Console.Clear();
                        MasterMenuAdmin.Admin();
                    }
                }
                else
                {
                    Warning("\n\u0416\u0416\u0416 Wrong card or PIN \u0416\u0416\u0416");
                    Console.ReadKey();
                    Console.Clear();
                    nokartu = "";
                }
            }
        }