private void cell_Click(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { DataGridViewRow row = this.dgvCapNhatVatTu.Rows[e.RowIndex]; int maVT = int.Parse(row.Cells[1].Value.ToString()); VatTu db = VatTu.GetVatTu(maVT); txtCapNhatVatTu.Text = db.TenVT.ToString(); } }
private void btnLuuCapNhatVatTu_Click(object sender, EventArgs e) { VatTu s = GetVatTu(); s.VatTuID = (int)dgvCapNhatVatTu.CurrentRow.Cells[1].Value; VatTu db = VatTu.GetVatTu(s.VatTuID); if (db != null) { db = s; db.InsertUpdate(); MessageBox.Show("Sửa thành công!"); } BindGrid(VatTu.GetAll()); }
private void btnThemDichVuVT_Click(object sender, EventArgs e) { try { VatTu s = GetVatTu(); VatTu db = VatTu.GetVatTu(s.VatTuID); if (db == null) { s.InsertUpdate(); MessageBox.Show("Thêm vật tư thành công!"); } BindGrid(VatTu.GetAll()); } catch (Exception ex) { MessageBox.Show(ex.Message); } }