0% found this document useful (0 votes)
9 views5 pages

Sai Assignment - 4

Uploaded by

saiganta210
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views5 pages

Sai Assignment - 4

Uploaded by

saiganta210
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Design Source Code

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"


Inherits="WebApplication8.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin
template="/Templates/bnk.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<style type="text/css">
<!--
.style1 {
font-size: 18px;
font-weight: bold;
}
-->
</style>
<!-- InstanceEndEditable -->
<link href="Templates/bank.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" border="0" class="brdr">
<tr class="bord">
<td colspan="2" class="bord"><p class="hdr">MAMAS //UIS BANK INC</p> </td>
</tr>
<tr>
<td width="23%" valign="top"><!-- InstanceBeginEditable name="EditRegion4" --
>EditRegion4<!-- InstanceEndEditable --></td>
<td width="77%" valign="top"><!-- InstanceBeginEditable name="EditRegion3" --
> <form action="deposit.php" method="post">
<table width="100%" border="1">
<tr>
<td colspan="2"><span class="style1">Making a deposit: </span></td>
</tr>
<tr>
<td width="33%"> </td>
<td width="67%"> </td>
</tr>
<tr>
<td>Balance:</td>
<td><?php $currbal = $obj->currbalance($_GET['accno']);
echo $currbal; ?>
<input type="hidden" name="currbal" value="<?php $currbal = $obj-
>currbalance($_GET['accno']);
echo $currbal; ?>" />
<input type="hidden" name="accno" value="<?php echo $_GET['accno'];?
>"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Amount to deposit: </td>
<td><label>
<input name="amount" type="text" id="amount" />
<input name="submit" type="submit" id="submit" value="submit" />
</label></td>
</tr>
</table>
</form>
<!-- InstanceEndEditable --></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</table>
</body>
<!-- InstanceEnd --></html>

CODE BEHIND

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication8
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
class Account
{
public const double defaultBalance = 1000;
private double _amount;
public double balance;
public double Balance
{
get { return defaultBalance; }
}

public double Amount


{
get
{
return _amount;
}
set
{
if (value < 0)
{
throw new ArgumentException("Please enter an amount
greater than 0");
}
else
{
_amount = value;
}
}
}

public double doDeposit()


{
balance += _amount;
return balance;
}
public double doWithdrawl()
{
balance -= _amount;

if (balance < 0)
{
throw new ArgumentException("Withdrawing " +
_amount.ToString("C") + " would leave you overdrawn!");
}
return balance;
}
}
}
}
}
namespace Account_Teller
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Account acc = new Account();

private void btnWithdraw_Click(object sender, EventArgs e)


{
try
{
acc.Amount = double.Parse(txtAmount.Text);
//Error in the line below. "Property cannot be assigned to -- it
is read only
//Trying to set the initial balance as $1000 using constructor
from 'Account' class
acc.Balance = double.Parse(lblBalance.Text);
lblBalance.Text = acc.doWithdrawl().ToString("C");
}
catch (FormatException ex)
{
MessageBox.Show(ex.Message);
}
catch (ArgumentException ex)
{
MessageBox.Show(ex.Message);
}
catch (Exception error)
{
MessageBox.Show(error.Message);
}
}

private void btnDeposit_Click(object sender, EventArgs e)


{
try
{
acc.Amount = double.Parse(txtAmount.Text);
lblBalance.Text = acc.doDeposit().ToString("C");
}
catch (FormatException ex)
{
MessageBox.Show(ex.Message);
}
catch (ArgumentException ex)
{
MessageBox.Show(ex.Message);
}
catch (Exception error)
{
MessageBox.Show(error.Message);
}
}
}

You might also like