public void withdraw() { AccEntities1 account_database = new AccEntities1(); Console.WriteLine("Enter the account id: "); int id = int.Parse(Console.ReadLine()); Console.WriteLine("Enter the account type:"); string acc_type = Console.ReadLine(); Console.WriteLine("Enter the amount you want to withdraw:"); int amount = int.Parse(Console.ReadLine()); int bal = account_database.ACCOUNTs.Find(id).balance; string AccountType = account_database.ACCOUNTs.Find(id).acc_type; if (AccountType == "saving" && bal == 1000) { Console.WriteLine("Not Enough Balance"); } else if (AccountType == "current" && bal == 0) { Console.WriteLine("Not Enough Blanace"); } else if (AccountType == "Dmat" && bal == (-10000)) { Console.WriteLine("Not Enough Balance"); } else { bal = bal - amount; if (AccountType == "saving" && bal < 1000) { Console.WriteLine("Cannot withdraw amount.Minimum balance of Rs 1000 required."); } else if (AccountType == "Dmat" && bal < (-10000)) { Console.WriteLine("Cannot withdraw amount.Minimum balance of -10000 required."); } else { var obj = new ACCOUNT { balance = bal, }; account_database.ACCOUNTs.Add(obj); } } }
public void deposit() { AccEntities1 account_database = new AccEntities1(); Console.WriteLine("Enter the account id : "); int id = int.Parse(Console.ReadLine()); Console.WriteLine("Enter the amount you want to deposit: "); int amount = int.Parse(Console.ReadLine()); var bal = account_database.ACCOUNTs.Find(id).balance; bal += amount; var obj = new ACCOUNT { balance = bal, }; account_database.ACCOUNTs.Add(obj); }
//AccEntities1 account_database = new AccEntities1(); public void Add_account() { AccEntities1 account_database = new AccEntities1(); Console.WriteLine("Enter customer name: "); string name = Console.ReadLine(); Console.WriteLine("Enter account id: "); int acc_id = int.Parse(Console.ReadLine()); Console.WriteLine("Enter account type: "); string acc_type = Console.ReadLine(); var data = new ACCOUNT { account_id = acc_id, acc_type = acc_type, cust_name = name, }; account_database.ACCOUNTs.Add(data); }