public IEnumerable <FindOrderdetaiByOrderIDModel> FindOrderdetaiByOrderID(int orderid) { var command = Command("dbo.FindOrderdetaiByOrderID"); command.Parameters.Add(new SqlParameter("@orderid", orderid)); command.Connection.Open(); SqlDataReader reader = command.ExecuteReader(); var FindOrderdetaiByOrderIDs = new List <FindOrderdetaiByOrderIDModel>(); while (reader.Read()) { var FindOrderdetaiByOrderID = new FindOrderdetaiByOrderIDModel(); FindOrderdetaiByOrderID = DbReaderModelBinder <FindOrderdetaiByOrderIDModel> .Bind(reader); FindOrderdetaiByOrderIDs.Add(FindOrderdetaiByOrderID); } command.Connection.Close(); return(FindOrderdetaiByOrderIDs); }
public IEnumerable <GetBuyerOrderModel> GetBuyerOrder(string memberID) { var command = Command("dbo.GetBuyerOrder"); command.Parameters.Add(new SqlParameter("@memberID", memberID)); command.Connection.Open(); SqlDataReader reader = command.ExecuteReader(); var GetBuyerOrders = new List <GetBuyerOrderModel>(); while (reader.Read()) { var GetBuyerOrder = new GetBuyerOrderModel(); GetBuyerOrder = DbReaderModelBinder <GetBuyerOrderModel> .Bind(reader); GetBuyerOrders.Add(GetBuyerOrder); } command.Connection.Close(); return(GetBuyerOrders); }
public IEnumerable <FindIndexProducts> FindMoneyBetween(decimal lower, decimal higher) { var command = Command("dbo.FindMoneyBetween"); command.Parameters.Add(new SqlParameter("@lower", lower)); command.Parameters.Add(new SqlParameter("@higher", higher)); command.Connection.Open(); SqlDataReader reader = command.ExecuteReader(); var FindMoneyBetween = new List <FindIndexProducts>(); while (reader.Read()) { var GetBetween = new FindIndexProducts(); GetBetween = DbReaderModelBinder <FindIndexProducts> .Bind(reader); FindMoneyBetween.Add(GetBetween); } command.Connection.Close(); return(FindMoneyBetween); }
public IEnumerable <FindFormatIDByProductIDCS> GetFormatIDByProductIDCS(int productid, string size, string color) { var command = Command("dbo.FindFormatIDByProductIDCS"); command.Parameters.Add(new SqlParameter("@productid", productid)); command.Parameters.Add(new SqlParameter("@color", color)); command.Parameters.Add(new SqlParameter("@size", size)); command.Connection.Open(); SqlDataReader reader = command.ExecuteReader(); var GetFormatIDByProductIDCS = new List <FindFormatIDByProductIDCS>(); while (reader.Read()) { var GetProductFormatID = new FindFormatIDByProductIDCS(); GetProductFormatID = DbReaderModelBinder <FindFormatIDByProductIDCS> .Bind(reader); GetFormatIDByProductIDCS.Add(GetProductFormatID); } command.Connection.Close(); return(GetFormatIDByProductIDCS); }
public IEnumerable <Orders> GetAll() //ok //()內不用給直 因為傳整個表格 { SqlConnection connection = new SqlConnection(source.connectcloud); var sql = "SELECT * FROM Orders"; SqlCommand command = new SqlCommand(sql, connection); var list = new List <Orders>(); var orders = new Orders(); connection.Open(); var reader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection); while (reader.Read()) { orders = DbReaderModelBinder <Orders> .Bind(reader); list.Add(orders); } reader.Close(); connection.Close(); return(list); }
public IEnumerable <Orders> GetByOrderID(int OrderID) //ok { SqlConnection connection = new SqlConnection(source.connectcloud); var sql = "SELECT * FROM Orders Where OrderID = @OrderID"; var list = new List <Orders>(); SqlCommand command = new SqlCommand(sql, connection); command.Parameters.AddWithValue("@OrderID", OrderID); connection.Open(); var orders = new Orders(); var reader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection); while (reader.Read()) { orders = DbReaderModelBinder <Orders> .Bind(reader); list.Add(orders); } reader.Close(); connection.Close(); return(list); //? }
public IEnumerable <OrderDetail> GetAll() //()內不用給直 因為傳整個表格 { SqlConnection connection = new SqlConnection(source.connectcloud); var sql = "SELECT * FROM OrderDetail"; SqlCommand command = new SqlCommand(sql, connection); connection.Open(); var reader = command.ExecuteReader(); var list = new List <OrderDetail>(); var orderDetail = new OrderDetail(); while (reader.Read()) { orderDetail = DbReaderModelBinder <OrderDetail> .Bind(reader); list.Add(orderDetail); } reader.Close(); connection.Close(); return(list); }
public IEnumerable <Discounts> OrderByDiscountDESC() { //找到所有產品,並用折扣排序 SqlConnection connection = new SqlConnection(source.connectcloud); var sql = "SELECT p.ProductID, p.Category, p.Name, p.UnitPrice FROM Products p INNER JOIN Discounts d ON d.ProductID = p.ProductID WHERE d.ProductID = p.ProductID ORDER BY d.Discount DESC"; SqlCommand command = new SqlCommand(sql, connection); connection.Open(); var reader = command.ExecuteReader(CommandBehavior.CloseConnection); var list = new List <Discounts>(); while (reader.Read()) { var discount = new Discounts(); discount = DbReaderModelBinder <Discounts> .Bind(reader); list.Add(discount); } reader.Close(); connection.Close(); return(list); }
/// <summary> /// Get All Discount /// </summary> /// <returns></returns> public IEnumerable <Discounts> GetAll() { SqlConnection connection = new SqlConnection(source.connectcloud); var sql = "SELECT * FROM Discounts"; SqlCommand command = new SqlCommand(sql, connection); connection.Open(); var reader = command.ExecuteReader(CommandBehavior.CloseConnection); var list = new List <Discounts>(); while (reader.Read()) { var discount = new Discounts(); discount = DbReaderModelBinder <Discounts> .Bind(reader); list.Add(discount); } reader.Close(); connection.Close(); return(list); }
public IEnumerable <Products> _GetAll() { SqlConnection connection = new SqlConnection(source.connectcloud); var sql = "SELECT * FROM Products"; SqlCommand command = new SqlCommand(sql, connection); connection.Open(); var reader = command.ExecuteReader(); var list = new List <Products>(); Products products = new Products(); while (reader.Read()) { products = DbReaderModelBinder <Products> .Bind(reader); list.Add(products); } reader.Close(); connection.Close(); return(list); }