Exemplo n.º 1
0
        public Form2()
        {/*create run time list of all apartments, houses, and offers. Allows extra options if authenticated*/
            InitializeComponent();
            radioButton1.Checked = true;
            if (Form1.auth == false)
            {
                button7.Hide();
                button8.Hide();
                textBox2.Hide();
                textBox3.Hide();
                label31.Hide();
                label32.Hide();
                label33.Hide();
                label34.Hide();
                label37.Hide();
                label38.Hide();
            }
            if (Form1.auth == true)
            {
                button7.Show();
                button8.Show();
                textBox2.Show();
                textBox3.Show();
                label31.Show();
                label32.Show();
                label33.Show();
                label34.Show();
                label37.Show();
                label38.Show();
            }
            StreamReader FileH = new StreamReader("Houselog.txt");
            StreamReader FileA = new StreamReader("Apartmentlog.txt");
            StreamReader FileO = new StreamReader("Offers.txt");

            while (line != null)
            {
                for (int i = 0; i < 17; i++)
                {
                    line = FileH.ReadLine();
                    if (line != null)
                    {
                        switch (i)
                        {
                        case 0:
                            if (int.TryParse(line, out test))
                            {
                                idx = test;
                            }
                            break;

                        case 1:
                            if (int.TryParse(line, out test))
                            {
                                housenumberx = test;
                            }
                            break;

                        case 2:
                            streetx = line;
                            break;

                        case 3:
                            cityx = line;
                            break;

                        case 4:
                            statex = line;
                            break;

                        case 5:
                            if (int.TryParse(line, out test))
                            {
                                zipx = test;
                            }
                            break;

                        case 6:
                            descrptionx = line;
                            break;

                        case 7:
                            statusx = line;
                            break;

                        case 8:
                            stylex = line;
                            break;

                        case 9:
                            if (double.TryParse(line, out test2))
                            {
                                sizex = test2;
                            }
                            break;

                        case 10:
                            if (int.TryParse(line, out test))
                            {
                                agex = test;
                            }
                            break;

                        case 11:
                            if (double.TryParse(line, out test2))
                            {
                                pricex = test2;
                            }
                            break;

                        case 12:
                            ownerNamex = line;
                            break;

                        case 13:
                            ownerPhonex = line;
                            break;

                        case 14:
                            realtorNamex = line;
                            break;

                        case 15:
                            realtorPhonex = line;
                            break;

                        case 16:
                            companyx = line;
                            break;
                        }
                    }
                }
                if (line != null)
                {
                    Agent        tempRealtor = new Agent(realtorNamex, realtorPhonex, companyx);
                    Owner        tempOwner   = new Owner(ownerNamex, ownerPhonex, tempRealtor);
                    AddressHouse newAddress  = new AddressHouse(housenumberx, streetx, cityx, statex, zipx);
                    House        newHouse    = new House(descrptionx, statusx, stylex, sizex, agex, pricex, newAddress, idx, tempOwner, tempRealtor);
                    houses.Add(newHouse);
                }
            }
            FileH.Close();
            line = "";
            while (line != null)
            {
                for (int i = 0; i < 18; i++)
                {
                    line = FileA.ReadLine();
                    if (line != null)
                    {
                        switch (i)
                        {
                        case 0:
                            if (int.TryParse(line, out test))
                            {
                                idx = test;
                            }
                            break;

                        case 1:
                            if (int.TryParse(line, out test))
                            {
                                housenumberx = test;
                            }
                            break;

                        case 2:
                            streetx = line;
                            break;

                        case 3:
                            cityx = line;
                            break;

                        case 4:
                            statex = line;
                            break;

                        case 5:
                            if (int.TryParse(line, out test))
                            {
                                zipx = test;
                            }
                            break;

                        case 6:
                            descrptionx = line;
                            break;

                        case 7:
                            statusx = line;
                            break;

                        case 8:
                            stylex = line;
                            break;

                        case 9:
                            if (double.TryParse(line, out test2))
                            {
                                sizex = test2;
                            }
                            break;

                        case 10:
                            if (int.TryParse(line, out test))
                            {
                                agex = test;
                            }
                            break;

                        case 11:
                            if (double.TryParse(line, out test2))
                            {
                                pricex = test2;
                            }
                            break;

                        case 12:
                            ownerNamex = line;
                            break;

                        case 13:
                            ownerPhonex = line;
                            break;

                        case 14:
                            realtorNamex = line;
                            break;

                        case 15:
                            realtorPhonex = line;
                            break;

                        case 16:
                            companyx = line;
                            break;

                        case 17:
                            aptx = line;
                            break;
                        }
                    }
                }
                if (line != null)
                {
                    Agent            tempRealtor = new Agent(realtorNamex, realtorPhonex, companyx);
                    Owner            tempOwner   = new Owner(ownerNamex, ownerPhonex, tempRealtor);
                    AddressApartment newAddressA = new AddressApartment(housenumberx, streetx, cityx, statex, zipx, aptx);
                    Apartment        newApt      = new Apartment(descrptionx, statusx, stylex, sizex, agex, pricex, newAddressA, idx, tempOwner, tempRealtor);
                    apartments.Add(newApt);
                }
            }
            FileA.Close();
            line = "";
            while (line != null)
            {
                for (int i = 0; i < 3; i++)
                {
                    line = FileO.ReadLine();
                    if (line != null)
                    {
                        switch (i)
                        {
                        case 0:
                            if (int.TryParse(line, out test))
                            {
                                idx = test;
                            }
                            break;

                        case 1:
                            namex = line;
                            break;

                        case 2:
                            if (double.TryParse(line, out test2))
                            {
                                pricex = test2;
                            }
                            break;
                        }
                    }
                }
                if (line != null)
                {
                    Offer tempOffer = new Offer(idx, namex, pricex);
                    offers.Add(tempOffer);
                }
            }
            FileO.Close();
        }
Exemplo n.º 2
0
 public House(string descriptionx, string statusx, string stylex, double sizex, int agex, double pricex, AddressHouse locationx, int idx, Owner ownerx, Agent agentx) : base(descriptionx, statusx, stylex, sizex, agex, idx, ownerx, agentx)
 {
     Price    = pricex;
     Location = locationx;
 }