-1
Hello, I have a webservice that returns me a list of "categories" with their sub-categories .
I need help to "filter this", for example:
Category 1 has sub-category 1 and 2;
Category 2 has sub-category 3;
Category 3 has sub-category 4, 5 and 6;
I want that when selecting the category 1, come in the next screen the sub-categories 1 and 2.
My web-service, already returns to me all categories and sub-categories of each, I want to know how to handle them to operate this way..
The parse made to pick up the category codes, would be these and are added to an Observablecollection:
string strDataTable = e.Result;
try
{
if (strDataTable.Length < 20)
{
MessageBox.Show("Não há dados disponíveis no momento, tente novamente mais tarde.\nCaso o erro persista, contactar o suporte técnico.");
return;
}
XElement doc = XElement.Parse(strDataTable);
foreach (XElement row in doc.Elements("GWDataTable"))
{
Produtos produto = new Produtos();
produto.descCateg = row.Element("DESCRICAOCATEGORIA").Value.ToString();
produto.descFamil = row.Element("DESCRICAOFAMILIA").Value.ToString();
produto.descGrupo = row.Element("DESCRICAOGRUPO").Value.ToString();
produto.descReceita = row.Element("DESCRICAOCRECEITA").Value.ToString();
produto.descricao = row.Element("OBS").Value.ToString();
produto.produto = row.Element("DESCRICAOPROD").Value.ToString();
produto.unidade = row.Element("UNIDADE").Value.ToString();
produto.precoN = row.Element("PRECONORMAL").Value.ToString();
produto.precoP = row.Element("PRECOPROMOCIONAL").Value.ToString();
produto.codCategoria = row.Element("CODCATEGORIA").Value.ToString();
produto.codFamilia = row.Element("CODFAMILIA").Value.ToString();
produto.codGrupo = row.Element("CODGRUPO").Value.ToString();
produto.codReceita = row.Element("CODCRECEITA").Value.ToString();
Resultados.ResProdutos.Add(produto);
}
try
{
SelectorProdutos.ItemsSource = Resultados.ResProdutos;
SetProgressIndicator(false);
}
catch (Exception)
{
MessageBox.Show("ERRO");
}
}
Resultados.ResProdutos.Add(produto);}
Products:
public class Produtos
{
public string descReceita { get; set; }
public string descGrupo { get; set; }
public string descCateg { get; set; }
public string descFamil { get; set; }
public string produto { get; set; }
public string codReceita { get; set; }
public string codGrupo { get; set; }
public string codCategoria { get; set; }
public string codFamilia { get; set; }
public string precoN { get; set; }
public string precoP { get; set; }
public string unidade { get; set; }
public string descricao { get; set; }
}
}
I prefer to use a Selectionchanged to start from the user by clicking on the Longlistselector item, move to the next screen, with the next category:
private void SelectorProdutos_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (SelectorProdutos.SelectedItem != null)
{
NavigationService.Navigate(new Uri("/Telas/frm5Grupo.xaml", UriKind.Relative));
}
else
{
MessageBox.Show("Erro");
}
}
At first I send to the screen the CODRECEITA for my Longlistselector, for the user to select the item you want, but after being selected, how can I proceed the filtering?
Web service response XML code:
<string xmlns="http://tempuri.org/">
<NewDataSet>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="GWDataTable" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="GWDataTable">
<xs:complexType>
<xs:sequence>
<xs:element name="CODPROD" type="xs:int" minOccurs="0" />
<xs:element name="DESCRICAOPROD" type="xs:string" minOccurs="0" />
<xs:element name="CODCRECEITA" type="xs:int" minOccurs="0" />
<xs:element name="DESCRICAOCRECEITA" type="xs:string" minOccurs="0" />
<xs:element name="CODGRUPO" type="xs:int" minOccurs="0" />
<xs:element name="DESCRICAOGRUPO" type="xs:string" minOccurs="0" />
<xs:element name="CODCATEGORIA" type="xs:int" minOccurs="0" />
<xs:element name="DESCRICAOCATEGORIA" type="xs:string" minOccurs="0" />
<xs:element name="CODFAMILIA" type="xs:int" minOccurs="0" />
<xs:element name="DESCRICAOFAMILIA" type="xs:string" minOccurs="0" />
<xs:element name="PRECONORMAL" type="xs:double" minOccurs="0" />
<xs:element name="PRECOPROMOCIONAL" type="xs:double" minOccurs="0" />
<xs:element name="UNIDADE" type="xs:string" minOccurs="0" />
<xs:element name="OBS" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<GWDataTable>
<CODPROD>1</CODPROD>
<DESCRICAOPROD>CERVEJA ANTARCTICA</DESCRICAOPROD>
<CODCRECEITA>12</CODCRECEITA>
<DESCRICAOCRECEITA>BEBIDAS</DESCRICAOCRECEITA>
<CODGRUPO>15</CODGRUPO>
<DESCRICAOGRUPO>BEBIBAS ALCOOLICA</DESCRICAOGRUPO>
<CODCATEGORIA>200</CODCATEGORIA>
<DESCRICAOCATEGORIA>EM LATA</DESCRICAOCATEGORIA>
<CODFAMILIA>105</CODFAMILIA>
<DESCRICAOFAMILIA>CERVEJA</DESCRICAOFAMILIA>
<PRECONORMAL>2.6</PRECONORMAL>
<PRECOPROMOCIONAL>2.3</PRECOPROMOCIONAL>
<UNIDADE>LATA</UNIDADE>
<OBS>Quantidade máxima por cliente (5).</OBS>
</GWDataTable>
<GWDataTable>
<CODPROD>14</CODPROD>
<DESCRICAOPROD>AMACIANTE OMO</DESCRICAOPROD>
<CODCRECEITA>19</CODCRECEITA>
<DESCRICAOCRECEITA>LIMPEZA</DESCRICAOCRECEITA>
<CODGRUPO>121</CODGRUPO>
<DESCRICAOGRUPO>LAVA ROUPAS</DESCRICAOGRUPO>
<CODCATEGORIA>76</CODCATEGORIA>
<DESCRICAOCATEGORIA>EM PÓ</DESCRICAOCATEGORIA>
<CODFAMILIA>15</CODFAMILIA>
<DESCRICAOFAMILIA>AMACIANTES</DESCRICAOFAMILIA>
<PRECONORMAL>7.4</PRECONORMAL>
<PRECOPROMOCIONAL>6.99</PRECOPROMOCIONAL>
<UNIDADE>CX</UNIDADE>
<OBS>Validade da oferta 15/05.</OBS>
</GWDataTable>
</NewDataSet>
</string>
Do you have a technical question or a process question? We don’t know your screen here and usually the posts here are about technical doubts. We can’t help just reading cat 1,2,3... and what you want to do. If there is a technical problem of using technology, put more information in the question and be more specific. You speak of Webservice and Canvas both were not shown.
– Malkaviano
@Malkavian You can see him now.
– Renan Serrão Nogueira