コード例 #1
0
ファイル: Form1.cs プロジェクト: t0is/fantastic-spork
 private void TablePlayers_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == TablePlayers.Columns["col_edit"].Index)
     {
         //detail!
         try
         {
             string p_id = TablePlayers.Rows[e.RowIndex].Cells[0].Value.ToString();
             Form2  f2   = new Form2("detail", p_id);
             f2.ShowDialog();
             refreshRows();
         }
         catch (Exception)
         {
             MessageBox.Show("You need to select a valid row", "", MessageBoxButtons.OK);
             return;
         }
     }
     else if (e.ColumnIndex == TablePlayers.Columns["col_del"].Index)
     {
         try
         {
             if (DialogResult.Yes == MessageBox.Show("Do you want to delete the row?", "", MessageBoxButtons.YesNo))
             {
                 //delete it!
                 string p_id = TablePlayers.Rows[e.RowIndex].Cells[0].Value.ToString();
                 PersonTable.Delete(Int32.Parse(p_id));
                 refreshRows();
             }
         }
         catch (Exception)
         {
             MessageBox.Show("You need to select a valid row", "", MessageBoxButtons.OK);
             return;
         }
     }
     else if (e.ColumnIndex == TablePlayers.Columns["col_ed"].Index)
     {
         try {
             string p_id = TablePlayers.Rows[e.RowIndex].Cells[0].Value.ToString();
             Form2  f2   = new Form2("edit", p_id);
             f2.ShowDialog();
             refreshRows();
         }
         catch (Exception)
         {
             MessageBox.Show("You need to select a valid row", "", MessageBoxButtons.OK);
             return;
         }
     }
 }
コード例 #2
0
        private void Button_Delete_Click(object sender, EventArgs e)
        {
            Person dperson = new Person();

            foreach (Person person in records_studentsList)
            {
                if (int.Parse(textBox_ID.Text) == person.Id)
                {
                    dperson = person;
                }
            }

            manager_studentsTable.Delete(dperson);
            manager_studentsTable = new PersonTable();

            Button_view_Click(sender, e);
        }