Exemplo n.º 1
0
 public HydroTopologyViewModel(HydroTopology hydroTopology)
 {
     this.hydroTopology = hydroTopology;
     elementsList       = new List <string>();
     SetElementsList();
     SetTypesList();
 }
Exemplo n.º 2
0
 public HydroTopologyViewModel()
 {
     hydroTopology        = new HydroTopology();
     hydroTopology.System = HydroTopologyPanel.HydroSystemName;
     elementsList         = new List <string>();
     typesList            = new List <string>();
 }
Exemplo n.º 3
0
        public static void DeleteElement(HydroTopology dataObject)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE Sistema = '{1}' " +
                                         "AND Elemento = '{2}' " +
                                         "AND Tipo = '{3}'",
                                         table, dataObject.System, dataObject.Element, dataObject.Type);

            DataBaseManager.ExecuteQuery(query);
        }
Exemplo n.º 4
0
        public static int UpdateObject(HydroTopology dataObject)
        {
            bool   isNew = false;
            string query = string.Format("SELECT Sistema " +
                                         "FROM {0} " +
                                         "WHERE Id = {1}", table, dataObject.Id);

            OleDbDataReader reader = DataBaseManager.ReadData(query);

            if (!reader.Read())
            {
                query = string.Format("INSERT INTO {0}(Sistema, Elemento, Tipo, TipoElemento) " +
                                      "VALUES('{1}', '{2}', '{3}', '{4}')",
                                      table, dataObject.System, dataObject.Element,
                                      dataObject.Type, dataObject.ElementType);
                isNew = true;
            }
            else
            {
                query = string.Format("UPDATE {0} SET " +
                                      "Sistema = '{1}', " +
                                      "Elemento = '{2}', " +
                                      "Tipo = '{3}', " +
                                      "TipoElemento = '{4}' " +
                                      "WHERE Id = {5}",
                                      table, dataObject.System, dataObject.Element,
                                      dataObject.Type, dataObject.ElementType, dataObject.Id);
            }
            DataBaseManager.DbConnection.Close();
            DataBaseManager.ExecuteQuery(query);

            if (isNew)
            {
                query  = string.Format("SELECT Max(Id) FROM {0}", table);
                reader = DataBaseManager.ReadData(query);
                reader.Read();
                int id = Convert.ToInt32(reader.GetValue(0));
                DataBaseManager.DbConnection.Close();
                return(id);
            }
            else
            {
                return(-1);
            }
        }