/// <summary> /// 查詢出貨公司(ShipperId & ShipperName) /// </summary> /// <returns>List<Models.Order></returns> public static List <Models.Order> GetShipper_Id_Name() { Models.Order result = new Models.Order(); DataTable dt = new DataTable(); string sql = "SELECT ShipperID As ShipperId , CompanyName As ShipperName FROM Sales.Shippers"; using (SqlConnection conn = new SqlConnection(GetDBConnectionString())) { conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); SqlDataAdapter sqlAdapter = new SqlDataAdapter(cmd); sqlAdapter.Fill(dt); conn.Close(); } return(OrderServiceConfig.MapOrderDataToList(dt)); /*List<Models.Order> result_Order = new List<Order>(); * * foreach (DataRow row in dt.Rows) * { * result_Order.Add(new Order() * { * ShipperId = (int)row["ShipperId"], * ShipperName = row["ShipperName"].ToString() * }); * } * return result_Order;*/ }
/// <summary> /// 查詢負責員工(EmpId & EmpName) /// </summary> /// <returns>List<Models.Order></returns> public static List <Models.Order> GetEmployee_Id_Name() { Models.Order result = new Models.Order(); DataTable dt = new DataTable(); string sql = "SELECT EmployeeID As EmpId , LastName + ' ' + FirstName As EmpName FROM HR.Employees"; using (SqlConnection conn = new SqlConnection(GetDBConnectionString())) { conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); SqlDataAdapter sqlAdapter = new SqlDataAdapter(cmd); sqlAdapter.Fill(dt); conn.Close(); } return(OrderServiceConfig.MapOrderDataToList(dt)); /*List<Models.Order> result_Order = new List<Order>(); * * foreach (DataRow row in dt.Rows) * { * result_Order.Add(new Order() * { * EmpId = (int)row["EmpId"], * EmpName = row["EmpName"].ToString() * }); * } * return result_Order;*/ }