Click here to Skip to main content
       

C#

 
GeneralRe: C# WPF Memory Leak PinmemberWu Bin Michael21-Feb-13 15:03 
GeneralRe: C# WPF Memory Leak PinprotectorPete O'Hanlon21-Feb-13 20:28 
AnswerRe: C# WPF Memory Leak PinmvpDave Kreskowiak21-Feb-13 2:28 
GeneralRe: C# WPF Memory Leak PinmemberWu Bin Michael21-Feb-13 14:54 
GeneralRe: C# WPF Memory Leak PinmvpDave Kreskowiak21-Feb-13 15:27 
AnswerRe: C# WPF Memory Leak PinmemberV.21-Feb-13 3:47 
GeneralRe: C# WPF Memory Leak PinmemberWu Bin Michael21-Feb-13 14:51 
AnswerRe: C# WPF Memory Leak PinmemberBernhard Hiller21-Feb-13 21:05 
QuestionHttpwebrequest + Socks5 Pinmembermathisderaltefuchs20-Feb-13 21:49 
AnswerRe: Httpwebrequest + Socks5 PinprotectorPete O'Hanlon21-Feb-13 2:30 
Questionimage resizing Pinmembervimalbala20-Feb-13 18:51 
AnswerRe: image resizing PinmvpSandeep Mewara20-Feb-13 22:01 
GeneralRe: image resizing Pinmembervimalbala23-Mar-13 1:30 
QuestionC# Money Transfer Question [modified] PinmemberJimmy173420-Feb-13 18:10 
Hi, so I'm having trouble with my coding. I've already figured out for to take money from Tom and Rob, but i can't figure out how to deposit that value into the bank. here's what i have so far.
I would really appreciate it if, someone would take a look.
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace Lab05_E00995877
{
public partial class Form1 : Form
{
//Add your form1 variables
Person Tom;
Person Rob;
decimal bank = 50M;
 
public Form1()
{
InitializeComponent();
//Initialize (create) Tom and Rob
Tom = new Person();
Tom.Name = "Joe";
Tom.Cash = 150M;
btnGetOne.Text = "Get from " + Tom.Name;
 

Rob = new Person();
Rob.Name = "Bob";
Rob.Cash = 200M;
btnGetTwo.Text = "Get from " + Rob.Name;
 
UpdateForm();
}
 
public void UpdateForm()
{
lblFirstName.Text = Tom.Name;
lblMoneyOne.Text = Tom.Cash.ToString();
 
lblSecondName.Text = Rob.Name;
lblMoneyTwo.Text = Rob.Cash.ToString();
 
lblMoneyBank.Text = bank.ToString();
}
 
private void btnGetOne_Click(object sender, EventArgs e)
{
decimal decAmount, decTomAmount, decRobAmount, decBankAmount;
try
{
decAmount = Decimal.Parse(txtMoney.Text);
decTomAmount = Decimal.Parse(lblMoneyOne.Text);
decRobAmount = Decimal.Parse(lblMoneyTwo.Text);
decBankAmount = Decimal.Parse(lblMoneyBank.Text);
//bankamount (bank) Amount punched in (decAmount)
if (decTomAmount >= decAmount)
{
decTomAmount -= decAmount;
lblMoneyOne.Text = Tom.ReceiveCash(decAmount).ToString();
lblMoneyBank.Text = bank.ToString();
 

//What do i put here to add to bank after subtracting from Tom?


UpdateForm();
 
}
else
{
MessageBox.Show("Tom doesnt have this many!");
}
txtMoney.Clear();
txtMoney.Focus();
}
catch
{
MessageBox.Show("Please enter numbers only!");
txtMoney.Clear();
txtMoney.Focus();
}
}

private void btnGetTwo_Click(object sender, EventArgs e)
{
 
decimal decAmount, decTomAmount, decRobAmount;
try
{
decAmount = Decimal.Parse(txtMoney.Text);
decTomAmount = Decimal.Parse(lblMoneyOne.Text);
decRobAmount = Decimal.Parse(lblMoneyTwo.Text);
//bankamount (bank) Amount punched in (decAmount)
if (decRobAmount >= decAmount)
{
decRobAmount -= decAmount;
lblMoneyTwo.Text = Rob.ReceiveCash(decAmount).ToString();
lblMoneyBank.Text = bank.ToString();
 
//What do i put here to add to bank after subtracting from Rob?


UpdateForm();
 
}
else
{
MessageBox.Show("Rob doesnt have this many!");
}
txtMoney.Clear();
txtMoney.Focus();
}
catch
{
MessageBox.Show("Please enter numbers only!");
txtMoney.Clear();
txtMoney.Focus();
}
}
}
}
 

 

