using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Data;
using Hierarchy_RIA.Web;
using Telerik.Windows.Data;
using Telerik.Windows.Controls.GridView;

namespace Hierarchy_RIA
{
	public partial class MainPage : UserControl
	{
		public MainPage()
		{
			InitializeComponent();
		}

		private void orderDomainDataSource_LoadedData(object sender, System.Windows.Controls.LoadedDataEventArgs e)
		{
			if (e.HasError)
			{
				System.Windows.MessageBox.Show(e.Error.ToString(), "Load Error", System.Windows.MessageBoxButton.OK);
				e.MarkErrorAsHandled();
			}
		}

		private void orderRadGridView_Sorting(object sender, Telerik.Windows.Controls.GridViewSortingEventArgs e)
		{
			//e.Cancel = true;
			//SortDescriptor sd = new SortDescriptor("Order_Details.UnitPrice", System.ComponentModel.ListSortDirection.Ascending);
			//orderDomainDataSource.SortDescriptors.Add(sd);
			//orderDomainDataSource.QueryName = "GetSortedOrdersQuery";
			//orderDomainDataSource.Load();
		}

		private void employeeDomainDataSource_LoadedData(object sender, LoadedDataEventArgs e)
		{

			if (e.HasError)
			{
				System.Windows.MessageBox.Show(e.Error.ToString(), "Load Error", System.Windows.MessageBoxButton.OK);
				e.MarkErrorAsHandled();
			}
		}

		private void RadGridView_RowLoaded(object sender, RowLoadedEventArgs e)
		{
			Employee emp = e.DataElement as Employee;
			GridViewRow row = e.Row as GridViewRow;

			if (row != null && emp != null)
			{
				if (emp.ReportsTo.HasValue)
				{
					//row.Visibility = Visibility.Collapsed;
				}
			}
		}

		private void Button_Click(object sender, RoutedEventArgs e)
		{
			ChildWindow1 child = new ChildWindow1();
			child.Show();
		}		
	}
}
