Program Mini Market Siti Mulia Sari
1.
Interface Program
(Gambar
1 Kalkulator Sederhana)
2.
Coding Program
Variable Komponen
|
Source Code
|
btnOk
|
private void btnOK_Click(object
sender, EventArgs e)
{
int TItem = Convert.ToInt32(cbtotalitemdibeli.Text);
string nmBarang;
int harga, jumlah, total;
double ttlBiaya, diskon = 0,
ttlHarga = 0;
lbdftrbrg.Items.Clear();
lbhargasatuan.Items.Clear();
lbjumlah.Items.Clear();
txttotalharga.Clear();
txtdiskon.Clear();
txttotalbiaya.Clear();
if (TItem <= 0)
{
MessageBox.Show("Maaf,
total item tidak boleh kurang sama dengan 0", "Peringatan",
MessageBoxButtons.OK, MessageBoxIcon.Warning); //untuk menampilkan peringatan
}
else
if (rbmember.Checked == false
&& rbagen.Checked == false)
{
MessageBox.Show("Item belum dicetang !", "Peringatan",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
if (rbmember.Checked ==
true && rbagen.Checked == true)
{
MessageBox.Show("Pilih Salah Satu", "Peringatan",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
for (int i = 0; i
< TItem; i++)
{
nmBarang =
Interaction.InputBox("Nama Barang", "Masukan Nama
Barang");
lbdftrbrg.Items.Add(nmBarang);
harga =
Convert.ToInt32(Interaction.InputBox("Harga Barang Persatuan",
"Harga " + nmBarang));
lbhargasatuan.Items.Add(harga.ToString());
jumlah =
Convert.ToInt32(Interaction.InputBox("Jumlah", "Jumlah "
+ nmBarang));
lbjumlah.Items.Add(jumlah.ToString());
total = harga *
jumlah;
lbtotal.Items.Add(total.ToString());
ttlHarga +=
total;
}
txttotalharga.Text =
ttlHarga.ToString();
if (rbmember.Checked
== true && rbagen.Checked == false)
{
diskon = 0.1 *
ttlHarga;
}
else if
(rbmember.Checked == false && rbagen.Checked == true)
{
diskon = 0.15 *
ttlHarga;
}
else if
(rbmember.Checked == false && rbagen.Checked == false)
{
diskon = 0;
}
txtdiskon.Text =
diskon.ToString();
ttlBiaya = ttlHarga -
diskon;
txttotalbiaya.Text =
ttlBiaya.ToString();
}
}
|
Btnbersih
|
private void btnbersih_Click(object sender, EventArgs e)
{
cbtotalitemdibeli.Text
= "0";
rbmember.Checked =
false;
rbagen.Checked = false;
lbdftrbrg.Items.Clear();
lbhargasatuan.Items.Clear();
lbjumlah.Items.Clear();
lbtotal.Items.Clear();
txttotalharga.Clear();
txtdiskon.Clear();
txttotalbiaya.Clear();
}
|
Btnkeluar
|
private void btnkeluar_Click(object sender, EventArgs e)
{
DialogResult Result =
MessageBox.Show("Apakah Anda yakin ingin keluar ? ",
"Peringatan", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (Result ==
DialogResult.Yes)
{
Application.Exit();
}
}
}
}
|
3.
Output
0 komentar:
Posting Komentar