private void FrmEditDataBarang_Load(object sender, EventArgs e) { Add add = new AddDAO().GetDataAddByKode(_code); if (add != null) { txtBoxCode.Text = add.Code; txtBoxName.Text = add.Name; txtBoxPrice.Text = add.Price.ToString(); } }
private void btnSave_Click(object sender, EventArgs e) { try { using (var addDao = new AddDAO()) { addDao.Simpan(listBarang); } MessageBox.Show("Success", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void QueryData(Add add = null) { try { this.dgvData.DataSource = null; List <Add> list = new AddDAO().QueryDataBarang(add); if (list != null) { this.dgvData.DataSource = list; this.dgvData.Columns[0].DataPropertyName = nameof(Add.Code); this.dgvData.Columns[1].DataPropertyName = nameof(Add.Name); this.dgvData.Columns[2].DataPropertyName = nameof(Add.Price); } } catch (Exception ex) { MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }