private void updateBtn_Click(object sender, EventArgs e) { int selectedrowindex = 0; if (table.SelectedCells.Count > 0) { Software.Model.Changelog changelogs = new Software.Model.Changelog(); selectedrowindex = table.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = table.Rows[selectedrowindex]; changelogs.Id = Convert.ToInt32(Convert.ToString(selectedRow.Cells["Id"].Value)); changelogs.Description = DescriptionBox.Text; changelogs.Employee_Id = Convert.ToInt32(Convert.ToString(selectedRow.Cells["Employee_Id"].Value)); Software.Database.SQL.ChangelogDB.UpdateChangelog(changelogs); MetroFramework.MetroMessageBox.Show(this, "Your data has been updated successfully.", "Successfully Completed", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MetroFramework.MetroMessageBox.Show(this, "You must select a row to update its value!", "Invalid Selection"); } DoRefresh(); table.Rows[selectedrowindex].Selected = true; }
private void createBtn_Click(object sender, EventArgs e) { Software.Model.Changelog changelogs = new Software.Model.Changelog(); changelogs.Description = DescriptionBox.Text; changelogs.Employee_Id = Convert.ToInt32(employeeBox.Text); Software.Database.SQL.ChangelogDB.InsertChangelog(changelogs); MetroFramework.MetroMessageBox.Show(this, "Data has been inserted!", "Successfully Completed", MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); }