private void button2_Click(object sender, EventArgs e) { int selectedRowCount = dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected); if (selectedRowCount != 1) { MessageBox.Show("Only one row must pe selected!", "Error selection", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { DataGridViewRow row = dataGridView1.SelectedRows[0]; int id = int.Parse(Convert.ToString(row.Cells["serviceId"].Value)); ServiceModify sm = new ServiceModify(id, companyId, Convert.ToString(row.Cells["name"].Value), Convert.ToString(row.Cells["description"].Value), true); this.Hide(); sm.ShowDialog(); // refresh gridview table conn.Open(); OleDbDataAdapter adapter = new OleDbDataAdapter("Select * from services where companyid = " + companyId, conn); DataTable dt = new DataTable(); adapter.Fill(dt); dataGridView1.DataSource = dt; conn.Close(); this.Show(); } }
private void button6_Click(object sender, EventArgs e) { ServiceModify sm = new ServiceModify(-1, companyId, "", "", false); this.Hide(); sm.ShowDialog(); // refresh gridview table conn.Open(); OleDbDataAdapter adapter = new OleDbDataAdapter("Select * from services where companyid = " + companyId, conn); DataTable dt = new DataTable(); adapter.Fill(dt); dataGridView1.DataSource = dt; conn.Close(); this.Show(); }