示例#1
0
        protected void btnVybrat_Click(object sender, EventArgs e)
        {
            Literal stavbaLiteral = (sender as Button).NamingContainer.FindControl("ltrIdStavby") as Literal;
            Literal zpusobLiteral = (sender as Button).NamingContainer.FindControl("ltrTypVytapeni") as Literal;

            if (stavbaLiteral != null && zpusobLiteral != null)
            {
                int.TryParse(stavbaLiteral.Text.ToString(), out stavbaId);
                zpusobTyp = zpusobLiteral.Text.ToString();
            }
            else
            {
                stavbaId  = -1;
                zpusobTyp = "";
            }

            konkretniZpusob = zpusob.Select_id(stavbaId, zpusobTyp);
            konkretniStavba = stavba.Select_id(konkretniZpusob.Id_stavby);
            object stavbaZpusob = new { konkretniStavba.Id_stavby, konkretniStavba.Typ_stavby, konkretniStavba.Ulice, konkretniStavba.Cislo_popisne, konkretniZpusob.Typ_vytapeni, konkretniZpusob.Platnost_od, konkretniZpusob.Platnost_do };

            stavbyZpusoby.Clear();
            stavbyZpusoby.Add(stavbaZpusob);
            DetailsViewZpusobu.DataSource = stavbyZpusoby;
            DetailsViewZpusobu.DataBind();
        }
示例#2
0
        /*
         * public static int Insert(Zpusob_vytapeni zpusob_vytapeni)
         * {
         *  Database db = new Database();
         *  db.Connect();
         *  OracleCommand command = db.CreateCommand(SQL_INSERT);
         *  PrepareCommand(command, zpusob_vytapeni);
         *  int ret = db.ExecuteNonQuery(command);
         *  db.Close();
         *  return ret;
         * }*/

        /*
         * public static int Update(Zpusob_vytapeni zpusob_vytapeni)
         * {
         *  Database db = new Database();
         *  db.Connect();
         *  OracleCommand command = db.CreateCommand(SQL_UPDATE);
         *  PrepareCommand(command, zpusob_vytapeni);
         *  int ret = db.ExecuteNonQuery(command);
         *  db.Close();
         *  return ret;
         * }*/

        /*
         * public static int Delete(Zpusob_vytapeni zpusob_vytapeni)
         * {
         *  Database db = new Database();
         *  db.Connect();
         *  OracleCommand command = db.CreateCommand(SQL_DELETE);
         *  PrepareCommand(command, zpusob_vytapeni);
         *  int ret = db.ExecuteNonQuery(command);
         *  db.Close();
         *  return ret;
         * }*/

        /*
         * public static Collection<Zpusob_vytapeni> Select(Database Db = null)
         * {
         *  Database db;
         *  if (Db == null)
         *  {
         *      db = new Database();
         *      db.Connect();
         *  }
         *  else
         *  {
         *      db = (Database)Db;
         *  }
         *
         *  OracleCommand command = db.CreateCommand(SQL_SELECT);
         *  OracleDataReader reader = db.Select(command);
         *
         *  Collection<Zpusob_vytapeni> Zpusoby_vytapeni = Read(reader, false);
         *  reader.Close();
         *
         *  if (Db == null)
         *  {
         *      db.Close();
         *  }
         *
         *  return Zpusoby_vytapeni;
         * }*/

        /*
         * public static Zpusob_vytapeni Select_id(int idStavba, string zpusobVytapeni, Database Db = null)
         * {
         *  Database db = new Database();
         *  db.Connect();
         *  OracleCommand command = db.CreateCommand(SQL_SELECT_ID);
         *
         *  command.Parameters.AddWithValue(":id", idStavba);
         *  command.Parameters.AddWithValue(":zpusob_vytapeni", zpusobVytapeni);
         *  OracleDataReader reader = db.Select(command);
         *
         *  Collection<Zpusob_vytapeni> zpusoby_vytapeni = Read(reader, true);
         *  Zpusob_vytapeni zpusob_vytapeni = null;
         *  if (zpusoby_vytapeni.Count == 1)
         *  {
         *      zpusob_vytapeni = zpusoby_vytapeni[0];
         *  }
         *  reader.Close();
         *  db.Close();
         *  return zpusob_vytapeni;
         * }*/

        private static void PrepareCommand(OracleCommand command, Zpusob_vytapeni Zpusob_vytapeni)
        {
            command.BindByName = true;
            command.Parameters.AddWithValue(":zpusob_vytapeni", Zpusob_vytapeni.Typ_vytapeni);
            command.Parameters.AddWithValue(":platnost_od", Zpusob_vytapeni.Platnost_od);
            command.Parameters.AddWithValue(":platnost_do", Zpusob_vytapeni.Platnost_do == null ? DBNull.Value : (object)Zpusob_vytapeni.Platnost_do);
            command.Parameters.AddWithValue(":id_stavby", Zpusob_vytapeni.Id_stavby);
        }
示例#3
0
        public void Delete(Zpusob_vytapeni zpusob_vytapeni)
        {
            Database db = new Database();

            db.Connect();
            OracleCommand command = db.CreateCommand(SQL_DELETE);

            PrepareCommand(command, zpusob_vytapeni);
            int ret = db.ExecuteNonQuery(command);

            db.Close();
        }
