public ImportPage(MainWindow mw) { mainWindow = mw; InitializeComponent(); projet4Entities ctx = new projet4Entities(); Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.DefaultExt = ".txt"; Nullable <bool> result = dlg.ShowDialog(); displayFile.Text = ""; if (result == true) { string filename = dlg.FileName; string[] file = Import.ReadFile(filename); foreach (string s in file) { displayFile.Text += string.Format("{0}\n", s); } List <MStatement> mStatementslist = Import.ConvertFile(file); numberRows.Text = mStatementslist.Count().ToString(); foreach (MStatement m in mStatementslist) { m.CaptorId = mainWindow.captor.CaptorId; ctx.statement.Add(m.ConvertToDao()); } ctx.SaveChanges(); } }
// get by date //rajouter by id public static List <MStatement> GetByDate(projet4Entities ctx, int id, DateTime debut, DateTime fin) { List <MStatement> ls = new List <MStatement>(); List <statement> l = ctx.statement.Where(s => s.captorId == id && s.dateTime >= debut && s.dateTime <= fin).ToList(); foreach (statement s in l) { MStatement ms = new MStatement(); ms.LoadFromDao(s); ls.Add(ms); } return(ls); }
public static List <MStatement> GetAll(projet4Entities ctx) { List <MStatement> ls = new List <MStatement>(); List <statement> l = ctx.statement.ToList(); foreach (statement s in l) { MStatement ms = new MStatement(); ms.LoadFromDao(s); ls.Add(ms); } return(ls); }
public static List <MStatement> GetAllByCaptorId(projet4Entities ctx, int captorId) { List <MStatement> ls = new List <MStatement>(); List <statement> l = ctx.statement.Where(st => st.captorId == captorId).ToList(); foreach (statement s in l) { MStatement ms = new MStatement(); ms.LoadFromDao(s); ls.Add(ms); } return(ls); }
public static List <MCaptor> GetAll(projet4Entities ctx) { List <MCaptor> lc = new List <MCaptor>(); List <captor> l = ctx.captor.ToList(); foreach (captor c in l) { MCaptor mc = new MCaptor(); mc.LoadFromDao(c); lc.Add(mc); } return(lc); }
public static void ClearDb() { projet4Entities ctx = new projet4Entities(); List <captor> captorlist = ctx.captor.ToList(); List <statement> statementlist = ctx.statement.ToList(); foreach (captor c in captorlist) { ctx.captor.Remove(c); } foreach (statement s in statementlist) { ctx.statement.Remove(s); } ctx.SaveChanges(); }
static void Main(string[] args) { ClearDb(); projet4Entities ctx = new projet4Entities(); MCaptor mc = new MCaptor(); mc.Serial_number = "482"; mc.Localisation = "ici"; mc.Description = "plop"; captor cpt = mc.ConvertToDao(); ctx.captor.Add(cpt); ctx.SaveChanges(); Console.WriteLine("capteur : id {0} ajouté !", cpt.captorId); Console.ReadLine(); }
public void Remove(projet4Entities ctx) { ctx.statement.Remove(ConvertToDao()); }
public void Add(projet4Entities ctx) { ctx.statement.Add(ConvertToDao()); }
public void Remove(projet4Entities ctx) { ctx.captor.Remove(ConvertToDao()); }
public void Add(projet4Entities ctx) { ctx.captor.Add(ConvertToDao()); }