private void btnDaftar_Click(object sender, EventArgs e)
        {
            Barang barang = null;

            if (this.tbNamaBrgBaru.Text.Trim() == "")//jika isian nama kosong
            {
                MessageBox.Show("Sorry , nama barang wajib isi ...");
                this.tbNamaBrgBaru.Focus();
            }
            else if (this.tbHargaBrgBaru.Text.Trim() == "")
            {
                MessageBox.Show("Sorry , harga barang wajib isi ...");
                this.tbHargaBrgBaru.Focus();
            }
            else if (this.tbPajakBrg.Text.Trim() == "")
            {
                MessageBox.Show("Sorry , pajak barang wajib isi ...");
                this.tbPajakBrg.Focus();
            }
            else
            {
                barang             = new Barang();
                barang.KodeBarang  = dao.GetKodeBarangBerikutnya();
                barang.NamaBarang  = this.tbNamaBrgBaru.Text;
                barang.HargaBarang = Convert.ToDouble(this.tbHargaBrgBaru.Text);
                barang.PajakBarang = Convert.ToDouble(this.tbPajakBrg.Text);
                dao.Insert(barang);
                this.Close();
            }
        }
Exemplo n.º 2
0
 private void FrmTambahBarang_Load(object sender, EventArgs e)
 {
     if (brg != null)
     {
         this.txtKodeBarang.Text    = brg.Kode;
         this.txtKodeBarang.Enabled = false;
         this.txtNamaBarang.Text    = brg.Nama;
         this.txtJumlahBarang.Text  = Convert.ToInt32(brg.Jumlah).ToString();
         this.txtHargaBarang.Text   = Convert.ToDecimal(brg.Harga).ToString();
     }
     else
     {
         var dao = new BarangDAO(sqlString);
         this.txtKodeBarang.Text    = dao.GetKodeBarangBerikutnya();
         this.txtKodeBarang.Enabled = false;
         this.btnHapus.Visible      = false;
     }
 }