public List <PVDConsuntivoModel> EstraiConsutivoMacchina(string IDRESOURCEF) { List <PVDConsuntivoModel> consuntivo = new List <PVDConsuntivoModel>(); PVDDS ds = new PVDDS(); using (PVDBusiness bPDV = new PVDBusiness()) { bPDV.FillRW_PVD_CONSUNTIVO(ds); } foreach (PVDDS.RW_PVD_CONSUNTIVORow m in ds.RW_PVD_CONSUNTIVO.Where(X => X.IDRESOURCEF == IDRESOURCEF).OrderByDescending(X => X.GIORNO)) { PVDConsuntivoModel model = new PVDConsuntivoModel(); model.Giorno = m.GIORNO; model.IDRESOURCEF = m.IDRESOURCEF; model.Macchina = m.MACCHINA; model.FinituraCodice = m.IsFINITURA_CODNull() ? string.Empty : m.FINITURA_COD; model.FinituraDescrizione = m.IsFINITURA_DESCNull() ? string.Empty : m.FINITURA_DESC; model.TipoCiclo = m.IsTIPONull() ? string.Empty : m.TIPO; model.Inizio = m.INIZIO; model.Fine = m.FINE; model.Quantita = (int)m.QUANTITA; model.Clienti = m.IsCLIENTINull() ? string.Empty : m.CLIENTI; model.Articolo = m.IsARTICOLONull() ? string.Empty : m.ARTICOLO; model.Impegno = m.IMPEGNO; model.IdConsuntivo = (int)m.IDCONSUNTIVO; consuntivo.Add(model); } return(consuntivo); }
public PVDReportModel EstraiConsutivo(DateTime dataInizio, DateTime dataFine, string Macchina) { List <PVDConsuntivoModel> consuntivo = new List <PVDConsuntivoModel>(); PVDDS ds = new PVDDS(); using (PVDBusiness bPDV = new PVDBusiness()) { bPDV.FillRW_PVD_CONSUNTIVO(ds); } List <PVDDS.RW_PVD_CONSUNTIVORow> elementiTrovati = ds.RW_PVD_CONSUNTIVO.Where(X => X.GIORNO >= dataInizio && X.GIORNO < dataFine).ToList(); if (!string.IsNullOrEmpty(Macchina)) { elementiTrovati = elementiTrovati.Where(x => x.IDRESOURCEF == Macchina).ToList(); } TimeSpan durataTotale = new TimeSpan(); foreach (PVDDS.RW_PVD_CONSUNTIVORow m in elementiTrovati) { PVDConsuntivoModel model = new PVDConsuntivoModel(); TimeSpan durata = DateTimeHelper.CalcolaDurata(m.INIZIO, m.FINE); durataTotale = durataTotale.Add(durata); model.Giorno = m.GIORNO; model.IDRESOURCEF = m.IDRESOURCEF; model.Macchina = m.MACCHINA; model.FinituraCodice = m.IsFINITURA_CODNull() ? string.Empty : m.FINITURA_COD; model.FinituraDescrizione = m.IsFINITURA_DESCNull() ? string.Empty : m.FINITURA_DESC; model.TipoCiclo = m.IsTIPONull() ? string.Empty : m.TIPO; model.Inizio = m.INIZIO; model.Fine = m.FINE; model.Quantita = (int)m.QUANTITA; model.Clienti = m.IsCLIENTINull() ? string.Empty : m.CLIENTI; model.Articolo = m.IsARTICOLONull() ? string.Empty : m.ARTICOLO; model.Impegno = m.IMPEGNO; model.IdConsuntivo = (int)m.IDCONSUNTIVO; model.Durata = durata.ToString(@"hh\:mm"); consuntivo.Add(model); } PVDReportModel report = new PVDReportModel(); report.Consuntivo = consuntivo; report.DurataTotale = DateTimeHelper.ToHoursMin(durataTotale); return(report); }