} //UpdateProduct() /* * public bool DeleteProduct(int productId) * { * hasError = false; * SqlConnection con = new SqlConnection(conString); * SqlCommand cmd = new SqlCommand("DeleteProduct", con); * cmd.CommandType = CommandType.StoredProcedure; * cmd.Parameters.Add("@ProductId", SqlDbType.Int, 4); * cmd.Parameters["@ProductId"].Value = productId; * try * { * con.Open(); * int rows = cmd.ExecuteNonQuery(); * } * catch (SqlException ex) * { * errorMessage = "DELETE SQL error, " + ex.Message; * hasError = true; * } * catch (Exception ex) * { * errorMessage = "DELETE error, " + ex.Message; * hasError = true; * } * finally * { * con.Close(); * } * return !hasError; * }// DeleteProduct() */ public bool DeleteProduct(int productId) { hasError = false; try { LinqDataContext dc = new LinqDataContext(); dc.DeleteProduct(productId); } catch (Exception ex) { errorMessage = "Delete error, " + ex.Message; hasError = true; } return(!hasError); }// DeleteProduct()
/* public bool DeleteProduct(int productId) { hasError = false; SqlConnection con = new SqlConnection(conString); SqlCommand cmd = new SqlCommand("DeleteProduct", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ProductId", SqlDbType.Int, 4); cmd.Parameters["@ProductId"].Value = productId; try { con.Open(); int rows = cmd.ExecuteNonQuery(); } catch (SqlException ex) { errorMessage = "DELETE SQL error, " + ex.Message; hasError = true; } catch (Exception ex) { errorMessage = "DELETE error, " + ex.Message; hasError = true; } finally { con.Close(); } return !hasError; }// DeleteProduct() */ public bool DeleteProduct(int productId) { hasError = false; try { LinqDataContext dc = new LinqDataContext(); dc.DeleteProduct(productId); } catch (Exception ex) { errorMessage = "Delete error, " + ex.Message; hasError = true; } return !hasError; }