コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Add_Student ads = new Add_Student();

            this.Hide();
            ads.Show();
        }
コード例 #2
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 9)
            {
                try
                {
                    rowIndex = e.RowIndex;
                    DataGridViewRow row = dataGridView1.Rows[rowIndex];
                    id = row.Cells[0].Value.ToString();
                    int         idd = int.Parse(id);
                    Add_Student ass = new Add_Student(idd);
                    this.Hide();
                    ass.Show();
                }
                catch
                {
                    MessageBox.Show("Try Again!");
                }
            }
            if (e.ColumnIndex == 10 && DialogResult.Yes == MessageBox.Show("Do You Want Delete ?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
            {
                try
                {
                    string sID   = dataGridView1.CurrentRow.Cells["Id"].Value.ToString();
                    string query = string.Format("delete Student where Id='{0}'", Convert.ToInt32(sID));
                    DatabaseConnection.getInstance().executeQuery(query);
                    string queryy = string.Format("delete Person where Id='{0}'", Convert.ToInt32(sID));
                    DatabaseConnection.getInstance().executeQuery(queryy);
                    //MessageBox.Show("Data deleted successfully...");
                    dataGridView1 = null;
                    this.Refresh();

                    //string queryyy = "select Student.Id, Student.RegistrationNo, Person.Id, Person.FirstName, Person.LastName, Person.Contact, Person.Email, Person.DateOfBirth, Person.Gender from Person join Student on Person.Id=Student.Id";
                    //var data = DatabaseConnection.getInstance().getAllData(queryyy);
                    //data.Fill(table);
                    //dataGridView1.DataSource = table;
                }
                catch
                {
                    MessageBox.Show("Try Again!");
                }
            }
        }