This is the other part defining the class
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace Lab05_E00995877
{
    class Person
    {
        public string Name;
        public decimal Cash;
        public decimal GiveCash;
 
        public decimal ReceiveCash(decimal amount)
        {
            if (amount > 0)
            {
       //      person       money punched in
                Cash -= amount;
                return Cash;
            }
            else
            {
                MessageBox.Show(amount + "  isnt an amount I'll take",
                    Name + " says..");
                return 0;
            }
        }
    }
}


modified 21-Feb-13 0:20am.

QuestionRe: C# Money Transfer Question PinmvpEddy Vluggen21-Feb-13 8:40 
QuestionMD5 hash encrypt and decryption Pinmemberthekoko8920-Feb-13 15:32 
GeneralRe: MD5 hash encrypt and decryption PinmemberPIEBALDconsult20-Feb-13 17:18 
AnswerRe: MD5 hash encrypt and decryption PinmemberBernhard Hiller20-Feb-13 21:12 
AnswerRe: MD5 hash encrypt and decryption PinmvpDave Kreskowiak21-Feb-13 2:34 
QuestionPost a file to remote server using HTTPWEBREQUEST Pinmembervanikanc20-Feb-13 9:07 
AnswerRe: Post a file to remote server using HTTPWEBREQUEST PinmvpEddy Vluggen20-Feb-13 9:51 
GeneralRe: Post a file to remote server using HTTPWEBREQUEST Pinmembervanikanc20-Feb-13 10:04 
AnswerRe: Post a file to remote server using HTTPWEBREQUEST PinmvpEddy Vluggen20-Feb-13 10:13 
GeneralRe: Post a file to remote server using HTTPWEBREQUEST Pinmembervanikanc21-Feb-13 2:53 
AnswerRe: Post a file to remote server using HTTPWEBREQUEST PinprotectorPete O'Hanlon20-Feb-13 10:18 
GeneralRe: Post a file to remote server using HTTPWEBREQUEST Pinmembervanikanc21-Feb-13 2:49 
Questionsource code for navigation PinmemberNani Maneesh20-Feb-13 7:07 
AnswerRe: source code for navigation PinmvpDave Kreskowiak20-Feb-13 7:38 
GeneralRe: source code for navigation PinmemberJibesh20-Feb-13 8:32 
GeneralRe: source code for navigation PinmvpDave Kreskowiak20-Feb-13 11:24 
QuestionHow to Show GIF Image Transparent C# Pinmemberishrar19-Feb-13 21:53 
AnswerRe: How to Show GIF Image Transparent C# PinmemberAlan Balkany20-Feb-13 8:28 
QuestionInstall software and menus depending upon radion button selection option used in MSI Pinmembersjs4u19-Feb-13 19:33 
AnswerRe: Install software and menus depending upon radion button selection option used in MSI PinmvpEddy Vluggen20-Feb-13 0:31 
GeneralRe: Install software and menus depending upon radion button selection option used in MSI Pinmembersjs4u20-Feb-13 18:12 
GeneralRe: Install software and menus depending upon radion button selection option used in MSI PinmvpEddy Vluggen21-Feb-13 7:06 
Questionproject Pinmemberpramodrastogi9119-Feb-13 18:14 
AnswerRe: project PinmemberJibesh19-Feb-13 19:52 
AnswerRe: project PinmvpAbhinav S19-Feb-13 22:25 
AnswerRe: project PinmvpMarcus Kramer20-Feb-13 3:17 
QuestionBinary stream '0' does not contain a valid BinaryHeader. Possible causes are invalid stream or object version change between serialization and deserialization. Pinmemberkandel1519-Feb-13 14:25 
AnswerRe: Binary stream '0' does not contain a valid BinaryHeader. Possible causes are invalid stream or object version change between serialization and deserialization. PinmemberBobJanova20-Feb-13 0:04 
AnswerRe: Binary stream '0' does not contain a valid BinaryHeader. Possible causes are invalid stream or object version change between serialization and deserialization. PinprotectorPete O'Hanlon20-Feb-13 0:11 
QuestionWindows Mobile Pinmemberaymen amri19-Feb-13 5:04 
AnswerRe: Windows Mobile PinmvpAbhinav S19-Feb-13 5:49 
GeneralRe: Windows Mobile Pinmemberaymen amri19-Feb-13 22:44 
AnswerRe: Windows Mobile PinprotectorPete O'Hanlon19-Feb-13 6:00 
GeneralRe: Windows Mobile Pinmemberaymen amri19-Feb-13 22:42 
AnswerRe: Windows Mobile PinprotectorPete O'Hanlon20-Feb-13 2:12 
QuestionHow to create dynamic menu Pinmemberebrahim kalteh19-Feb-13 1:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 30 Sep 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid