Пример #1
0
        public void insert(string sir)
        {
            Donor      d   = new Donor();
            TextReader str = new StreamReader("DATA.txt");

            int[]       f = new int[3];
            double      cp, dp;
            string      w, x, y, z;
            PointLatLng et    = new PointLatLng();
            int         count = 0;

            while (str.Peek() >= 0)//reading data form donor and inputting it in donor class
            {
                count++;
                d = new Donor();
                w = str.ReadLine();
                x = str.ReadLine();
                y = str.ReadLine();
                z = str.ReadLine();
                d.setName(w);
                d.setEmail(x);
                d.setphone_number(y);
                d.setBG(z);
                f[0] = Convert.ToInt32(str.ReadLine());
                f[1] = Convert.ToInt32(str.ReadLine());
                f[2] = Convert.ToInt32(str.ReadLine());
                DateTime j = new DateTime(f[2], f[1], f[0]);
                d.setLast_donated(j);
                cp     = Convert.ToDouble(str.ReadLine());
                dp     = Convert.ToDouble(str.ReadLine());
                et.Lat = cp; et.Lng = dp;
                d.setlatlog(et);
                if (head == null && d.blood_group == sir)
                {
                    head      = new Tnode();
                    head.data = d;
                    head.next = null;
                    length++; listed.a++;
                }
                else if (d.blood_group == sir)
                {
                    Tnode newnode = new Tnode();
                    newnode.data = new Donor();
                    newnode.data = d;
                    newnode.next = new Tnode();
                    newnode.next = head;
                    head         = new Tnode();
                    head.data    = newnode.data;
                    head.next    = newnode.next;
                    length++; listed.a++;
                }

                //MessageBox.Show("inserted " + head.data.getBloodGroup());
            }
        }
Пример #2
0
        public void readdata()
        {
            Donor      d   = new Donor();
            TextReader str = new StreamReader("DATA.txt");

            int[]       f = new int[3];
            double      cp, dp;
            string      w, x, y, z;
            PointLatLng et    = new PointLatLng();
            int         count = 0;

            while (str.Peek() >= 0)//reading data form donor and inputting it in donor class
            {
                count++;
                w = str.ReadLine();
                x = str.ReadLine();
                y = str.ReadLine();
                z = str.ReadLine();
                d.setName(w);
                d.setEmail(x);
                d.setphone_number(y);
                d.setBG(z);
                f[0] = Convert.ToInt32(str.ReadLine());
                f[1] = Convert.ToInt32(str.ReadLine());
                f[2] = Convert.ToInt32(str.ReadLine());
                DateTime j = new DateTime(f[2], f[1], f[0]);
                d.setLast_donated(j);
                cp     = Convert.ToDouble(str.ReadLine());
                dp     = Convert.ToDouble(str.ReadLine());
                et.Lat = cp; et.Lng = dp;
                d.setlatlog(et);
                string group = d.getBloodGroup();
                if (group == "A+")
                {
                    L[0].AddFirst(d); MessageBox.Show("Inserting A+ donor");
                }
                else if (group == "A-")
                {
                    L[1].AddFirst(d); MessageBox.Show("Inserting A- donor");
                }
                else if (group == "B+")
                {
                    L[2].AddFirst(d); MessageBox.Show("Inserting B+ donor");
                }
                else if (group == "B-")
                {
                    L[3].AddFirst(d); MessageBox.Show("Inserting B- donor");
                }
                else if (group == "AB+")
                {
                    L[4].AddFirst(d); MessageBox.Show("Inserting AB+ donor");
                }
                else if (group == "AB-")
                {
                    L[5].AddFirst(d); MessageBox.Show("Inserting AB- donor");
                }
                else if (group == "O+")
                {
                    L[6].AddFirst(d); MessageBox.Show("Inserting O+ donor");
                }
                else if (group == "O-")
                {
                    L[7].AddFirst(d); MessageBox.Show("Inserting O- donor");
                }
            }
            str.Close();
            MessageBox.Show(count + " lines read!");
        }