Пример #1
0
        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();
            }
        }
Пример #2
0
        // 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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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();
        }
Пример #7
0
        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();
        }
Пример #8
0
 public void Remove(projet4Entities ctx)
 {
     ctx.statement.Remove(ConvertToDao());
 }
Пример #9
0
 public void Add(projet4Entities ctx)
 {
     ctx.statement.Add(ConvertToDao());
 }
Пример #10
0
 public void Remove(projet4Entities ctx)
 {
     ctx.captor.Remove(ConvertToDao());
 }
Пример #11
0
 public void Add(projet4Entities ctx)
 {
     ctx.captor.Add(ConvertToDao());
 }