private void TransBtn_Click(object sender, EventArgs e) { TransFirm newShop = new TransFirm(CliKRSAdd.Text, CliPassBox.Text, CliNameAdd.Text); LoggedBank.AddClient(newShop); dataGridView1.Rows.Add(newShop.GetName(), newShop.GetKRS(), newShop.GetType()); }
public static void LoadBankData() { StreamReader file = new StreamReader(PathToBankData); string line; while ((line = file.ReadLine()) != null) { string[] Words = line.Split(' '); string BankName = "", BankPass = ""; int i = 0; while (Words[i] != ";") { BankName += Words[i]; BankName += " ";//adds space if there should be one, if not its deleted when exiting loop i++; } i++; BankName = BankName.Remove(BankName.ToString().Length - 1);//skiping seperator and deleteing excessive space, bank read while (Words[i] != ";") { BankPass += Words[i];// BankName += " ";//adds space if there should be one, if not its deleted when exiting loop i++; } i++;// BankPass = BankPass.Remove(BankPass.ToString().Length - 1);//skiping seperator and deleteing excessive space, bank read Bank tmpBank = new Bank(BankName, BankPass); Client tmpClient = null; PaymentCard PCard = null; int Clientsnum = Convert.ToInt32(Words[i]); i++; while (Clientsnum > 0) { Clientsnum--; while (Words[i] != ";") { string KRS = Words[i]; i++; string Password = ""; while (Words[i] != "}") { Password += Words[i]; i++; } i++; string Name = ""; while (Words[i] != "}") { Name += Words[i]; i++; Name += " "; } i++; Name = Name.Remove(Name.ToString().Length - 1); //skiping seperator and deleteing excessive space string ClientType = Words[i]; i++; if (ClientType == "Trans") { TransFirm tmp = new TransFirm(KRS, Password, Name); tmpClient = tmp; } if (ClientType == "Shop") { Shop tmp = new Shop(KRS, Password, Name); tmpClient = tmp; } if (ClientType == "Serv") { ServiceEstablishment tmp = new ServiceEstablishment(KRS, Password, Name); tmpClient = tmp; } } i++; //skiping seperator, client read tmpBank.AddClient(tmpClient); int CardsNum = Convert.ToInt32(Words[i]); i++; while (CardsNum > 0) { CardsNum--; while (Words[i] != "|" && i < Words.Count()) { double CardFunds = Convert.ToDouble(Words[i]); i++; string CardNr = Words[i]; i++; string CardBankName = ""; while (Words[i] != "}") { CardBankName += Words[i]; i++; CardBankName += " "; } i++; CardBankName = CardBankName.Remove(CardBankName.ToString().Length - 1); //skiping seperator and deleteing excessive space string CardOwner = ""; while (Words[i] != "}") { CardOwner += Words[i]; i++; CardOwner += " "; } i++; CardOwner = CardOwner.Remove(CardOwner.ToString().Length - 1); //skiping seperator and deleteing excessive space string KRS = Words[i]; i++; string CardType = Words[i]; i++; if (CardType == "ATM") { ATMCard tmpATM = new ATMCard(CardNr, CardFunds, CardBankName, CardOwner, KRS); PCard = tmpATM; } if (CardType == "Debit") { DebitCard tmpDebit = new DebitCard(CardNr, CardFunds, CardBankName, CardOwner, KRS); PCard = tmpDebit; } if (CardType == "Credit") { CreditCard tmpCredit = new CreditCard(CardNr, CardFunds, CardBankName, CardOwner, KRS); PCard = tmpCredit; } tmpClient.AddCard(PCard); tmpBank.AddCard(PCard); } i++; //skiping seperator, cards read } i++; } PaymentCardServiceCenter.AddBank(tmpBank); } file.Close(); }