Advertisement
AleksandarH

Niki - 1 Zad.

Dec 15th, 2022
763
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.93 KB | None | 0 0
  1. // FORM 1
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Windows.Forms;
  5. using static System.Windows.Forms.VisualStyles.VisualStyleElement;
  6.  
  7. namespace KP2_V4
  8. {
  9.  
  10.     public partial class Form1 : Form
  11.     {
  12.         public Form1()
  13.         {
  14.             InitializeComponent();
  15.         }
  16.  
  17.         private void button1_Click(object sender, EventArgs e)
  18.         {
  19.             double value1 = 0;
  20.             double value2 = 0;
  21.             double value3 = 0;
  22.             try
  23.             {
  24.                 listBox1.Items.Add(textBox1.Text);
  25.                 listBox1.Items.Add(textBox2.Text);
  26.                 listBox1.Items.Add(textBox3.Text);
  27.                 listBox1.Items.Add(textBox4.Text);
  28.                 listBox1.Items.Add(dateTimePicker1.Value);
  29.                 textBox1.Clear();
  30.                 textBox2.Clear();
  31.                 textBox3.Clear();
  32.                 foreach (RadioButton rad in groupBox1.Controls)
  33.                 {
  34.                     if (rad.Checked)
  35.                         listBox1.Items.Add(rad.Text);
  36.                 }
  37.                 if (radioButton1.Checked)
  38.                     value1 = 3.09;
  39.                 else if (radioButton2.Checked)
  40.                     value1 = 5.30;
  41.                 else if (radioButton3.Checked)
  42.                     value1 = 4.00;
  43.                 foreach (RadioButton rad in groupBox2.Controls)
  44.                 {
  45.                     if (rad.Checked)
  46.                         listBox1.Items.Add(rad.Text);
  47.                 }
  48.                 if (radioButton4.Checked)
  49.                     value2 = 5.50;
  50.                 else if (radioButton5.Checked)
  51.                     value2 = 6.00;
  52.                 else if (radioButton6.Checked)
  53.                     value2 = 7.23;
  54.                 foreach (RadioButton rad in groupBox3.Controls)
  55.                 {
  56.                     if (rad.Checked)
  57.                         listBox1.Items.Add(rad.Text);
  58.                 }
  59.                 if (radioButton7.Checked)
  60.                     value3 = 9.00;
  61.                 else if (radioButton8.Checked)
  62.                     value3 = 6.00;
  63.                 else if (radioButton9.Checked)
  64.                     value3 = 4.50;
  65.                 double value = value1 + value2 + value3;
  66.                 textBox5.Text = ((value * (double.Parse(textBox4.Text) / 100)) * 1.2).ToString();
  67.                 foreach(RadioButton rad in groupBox1.Controls)
  68.                 { rad.Checked = false;}
  69.                 foreach (RadioButton rad in groupBox2.Controls)
  70.                 { rad.Checked = false; }
  71.                 foreach (RadioButton rad in groupBox3.Controls)
  72.                 { rad.Checked = false; }
  73.                 textBox4.Clear();
  74.             }
  75.             catch{ }
  76.         }
  77.  
  78.         private void button2_Click(object sender, EventArgs e)
  79.         {
  80.             textBox5.Clear();
  81.             listBox1.Items.Clear();
  82.         }
  83.  
  84.         private void button3_Click(object sender, EventArgs e)
  85.         {
  86.             Form2 form = new Form2(listBox1.Items);
  87.             form.Show();
  88.         }
  89.     }
  90. }
  91.  
  92. // FORM 2
  93. using System;
  94. using System.Collections.Generic;
  95. using System.ComponentModel;
  96. using System.Data;
  97. using System.Drawing;
  98. using System.Linq;
  99. using System.Text;
  100. using System.Threading.Tasks;
  101. using System.Windows.Forms;
  102. using static System.Windows.Forms.VisualStyles.VisualStyleElement;
  103.  
  104. namespace KP2_V4
  105. {
  106.     public partial class Form2 : Form
  107.     {
  108.         public Form2()
  109.         {
  110.             InitializeComponent();
  111.         }
  112.  
  113.         public Form2(ListBox.ObjectCollection objectCollection)
  114.         {
  115.             InitializeComponent();
  116.             this.listBox1.DataSource = objectCollection;
  117.         }
  118.  
  119.         private void button1_Click(object sender, EventArgs e)
  120.         {
  121.             TextWriter txt = new StreamWriter(@"listbox.txt");
  122.             txt.Write(listBox1.Text);
  123.             txt.Close();
  124.             MessageBox.Show("Saved");
  125.         }
  126.  
  127.  
  128.     }
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement