private void GroupStudentDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { int currentRow = int.Parse(e.RowIndex.ToString()); int curentcolumnindex = int.Parse(e.ColumnIndex.ToString()); int sid = Convert.ToInt32(GroupStudentDataGridView.Rows[currentRow].Cells[1].Value); if (curentcolumnindex == 0) { SqlConnection conn = new SqlConnection(conURL); conn.Open(); String UpdateCMD = "UPDATE GroupStudent SET Status = @status WHERE GroupStudent.StudentId = @sid"; SqlCommand UpdateCommand = new SqlCommand(UpdateCMD, conn); UpdateCommand.Parameters.Add(new SqlParameter("status", 4)); UpdateCommand.Parameters.Add(new SqlParameter("sid", sid)); int count = UpdateCommand.ExecuteNonQuery(); String AddCMD = "INSERT INTO GroupStudent (GroupId, StudentId, Status, AssignmentDate) VALUES (@gid, @sid, @status, @asgnDate)"; SqlCommand AddCommand = new SqlCommand(AddCMD, conn); AddCommand.Parameters.Add(new SqlParameter("status", 3)); AddCommand.Parameters.Add(new SqlParameter("sid", sid)); AddCommand.Parameters.Add(new SqlParameter("gid", groupId)); AddCommand.Parameters.Add(new SqlParameter("asgnDate", DateTime.Today)); count = AddCommand.ExecuteNonQuery(); AddStudentGroup form = new AddStudentGroup(Convert.ToInt32(groupId)); form.Show(); this.Hide(); } }
private void StdGroupDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { int currentRow = int.Parse(e.RowIndex.ToString()); int curentcolumnindex = int.Parse(e.ColumnIndex.ToString()); string gid = StdGroupDataGridView.Rows[currentRow].Cells[0].Value.ToString(); if (curentcolumnindex == 2) { AddStudentGroup form = new AddStudentGroup(Convert.ToInt32(gid)); form.Show(); this.Hide(); } if (curentcolumnindex == 3) { ViewGroupStudents form = new ViewGroupStudents(Convert.ToInt32(gid)); form.Show(); this.Hide(); } if (curentcolumnindex == 4) { AddEvaluationGroup form = new AddEvaluationGroup(Convert.ToInt32(gid)); form.Show(); this.Hide(); } if (curentcolumnindex == 5) { ViewGroupEvaluation form = new ViewGroupEvaluation(Convert.ToInt32(gid)); form.Show(); this.Hide(); } if (curentcolumnindex == 6) { AddGroupProject form = new AddGroupProject(Convert.ToInt32(gid)); form.Show(); this.Hide(); } if (curentcolumnindex == 7) { ViewGroupProject form = new ViewGroupProject(Convert.ToInt32(gid)); form.Show(); this.Hide(); } if (curentcolumnindex == 8) { SqlConnection conn = new SqlConnection(conURL); conn.Open(); String DeleteCMD = "DELETE FROM GroupStudent WHERE GroupStudent.GroupId = @id"; SqlCommand DeleteCommand = new SqlCommand(DeleteCMD, conn); DeleteCommand.Parameters.Add(new SqlParameter("id", Convert.ToInt32(gid))); int count = DeleteCommand.ExecuteNonQuery(); String DeleteCMD2 = "DELETE FROM GroupEvaluation WHERE GroupEvaluation.GroupId = @id"; SqlCommand DeleteCommand2 = new SqlCommand(DeleteCMD2, conn); DeleteCommand2.Parameters.Add(new SqlParameter("id", Convert.ToInt32(gid))); count = DeleteCommand2.ExecuteNonQuery(); String DeleteCMD3 = "DELETE FROM GroupProject WHERE GroupProject.GroupId = @id"; SqlCommand DeleteCommand3 = new SqlCommand(DeleteCMD3, conn); DeleteCommand3.Parameters.Add(new SqlParameter("id", Convert.ToInt32(gid))); count = DeleteCommand3.ExecuteNonQuery(); String DeleteCMD4 = "DELETE FROM [Group] WHERE [Group].Id = @id"; SqlCommand DeleteCommand4 = new SqlCommand(DeleteCMD4, conn); DeleteCommand4.Parameters.Add(new SqlParameter("id", Convert.ToInt32(gid))); count = DeleteCommand4.ExecuteNonQuery(); GroupStudent form = new GroupStudent(); form.Show(); this.Hide(); } }