Exemplo n.º 1
0
 private void btnEnter_Click(object sender, EventArgs e)
 {
     if (tbStok.Text != "")
     {
         db.OpenConnection();
         b = db.CariNama(db.myConnection, tbCariNama.Text);
         if (int.Parse(tbStok.Text) > b.stok)
         {
             MessageBox.Show("Jumlah yang anda masukkan tidak tepat");
         }
         else
         {
             float income = float.Parse(b.harga) * float.Parse(tbStok.Text);
             incomeToday.Add(income);
             lblMoney.Visible = true;
             float sum = incomeToday.Sum();
             lblMoney.Text = Convert.ToString(sum);
             int stokNow = b.stok - int.Parse(tbStok.Text);
             db.UpdateStok(db.myConnection, tbCariNama.Text, stokNow);
         }
         db.CloseConnection();
     }
 }
Exemplo n.º 2
0
 private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (modeHapus)
     {
         selectedId = dataGridView1.Rows[e.RowIndex].Cells["ID"].FormattedValue.ToString();
         db.OpenConnection();
         db.HapusBarang(db.myConnection, selectedId);
         db.CloseConnection();
         ShowData();
         modeHapus = false;
     }
     else if (modeEdit)
     {
         selectedId = dataGridView1.Rows[e.RowIndex].Cells["ID"].FormattedValue.ToString();
         Barang b = new Barang();
         b.nama  = dataGridView1.Rows[e.RowIndex].Cells["Nama"].FormattedValue.ToString();
         b.harga = dataGridView1.Rows[e.RowIndex].Cells["Harga"].FormattedValue.ToString();
         b.stok  = int.Parse(dataGridView1.Rows[e.RowIndex].Cells["Stok"].FormattedValue.ToString());
         FormEdit formEdit = new FormEdit(b, selectedId);
         formEdit.ShowDialog();
         ShowData();
         modeEdit = false;
     }
 }