Ejemplo n.º 1
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            if (this.textBoxUsername.Text == "" || this.textBoxPassword.Text == "")
            {
                MessageBox.Show("All fields are required.");
            }
            else
            {
                queries action = new queries();

                if (action.AuthorizeUser(textBoxUsername.Text, textBoxPassword.Text))
                {
                    //MessageBox.Show("Login ok.");
                    this.Hide();

                    List showEmployees = new List();
                    showEmployees.ShowDialog();

                    this.Close();
                }
                else
                {
                    MessageBox.Show("Error logging in.");
                    textBoxPassword.Text = "";
                }
            }
        }
Ejemplo n.º 2
0
        public void refreshList()
        {
            queries action = new queries();

            action.loadList(this.listView1);

            this.refreshEmployeesCount();
        }
Ejemplo n.º 3
0
        private void textBoxSearchKeyword_TextChanged(object sender, EventArgs e)
        {
            queries action = new queries();

            action.searchEmployee(this.listView1, this.textBoxSearchKeyword.Text);

            this.refreshEmployeesCount();
        }
Ejemplo n.º 4
0
        private void LoadQueryTemplates(string content)
        {
            XmlSerializer ser = new XmlSerializer(typeof(queries));

            using (StringReader sreader = new StringReader(content))
            {
                using (XmlReader reader = XmlReader.Create(sreader))
                {
                    _queryTemplates = (queries)ser.Deserialize(reader);
                }
            }
        }
Ejemplo n.º 5
0
        private void toolStripMenuItemRemove_Click(object sender, EventArgs e)
        {
            try
            {
                int     selectedID = Convert.ToInt32(this.listView1.SelectedItems[0].Text);
                queries action     = new queries();
                action.id = selectedID;
                action.removeEmployee();

                this.refreshList();
            }
            catch { }
        }
Ejemplo n.º 6
0
            public List <data> runqueries(string querynom, List <vertex> nlistofpoints)
            {
                List <data>  qeuriesdata = new List <data>();
                queries      QE          = new queries();
                FileStream   fss         = new FileStream(querynom, FileMode.Open, FileAccess.Read);
                StreamReader srr         = new StreamReader(fss);
                int          countQ      = Int32.Parse(srr.ReadLine());

                using (StreamReader reader = File.OpenText(querynom))
                {
                    reader.ReadLine();
                    for (int i = 0; i < countQ; i++)
                    {
                        string   text  = reader.ReadLine();
                        string[] bitss = text.Split(' ');
                        QE.startX = float.Parse(bitss[0]);
                        QE.startY = float.Parse(bitss[1]);
                        QE.endX   = float.Parse(bitss[2]);
                        QE.endY   = float.Parse(bitss[3]);
                        QE.rad    = float.Parse(bitss[4]);

                        vertex v = new vertex();
                        v.x     = QE.startX;
                        v.y     = QE.startY;
                        v.index = 0;
                        nlistofpoints.Insert(0, v);

                        vertex vv = new vertex();
                        vv.x     = QE.endX;
                        vv.y     = QE.endY;
                        vv.index = nlistofpoints.Count();
                        nlistofpoints.Add(vv);

                        int cc = nlistofpoints.Count();
                        for (int j = 0; j < nlistofpoints.Count(); j++)
                        {
                            double result = Math.Pow(Math.Pow((nlistofpoints[j].x - QE.startX), 2) + Math.Pow((nlistofpoints[j].y - QE.startY), 2), 0.5);

                            if (QE.rad / 1000 >= result)
                            {
                                weightededge n  = new weightededge(0, j, (result / 5), 5, result);
                                nieghbours   ne = new nieghbours(j, n);
                                nlistofpoints[0].nieghbourr.Add(ne);


                                weightededge nn  = new weightededge(j, 0, (result / 5), 5, result);
                                nieghbours   nee = new nieghbours(0, nn);
                                nlistofpoints[j].nieghbourr.Add(nee);
                            }


                            if (j != nlistofpoints.Count() - 1)
                            {
                                double result1 = Math.Pow(Math.Pow((nlistofpoints[j].x - QE.endX), 2) + Math.Pow((nlistofpoints[j].y - QE.endY), 2), 0.5);

                                if (QE.rad / 1000 >= result1)
                                {
                                    weightededge n  = new weightededge((nlistofpoints.Count() - 1), j, (result1 / 5), 5, result1);
                                    nieghbours   ne = new nieghbours(j, n);
                                    nlistofpoints[(nlistofpoints.Count() - 1)].nieghbourr.Add(ne);
                                    weightededge nn  = new weightededge(j, (nlistofpoints.Count() - 1), (result1 / 5), 5, result1);
                                    nieghbours   nee = new nieghbours((nlistofpoints.Count() - 1), nn);
                                    nlistofpoints[j].nieghbourr.Add(nee);
                                }
                            }
                        }
                        wightedgraph g  = new wightedgraph(nlistofpoints);
                        dikstra      DS = new dikstra();
                        Stopwatch    sw = new Stopwatch();
                        sw.Start();
                        data qeurydata = DS.rundijkstra(g.graph.First().index, g.graph.Last().index, g);
                        sw.Stop();
                        long lon = sw.ElapsedMilliseconds;
                        sw.Reset();
                        qeurydata.elapsed = lon;
                        qeuriesdata.Add(qeurydata);

                        for (int m = 0; m < nlistofpoints.Count(); m++)
                        {
                            for (int n = 0; n < nlistofpoints[m].nieghbourr.Count(); n++)
                            {
                                if (nlistofpoints[m].nieghbourr[n].destnode == nlistofpoints.First().index || nlistofpoints[m].nieghbourr[n].destnode == nlistofpoints.Last().index)
                                {
                                    nlistofpoints[m].nieghbourr.RemoveAt(n);
                                }
                            }
                        }
                        nlistofpoints.Remove(nlistofpoints.First());
                        nlistofpoints.Remove(nlistofpoints.Last());
                    }
                }

                //Console.Write(sw.ElapsedMilliseconds + " \n");
                return(qeuriesdata);
            }
Ejemplo n.º 7
0
 var(queries, expected) = scenarios;