using System.Collections.Generic;
using System.Web.UI.WebControls;
using B4Restore.Common.Control;
using B4Restore.Common.Control.BaseDS;
using System;
using System.Web;
using DebriefingSoftware.Common;
using DebriefingSoftware.Web.PresentationObjects;
using Telerik.Web.UI;
using DebriefingSoftware.Common.Business.Filtering;
using System.Linq;

namespace Controls.Distributor
{
	public partial class DistributorView : DSBaseViewControl
	{
		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad(e);
			dsgridDistributorView.DataExport += GetDataForExport;
		}

		public void GetDataForExport()
		{
			if ((HttpContext.Current.Session[GridEntitySessionData.Distributor.ToString()]) != null)
			{
				dsgridDistributorView.DataSource = HttpContext.Current.Session[GridEntitySessionData.Distributor.ToString()];
			}
		}

		protected override void OnPreRender(EventArgs e)
		{
		}

		protected void lnkOur_PreRender(object sender, EventArgs e)
		{
			//var hyperLink = sender as HyperLink;
			//var filterParameter = new FilterParameter
			//                            {
			//                                FieldName = "DSWIZARD.COMPANY.PARENT_ID",
			//                                FieldValues = new[] {CompanyController.CurrentCompany.ID.ToString()},
			//                                DataType = SqlDataType.Integer,
			//                                OperationType = SqlOperationType.EqualTo,
			//                                Group = "Distributor"
			//                            };
			//var filter = new Filter();
			//filter.AddUrlParameter(filterParameter);
			//if (hyperLink != null)
			//{
			//    hyperLink.NavigateUrl = String.Format("~/Pages/DistributorView.aspx?{0}", filter.GetCurrentUrlString);
			//}
		}

		protected void lnkCompanyID_PreRender(object sender, EventArgs e)
		{
			//var hyperLink = sender as HyperLink;
			//var filterParameter = new FilterParameter
			//{
			//    FieldName = "DSWIZARD.COMPANY.ID",
			//    FieldValues = new[] { "3", "5" },
			//    DataType = SqlDataType.Integer,
			//    OperationType = SqlOperationType.In,
			//    Group = "Distributor"
			//};
			//var filter = new Filter();
			//filter.AddUrlParameter(filterParameter);
			//filter.AddUrlParameters(Filter.Current.GetCurrentUrlParameters);
			//if (hyperLink != null)
			//{
			//    hyperLink.NavigateUrl = String.Format("~/Pages/DistributorView.aspx?{0}", filter.GetCurrentUrlString);
			//}
		}

		protected void Loader(object sender, EventArgs e)
		{
			//var ourJoy = sender as RadioButtonList;
			var ourJoy = sender as ListBox;
			//var gridInfoList = new List<DebriefingSoftware.Web.PresentationObjects.Distributor.GridInfo>
			//                {
			//                    new DebriefingSoftware.Web.PresentationObjects.Distributor.GridInfo {ID = 0, ContactEmail = "ivan@ivan.com", Name = "Ivan", LastName = "Ivanov" },
			//                    new DebriefingSoftware.Web.PresentationObjects.Distributor.GridInfo {ID = 1, ContactEmail = "sasha@sasha.com", Name = "Sasha", LastName = "Sashev"},
			//                    new DebriefingSoftware.Web.PresentationObjects.Distributor.GridInfo {ID = 2, ContactEmail = "dmitry@dmitry.com", Name = "Dmitry", LastName = "Dmitriev"},
			//                    new DebriefingSoftware.Web.PresentationObjects.Distributor.GridInfo {ID = 3, ContactEmail = "yana@yana.com", Name = "Yana", LastName = "Yanova"}
			//                };
			//var dataSource = gridInfoList;
			//ourJoy.DataSource = dataSource;
			//ourJoy.DataTextField = "Name";
			//ourJoy.DataValueField = "ID";
			//ourJoy.DataBind();
			//ourJoy.Items[0].Selected = true;
		}
	}
}