Class Form1
|
||
Variabel Komponen
|
Event
|
Source Code
|
btnOK
|
Click
|
private void btnOK_Click_1(object
sender, EventArgs e)
{ int TItem =
Convert.ToInt32(cbItem.Text);
string nmBarang;
int
harga, jumlah, total;
double ttlBiaya, diskon = 0, ttlHarga = 0;
lbDaftarbarang.Items.Clear();
lbHargasatuan.Items.Clear();
lbJumlah.Items.Clear();
lbTotal.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);
}
else
if (cbMember.Checked == false && cbAgen.Checked == false)
{
MessageBox.Show("Item belum dicetang !",
"Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
if (cbMember.Checked == true && cbAgen.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");
lbDaftarbarang.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 (cbMember.Checked == true && cbAgen.Checked == false)
{
diskon = 0.1 * ttlHarga; }
else if (cbMember.Checked == false && cbAgen.Checked == true)
{
diskon = 0.15 * ttlHarga; }
else if (cbMember.Checked == false && cbAgen.Checked == false)
{ diskon = 0; }
txtDiskon.Text = diskon.ToString();
ttlBiaya = ttlHarga - diskon;
txtTotalBiaya.Text = ttlBiaya.ToString();
}
}
|
btnClear
|
Click
|
private void btnClear_Click(object
sender, EventArgs e)
{
cbItem.Text = "0";
cbMember.Checked = false;
cbAgen.Checked = false;
lbDaftarbarang.Items.Clear();
lbHargasatuan.Items.Clear();
lbJumlah.Items.Clear();
lbTotal.Items.Clear();
txtTotalHarga.Clear();
txtDiskon.Clear();
txtTotalBiaya.Clear();
}
|
btnExit
|
Click
|
private void btnExit_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();
}
}
|
Langganan:
Posting Komentar (Atom)
Posting Komentar