private void GroupEvaluationsGrid_CellClick_1(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == GroupEvaluationsGrid.NewRowIndex || e.RowIndex < 0) return; if (e.ColumnIndex == GroupEvaluationsGrid.Columns["EvaluationRemoveButton"].Index) { int i = e.RowIndex; int groupId = Convert.ToInt32(GroupEvaluationsGrid.Rows[i].Cells[0].Value); string EvalName = GroupEvaluationsGrid.Rows[i].Cells[1].Value.ToString(); SqlConnection conn = new SqlConnection(connString); conn.Open(); string getid = string.Format("SELECT Id FROM Evaluation WHERE Name = '{0}'", EvalName); SqlCommand cmd = new SqlCommand(getid, conn); int id = (Int32)cmd.ExecuteScalar(); string remove = string.Format("DELETE FROM GroupEvaluation WHERE GroupId = '{0}' AND EvaluationId = '{1}'", groupId, id); cmd.CommandText = remove; cmd.ExecuteNonQuery(); MessageBox.Show("Evaluation Removed!"); GroupEvaluationsGrid.Rows.RemoveAt(i); conn.Close(); } else if (e.ColumnIndex == GroupEvaluationsGrid.Columns["EvaluationEditButton"].Index) { int i = e.RowIndex; int groupId = Convert.ToInt32(GroupEvaluationsGrid.Rows[i].Cells[0].Value); string EvalName = GroupEvaluationsGrid.Rows[i].Cells[1].Value.ToString(); string obtMarks = GroupEvaluationsGrid.Rows[i].Cells[3].Value.ToString(); EvaluateGroupsForm form = new EvaluateGroupsForm(groupId, EvalName, obtMarks, "edit"); form.Show(); this.Close(); } }
private void AddGroupEvaluation_Click_1(object sender, EventArgs e) { EvaluateGroupsForm form = new EvaluateGroupsForm(0, null, null, "add"); form.Show(); this.Close(); }