コード例 #1
0
        private void AccountScreen_Load(object sender, EventArgs e)
        {
            try
            {
                Timer.Enabled     = true;
                CurrencyInfo.Text = "Current savings in your accounts:\n\n" + client.GetBalance();
                NameLabel.Text    = client.GetName();
                foreach (string otherName in AccountHolders.OtherName(client.GetName()))
                {
                    PersonComboBox.Items.Add(otherName);
                }
                ChoosenIBANComboBox.Items.Clear();
                foreach (string iban in client.GetIbans())
                {
                    ChoosenIBANComboBox.Items.Add(iban);
                }

                if (ChoosenIBANComboBox.Items.Count <= 0)
                {
                    throw new Error("Your Account has  not got a Account");
                }
                if (PersonComboBox.Items.Count <= 0)
                {
                    throw new Error("I'm sorry this bank has got a only member. He is you :)");
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, ":(", MessageBoxButtons.OK);
            }
        }
コード例 #2
0
 private void EnterButton_Click(object sender, EventArgs e)
 {
     if ((UserIdText.Text.Length != 6 || PasswordText.Text.Length != 8))
     {
         MessageBox.Show("Account Number should be 6 character. Password should be 8 character, Please Try Again.", "Notice", MessageBoxButtons.OK);
         UserIdText.Clear();
         PasswordText.Clear();
     }
     else
     {
         if ((client = AccountHolders.FindClient(UserIdText.Text, "Account Number")) == null)
         {
             MessageBox.Show("Account Number or Password is Incorrect, Please Try Again.", "Notice", MessageBoxButtons.OK);
             PasswordText.Clear();
         }
         else
         {
             if (client.Check(PasswordText.Text) && client.IsLocked())
             {
                 AccountScreen accountScreen = new AccountScreen(UserIdText.Text);
                 this.Hide();
                 accountScreen.Show();
                 PasswordText.Clear();
             }
             else
             {
                 Logger();
                 MessageBox.Show("Account Number or Password is Incorrect, Please Try Again.", "Notice", MessageBoxButtons.OK);
                 PasswordText.Clear();
             }
         }
     }
 }
コード例 #3
0
        public void Read()
        {
            FileStream   fileStream;
            StreamReader streamReader;

            try
            {
                fileStream   = new FileStream(@"c:\\final\\client.txt", FileMode.Open, FileAccess.Read);
                streamReader = new StreamReader(fileStream);
                string line = streamReader.ReadLine();
                if (line == null)
                {
                    streamReader.Close();
                    fileStream.Close();
                    new Error("Client File is Empty.");
                }
                while (line != null)
                {
                    string[] lines = line.Split(',');
                    if (String.Compare(lines[3], "TL") == 0)
                    {
                        BankAccount client = AccountHolders.FindClient(lines[0], "Account Number");
                        client.SetAccounts(new Tl(lines[1], Convert.ToDouble(lines[2])));
                    }
                    else if (String.Compare(lines[3], "EURO") == 0)
                    {
                        BankAccount client = AccountHolders.FindClient(lines[0], "Account Number");
                        client.SetAccounts(new Euro(lines[1], Convert.ToDouble(lines[2])));
                    }
                    else if (String.Compare(lines[3], "USD") == 0)
                    {
                        BankAccount client = AccountHolders.FindClient(lines[0], "Account Number");
                        client.SetAccounts(new Usd(lines[1], Convert.ToDouble(lines[2])));
                    }
                    line = streamReader.ReadLine();
                }
                streamReader.Close();
                fileStream.Close();
            }catch (Exception exception)
            {
                FileOperations.CreateDefaultClient("force");
                this.Read();
                MessageBox.Show(exception + "All Currency forget!", "Problem", MessageBoxButtons.OK);
            }
        }
コード例 #4
0
        internal void TransferMoney(string iban, string name, string ibanII, string amount)
        {
            Money senderaccount = null;

            foreach (Money account in this.Accounts)
            {
                if (String.Compare(account.Iban, iban) == 0)
                {
                    senderaccount = account;
                    break;
                }
            }
            BankAccount receiver        = AccountHolders.FindClient(name, "Name");
            Money       receiveraccount = null;

            foreach (Money account in receiver.Accounts)
            {
                if (String.Compare(account.Iban, ibanII) == 0)
                {
                    receiveraccount = account;
                    break;
                }
            }
            try
            {
                if (senderaccount.Check(amount))
                {
                    string type = senderaccount.SendMoneyByEft(Convert.ToDouble(amount));
                    if (String.IsNullOrEmpty(type))
                    {
                        throw new Error("You have not got enough money?");
                    }
                    receiveraccount.TakeMoneyByEft(Convert.ToDouble(amount), type);
                }
                else
                {
                    throw new Error("You have not got enough money?");
                }
            }
            catch (Exception exception)
            {
                throw new Error(exception.Message);
            }
        }
コード例 #5
0
 private void PersonComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         IBANComboBox.Items.Clear();
         IBANComboBox.SelectedIndex = -1;
         BankAccount choosen = AccountHolders.FindClient(PersonComboBox.SelectedItem.ToString(), "Name");
         if (choosen == null)
         {
             throw new Error("Your chosen Person is gone to another bank.");
         }
         foreach (string iban in choosen.GetIbans())
         {
             IBANComboBox.Items.Add(iban);
         }
     }catch (Exception exception)
     {
         MessageBox.Show(exception.Message, ":(", MessageBoxButtons.OK);
     }
 }
コード例 #6
0
        static internal void ReadToAuth()
        {
            try
            {
                FileStream   fileStream   = new FileStream(@"c:\\final\\auth.txt", FileMode.Open, FileAccess.Read);
                StreamReader streamReader = new StreamReader(fileStream);
                string       line         = streamReader.ReadLine();
                if (line == null)
                {
                    streamReader.Close();
                    fileStream.Close();
                    new Error("Auth File is Empty.");
                }
                while (line != null)
                {
                    string[]    lines  = line.Split(',');
                    BankAccount client = AccountHolders.FindClient(lines[0], "Account Number");
                    if (client == null)
                    {
                        streamReader.Close();
                        fileStream.Close();
                        throw new Error("");
                    }
                    client.Password = lines[1];
                    line            = streamReader.ReadLine();
                }
                streamReader.Close();
                fileStream.Close();
            }
#pragma warning disable CS0168
            catch (Exception exception)
#pragma warning restore CS0168
            {
                FileOperations.CreateDefaultAuth("force");
                ReadToAuth();
                throw new Error("Auth File Destoried. But Recoveried File");
            }
        }
コード例 #7
0
 public AccountScreen(string accountNumber)
 {
     client = AccountHolders.FindClient(accountNumber, "Account Number");
     InitializeComponent();
 }