private void btnEdit_Click(object sender, RoutedEventArgs e) { try { DataRowView dataRowView = (DataRowView)((Button)e.Source).DataContext; FormObat formObat = new FormObat("Edit", dataRowView[1].ToString()); formObat.txtNamaObat.Text = dataRowView[2].ToString(); formObat.cmbKategori.SelectedValue = dataRowView[3].ToString(); formObat.cmbSatuan.SelectedValue = dataRowView[4].ToString(); formObat.txtTglExpired.SelectedDate = DateTime.Parse(dataRowView[6].ToString()); formObat.txtStok.Text = dataRowView[7].ToString(); formObat.txtHargaBeli.Text = Kenko.getNumber1(dataRowView[8].ToString()); formObat.txtHargaJual.Text = Kenko.getNumber1(dataRowView[9].ToString()); formObat.txtHet.Text = Kenko.getNumber1(dataRowView[10].ToString()); formObat.txtProdusen.Text = dataRowView[11].ToString(); formObat.txtDeskripsi.Text = dataRowView[12].ToString(); formObat.ShowDialog(); RefreshDataGrid(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
private void btnTambah_Click(object sender, RoutedEventArgs e) { FormObat formObat = new FormObat(); formObat.ShowDialog(); RefreshDataGrid(); }