K
K
Kiha Ki2020-04-20 09:57:56
C++ / C#
Kiha Ki, 2020-04-20 09:57:56

With the help of which you can save the update of the cinema seats, places - group. Picturebox, located on the form using an xml file, and how?

I looked on youtube for something like this but couldn't find it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2020-04-20
@firedragon

1 create a class for the session
2 make an ObjectDataSource based on it
3 bind the controls to the fields
4 Serialize

[Serializable]
    public class FilmShow
    {
        [Serializable]
        public class Place
        {
            public Place() { }
            public int? UserId { get; set; }
            public bool IsReserved { get; set; }
        }
        [Serializable]
        public class Row
        {
            public Row() { }
            public Place[] Places { get; set; }
        }
        public DateTime Date { get; set; }
        public string Name { get; set; }
        public Row[] Rows { get; set; }

        public FilmShow()
        {
        }

        public FilmShow(DateTime date, string name, int row, int column)
        {
            Date = date;
            Name = name;
            Rows = new Row[row];
            for (var i = 0; i < Rows.Length; i++)
            {
                var item = new Row() { Places = new Place[column] };
                for (var j = 0; j < item.Places.Length; j++)
                {
                    item.Places[j] = new Place();
                }
                Rows[i] = item;
            }
        }

        public static void Save(FilmShow filmShow, string path)
        {
            var formatter = new XmlSerializer(typeof(FilmShow));
            using var fs = new FileStream(path, FileMode.OpenOrCreate);
            formatter.Serialize(fs, filmShow);
        }

        public static FilmShow Load(string path)
        {
            var formatter = new XmlSerializer(typeof(FilmShow));
            using var fs = new FileStream(path, FileMode.OpenOrCreate);
            return (FilmShow)formatter.Deserialize(fs);
        }
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question