private void Header_Click(object sender, EventArgs e)
		{
			DataMember member = DataSource.Members.Where(mi => ((ILabelButton) sender).Text == Translator.Translate(mi.DataMember.Member.FinalMemberInfo)).Select(mi => mi.DataMember).Single();
			OrderBy order = DataSource.OrderBy.Where(ob => ob.Member == member).SingleOrDefault();

			DataSource.OrderBy.Clear();

			if (order != null)
			{
				if (order.Direction == Data.SortDirection.Ascending)
				{
					order.Direction = Data.SortDirection.Descending;
				}
				else
				{
					order.Direction = Data.SortDirection.Ascending;
				}
			}
			else
			{
				order = new OrderBy(member, Data.SortDirection.Ascending);
				DataSource.OrderBy.Add(order);
			}

			DataBind();
		}
Beispiel #2
0
		/// <summary>
		/// Headers the click.
		/// <para xml:lang="es">
		/// Contiene el evento clic del encavezado seleccionado.
		/// </para>
		/// </summary>
		/// <param name="sender">Sender.
		/// <para xml:lang="es">Objeto seleccionado.</para>
		/// </param>
		/// <param name="e">E.
		/// <para xml:lang="es">Eventos para el objeto.</para>
		/// </param>
		private void Header_Click(object sender, EventArgs e)
		{
			SelectMember member = (SelectMember) ((ILabelButton) sender).Tag;
			SelectJoin join = DataSource.Joins.Where(j => j.Members.Contains(member)).SingleOrDefault();
			OrderBy order;

			if (join == null)
			{
				order = DataSource.OrderBy.Where(ob => ob.Member == member.DataMember).SingleOrDefault();
			}
			else
			{
				order = DataSource.OrderBy.Where(ob => ob.Member == member.DataMember && ob.TypeAlias == join.Alias).SingleOrDefault();
			}

			DataSource.OrderBy.Clear();

			if (order != null)
			{
				//If the order is Ascending, sorts ascendingly
				if (order.Direction == Data.SortDirection.Ascending)
				{
					order.Direction = Data.SortDirection.Descending;
				}
				//otherwise, it ordered ascendingly.
				else
				{
					order.Direction = Data.SortDirection.Ascending;
				}
			}
			else
			{
				//if there is no order, ascending order.
				if (join == null)
				{
					order = new OrderBy(member.DataMember, Data.SortDirection.Ascending);
				}
				else
				{
					order = new OrderBy(member.DataMember, Data.SortDirection.Ascending, join.Alias);
				}
			}

			DataSource.OrderBy.Add(order);
			DataBind();

			OnSorted();
		}