3 Replies - 18457 Views - Last Post: 12 January 2010 - 08:26 AM Rate Topic: -----

#1 russian777  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 11-January 10

C# banking application from console to GUI

Post icon  Posted 11 January 2010 - 08:35 PM

Hi Everyone!
The problem I have is that I can't seem to make a GUI pop up that ask for information on my choice.
For example, the one that requires you to input data like checking or saving and then process it.
Also, I believe there is no way to manipulate the yes/no option like making it checking or saving.

This was a homework but I already turned it in as it is but I still want to learn how to make this a GUI application.
Every time I try to do it I get all sorts of errors.

Thank for any help or idea of how to transfer this into GUI application. The code for account, checking and savings is stand alone so there is no need for changes there.

{
	class Program
	{
		static void Main(string[] args)
		{
			{
			//Create the array of Acount
			Account[] MyAccount = new Account[2];
			//Initialize accounts
			MyAccount[0] = new SavingsAccount(100m, .2m);		  
			MyAccount[1] = new CheckingAccount(100m, 2m);
			
			Console.WriteLine("Banking Application");
			Console.WriteLine("");
			//Display balances
			Console.WriteLine("Savings Acount Balance : $" + MyAccount[0].Balance.ToString());
			Console.WriteLine("Checking Acount Balance : $" + MyAccount[1].Balance.ToString());
			
			  // processes account data	
			ProcessAccount(MyAccount);
		  
			string s;
			do{		   
				do
				{
					Console.WriteLine("Another transaction? (Y = Yes; N = No)");
					s = Console.ReadLine();
				}while (s.ToUpper() != "Y" && s.ToUpper() != "N");
				if(s.ToUpper ()=="Y")
					ProcessAccount(MyAccount);
			}while(s.ToUpper()=="Y");
			Console.WriteLine("");
			Console.WriteLine("Thank You for using our bank!");
			Console.ReadLine();
			}
		}
		//Extract Method: An operation of account
		private static void ProcessAccount(Account[] MyAccount)
		{
			string s;
			do
			{
				Console.WriteLine("");
				Console.WriteLine("Please Select Deposit Or Withdraw……");
				Console.WriteLine("Input '1' for Deposit	or	'2' for Withdraw");
				s = Console.ReadLine();
			}
			while (s != "1" && s != "2");
			string s_amount;
			do
			{
				Console.WriteLine("Please Input Amount in numeric value");
				s_amount = Console.ReadLine();
			}
			while (!System.Text.RegularExpressions.Regex.IsMatch(s_amount, "^[0-9]*[1-9][0-9]*$"));
			decimal amount = decimal.Parse(s_amount);
			switch (s)
			{
				case "1":
					do
					{
						Console.WriteLine("Please Select Deposit Acount.");
						Console.WriteLine("1. Savings		2. Checking");
						s = Console.ReadLine();
					} while (s != "1" && s != "2");
					switch (s)
					{
						case "1":
							MyAccount[0].Credit(amount);
							break;
						case "2":
							MyAccount[1].Credit(amount);
							break;
					}
					break;
				case "2":
					do
					{
						Console.WriteLine("Please Select Withdraw Acount.");
						Console.WriteLine("Input '1' for Savings   or   Input '2' for Checking");
						s = Console.ReadLine();
					} while (s != "1" && s != "2");
					switch (s)
					{
						case "1":
							MyAccount[0].Debit(amount);
							break;
						case "2":
							MyAccount[1].Debit(amount);
							break;
					}
					break;
			}
			Console.WriteLine("");
			Console.WriteLine("Savings Acount Balance : $" + MyAccount[0].Balance.ToString());
			Console.WriteLine("Cheching Acount Balance : $" + MyAccount[1].Balance.ToString());
			Console.WriteLine("");
		}
	}

		}



Is This A Good Question/Topic? 0
  • +

Replies To: C# banking application from console to GUI

