コード例 #1
0
        private void btnaddAttendance_Click(object sender, EventArgs e)
        {
            this.Hide();
            AddClassAttendace cl = new AddClassAttendace();

            cl.Show();
        }
コード例 #2
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (ClassAttendanceRecord.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "Edit")
            {
                Class1.stuId = Convert.ToInt32(ClassAttendanceRecord.Rows[e.RowIndex].Cells[0].Value);
                this.Hide();
                AddClassAttendace cl = new AddClassAttendace();
                cl.Show();
            }
            if (ClassAttendanceRecord.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "Delete")
            {
                int Id = Convert.ToInt32(ClassAttendanceRecord.Rows[e.RowIndex].Cells[0].Value);
                if (MessageBox.Show("Are you sure to perform this action!?" + ClassAttendanceRecord.Rows[e.RowIndex].Cells[1].Value.ToString() + "?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    SqlConnection newconn = new SqlConnection(con);
                    newconn.Open();
                    SqlCommand command = new SqlCommand("delete from StudentAttendance where AttendanceId = '" + Id + "'", newconn);
                    command.ExecuteNonQuery();
                    newconn.Close();
                    newconn.Open();
                    SqlCommand command1 = new SqlCommand("delete from ClassAttendance where Id  = '" + Id + "'", newconn);
                    command1.ExecuteNonQuery();

                    newconn.Close();
                    this.classAttendanceTableAdapter.Fill(this.projectBDataSet.ClassAttendance);
                }
            }
        }