PersonnelwantedtohaveemptyandeditablecellsinacolumnofaListViewthatpullsinformationfromtheSQLServerdatabasetomyproject.TopulltheinformationIuseLINQandIcanlistallthedataIwant.Theideais:whenthislistisloadedtheusercaneditthecellsofanewcolumn(Quantity),theinformationthatwillbeenteredinthesecells(wholenumbers)willbeusedforothercalculationsintheproject.
IntheXMALcodeIamnotabletoleavethevaluesempty...Thatwayitisreturningthepathoftheclass.
Anyonewhocanhelpwillbeverygrateful!!
I'veattachedanimagetomakethequestioneasier...It'sintheQuantitycolumnthatthecellsneedtobeemptyandeditabletotheuser.ItisnotpartoftheSQLdatabase,displayonlyfortheusertoenterthedata.
XMALcode:
<ListViewx:Name="listView_tabMaqPrda_ApontaPrd" Margin="99,117,915,583" ItemsSource="{Binding}" ScrollViewer.CanContentScroll="True" SelectionMode="Single"> <ListView.View> <GridView> <GridViewColumn Header="Código" Width="Auto" DisplayMemberBinding="{Binding CodigoParada}"/> <GridViewColumn Header="Descrição da Parada" Width="Auto" DisplayMemberBinding="{Binding DescricaoParada}"/> <GridViewColumn Header="Tempo(min)" Width="Auto" DisplayMemberBinding="{Binding TempoParada}"/> <GridViewColumn Header="Tipo de Parada" Width="Auto" DisplayMemberBinding="{Binding TipoParada}"/> <GridViewColumn Header="Quantidade" Width="Auto" /> </GridView> </ListView.View> </ListView>
LINQ Class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TRSSystem.AcessoDados
{
public class tabMaquinaParadaAcesso
{
//Consultar pela MAQUINA no Banco pela estrutura LINQ TO SQL Server
public static List<tabMaquinaParada> Consultar_OnlyMaquina(string pMaquina, string pTipo)
{
TRSSystemDataClassesDataContext oDB = new TRSSystemDataClassesDataContext();
List<tabMaquinaParada> aMaquina = (from Selecao in oDB.tabMaquinaParadas where Selecao.Maquina == pMaquina && Selecao.Sacaria == pTipo select Selecao).ToList<tabMaquinaParada>();
return aMaquina;
}
}
}
LostFocus event of a Combox, when the list is loaded:
private void CarregarParadas_ApontaPrd(object sender, RoutedEventArgs e)
{
try
{
listView_tabMaqPrda_ApontaPrd.ItemsSource = TRSSystem.AcessoDados.tabMaquinaParadaAcesso.Consultar_OnlyMaquina(CmBox_MaquinaApontaPrd.Text, CmBox_TipoApontaPrd.Text);
}catch(Exception error)
{
MessageBox.Show("Erro de Compilação, contacte o Administrador do Sistema." + error, "Erro de Compilação", MessageBoxButton.OK, MessageBoxImage.Error);
}
}