Ejemplo n.º 1
0
        //data insert section
        private void btntsave_Click(object sender, EventArgs e)
        {
            DboTrainsEntities1 entit       = new DboTrainsEntities1();
            string             stationName = textBox1.Text.ToString();

            //array created
            string[]  InsertArray = new string[1];
            Stopwatch stopwatch   = new Stopwatch();

            stopwatch.Start();

            //set value to array
            InsertArray[0] = stationName;

            //retrive data from array and insert to database
            for (int J = 0; J < InsertArray.Length; J++)
            {
                TbStation PTE = new TbStation();
                PTE.Name = InsertArray[J];
                entit.TbStations.Add(PTE);
                entit.SaveChanges();
            }
            stopwatch.Stop();
            TimeSpan ts = stopwatch.Elapsed;

            //show spending times
            Lblinsert.Text = " Data Insert Time: " + stopwatch.ElapsedMilliseconds + " Ms";
            textBox1.Text  = "";
        }
Ejemplo n.º 2
0
        //open minimum connecters algorithm app
        private void btnmincon_Click(object sender, EventArgs e)
        {
            DboTrainsEntities1 entit = new DboTrainsEntities1();
            var cc = (from p in entit.TbStations
                      select new
            {
                id = p.id,
                name = p.Name
            });

            var vv             = cc.ToList();
            List <TbStation> v = new List <TbStation>();

            foreach (var val in vv)
            {
                TbStation s = new TbStation();
                s.id   = val.id;
                s.Name = val.name;
                v.Add(s);
            }

            var cc2 = (from p in entit.Tbdistances
                       select new
            {
                id = p.id,
                station1 = p.station1Id,
                station2 = p.station2id,
                distance = p.distance
            });

            var vv2 = cc2.ToList();
            List <Tbdistance> v1 = new List <Tbdistance>();

            foreach (var val in vv2)
            {
                Tbdistance s1 = new Tbdistance();
                s1.id         = val.id;
                s1.station1Id = val.station1;
                s1.station2id = val.station2;
                s1.distance   = val.distance;
                v1.Add(s1);
            }


            Form1 f = new Form1(v1, v);

            f.Show();
        }