public bool Delete(TripCostBLL c) { bool isSuccess = false; SqlConnection conn = new SqlConnection(myconnstring); try { String sql = "Delete from Trip_Cost where trip_id=@trip_id"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@trip_id", c.trip_id); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { isSuccess = true; } else { isSuccess = false; } } catch (Exception e) { MessageBox.Show(e.Message); } finally { conn.Close(); } return(isSuccess); }
public bool Insert(TripCostBLL c) { bool isSuccess = false; SqlConnection conn = new SqlConnection(myconnstring); try { String sql = "insert into Trip_Cost(trip_id,diesel_cost,toll_cost,other_cost,total_cost) values(@trip_id,@diesel_cost,@toll_cost,@other_cost,@total_cost) "; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@trip_id", c.trip_id); cmd.Parameters.AddWithValue("@diesel_cost", c.diesel_cost); cmd.Parameters.AddWithValue("@toll_cost", c.toll_cost); cmd.Parameters.AddWithValue("@other_cost", c.other_cost); cmd.Parameters.AddWithValue("@total_cost", c.total_cost); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { isSuccess = true; } else { isSuccess = false; } } catch (Exception e) { MessageBox.Show(e.Message); } finally { conn.Close(); } return(isSuccess); }