Ejemplo n.º 1
0
        public void UpdateCountrysName(Valstybe old, string newName)
        {
            SqlCommand update = new SqlCommand();

            update.Connection  = cn;
            update.CommandType = System.Data.CommandType.Text;
            update.CommandText = "UPDATE ValstybeSet SET Pavadinimas = @NEWPAV WHERE Id = @PAV";


            update.Parameters.Add(new SqlParameter("@NEWPAV", SqlDbType.NVarChar, 20, "Pavadinimas"));
            update.Parameters.AddWithValue("@PAV", old.Id);

            SqlDataAdapter da = new SqlDataAdapter("Select Id, Pavadinimas, Susikure FROM ValstybeSet", cn);

            da.UpdateCommand = update;

            DataSet ds = new DataSet();

            da.Fill(ds, "ValstybeSet");

            ds.Tables[0].Rows[0]["Pavadinimas"] = newName;

            da.Update(ds.Tables[0]);
            da.Dispose();
        }
Ejemplo n.º 2
0
        public void GenerateNewWarrior(string name, int power, Valstybe country)
        {
            var warrior = new Karvedys {
                Vardas = name, PulkuSkaicius = power, Tarnauja = country
            };

            db.KarvedysSet.Add(warrior);
            db.SaveChanges();
        }
Ejemplo n.º 3
0
        public Valstybe GetCountryByName(string countryName)
        {
            var query = (from b in db.ValstybeSet
                         where b.Pavadinimas == countryName
                         orderby b.Id
                         select b).Skip(0).Take(1);

            foreach (var b in query)
            {
                country = b;
            }
            return(country);
        }
Ejemplo n.º 4
0
        public void DeleteCountry(Valstybe name)
        {
            SqlCommand delete = new SqlCommand();

            delete.Connection  = cn;
            delete.CommandType = System.Data.CommandType.Text;
            delete.CommandText = "DELETE FROM ValstybeSet WHERE Id = @PAV";

            delete.Parameters.AddWithValue("@PAV", name.Id);

            SqlDataAdapter da = new SqlDataAdapter("Select Pavadinimas FROM ValstybeSet", cn);

            da.DeleteCommand = delete;

            DataSet ds = new DataSet();

            da.Fill(ds, "ValstybeSet");

            ds.Tables[0].Rows[0].Delete();

            da.Update(ds.Tables[0]);
            da.Dispose();
        }
Ejemplo n.º 5
0
 private void RefreshCountry(string countryName)
 {
     country = dbInter.GetCountryByName(countryName);
     countryNameLabel.Text = countryName;
     countryDates.Text     = country.Susikure.ToShortDateString();
 }