public static IBank GetBank(Transaction transaction)
        {
            string bankCode = string.Empty;
            IBank  bank     = null;

            if (transaction.CardDetail == null)
            {
                throw new Exception(Common.Constants.CardNotAvailable);
            }

            var cardNumber = transaction.CardDetail.CardNumber;

            if (!string.IsNullOrEmpty(cardNumber))
            {
                bankCode = cardNumber.Substring(0, 4);

                switch (bankCode)
                {
                case "1234":
                    bank = new HSBC(new FileLogger());
                    break;

                case "4567":
                    bank = new MCB(new EventViewerLogger());
                    break;

                default:
                    throw new Exception(Common.Constants.BankUnavailable);
                }
            }

            return(bank);
        }
示例#2
0
        static void Main(string[] args)
        {
            ICICI iCICIObj1 = new ICICI();

            iCICIObj1.AccountType = BankAccountTypeEnum.Saving;
            iCICIObj1.deposite(50000);

            ICICI iCICIObj2 = new ICICI();

            iCICIObj2.AccountType = BankAccountTypeEnum.Current;
            iCICIObj2.deposite(20000);

            Console.WriteLine("Saving account of ICICI " + iCICIObj1.getBalance());
            Console.WriteLine("Current account of ICICI " + iCICIObj2.getBalance());

            iCICIObj1.transfer(iCICIObj2, 5000);

            Console.WriteLine();

            Console.WriteLine("Saving account of ICICI " + iCICIObj1.getBalance());
            Console.WriteLine("Current account of ICICI " + iCICIObj2.getBalance());

            Console.WriteLine();

            HSBC hSBCObj1 = new HSBC();

            hSBCObj1.AccountType = BankAccountTypeEnum.Saving;
            hSBCObj1.deposite(50000);

            HSBC hSBCObj2 = new HSBC();

            hSBCObj2.AccountType = BankAccountTypeEnum.Current;
            hSBCObj2.deposite(20000);

            Console.WriteLine("Saving account of HSBC " + hSBCObj1.getBalance());
            Console.WriteLine("Current account of HSBC " + hSBCObj2.getBalance());

            hSBCObj1.transfer(hSBCObj2, 30000);

            Console.WriteLine();

            Console.WriteLine("Saving account of HSBC " + hSBCObj1.getBalance());
            Console.WriteLine("Current account of HSBC " + hSBCObj2.getBalance());

            Console.WriteLine();

            iCICIObj1.calculateInterest();

            Console.WriteLine();
            hSBCObj1.calculateInterest();

            Console.ReadLine();
        }
示例#3
0
文件: Boleto.cs 项目: mbdavid/NBoleto
        public static Boleto Gerar(int codBanco, Cedente cedente, string nossoNumero, DateTime dtVencto, decimal vrBoleto)
        {
            Boleto b = null;

            switch (codBanco)
            {
            case 1: b = new BancoBrasil(); break;

            case 104: b = new Caixa(); break;

            case 41: b = new Banrisul(); break;

            case 237: b = new Bradesco(); break;

            case 341: b = new Itau(); break;

            case 33: b = new Santander(); break;

            case 399: b = new HSBC(); break;

            default: throw new NotImplementedException("Código de banco não implementado");
            }

            b.ValidaDados(cedente, nossoNumero);
            b.NossoNumero  = b.FormataNossoNumero(nossoNumero, cedente, dtVencto);
            b.AgCodCedente = b.FormataAgCodCedente(cedente);

            var barras   = b.GerarCodigoBarras(cedente, nossoNumero, dtVencto, vrBoleto);
            var linhadig = b.GerarLinhaDigitavel(barras);

            b.CodigoBarras   = barras.ToString();
            b.LinhaDigitavel = linhadig.ToString();

            b.Cedente           = cedente.Nome + " (CNPJ: " + Helper.FormatCpfCnpj(cedente.CNPJ) + ")";
            b.Carteira          = cedente.Carteira;
            b.NumeroDocumento   = nossoNumero;
            b.DataProcessamento = DateTime.Now.ToString(DATE_FORMAT);
            b.DataDocumento     = DateTime.Now.ToString(DATE_FORMAT);
            b.LocalPagamento    = "QUALQUER AGÊNCIA BANCÁRIA ATÉ A DATA DO VENCIMENTO";
            b.DataVencimento    = dtVencto.ToString(DATE_FORMAT);
            b.ValorDocumento    = vrBoleto.ToString(MONEY_FORMAT);
            b.Instrucoes        = "ATENÇÃO SENHOR CAIXA: NÃO RECEBER APÓS VENCIMENTO";

#if !DEBUG
            // Quando release, gera o Base64 do logotipo e codigo de barras
            b.Logotipo     = Helper.Logotipo(b.Banco.Substring(0, 3));
            b.CodigoBarras = Helper.CodigoBarras(b.CodigoBarras);
#endif

            return(b);
        }
        static void Main(string[] args)
        {
            ICICI i1      = new ICICI();
            int   AccType = (int)BankAccountTypeEnum.Saving;

            Console.WriteLine("Depositing 50000");
            i1.Deposit(50000);
            i1.GetBalance();

            ICICI i2       = new ICICI();
            int   AccType2 = (int)BankAccountTypeEnum.Current;

            Console.WriteLine("Depositing 20000");
            i2.Deposit(20000);
            i2.GetBalance();

            i1.Transfer(i2, 5000);
            i1.GetBalance();
            i2.GetBalance();

            HSBC h1       = new HSBC();
            int  AccType1 = (int)BankAccountTypeEnum.Saving;

            Console.WriteLine("Depositing 30000");
            h1.Deposit(30000);
            h1.GetBalance();

            HSBC h2       = new HSBC();
            int  AccType3 = (int)BankAccountTypeEnum.Current;

            Console.WriteLine("Depositing 20000");
            h2.Deposit(20000);
            h2.GetBalance();

            h1.Transfer(h2, 20000);

            h1.GetBalance();
            h2.GetBalance();
            Console.ReadKey();
        }
