Exemplo n.º 1
0
        public int Update <T>(T entity)
        {
            Type type = entity.GetType();

            if (type == typeof(City))
            {
                return(CityTable.Update(entity as City));
            }

            if (type == typeof(Customer))
            {
                return(CustomerTable.Update(entity as Customer));
            }

            if (type == typeof(Distillation))
            {
                return(DistillationTable.Update(entity as Distillation));
            }

            if (type == typeof(District))
            {
                return(DistrictTable.Update(entity as District));
            }

            if (type == typeof(Material))
            {
                return(MaterialTable.Update(entity as Material));
            }

            if (type == typeof(Period))
            {
                return(PeriodTable.Update(entity as Period));
            }

            if (type == typeof(Region))
            {
                return(RegionTable.Update(entity as Region));
            }

            if (type == typeof(Reservation))
            {
                return(ReservationTable.Update(entity as Reservation));
            }

            if (type == typeof(Season))
            {
                return(SeasonTable.Update(entity as Season));
            }

            if (type == typeof(UserInfo))
            {
                return(UserInfoTable.Update(entity as UserInfo));
            }

            return(0);
        }
Exemplo n.º 2
0
        private void BindBack()
        {
            Material m = new Material();

            bool IsInsert = Material.MId == -1 ? true : false;

            m.MId      = Material.MId != -1 ? Material.MId : getNextID();
            m.Predmet  = Material.Predmet != null ? Material.Predmet : new PredmetTable().SelectByID((int)predmetComboBox.SelectedValue);
            m.Uzivatel = Material.Uzivatel != null ? Material.Uzivatel : new UzivatelTable().SelectByID((int)uzivatelComboBox.SelectedValue);

            m.Typ = TypBox.Text;

            m.Dokument = DokumentBox.Text;;

            try
            {
                m.Datum = DateTime.Parse(DatumBox.Text);
            }
            catch (Exception)
            {
                Dialog.BadDateNotify notify = new Dialog.BadDateNotify();
                notify.ShowDialog();
                return;
            }

            m.Okruh = OkruhBox.Text;

            if (m.Okruh != "zap." && m.Okruh != "klzap." && m.Okruh != "zk.")
            {
                Dialog.InvalidInput notify = new Dialog.InvalidInput();
                notify.ShowDialog();
                return;
            }

            if (IsInsert)
            {
                MaterialTable.Insert(m);
            }
            else
            {
                MaterialTable.Update(m);
            }
        }