Ejemplo n.º 1
0
        internal void UpdateTownState(TableTownState TownState)
        {
            SqlConnection conn = new SqlConnection(connectionString);

            try
            {
                conn.Open();
            }
            catch (SqlException se)
            {
                return;
            }

            SqlCommand cmd = new SqlCommand("Insert into Town_State" + "(IdTown,IdState,Duration) Values (@IdTown, @IdState, @Duration)", conn);

            SqlParameter param = new SqlParameter();

            param.ParameterName = "@IdTown";
            param.Value         = TownState.GetId();
            param.SqlDbType     = SqlDbType.VarChar;
            cmd.Parameters.Add(param);

            param = new SqlParameter();
            param.ParameterName = "@IdState";
            param.Value         = TownState.GetIdState();
            param.SqlDbType     = SqlDbType.VarChar;
            cmd.Parameters.Add(param);

            param = new SqlParameter();
            param.ParameterName = "@Duration";
            param.Value         = TownState.GetDuration();
            param.SqlDbType     = SqlDbType.Int;
            cmd.Parameters.Add(param);

            try
            {
                cmd.ExecuteNonQuery();
            }
            catch (SqlException se)
            {
                return;
            }
            conn.Close();
            conn.Dispose();
        }
Ejemplo n.º 2
0
        public static Boolean NowyStan(string ids, string idm, int czas)
        {
            Boolean flaga = false;
            string  ids2;
            string  idm2;

            foreach (TableTownState stan in tableTownState)
            {
                idm2 = stan.GetId();
                ids2 = stan.GetIdState();
                if (idm2 == idm && ids2 == ids)
                {
                    flaga = true;
                    stan.SetDuration(czas);
                }
            }
            if (flaga == false)
            {
                TableTownState nowy = new TableTownState(idm, ids, czas);
                tableTownState.Add(nowy);
            }
            return(flaga);
        }
Ejemplo n.º 3
0
        public static TableTownState ZnajdzStanMiasta(string idm, string ids)
        {
            TableTownState stan = tableTownState.Select(n => n).Where(x => x.GetId() == idm && x.GetIdState() == ids).FirstOrDefault();

            return(stan);
        }