//Última data de inserção do REP public void CadastraUltimaColeta(int IDREP, DateTime DTUltimaColeta) { DataSetREPTableAdapters.TBREPColetaTableAdapter adpColetaREP = new DataSetREPTableAdapters.TBREPColetaTableAdapter(); try { adpColetaREP.Insert(IDREP, DTUltimaColeta); } catch (Exception ex) { } }
//Última coleta da REP public DateTime UltimaColetaREP(DataSetREP ds, int IDREP) { DataSetREPTableAdapters.TBREPColetaTableAdapter adpREPColeta = new DataSetREPTableAdapters.TBREPColetaTableAdapter(); DateTime dd = new DateTime(1900, 01, 01); try { adpREPColeta.FillIDREP(ds.TBREPColeta, IDREP); dd = ds.TBREPColeta[0].DTUltimaColeta; } catch (System.Data.OleDb.OleDbException ex) { ex.ToString(); } catch (Exception ex) { ex.ToString(); } return(dd); }
//Para ultima coleta quando for cadastro de usuário public void CadastraUltimaColetaUsuario(int IDREP, DateTime DTUltimaColeta, string DT) { DataSetREPTableAdapters.TBREPColetaTableAdapter adpColeta = new DataSetREPTableAdapters.TBREPColetaTableAdapter(); DataSetREP.TBREPColetaDataTable TBcoleta = new DataSetREP.TBREPColetaDataTable(); adpColeta.FillIDREPColeta(TBcoleta, IDREP, DT); if (TBcoleta.Rows.Count == 0) { try { adpColeta.Insert(IDREP, DTUltimaColeta); } catch (Exception ex) { } } else { adpColeta.UpdateUltimaColeta(DTUltimaColeta, IDREP); } }