001.
using System;
002.
using System.Collections.Generic;
003.
using System.ComponentModel;
004.
using System.Data;
005.
using System.Drawing;
006.
using System.Linq;
007.
using System.Text;
008.
using System.Windows.Forms;
009.
010.
namespace WindowsFormsApplication4
011.
{
012.
public
partial
class
Form1 : Form
013.
{
014.
int
a;
015.
bool plus =
false
;
016.
bool minus =
false
;
017.
bool multiply =
false
;
018.
bool divide =
false
;
019.
bool power =
false
;
020.
public
Form1()
021.
{
022.
InitializeComponent();
023.
}
024.
025.
026.
private
void
Form1_Load(object sender, EventArgs e)
027.
{
028.
029.
}
030.
031.
private
void
button9_Click(object sender, EventArgs e)
032.
{
033.
textBox1.Text = textBox1.Text +
"1"
;
034.
035.
}
036.
037.
private
void
button8_Click(object sender, EventArgs e)
038.
{
039.
textBox1.Text = textBox1.Text +
"2"
;
040.
041.
}
042.
043.
private
void
button7_Click(object sender, EventArgs e)
044.
{
045.
textBox1.Text = textBox1.Text +
"3"
;
046.
047.
}
048.
049.
private
void
button4_Click(object sender, EventArgs e)
050.
{
051.
textBox1.Text = textBox1.Text +
"4"
;
052.
053.
}
054.
055.
private
void
button5_Click(object sender, EventArgs e)
056.
{
057.
textBox1.Text = textBox1.Text +
"5"
;
058.
059.
}
060.
061.
private
void
button6_Click(object sender, EventArgs e)
062.
{
063.
textBox1.Text = textBox1.Text +
"6"
;
064.
065.
}
066.
067.
private
void
button1_Click(object sender, EventArgs e)
068.
{
069.
textBox1.Text = textBox1.Text +
"7"
;
070.
071.
}
072.
073.
private
void
button2_Click(object sender, EventArgs e)
074.
{
075.
textBox1.Text = textBox1.Text +
"8"
;
076.
077.
}
078.
079.
private
void
button3_Click(object sender, EventArgs e)
080.
{
081.
textBox1.Text = textBox1.Text +
"9"
;
082.
083.
}
084.
085.
private
void
button19_Click(object sender, EventArgs e)
086.
{
087.
textBox1.Text =
""
;
088.
}
089.
090.
private
void
button18_Click(object sender, EventArgs e)
091.
{
092.
int
a = textBox1.Text.Length;
093.
if
(textBox1.Text ==
""
)
094.
{
095.
textBox1.Text =
""
;
096.
}
097.
else
098.
{
099.
textBox1.Text = textBox1.Text.Remove(a -
1
);
100.
}
101.
102.
}
103.
104.
private
void
button13_Click(object sender, EventArgs e)
105.
{
106.
if
(textBox1.Text ==
""
)
107.
{
108.
return
;
109.
}
110.
else
111.
{
112.
plus =
true
;
113.
textBox1.Tag = textBox1.Text;
114.
textBox1.Text =
""
;
115.
}
116.
}
117.
118.
private
void
button17_Click(object sender, EventArgs e)
119.
{
120.
if
(plus)
121.
{
122.
decimal dec = Convert.ToDecimal(textBox1.Tag) + Convert.ToDecimal(textBox1.Text);
123.
textBox1.Text = dec.ToString();
124.
}
125.
else
if
(minus)
126.
{
127.
decimal dec = Convert.ToDecimal(textBox1.Tag) - Convert.ToDecimal(textBox1.Text);
128.
textBox1.Text = dec.ToString();
129.
}
130.
else
if
(multiply)
131.
{
132.
decimal dec = Convert.ToDecimal(textBox1.Tag) * Convert.ToDecimal(textBox1.Text);
133.
textBox1.Text = dec.ToString();
134.
}
135.
else
if
(divide)
136.
{
137.
if
(textBox1.Text ==
"0"
)
138.
{
139.
textBox1.Text =
"0"
;
140.
}
141.
else
if
(textBox1.Text !=
"0"
)
142.
{
143.
decimal dec = Convert.ToDecimal(textBox1.Tag) / Convert.ToDecimal(textBox1.Text);
144.
textBox1.Text = dec.ToString();
145.
}
146.
}
147.
else
if
(power)
148.
{
149.
decimal dec = Convert.ToDecimal(textBox1.Tag) * Convert.ToDecimal(textBox1.Tag);
150.
textBox1.Text = dec.ToString();
151.
}
152.
153.
154.
return
;
155.
}
156.
157.
private
void
button14_Click(object sender, EventArgs e)
158.
{
159.
if
(textBox1.Text.Contains(
"."
))
160.
{
161.
return
;
162.
}
163.
else
164.
{
165.
textBox1.Text = textBox1.Text +
"."
;
166.
}
167.
}
168.
169.
private
void
button12_Click(object sender, EventArgs e)
170.
{
171.
if
(textBox1.Text ==
""
)
172.
{
173.
return
;
174.
}
175.
else
176.
{
177.
minus =
true
;
178.
textBox1.Tag = textBox1.Text;
179.
textBox1.Text =
""
;
180.
181.
}
182.
}
183.
184.
private
void
button11_Click(object sender, EventArgs e)
185.
{
186.
if
(textBox1.Text ==
""
)
187.
{
188.
return
;
189.
}
190.
else
191.
{
192.
multiply =
true
;
193.
textBox1.Tag = textBox1.Text;
194.
textBox1.Text =
""
;
195.
}
196.
}
197.
198.
private
void
button10_Click(object sender, EventArgs e)
199.
{
200.
if
(textBox1.Text ==
""
)
201.
{
202.
return
;
203.
}
204.
else
205.
{
206.
divide =
true
;
207.
textBox1.Tag = textBox1.Text;
208.
textBox1.Text =
""
;
209.
}
210.
}
211.
212.
private
void
button15_Click(object sender, EventArgs e)
213.
{
214.
if
(textBox1.Text !=
"0"
)
215.
{
216.
if
(textBox1.Text.Contains(
'-'
))
217.
{
218.
textBox1.Text = textBox1.Text.Remove(
0
,
1
);
219.
}
220.
else
221.
{
222.
textBox1.Text =
"-"
+ textBox1.Text;
223.
}
224.
}
225.
}
226.
227.
private
void
button16_Click(object sender, EventArgs e)
228.
{
229.
textBox1.Text = textBox1.Text +
"0"
;
230.
}
231.
232.
private
void
textBox1_TextChanged(object sender, EventArgs e)
233.
{
234.
235.
}
236.
237.
private
void
label1_Click(object sender, EventArgs e)
238.
{
239.
240.
}
241.
242.
private
void
button20_Click(object sender, EventArgs e)
243.
{
244.
245.
}
246.
247.
private
void
button20_Click_1(object sender, EventArgs e)
248.
{
249.
if
(textBox1.Text ==
""
)
250.
{
251.
return
;
252.
}
253.
else
254.
power =
true
;
255.
textBox1.Tag = textBox1.Text;
256.
textBox1.Text =
""
;
257.
}
258.
}
259.
}