Esempio n. 1
0
        private void editButton_Click(object sender, EventArgs e)
        {
            int idx = -1;

            label8.Visible = false;
            try
            {
                idx = int.Parse(textNum.Text);
            }
            catch (System.FormatException) { }

            int a = -1;

            a = h.FindIndex(x => x.getAppNumber() == idx);
            if (a != -1)
            {
                bool tmp;
                if (textOcc.Text == "YES")
                {
                    tmp = true;
                }
                else
                {
                    tmp = false;
                }
                int?p;
                if (textPrice.Text == "null" || textPrice.Text == "")
                {
                    p = null;
                }
                else
                {
                    p = int.Parse(textPrice.Text);
                }

                int?an;
                if (textNum.Text == "null" || textNum.Text == "")
                {
                    an = null;
                }
                else
                {
                    an = int.Parse(textNum.Text);
                }
                try
                {
                    h[a] = new Appartment(an, p, textAddress.Text, tmp);
                }
                catch (System.FormatException)
                {
                }
            }
            refreshRows();
            clearTextBoxes();
            resetLabels();
            textNum.ReadOnly = false;
        }
Esempio n. 2
0
        public void importXML(string path = "D:\\DATA\\data.xml")
        {
            resetLabels();
            DataSet data = new DataSet("ProjData");

            data.ReadXml(path);
            Appartment a = null;
            bool       tmp;

            try
            {
                foreach (DataRow r in data.Tables["Appartments"].Rows)
                {
                    if (r[3].ToString() == "true")
                    {
                        tmp = true;
                    }
                    else
                    {
                        tmp = false;
                    }
                    int?p;
                    if (r[0].ToString() == "")
                    {
                        p = null;
                    }
                    else
                    {
                        p = int.Parse(r[0].ToString());
                    }

                    int?an;
                    if (r[2].ToString() == "")
                    {
                        an = null;
                    }
                    else
                    {
                        an = int.Parse(r[2].ToString());
                    }


                    a = new Appartment(p, an, r[1].ToString(), tmp);
                    h.Add(a);
                }
                refreshRows();
            }
            catch (System.NullReferenceException) { }
        }
Esempio n. 3
0
 public void Remove(Appartment a)
 {
     this.apps.Remove(a);
 }
Esempio n. 4
0
 public void Add(Appartment a)
 {
     this.apps.Add(a);
 }