#2 papuccino1  Icon User is offline

  • His name was Robert Paulson.
  • member icon

Reputation: 63
  • View blog
  • Posts: 1,121
  • Joined: 02-March 08

Re: C# banking application from console to GUI

Posted 11 January 2010 - 08:57 PM

Hi there! I'd love to help you out. First things first.

You cannot make a GUI in a Console aplication unless you use some nifty ASCII. There are certain symbols you can use to 'draw' a window so to speak.

Are you curious on how to make these?

Can you explain you question in a single sentence so we don't get mixed up? :P

This post has been edited by papuccino1: 11 January 2010 - 08:57 PM

Was This Post Helpful? 0
  • +
  • -

#3 rocky_upadhaya  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 52
  • Joined: 09-January 10

Re: C# banking application from console to GUI

Posted 11 January 2010 - 11:48 PM

It is Tried, Tested and 100% working Code. Hope this Helps you to take it as refrence or even Make Your own application from ir. Just call the Methods of Bank class to do all the job
public static class Bank
	{
		public static List<Account1> AccountList = new List<Account1>();
		private static int account_id = 100;

		public static int acc_id
		{
			get { return account_id; }
			set { account_id = value; }
		}
		public static void CreateAccount(string name,string pass, int amount)
		{
			Account1 a = new Account1(account_id, name,pass,amount);
			account_id++;
			AccountList.Add(a);
		}
		
		

		public static Account1 GetAccount(int id)
		{
			
			return (from a in AccountList
					where a.Account_ID == id
					select a).FirstOrDefault();
		}

		public static bool DeleteAccount(int id,string pass)
		{
			var accountToDelete = (from a in AccountList where a.Account_ID == id && a.Pass == pass select a).FirstOrDefault();
			return AccountList.Remove(accountToDelete);
		}

		public static Account1 AddM(int id, int amount)
		{
			var addM = (from a in AccountList where a.Account_ID == id select a).FirstOrDefault();
			addM.Amount += amount;
			return addM;
		}


		public static Account1 TakeM(int id, int amount,string pass)
		{
			var takeM = (from a in AccountList where a.Account_ID == id && a.Pass==pass select a).FirstOrDefault();
			takeM.Amount -= amount;
			if (takeM.Amount <= 500)
			{
				takeM.Amount += amount;
				MessageBox.Show("Sorry Rs.500 is the minimum Balance");
			}
			else
			{
				MessageBox.Show("WithDrawn Successfully");
			}
			return takeM;
		}

		public static void TranM(int id1, int id2, int amount,string pass)
		{
			var tranM1 = (from a in AccountList where a.Account_ID == id1 && a.Pass  == pass  select a).FirstOrDefault();
			var tranM2 = (from a in AccountList where a.Account_ID == id2 select a).FirstOrDefault();
			tranM1.Amount  -= amount;
			if (tranM1.Amount  < 500)
			{
				tranM1.Amount   += amount;
				MessageBox.Show("Sorry Rs.500 is the minimum Balance");
			}
			else
			{
				tranM2.Amount += amount;
				MessageBox.Show("Transfered Successfully!!");
				
			}
			
		}


	}

	public class Account1
	{
		public int Account_ID { get; set; }
		public string Name { get; set; }
		public int Amount { get; set; }
		public string Pass { get; set; }
		public Account1(int id, string name, string pass, int amount)
		{
			Account_ID = id;
			Name = name;
			Amount = amount;
			Pass = pass;
			
		}


Was This Post Helpful? 1
  • +
  • -

#4 russian777  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 11-January 10

Re: C# banking application from console to GUI

Posted 12 January 2010 - 08:26 AM

Hi papuccino1 and rocky_upadhaya!

Thanks for the code.

I should have separated and conquered before but I just was stuck with building it, like I would have in VB.Net.

Looking at the code I can see now how I can organize my code to put it in GUI.

Thanks a lot, it was killing me not knowing.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1