ASP.NET Hesap Makinesi Yapımı

sdkbyrm

webmasterfrm
Üyelik Tarihi
23 Aralık 2020
Mesajlar
813
Beğeniler
1
Ticaret: 0 / 0 / 0
Bu yazımızda ASP.NET’ te hesap makinesi oluşturan örneği oluşturacağız. Örneğimizde oluşturacağımız hesap makinesi aşağıdaki gibi olacaktır
1608737809767.png
Projemize ait WebForm1.aspx dosyası:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>www.yazilimkodlama.com</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:panel ID="Panel1" runat="server" GroupingText="Hesap Makinesi"
Width="280px">
<table class="style1">
<tr>
<td colspan="4">
<asp:TextBox ID="TextBox1" runat="server" Height="60px" Width="250px"
CssClass="kutu"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button16" runat="server" Height="60px" Text="C" Width="60px" OnClick="Button16_Click" />
</td>
<td>
<asp:Button ID="Button10" runat="server" Height="60px"
Text="/" Width="60px" OnClick="Button10_Click" />
</td>
<td>
<asp:Button ID="Button11" runat="server" Height="60px"
Text="*" Width="60px" OnClick="Button11_Click" />
</td>
<td>
<asp:Button ID="Button12" runat="server" Height="60px"
Text="-" Width="60px" OnClick="Button12_Click" />
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button7" runat="server" Height="60px"
Text="7" Width="60px" OnClick="Button7_Click" />
</td>
<td>
<asp:Button ID="Button8" runat="server" Height="60px"
Text="8" Width="60px" OnClick="Button8_Click" />
</td>
<td>
<asp:Button ID="Button9" runat="server" Height="60px"
Text="9" Width="60px" OnClick="Button9_Click" />
</td>
<td rowspan="2">
<asp:Button ID="Button13" runat="server" Height="120px"
Text="+" Width="60px" OnClick="Button13_Click" />
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button4" runat="server" Height="60px"
Text="4" Width="60px" OnClick="Button4_Click" />
</td>
<td>
<asp:Button ID="Button5" runat="server" Height="60px"
Text="5" Width="60px" OnClick="Button5_Click" />
</td>
<td>
<asp:Button ID="Button6" runat="server" Height="60px"
Text="6" Width="60px" OnClick="Button6_Click" />
</td>
</tr><!--http://www.yazilimkodlama.com/ -->
<tr>
<td>
<asp:Button ID="Button1" runat="server" Height="60px"
Text="1" Width="60px" OnClick="Button1_Click" />
</td>
<td>
<asp:Button ID="Button2" runat="server" Height="60px"
Text="2" Width="60px" OnClick="Button2_Click" />
</td>
<td>
<asp:Button ID="Button3" runat="server" Height="60px"
Text="3" Width="60px" OnClick="Button3_Click" />
</td><!--http://www.yazilimkodlama.com/ -->
<td rowspan="2">
<asp:Button ID="Button14" runat="server" Height="120px"
Text="=" Width="60px" OnClick="Button14_Click" />
</td>
</tr>
<tr>
<td colspan="3">
<asp:Button ID="Button15" runat="server" Height="60px"
Text="0" Width="199px" OnClick="Button15_Click" />
</td>
</tr>
</table>
</asp:panel>

</div>
</form>
</body>
</html>


Örneğimize ait WebForm1.aspx.cs kodları:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136

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

namespace WebApplication3
{
public partial class WebForm1 : System.Web.UI.Page
{
static double a, b;
static string d;
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "")
{ TextBox1.Text = "1"; }
else
{ TextBox1.Text = TextBox1.Text + "1"; }
}
protected void Button15_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "")
{ TextBox1.Text = "0"; }
else
{ TextBox1.Text = TextBox1.Text + "0"; }
}
protected void Button2_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "")
{ TextBox1.Text = "2"; }
else
//http://www.yazilimkodlama.com/
{ TextBox1.Text = TextBox1.Text + "2"; }
}
protected void Button3_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "")
{ TextBox1.Text = "3"; }
else
{ TextBox1.Text = TextBox1.Text + "3"; }
}
protected void Button4_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "")
{ TextBox1.Text = "4"; }
else
{ TextBox1.Text = TextBox1.Text + "4"; }
}
protected void Button5_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "")
{ TextBox1.Text = "5"; }
else
{ TextBox1.Text = TextBox1.Text + "5"; }
}
protected void Button6_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "")
{ TextBox1.Text = "6"; }
else
{ TextBox1.Text = TextBox1.Text + "6"; }
}
protected void Button7_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "")
{ TextBox1.Text = "7"; }
else
//http://www.yazilimkodlama.com/
{ TextBox1.Text = TextBox1.Text + "7"; }
}
protected void Button8_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "")
{ TextBox1.Text = "8"; }
else
{ TextBox1.Text = TextBox1.Text + "8"; }
}
protected void Button9_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "")
{ TextBox1.Text = "9"; }
else
{ TextBox1.Text = TextBox1.Text + "9"; }
}
protected void Button13_Click(object sender, EventArgs e)
{
d = "+";
a = Convert.ToInt16(TextBox1.Text);
TextBox1.Text = "";
}
protected void Button12_Click(object sender, EventArgs e)
{
d = "-";
a = Convert.ToInt16(TextBox1.Text);
TextBox1.Text = "";
}
protected void Button11_Click(object sender, EventArgs e)
{
d = "*";
a = Convert.ToInt16(TextBox1.Text);
TextBox1.Text = "";
}
protected void Button10_Click(object sender, EventArgs e)
{
d = "/";
a = Convert.ToInt16(TextBox1.Text);
TextBox1.Text = "";
//http://www.yazilimkodlama.com/
}
protected void Button14_Click(object sender, EventArgs e)
{
b = Convert.ToInt16(TextBox1.Text);

if (d == "+")
TextBox1.Text = Convert.ToString(a + b);
if (d == "-")
TextBox1.Text = Convert.ToString((sbyte)(a - b));
if (d == "*")
TextBox1.Text = Convert.ToString(a * b);
if (d == "/")
TextBox1.Text = Convert.ToString(a / b);
}

protected void Button16_Click(object sender, EventArgs e)
{
TextBox1.Text = "";
}
}
}


Projemizi çalıştıralım.
1608737829703.png
 
Üst