示例#4
0
        public void Insert(Zpusob_vytapeni zpusob_vytapeni)
        {
            XDocument xDoc = XDocument.Load(ConstantsXml.FilePath);

            XElement result = new XElement("Zpusob_vytapeni",
                                           new XAttribute("Typ_vytapeni", zpusob_vytapeni.Typ_vytapeni),
                                           new XAttribute("Platnost_od", zpusob_vytapeni.Platnost_od.ToShortDateString()),
                                           new XAttribute("Platnost_do", zpusob_vytapeni.Platnost_do == null ? DBNull.Value : (object)zpusob_vytapeni.Platnost_do.ToString()),
                                           new XAttribute("Id_stavby", zpusob_vytapeni.Id_stavby));

            xDoc.Root.Element("Zpusoby_vytapeni").Add(result);
            xDoc.Save(ConstantsXml.FilePath);
        }
示例#5
0
        public void Delete(Zpusob_vytapeni zpusob_vytapeni)
        {
            XDocument xDoc = XDocument.Load(ConstantsXml.FilePath);

            var q = from node in xDoc.Descendants("Zpusoby_vytapeni").Descendants("Zpusob_vytapeni")
                    let attr                         = node.Attribute("Typ_vytapeni")
                                           let attr1 = node.Attribute("Id_stavby")
                                                       where (attr != null && attr.Value == zpusob_vytapeni.Typ_vytapeni) && (attr1 != null && attr1.Value == zpusob_vytapeni.Id_stavby.ToString())
                                                       select node;

            q.ToList().ForEach(x => x.Attribute("Platnost_do").Value = zpusob_vytapeni.Platnost_do.ToString());

            xDoc.Save(ConstantsXml.FilePath);
        }
示例#6
0
        public Zpusob_vytapeni Select_id(int idStavba, string zpusobVytapeni)
        {
            Collection <Zpusob_vytapeni> vsechnyZpusoby = this.Select();
            Zpusob_vytapeni vybranyZpusob = null;

            foreach (Zpusob_vytapeni zpusob in vsechnyZpusoby)
            {
                if (zpusob.Id_stavby == idStavba && zpusob.Typ_vytapeni == zpusobVytapeni)
                {
                    vybranyZpusob = zpusob;
                }
            }

            return(vybranyZpusob);
        }
示例#7
0
        private static Collection <Zpusob_vytapeni> Read(OracleDataReader reader, bool complete)
        {
            Collection <Zpusob_vytapeni> Zpusoby_vytapeni = new Collection <Zpusob_vytapeni>();

            while (reader.Read())
            {
                int             i = -1;
                Zpusob_vytapeni Zpusob_vytapeni = new Zpusob_vytapeni();
                Zpusob_vytapeni.Typ_vytapeni = reader.GetString(++i);
                if (complete)
                {
                    Zpusob_vytapeni.Platnost_od = reader.GetDateTime(++i);
                    if (!reader.IsDBNull(++i))
                    {
                        Zpusob_vytapeni.Platnost_do = reader.GetDateTime(i);
                    }
                }
                Zpusob_vytapeni.Id_stavby = reader.GetInt32(++i);

                Zpusoby_vytapeni.Add(Zpusob_vytapeni);
            }
            return(Zpusoby_vytapeni);
        }
示例#8
0
        public Collection <Zpusob_vytapeni> Select()
        {
            XDocument xDoc = XDocument.Load(ConstantsXml.FilePath);

            List <XElement> elementy = xDoc.Descendants("Zpusoby_vytapeni").Descendants("Zpusob_vytapeni").ToList();

            Collection <Zpusob_vytapeni> vsechnyZpusoby = new Collection <Zpusob_vytapeni>();
            DateTime platnostOd;
            DateTime platnostDo;
            int      idStavby;

            foreach (XElement element in elementy)
            {
                Zpusob_vytapeni zpusob = new Zpusob_vytapeni();

                zpusob.Typ_vytapeni = element.Attribute("Typ_vytapeni").Value;
                DateTime.TryParse(element.Attribute("Platnost_od").Value, out platnostOd);
                try
                {
                    DateTime.TryParse(element.Attribute("Platnost_do").Value, out platnostDo);
                    zpusob.Platnost_do = platnostDo;
                }
                catch (Exception e)
                {
                    zpusob.Platnost_do = null;
                }
                int.TryParse(element.Attribute("Id_stavby").Value, out idStavby);

                zpusob.Platnost_od = platnostOd;
                zpusob.Id_stavby   = idStavby;

                vsechnyZpusoby.Add(zpusob);
                zpusob = null;
            }

            return(vsechnyZpusoby);
        }
示例#9
0
        public Zpusob_vytapeni Select_id(int idStavba, string zpusobVytapeni)
        {
            Database db = new Database();

            db.Connect();
            OracleCommand command = db.CreateCommand(SQL_SELECT_ID);

            command.Parameters.AddWithValue(":id", idStavba);
            command.Parameters.AddWithValue(":zpusob_vytapeni", zpusobVytapeni);
            OracleDataReader reader = db.Select(command);

            Collection <Zpusob_vytapeni> zpusoby_vytapeni = Read(reader, true);
            Zpusob_vytapeni zpusob_vytapeni = null;

            if (zpusoby_vytapeni.Count == 1)
            {
                zpusob_vytapeni = zpusoby_vytapeni[0];
            }

            reader.Close();
            db.Close();

            return(zpusob_vytapeni);
        }