walec91

kalkulator

Dec 18th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.82 KB | None | 0 0
  1. using System;
  2. using System.Windows.Forms;
  3.  
  4. namespace MojaAplikacjaFormsowa
  5. {
  6.     public partial class Form1 : Form
  7.     {
  8.         private decimal? zmienna = null;
  9.  
  10.         public Form1() => InitializeComponent();
  11.  
  12.         private void button1_Click(object sender, EventArgs e) => WindowState = FormWindowState.Minimized;
  13.  
  14.         private void button19_Click(object sender, EventArgs e) => WindowState = FormWindowState.Maximized;
  15.  
  16.         private void button10_Click(object sender, EventArgs e)
  17.         {
  18.  
  19.         }
  20.  
  21.         private void button12_Click(object sender, EventArgs e)
  22.         {
  23.  
  24.         }
  25.  
  26.         private void button11_Click(object sender, EventArgs e)
  27.         {
  28.  
  29.         }
  30.  
  31.         private void button17_Click(object sender, EventArgs e)
  32.         {
  33.  
  34.         }
  35.  
  36.         private void button15_Click(object sender, EventArgs e)
  37.         {
  38.  
  39.         }
  40.  
  41.         private void button15_Click_1(object sender, EventArgs e)
  42.         {
  43.             if (textBox1.Text.IndexOf(",") == -1)
  44.             {
  45.                 textBox1.Text += ",";
  46.             }
  47.         }
  48.  
  49.         private void button17_Click_1(object sender, EventArgs e) => textBox1.Text += button17.Text;
  50.  
  51.         private void textBox1_TextChanged(object sender, EventArgs e)
  52.         {
  53.  
  54.         }
  55.  
  56.         private void button16_Click(object sender, EventArgs e) => textBox1.Text += button16.Text;
  57.  
  58.         private void button14_Click(object sender, EventArgs e) => textBox1.Text += button14.Text;
  59.  
  60.         private void button10_Click_1(object sender, EventArgs e) => textBox1.Text += button10.Text;
  61.  
  62.         private void button11_Click_1(object sender, EventArgs e) => textBox1.Text += button11.Text;
  63.  
  64.         private void button2_Click(object sender, EventArgs e) => textBox1.Text += button2.Text;
  65.  
  66.         private void button3_Click(object sender, EventArgs e) => textBox1.Text += button3.Text;
  67.  
  68.         private void button4_Click(object sender, EventArgs e) => textBox1.Text += button4.Text;
  69.  
  70.         private void button13_Click(object sender, EventArgs e) => textBox1.Text += button13.Text;
  71.  
  72.         private void button12_Click_1(object sender, EventArgs e) => textBox1.Text += button12.Text;
  73.  
  74.         private void button18_Click(object sender, EventArgs e) => textBox1.Text = null;
  75.  
  76.        
  77.  
  78.  
  79.  
  80.         private void wykonajDzialanie(decimal wartosc, string dzialanie)
  81.         {
  82.             switch (dzialanie)
  83.             {
  84.                 case "+":
  85.                     zmienna += decimal.Parse(textBox1.Text) + wartosc;
  86.                     break;
  87.                 case "-":
  88.                     zmienna -= decimal.Parse(textBox1.Text) + wartosc;
  89.                     break;
  90.                 case "x":
  91.                     zmienna *= decimal.Parse(textBox1.Text) + wartosc;
  92.                     break;
  93.                 case "%":
  94.                     zmienna /= decimal.Parse(textBox1.Text) + wartosc;
  95.                     break;
  96.                 case "=":
  97.                     textBox1.Text = zmienna.ToString();
  98.                     break;
  99.             }
  100.         }
  101.  
  102.         private void button5_Click(object sender, EventArgs e)
  103.         {
  104.             wykonajDzialanie("%");
  105.             textBox1.Text = "";
  106.         }
  107.  
  108.         private void button6_Click(object sender, EventArgs e)
  109.         {
  110.             wykonajDzialanie("x");
  111.             textBox1.Text = "";
  112.         }
  113.  
  114.         private void button8_Click(object sender, EventArgs e)
  115.         {
  116.             wykonajDzialanie("+");
  117.             textBox1.Text = "";
  118.         }
  119.  
  120.         private void button9_Click(object sender, EventArgs e)
  121.         {
  122.             wykonajDzialanie("=");
  123.             textBox1.Text = "";
  124.         }
  125.  
  126.         private void button7_Click(object sender, EventArgs e)
  127.         {
  128.             wykonajDzialanie("-");
  129.             textBox1.Text = "";
  130.         }
  131.     }
  132. }
Add Comment
Please, Sign In to add comment