Example #1
0
        private void btn_deleteall_Click(object sender, EventArgs e)
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            foreach (tbStations addstations in stationsdeletelist)
            {
                tbStations removestations = db.stations.Find(addstations.id); // find the row what row will delete(id get from link list)
                db.stations.Remove(removestations);                           //delete the row from id
                db.SaveChanges();
            }
            stopWatch.Stop();
            TimeSpan ts          = stopWatch.Elapsed;
            string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);

            lbl_time.Text = "Multiple delete time " + elapsedTime;
            list          = db.stations.ToList();
            listdistance  = db.stationDistances.ToList();
            loadComboData();
        }
Example #2
0
        private void addall_Click(object sender, EventArgs e)
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            foreach (tbStations addstations in stationslist) //read the link list value
            {
                tbStations addstations1 = new tbStations();  //create the table tbstation object for store the data
                addstations1.Name = addstations.Name;        // add the name to the created object
                db.stations.Add(addstations1);               //add the data to database
                db.SaveChanges();
            }
            stopWatch.Stop();
            TimeSpan ts          = stopWatch.Elapsed;
            string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);

            lbl_time.Text = "Multiple add time " + elapsedTime;
            list          = db.stations.ToList();         //reload the tbstation  to the list
            listdistance  = db.stationDistances.ToList(); //reload the Tbdistance to the listdistance
            loadComboData();                              //reload the all comboboxes
        }
Example #3
0
        private void btn_updateall_Click(object sender, EventArgs e)
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            foreach (tbStations addstations in stationsupdatelist)      //read the link list values
            {
                tbStations add = new tbStations();                      //create the stations table object to update the updated data
                add                 = db.stations.Find(addstations.id); //find the update data id to update correct row (id get from link list)
                add.Name            = addstations.Name;                 //update the station name(Name get from link list)
                db.Entry(add).State = EntityState.Modified;
                db.SaveChanges();
            }
            stopWatch.Stop();
            TimeSpan ts          = stopWatch.Elapsed;
            string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);

            lbl_time.Text = "Multiple update time " + elapsedTime;
            list          = db.stations.ToList();         //reload the statios data collection
            listdistance  = db.stationDistances.ToList(); //reload the statios distance data collection
            loadComboData();                              //reload the all combo boxes
        }
Example #4
0
        LinkedList <tbStations> stationslist = new LinkedList <tbStations>(); //this link list using for store the adding stations
        private void button1_Click(object sender, EventArgs e)
        {
            Stopwatch stopWatch = new Stopwatch(); //create stopwoch object

            stopWatch.Start();                     //start stopwatch
            tbStations add = new tbStations();     //create the table tbstation object

            add.id = 0;
            if (textBox1.Text.Length == 0)
            {
                MessageBox.Show("please enter a station Name", "Missing details", MessageBoxButtons.OK);
                return;
            }
            add.Name = textBox1.Text;                                                                                                    //add the textfield value to the created object
            stationslist.AddLast(add);                                                                                                   // add the link list adding values
            stopWatch.Stop();                                                                                                            //after proces is over then stop the stopwatch
            TimeSpan ts          = stopWatch.Elapsed;                                                                                    //get the stopwatch timestamp
            string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); //convert time stamp to normal  standed time

            lbl_time.Text = "single add time " + elapsedTime;                                                                            // set the timt to the lable

            textBox1.Text = "";                                                                                                          // clear the textfield value
        }
Example #5
0
        LinkedList <tbStations> stationsdeletelist = new LinkedList <tbStations>(); //create a link list for store deleted data
        private void btn_delete_Click(object sender, EventArgs e)                   //delete one by one
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            tbStations add = new tbStations(); //create the object for add to link list

            if (txt_stationsearch.Text.Length == 0)
            {
                MessageBox.Show("Please enter a station ID", "missing details", MessageBoxButtons.OK);
                return;
            }
            add.id   = Convert.ToInt32(txt_stationsearch.Text);
            add.Name = textBox1.Text;
            stationsdeletelist.AddLast(add); //add deleted data to  link list
            stopWatch.Stop();
            TimeSpan ts          = stopWatch.Elapsed;
            string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);

            lbl_time.Text          = "single delete time " + elapsedTime;
            textBox1.Text          = "";
            txt_stationsearch.Text = "";
        }
Example #6
0
        LinkedList <tbStations> stationsupdatelist = new LinkedList <tbStations>(); //create link list for store updated values
        private void btn_update_Click(object sender, EventArgs e)
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            tbStations add = new tbStations();

            if (txt_stationsearch.Text.Length == 0 || textBox1.Text.Length == 0) // text field validations to integers
            {
                MessageBox.Show("please enter a station Name and its id...", "Missing details", MessageBoxButtons.OK);
                return;
            }
            add.id   = Convert.ToInt32(txt_stationsearch.Text);
            add.Name = textBox1.Text;
            stationsupdatelist.AddLast(add); // add the link list updated values
            stopWatch.Stop();
            TimeSpan ts          = stopWatch.Elapsed;
            string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);

            lbl_time.Text          = "single update time " + elapsedTime;
            textBox1.Text          = "";
            txt_stationsearch.Text = "";
        }