public static Building Read_BuildingID(int BuildingID)
 {
     using (var db = new M120_ProjektEntities())
     {
         return((from rec in db.Buildings where rec.BuildingID == BuildingID select rec).FirstOrDefault());
     }
 }
Exemple #2
0
 public static Int64 Create(Building building)
 {
     if (building.name == null)
     {
         building.name = "";
     }
     if (building.street == null)
     {
         building.street = "";
     }
     if (building.streetNr == null)
     {
         building.streetNr = "0";
     }
     if (building.place == null)
     {
         building.place = "";
     }
     if (building.purpose == null)
     {
         building.purpose = "";
     }
     using (var db = new M120_ProjektEntities())
     {
         db.Buildings.Add(building);
         db.SaveChanges();
         db.Entry(building).Reload();
         return(building.BuildingID);
     }
 }
Exemple #3
0
 public static List <Building> ReadAll()
 {
     using (var db = new M120_ProjektEntities())
     {
         return((from rec in db.Buildings select rec).ToList());
     }
 }
        private void button_Click_1(object sender, RoutedEventArgs e)
        {
            Console.WriteLine(Birthday.DisplayDate);
            using (var context = new M120_ProjektEntities())
            {
                context.Citizens.ToList();
            }

            string gender;

            if (Male.IsChecked == true)
            {
                gender = "Herr";
            }
            else
            {
                gender = "Frau";
            }


            try //Absturz bei falschem Datenformat wird verhindert
            {
                format.Opacity = 0;
                Console.WriteLine(Birthday.DisplayDate);
                CreateCitizen(Convert.ToInt32(CitizenID.Text), Name.Text, FirstName.Text, gender, Convert.ToDateTime(Birthday.Text), Convert.ToInt32(Income.Text), Convert.ToInt32(Building.Text));
            }
            catch
            {
                format.Opacity = 1;
            }
            addSuccessful();
        }
        public static Int64 Create(Citizen citizen)
        {
            if (citizen.name == null)
            {
                citizen.name = "";
            }
            if (citizen.firstName == null)
            {
                citizen.firstName = "";
            }
            if (citizen.gender == null)
            {
                citizen.gender = "";
            }
            if (citizen.birthday == null)
            {
                citizen.birthday = DateTime.Today;
            }
            if (citizen.incomePerMonth == null)
            {
                citizen.incomePerMonth = 0;
            }
            if (citizen.fk_buildingID == null)
            {
                citizen.fk_buildingID = 1;
            }

            using (var db = new M120_ProjektEntities())
            {
                db.Citizens.Add(citizen);
                db.SaveChanges();
                db.Entry(citizen).Reload();
                return(citizen.citizenID);
            }
        }
 public static Citizen Read_CitizenID(int citizenID)
 {
     using (var db = new M120_ProjektEntities())
     {
         return((from rec in db.Citizens where rec.citizenID == citizenID select rec).FirstOrDefault());
     }
 }
 public static void Delete(Building building)
 {
     using (var db = new M120_ProjektEntities())
     {
         db.Entry(building).State = System.Data.Entity.EntityState.Deleted;
         db.SaveChanges();
     }
 }
 public static void Delete(Citizen citizen)
 {
     using (var db = new M120_ProjektEntities())
     {
         db.Entry(citizen).State = System.Data.Entity.EntityState.Deleted;
         db.SaveChanges();
     }
 }
Exemple #9
0
        private void button_Click_1(object sender, RoutedEventArgs e)
        {
            using (var context = new M120_ProjektEntities())
            {
                context.Users.ToList();
            }

            try
            {
                format.Opacity = 0;
                CreateBuilding(Convert.ToInt32(ID.Text), name.Text, street.Text, streetNr.Text, Convert.ToInt16(postcode.Text), place.Text, purpose.Text);
            }
            catch
            {
                format.Opacity = 100;
            }
        }