public TourCodePrice Get(int tourCodeId) { if (_connection.State == System.Data.ConnectionState.Open) { _connection.Close(); } var price = new TourCodePrice { TourCodeID = tourCodeId }; _connection.Open(); _cmd = _connection.CreateCommand(); _cmd.CommandText = "Select price, pricechild, pricefamilychild, goldprice, goldpricechild, goldpricefamilychild from tourcodeprices where tourcodeid='" + tourCodeId + "' and active_f=1;"; _dr = _cmd.ExecuteReader(); while (_dr.Read()) { price.Price = _dr.GetFloat(0); price.PriceChild = _dr.GetFloat(1); price.PriceFamilyChild = _dr.GetFloat(2); price.GoldPrice = _dr.GetFloat(3); price.GoldPriceChild = _dr.GetFloat(4); price.GoldPriceFamilyChild = _dr.GetFloat(5); } _dr.Close(); if (_connection.State == System.Data.ConnectionState.Open) { _connection.Close(); } return(price); }
public void Delete(TourCodePrice obj) { if (_connection.State == System.Data.ConnectionState.Open) { _connection.Close(); } _connection.Open(); _cmd = _connection.CreateCommand(); _cmd.CommandText = " DELETE from tourcodeprices where tourcodeid=@tourCodeId; "; _cmd.Parameters.AddWithValue("@tourCodeId", obj.TourCodeID); _cmd.ExecuteNonQuery(); _dr.Close(); }
public void Insert(TourCodePrice obj) { if (_connection.State == System.Data.ConnectionState.Open) { _connection.Close(); } _connection.Open(); _cmd = _connection.CreateCommand(); _cmd.CommandText = " INSERT INTO tourcodeprices (`TourCodeID`, `Price`, `PriceChild`, `PriceFamilyChild`, `GoldPrice`, `GoldPriceChild`, `GoldPriceFamilyChild`) VALUES (@tourCodeId, @price, @pricechild, @pricefamilychild, @goldprice, @goldpricechild, @goldpricefamilychild); "; _cmd.Parameters.AddWithValue("@tourCodeId", obj.TourCodeID); _cmd.Parameters.AddWithValue("@price", obj.Price); _cmd.Parameters.AddWithValue("@pricechild", obj.PriceChild); _cmd.Parameters.AddWithValue("@pricefamilychild", obj.PriceFamilyChild); _cmd.Parameters.AddWithValue("@goldprice", obj.GoldPrice); _cmd.Parameters.AddWithValue("@goldpricechild", obj.GoldPriceChild); _cmd.Parameters.AddWithValue("@goldpricefamilychild", obj.GoldPriceFamilyChild); _cmd.ExecuteNonQuery(); _dr.Close(); }
public void Update(TourCodePrice obj) { if (_connection.State == System.Data.ConnectionState.Open) { _connection.Close(); } _connection.Open(); _cmd = _connection.CreateCommand(); _cmd.CommandText = " UPDATE tourcodeprices SET `Price`=@price,`PriceChild`=@pricechild,`PriceFamilyChild`=@pricefamilychild,`GoldPrice`=@goldprice,`GoldPriceChild`=@goldpricechild,`GoldPriceFamilyChild`=@goldpricefamilychild where tourcodeid=@tourCodeId; "; _cmd.Parameters.AddWithValue("@tourCodeId", obj.TourCodeID); _cmd.Parameters.AddWithValue("@price", obj.Price); _cmd.Parameters.AddWithValue("@pricechild", obj.PriceChild); _cmd.Parameters.AddWithValue("@pricefamilychild", obj.PriceFamilyChild); _cmd.Parameters.AddWithValue("@goldprice", obj.GoldPrice); _cmd.Parameters.AddWithValue("@goldpricechild", obj.GoldPriceChild); _cmd.Parameters.AddWithValue("@goldpricefamilychild", obj.GoldPriceFamilyChild); _cmd.ExecuteNonQuery(); _dr.Close(); }