Exemplo n.º 1
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     try
     {
         if (Ap.IsChecked == true)
         {
             Entities          db  = new Entities();
             var               nub = Convert.ToInt32(IdD.Text);
             apartment_demands ap  = db.apartment_demands.Where(p => p.Id == nub).FirstOrDefault();
             db.apartment_demands.Remove(ap);
             db.SaveChanges();
         }
         if (Ho.IsChecked == true)
         {
             Entities      db  = new Entities();
             var           nub = Convert.ToInt32(IdD.Text);
             house_demands ap  = db.house_demands.Where(p => p.Id == nub).FirstOrDefault();
             db.house_demands.Remove(ap);
             db.SaveChanges();
         }
         if (La.IsChecked == true)
         {
             Entities     db  = new Entities();
             var          nub = Convert.ToInt32(IdD.Text);
             land_demands ap  = db.land_demands.Where(p => p.Id == nub).FirstOrDefault();
             db.land_demands.Remove(ap);
             db.SaveChanges();
         }
     }
     catch
     {
     }
 }
Exemplo n.º 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (Ap.IsChecked == true)
                {
                    int      MaxP = 0;
                    var      MinP = 0;
                    Entities db   = new Entities();
                    if (Maxp.Text != "")
                    {
                        MaxP = Convert.ToInt32(Maxp.Text);
                    }
                    if (Minp.Text != "")
                    {
                        MinP = Convert.ToInt32(Maxp.Text);
                    }

                    agent  fo    = db.agents.Where(p => p.FirstName == AId.SelectedItem.ToString()).FirstOrDefault();
                    client of    = db.clients.Where(p => p.FirstName == CId.SelectedItem.ToString()).FirstOrDefault();
                    var    apnew = new apartment_demands();
                    apnew.MaxArea  = MaxA.Text;
                    apnew.MinArea  = MinA.Text;
                    apnew.MaxFloor = MaxF.Text;
                    apnew.MinFloor = MinF.Text;

                    apnew.MaxPrice       = MaxP;
                    apnew.MinPrice       = MinP;
                    apnew.MaxRooms       = MaxR.Text;
                    apnew.MinRooms       = MinR.Text;
                    apnew.Address_City   = Ac.Text;
                    apnew.Address_House  = Ah.Text;
                    apnew.Address_Number = An.Text;
                    apnew.Address_Street = As.Text;
                    apnew.AgentId        = fo.Id;
                    apnew.ClientId       = of.Id;
                    db.apartment_demands.Add(apnew);
                    db.SaveChanges();
                }
                if (Ho.IsChecked == true)
                {
                    int      MaxP = 0;
                    var      MinP = 0;
                    Entities db   = new Entities();
                    if (Maxp.Text != "")
                    {
                        MaxP = Convert.ToInt32(Maxp.Text);
                    }
                    if (Minp.Text != "")
                    {
                        MinP = Convert.ToInt32(Maxp.Text);
                    }

                    agent  fo    = db.agents.Where(p => p.FirstName == AId.SelectedItem.ToString()).FirstOrDefault();
                    client of    = db.clients.Where(p => p.FirstName == CId.SelectedItem.ToString()).FirstOrDefault();
                    var    apnew = new house_demands();
                    apnew.MaxArea        = MaxA.Text;
                    apnew.MinArea        = MinA.Text;
                    apnew.MaxFloors      = MaxF.Text;
                    apnew.MinFloors      = MinF.Text;
                    apnew.MaxPrice       = MaxP;
                    apnew.MinPrice       = MinP;
                    apnew.MaxRooms       = MaxR.Text;
                    apnew.MinRooms       = MinR.Text;
                    apnew.Address_City   = Ac.Text;
                    apnew.Address_House  = Ah.Text;
                    apnew.Address_Number = An.Text;
                    apnew.Address_Street = As.Text;
                    apnew.AgentId        = fo.Id;
                    apnew.ClientId       = of.Id;
                    db.house_demands.Add(apnew);
                    db.SaveChanges();
                }
                if (La.IsChecked == true)
                {
                    Entities db   = new Entities();
                    int      MaxP = 0;
                    var      MinP = 0;
                    if (Maxp.Text != "")
                    {
                        MaxP = Convert.ToInt32(Maxp.Text);
                    }
                    if (Minp.Text != "")
                    {
                        MinP = Convert.ToInt32(Maxp.Text);
                    }
                    agent  fo    = db.agents.Where(p => p.FirstName == AId.SelectedItem.ToString()).FirstOrDefault();
                    client of    = db.clients.Where(p => p.FirstName == CId.SelectedItem.ToString()).FirstOrDefault();
                    var    apnew = new land_demands();
                    apnew.MaxArea        = MaxA.Text;
                    apnew.MinArea        = MinA.Text;
                    apnew.MaxPrice       = MaxP;
                    apnew.MinPrice       = MinP;
                    apnew.Address_City   = Ac.Text;
                    apnew.Address_House  = Ah.Text;
                    apnew.Address_Number = An.Text;
                    apnew.Address_Street = As.Text;
                    apnew.AgentId        = fo.Id;
                    apnew.ClientId       = of.Id;
                    db.land_demands.Add(apnew);
                    db.SaveChanges();
                }
            }
            catch
            {
            }
        }