Пример #1
0
 public static bool DeleteRecord(int id)
 {
     try
     {
         IDeleteDataSourceFace query = new DeleteSQL(TableName.Recomment);
         query.DataBaseAlias = Const.LogConnection;
         query.AddWhere("Id", id);
         return(query.ExecuteNonQuery() > 0);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         return(false);
     }
 }
Пример #2
0
 private void dgvProductInfo_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     //修改商品
     if (e.ColumnIndex == dgvProductInfo.Columns[0].Index)
     {
         ProductInfo productInfo = new ProductInfo("修改", int.Parse(dgvProductInfo.Rows[e.RowIndex].Cells["ProductID"].Value.ToString()));
         productInfo.ShowDialog();
     }
     //删除商品
     if (e.ColumnIndex == dgvProductInfo.Columns[1].Index)
     {
         //弹出确认删除框,确认删除后,调用删除语句
         if (MessageBox.Show("确认删除?", "此删除不可恢复", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             var sql = DeleteSQL.DeleteProductWithId(int.Parse(dgvProductInfo.Rows[e.RowIndex].Cells["ProductID"].Value.ToString()));
             MessageBox.Show(DeleteData.DeleteInfo(sql) ? "删除商品成功" : "删除商品失败");
         }
     }
 }