Exemple #1
0
 private void FillEditS(Status status)
 {
     status                 = db.Status.Find(status.status_id);
     status.name            = StTB.Text;
     db.Entry(status).State = EntityState.Modified;
     db.SaveChanges();
     FillDataGrid();
 }
Exemple #2
0
        private void ButtonAddObjectEstate_Click(object sender, RoutedEventArgs e)
        {
            newTrade = new Trade();
            dynamic b  = BuyerCB.SelectedItem;
            dynamic a  = AddressCB.SelectedItem;
            dynamic ag = AgentCB.SelectedItem;


            newTrade.date      = (DateTime)DateTrade.SelectedDate;
            newTrade.object_id = a.id;
            newTrade.buyer_id  = b.id;
            newTrade.agent_id  = ag.id;

            db.Trades.Add(newTrade);

            if (TBRent.IsChecked == false)
            {
                newSale         = new Sale();
                newSale.sale_id = newTrade.trade_id;
                newSale.price   = int.Parse(Price.Text);
                db.Sales.Add(newSale);

                ob                 = db.ObjectEstates.Find(a.id);
                ob.status_id       = 2;
                db.Entry(ob).State = EntityState.Modified;
            }
            else
            {
                newRent            = new Rent();
                newRent.rent_id    = newTrade.trade_id;
                newRent.date_start = (DateTime)DateStartRent.SelectedDate;
                newRent.date_end   = (DateTime)DateEndRent.SelectedDate;
                newRent.rent_price = int.Parse(PriceRent.Text);
                db.Rents.Add(newRent);
                ob                 = db.ObjectEstates.Find(a.id);
                ob.status_id       = 6;
                db.Entry(ob).State = EntityState.Modified;
            }

            db.SaveChanges();

            this.Close();
        }
        private void ButtonEditTrade_Click(object sender, RoutedEventArgs e)
        {
            trade      = db.Trades.Find(trade.trade_id);
            trade.date = (DateTime)DateTrade.SelectedDate;

            Agent a = (Agent)AgentCB.SelectedItem;

            trade.agent_id = a.agent_id;

            Client c = (Client)BuyerCB.SelectedItem;

            trade.buyer_id = c.client_id;

            ObjectEstate o = (ObjectEstate)AddressCB.SelectedItem;

            trade.object_id = o.object_id;

            db.Entry(trade).State = EntityState.Modified;

            if (db.Sales.Find(trade.trade_id) != null)
            {
                sale.sale_id = trade.trade_id;
                sale.price   = int.Parse(Price.Text);

                db.Entry(sale).State = EntityState.Modified;
            }
            else
            {
                rent.rent_id    = trade.trade_id;
                rent.date_start = (DateTime)DateStartRent.SelectedDate;
                rent.date_end   = (DateTime)DateEndRent.SelectedDate;
                rent.rent_price = int.Parse(PriceRent.Text);

                db.Entry(rent).State = EntityState.Modified;
            }

            db.SaveChanges();
            this.Close();
        }
        private void ButtonEditObject(object sender, RoutedEventArgs e)
        {
            objectestate                  = db.ObjectEstates.Find(objectestate.object_id);
            objectestate.address          = AddressObject.Text;
            objectestate.cadastral_number = CadastralNumber.Text;
            objectestate.price            = int.Parse(PriceObjectEstate.Text);
            objectestate.square           = int.Parse(Square.Text);

            Client c = (Client)OwnerCB.SelectedItem;

            objectestate.owner_id = c.client_id;

            Status s = (Status)StatusCB.SelectedItem;

            objectestate.status_id = s.status_id;

            db.Entry(objectestate).State = EntityState.Modified;

            if (db.Flats.Find(objectestate.object_id) != null)
            {
                flat.flat_number    = int.Parse(NumberFlat.Text);
                flat.flat_id        = objectestate.object_id;
                flat.number_floor   = int.Parse(NumberFlat.Text);
                flat.quantity_rooms = int.Parse(QuantityRooms.Text);

                db.Entry(flat).State = EntityState.Modified;
            }
            else
            {
                house.house_id        = objectestate.object_id;
                house.plot_size       = int.Parse(PlotSize.Text);
                house.quantity_floors = int.Parse(QuantityFloors.Text);
                db.Entry(house).State = EntityState.Modified;
            }

            db.SaveChanges();
            this.Close();
        }
Exemple #5
0
 private void ButtonEdit_Click(object sender, RoutedEventArgs e)
 {
     agent           = db.Agents.Find(agent.agent_id);
     agent.full_name = FIOagent.Text;
     agent.birthday  = (DateTime)BirthDate.SelectedDate;
     agent.address   = Address.Text;
     agent.passport_series_number = PassportSeriesNumber.Text;
     agent.passport_issued_by     = PassportIssuedBy.Text;
     agent.passport_date          = (DateTime)PassportDate.SelectedDate;
     agent.phone_number           = Phone.Text;
     agent.INN             = INN.Text;
     db.Entry(agent).State = EntityState.Modified;
     db.SaveChanges();
     this.Close();
 }
        private void ButtonEditClient(object sender, RoutedEventArgs e)
        {
            client           = db.Clients.Find(client.client_id);
            client.full_name = FIOclient.Text;
            client.birthday  = (DateTime)BirthDate.SelectedDate;
            client.address   = Address.Text;
            client.passport_series_number = PassportSeriesNumber.Text;
            client.passport_issued_by     = PassportIssuedBy.Text;
            client.passport_date          = (DateTime)PassportDate.SelectedDate;
            client.phone_number           = Phone.Text;

            Role r = (Role)RoleCB.SelectedItem;

            client.role_id = r.role_id;


            db.Entry(client).State = EntityState.Modified;
            db.SaveChanges();
            this.Close();
        }