Click here to Skip to main content
15,889,651 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# WPF Memory Leak Pin
Wu Bin Michael21-Feb-13 14:51
Wu Bin Michael21-Feb-13 14:51 
AnswerRe: C# WPF Memory Leak Pin
Bernhard Hiller21-Feb-13 21:05
Bernhard Hiller21-Feb-13 21:05 
QuestionHttpwebrequest + Socks5 Pin
mathisderaltefuchs20-Feb-13 21:49
mathisderaltefuchs20-Feb-13 21:49 
AnswerRe: Httpwebrequest + Socks5 Pin
Pete O'Hanlon21-Feb-13 2:30
mvePete O'Hanlon21-Feb-13 2:30 
Questionimage resizing Pin
vimalbala20-Feb-13 18:51
vimalbala20-Feb-13 18:51 
AnswerRe: image resizing Pin
Sandeep Mewara20-Feb-13 22:01
mveSandeep Mewara20-Feb-13 22:01 
GeneralRe: image resizing Pin
vimalbala23-Mar-13 1:30
vimalbala23-Mar-13 1:30 
QuestionC# Money Transfer Question Pin
Jimmy173420-Feb-13 18:10
Jimmy173420-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

C#
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 Pin
Eddy Vluggen21-Feb-13 8:40
professionalEddy Vluggen21-Feb-13 8:40 
QuestionMD5 hash encrypt and decryption Pin
thekoko8920-Feb-13 15:32
thekoko8920-Feb-13 15:32 
GeneralRe: MD5 hash encrypt and decryption Pin
PIEBALDconsult20-Feb-13 17:18
mvePIEBALDconsult20-Feb-13 17:18 
AnswerRe: MD5 hash encrypt and decryption Pin
Bernhard Hiller20-Feb-13 21:12
Bernhard Hiller20-Feb-13 21:12 
AnswerRe: MD5 hash encrypt and decryption Pin
Dave Kreskowiak21-Feb-13 2:34
mveDave Kreskowiak21-Feb-13 2:34 
QuestionPost a file to remote server using HTTPWEBREQUEST Pin
vanikanc20-Feb-13 9:07
vanikanc20-Feb-13 9:07 
AnswerRe: Post a file to remote server using HTTPWEBREQUEST Pin
Eddy Vluggen20-Feb-13 9:51
professionalEddy Vluggen20-Feb-13 9:51 
GeneralRe: Post a file to remote server using HTTPWEBREQUEST Pin
vanikanc20-Feb-13 10:04
vanikanc20-Feb-13 10:04 
AnswerRe: Post a file to remote server using HTTPWEBREQUEST Pin
Eddy Vluggen20-Feb-13 10:13
professionalEddy Vluggen20-Feb-13 10:13 
GeneralRe: Post a file to remote server using HTTPWEBREQUEST Pin
vanikanc21-Feb-13 2:53
vanikanc21-Feb-13 2:53 
AnswerRe: Post a file to remote server using HTTPWEBREQUEST Pin
Pete O'Hanlon20-Feb-13 10:18
mvePete O'Hanlon20-Feb-13 10:18 
GeneralRe: Post a file to remote server using HTTPWEBREQUEST Pin
vanikanc21-Feb-13 2:49
vanikanc21-Feb-13 2:49 
Questionsource code for navigation Pin
Nani Maneesh20-Feb-13 7:07
Nani Maneesh20-Feb-13 7:07 
AnswerRe: source code for navigation Pin
Dave Kreskowiak20-Feb-13 7:38
mveDave Kreskowiak20-Feb-13 7:38 
GeneralRe: source code for navigation Pin
Jibesh20-Feb-13 8:32
professionalJibesh20-Feb-13 8:32 
GeneralRe: source code for navigation Pin
Dave Kreskowiak20-Feb-13 11:24
mveDave Kreskowiak20-Feb-13 11:24 
QuestionHow to Show GIF Image Transparent C# Pin
ishrar19-Feb-13 21:53
ishrar19-Feb-13 21:53 

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

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