示例#5
0
        static void Main(string[] args)
        {
            List <object> arrayList = new List <object>();
            int           i, j, bankk, acctype;

            void fucntionss()
            {
                Console.WriteLine(methodcall.deposit + " " + (int)methodcall.deposit);
                Console.WriteLine(methodcall.transfer + " " + (int)methodcall.transfer);
                Console.WriteLine(methodcall.withdraw + " " + (int)methodcall.withdraw);
                Console.WriteLine(methodcall.getbalance + " " + (int)methodcall.getbalance);
            }

            do
            {
                Console.WriteLine("Enter the bank:");
                Console.WriteLine(bank.ICICI + " " + (int)bank.ICICI);
                Console.WriteLine(bank.HSBC + " " + (int)bank.HSBC);
                bankk = int.Parse(Console.ReadLine());
                switch (bankk)
                {
                case 0:
                    break;

                case 1:
                    break;

                case 2:
                    Console.Write("Exit from bankk");
                    break;
                }
                if (bankk != 2)
                {
                    do
                    {
                        Console.WriteLine("Enter the account type:");
                        Console.WriteLine(BankAccountTypeEnum.Saving + " " + (int)BankAccountTypeEnum.Saving);
                        Console.WriteLine(BankAccountTypeEnum.Current + " " + (int)BankAccountTypeEnum.Current);
                        acctype = int.Parse(Console.ReadLine());
                        //i = int.Parse(Console.ReadLine());
                        switch (acctype)
                        {
                        case 0:
                            ICICI icicisave = new ICICI();

                            var hsbcsave = new LQ5LibraryProject.HSBC();

                            IBankAccount bankAccountinterfaceicici = new ICICI();
                            IBankAccount bankAccountinterfacehsbc  = new HSBC();
                            arrayList.Add(bankAccountinterfaceicici);
                            arrayList.Add(bankAccountinterfacehsbc);
                            do
                            {
                                Console.WriteLine("select function:");
                                fucntionss();
                                j = int.Parse(Console.ReadLine());
                                switch (j)
                                {
                                case 0:

                                    if (acctype == 0 && bankk == 0)
                                    {
                                        //    var icsave = new LQ5LibraryProject.ICICI();
                                        Console.WriteLine("Enter the deposit amount:");
                                        double amount = double.Parse(Console.ReadLine());
                                        double result = icicisave.Deposit(amount);
                                        Console.WriteLine("balance is:" + result);
                                    }
                                    else if (acctype == 0 && bankk == 1)
                                    {
                                        Console.WriteLine("Enter the deposit amount:");
                                        double amount = double.Parse(Console.ReadLine());
                                        double result = hsbcsave.Deposit(amount);
                                        Console.WriteLine("balance is:" + result);
                                    }

                                    break;

                                case 1:
                                    if (acctype == 0 && bankk == 0)
                                    {
                                        Console.WriteLine("Enter the transfer amount:");
                                        double amount = double.Parse(Console.ReadLine());
                                        Console.WriteLine("Enter the transfer account:");
                                        icicisave.Transfer(amount, );
                                    }
                                    else if (acctype == 0 && bankk == 1)
                                    {
                                        Console.WriteLine("Enter the deposit amount:");
                                        double amount = double.Parse(Console.ReadLine());
                                        hsbcsave.Deposit(amount);
                                    }

                                    break;

                                case 2:
                                    if (acctype == 0 && bankk == 0)
                                    {
                                        //    var icsave = new LQ5LibraryProject.ICICI();
                                        Console.WriteLine("Enter the withdraw amount:");
                                        double amount = double.Parse(Console.ReadLine());
                                        bool   result = icicisave.Withdraw(amount);
                                        Console.WriteLine("balance is:" + result);
                                    }
                                    else if (acctype == 0 && bankk == 1)
                                    {
                                        Console.WriteLine("Enter the deposit amount:");
                                        double amount = double.Parse(Console.ReadLine());
                                        bool   result = hsbcsave.Withdraw(amount);
                                        Console.WriteLine("balance is:" + result);
                                    }
                                    break;

                                case 3:
                                    if (acctype == 0 && bankk == 0)
                                    {
                                        icicisave.GetBalance();
                                    }
                                    if (acctype == 0 && bankk == 1)
                                    {
                                        hsbcsave.GetBalance();
                                    }

                                    break;
                                }
                            } while (j != 4);

                            break;

                        case 1:
                            var          icicicurr = new LQ5LibraryProject.ICICI();
                            var          hsbccurr  = new LQ5LibraryProject.HSBC();
                            IBankAccount bankAccountinterfaceicicicurr = new ICICI();
                            IBankAccount bankAccountinterfacehsbccurr  = new HSBC();
                            arrayList.Add(bankAccountinterfaceicicicurr);
                            arrayList.Add(bankAccountinterfacehsbccurr);

                            do
                            {
                                Console.WriteLine("select function:");
                                fucntionss();
                                j = int.Parse(Console.ReadLine());
                                switch (j)
                                {
                                case 0:

                                    if (acctype == 0 && bankk == 0)
                                    {
                                        //    var icsave = new LQ5LibraryProject.ICICI();
                                        Console.WriteLine("Enter the deposit amount:");
                                        double amount = double.Parse(Console.ReadLine());
                                        double result = icicicurr.Deposit(amount);
                                        Console.WriteLine("balance is:" + result);
                                    }
                                    else if (acctype == 0 && bankk == 1)
                                    {
                                        Console.WriteLine("Enter the deposit amount:");
                                        double amount = double.Parse(Console.ReadLine());
                                        double result = hsbccurr.Deposit(amount);
                                        Console.WriteLine("balance is:" + result);
                                    }

                                    break;

                                case 1:
                                    if (acctype == 0 && bankk == 0)
                                    {
                                        Console.WriteLine("Enter the deposit amount:");
                                        double amount = double.Parse(Console.ReadLine());
                                        icicicurr.Deposit(amount);
                                    }
                                    else if (acctype == 0 && bankk == 1)
                                    {
                                        Console.WriteLine("Enter the deposit amount:");
                                        double amount = double.Parse(Console.ReadLine());
                                        foreach (var item in arrayList)
                                        {
                                            Console.WriteLine("select account:" + item);
                                        }
                                        int varr = int.Parse(Console.ReadLine());

                                        //   hsbccurr.Transfer(amount,IBankAccount.);
                                    }

                                    break;

                                case 2:
                                    if (acctype == 0 && bankk == 0)
                                    {
                                        Console.WriteLine("Enter the withdraw amount:");
                                        double amount = double.Parse(Console.ReadLine());
                                        bool   result = icicicurr.Withdraw(amount);
                                        Console.WriteLine("balance is:" + result);
                                    }
                                    else if (acctype == 0 && bankk == 1)
                                    {
                                        Console.WriteLine("Enter the deposit amount:");
                                        double amount = double.Parse(Console.ReadLine());
                                        bool   result = hsbccurr.Withdraw(amount);
                                        Console.WriteLine("balance is:" + result);
                                    }
                                    break;

                                case 3:
                                    if (acctype == 0 && bankk == 0)
                                    {
                                        icicicurr.GetBalance();
                                    }
                                    if (acctype == 0 && bankk == 1)
                                    {
                                        hsbccurr.GetBalance();
                                    }

                                    break;
                                }
                            } while (j != 4);



                            //if (acctype == 1 && bankk == 0) {
                            //    Console.WriteLine("Enter the deposit amount:");
                            //    double amount = double.Parse(Console.ReadLine());
                            //    icicicurr.Deposit(amount);

                            //}
                            //if (acctype == 1 && bankk == 1) { var hsbccurr = new LQ5LibraryProject.HSBC();


                            //}
                            break;

                        case 2:
                            Console.Write("Exit from acctype");
                            break;
                        }
                    } while (acctype != 2);
                }
            } while (bankk != 2);
        }