コード例 #1
0
ファイル: MainForm.cs プロジェクト: munnaonc/PrizeBondManager
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex < 0)
         return;
     //edit
     if (e.ColumnIndex == 0)
     {
         var dataGridViewRow = dataGridView1.Rows[e.RowIndex];
         var dataBoundItem = (Bond)dataGridViewRow.DataBoundItem;
         var addBond = new AddBond();
         addBond.SetUiMode();
         addBond.SetData(dataBoundItem);
         addBond.ShowDialog(this);
         LoadBonds();
     }
     //delete
     if (e.ColumnIndex == 1)
     {
         var dataGridViewRow = dataGridView1.Rows[e.RowIndex];
         var dataBoundItem = (Bond)dataGridViewRow.DataBoundItem;
         var result = MessageBox.Show(@"Are you sure,you want to delete?",
         @"Delete Bond", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
         if (result == DialogResult.OK)
         {
             var dal = new DAL();
             dal.DeleteBond(dataBoundItem.Id);
             LoadBonds();
         }
     }
 }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: munnaonc/PrizeBondManager
 private void btnAddBond_Click(object sender, EventArgs e)
 {
     var addBond = new AddBond();
     addBond.ShowDialog(this);
     LoadBonds();
 }