Görsel Programlama (Güz-2016) Hafta-9-1
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 |
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace ornek1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); ctur.Text = "Seçiniz"; } private void bekle_Click(object sender, EventArgs e) { int adet; bool kontrol = Int32.TryParse(tadet.Text, out adet); if (kontrol && ctur.SelectedIndex > -1) { ltur.Items.Add(ctur.Text); ladet.Items.Add(adet); double birimfiyat = (double)lf.Items[ctur.SelectedIndex]; double tutar = adet * birimfiyat; ltutar.Items.Add(tutar); ctur.Text = "Seçiniz"; tadet.Clear(); label_guncelle(); } } private void bsil_Click(object sender, EventArgs e) { int secilen = ltur.SelectedIndex; if (secilen > -1) { ltur.Items.RemoveAt(secilen); ladet.Items.RemoveAt(secilen); ltutar.Items.RemoveAt(secilen); label_guncelle(); } } private void label_guncelle() { double tutar = 0; int adet = 0; for (int i = 0; i < ltur.Items.Count; i++) { tutar += (double)ltutar.Items[i]; adet += (int)ladet.Items[i]; } latoplam.Text = "Toplam: " + tutar; laadet.Text = "Adet: " + adet; } ListBox lt = new ListBox(); ListBox lf = new ListBox(); private void btanimla_Click(object sender, EventArgs e) { fturler frm = new fturler(lt,lf); frm.ShowDialog(); ctur.Items.Clear(); for (int i = 0; i < lt.Items.Count; i++) ctur.Items.Add(lt.Items[i]); ctur.Text = "Seçiniz"; } } } |
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 |
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace ornek1 { public partial class fturler : Form { ListBox lt, lf; public fturler(ListBox lt1, ListBox lf1) { InitializeComponent(); lt = lt1; lf = lf1; for (int i = 0; i < lt.Items.Count; i++) { ltur.Items.Add(lt.Items[i]); lfiyat.Items.Add(lf.Items[i]); } } private void bekle_Click(object sender, EventArgs e) { double fiyat; bool kontrol = Double.TryParse(tfiyat.Text, out fiyat); if (kontrol && ttur.Text.Length > 0) { ltur.Items.Add(ttur.Text); lfiyat.Items.Add(fiyat); lt.Items.Add(ttur.Text); lf.Items.Add(fiyat); ttur.Clear(); tfiyat.Clear(); } } private void bkapat_Click(object sender, EventArgs e) { this.Close(); } } } |