Esempio n. 1
0
 /// <summary>
 /// 点击数据网格
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dataGridView1.Columns[e.ColumnIndex].Name == "colBtn_alter")
     {
         Blog model = new Blog();
         model.Id     = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["Id"].Value);
         model.name   = dataGridView1.Rows[e.RowIndex].Cells["name"].Value.ToString();
         model.author = dataGridView1.Rows[e.RowIndex].Cells["author"].Value.ToString();
         model.date   = dataGridView1.Rows[e.RowIndex].Cells["date"].Value.ToString();
         if (BlogDAL.AlterByPK(model, "Id"))
         {
             ShowDataGird(); MessageBox.Show("修改成功", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }