private void listBoxRealEstate_SelectedIndexChanged(object sender, EventArgs e) { realEstate = listBoxRealEstate.SelectedItem as RealEstate; textBoxStreet.Text = realEstate.Street; textBoxCity.Text = realEstate.City.ToString(); textBoxPrice.Text = realEstate.Price.ToString(); textBoxRoom.Text = realEstate.Rooms.ToString(); textBoxFloor.Text = realEstate.Floor.ToString(); textBoxDescription.Text = realEstate.Description; photoNumber = 0; labelPhotoNumber.Text = "1/5"; if (realEstate.Status == Status.Waiting || realEstate.Status == Status.Renting) { labelAvailable.Text = "X"; labelAvailable.ForeColor = Color.Red; } else { labelAvailable.Text = "V"; labelAvailable.ForeColor = Color.Green; } photoSlider = ImageManip.ByteArrToPhotoSlider(realEstate.PhotoSlider); pictureBoxSlider.Image = ImageManip.ByteArrayToImage(photoSlider[photoNumber]); }
public FormClient(Client c) { InitializeComponent(); client = db.Clients.Single(x => x.Id == c.Id); labelWelcome.Text = "Welcome, " + client.FirstName; pictureBoxProfilePhoto.Image = ImageManip.ByteArrayToImage(client.ProfilePhoto); if (client.Status == Status.Renting) { RealEstate tmp = db.RealEstate.Single(x => x.Id == client.Id); int realEstateClientId = tmp.Id; realEstate = db.RealEstate.Single(x => x.Id == realEstateClientId); labelRentingNow.Text = "Yes"; labelPrice.Text = "$" + realEstate.Price.ToString(); labelStreet.Text = realEstate.Street; labelFloor.Text = realEstate.Floor.ToString(); } else { labelRentingNow.Text = "No"; labelPrice.Text = "$0"; labelStreet.Text = "Unknown"; labelFloor.Text = "0"; } }
private void buttonStopRenting_Click(object sender, EventArgs e) { if (client.Status == Status.Renting || client.Status == Status.Waiting) { client.Status = Status.None; RealEstate tmp = db.RealEstate.Single(x => x.Id == client.Id); int realEstateClientId = tmp.Id; realEstate = db.RealEstate.Single(x => x.Id == realEstateClientId); realEstate.Client = db.Clients.FirstOrDefault(); realEstate.Status = Status.None; } db.SaveChanges(); }
void TcpProcess() { try { Client tmpClient = db.Clients.Single(x => x.Id == client.Id); RealEstate tmpRealEstate = db.RealEstate.Single(x => x.Id == realEstate.Id); tcpClient = new TcpClient(); tcpClient.Connect(IPAddress.Loopback, 8888); stream = tcpClient.GetStream(); while (true) { if (tmpClient.Status == Status.Renting || tmpClient.Status == Status.Waiting) { return; } if (tmpRealEstate.Status == Status.Renting || tmpRealEstate.Status == Status.Waiting) { MessageBox.Show("This real estate is taken", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string realEstateId = tmpRealEstate.Id.ToString(); string clientId = tmpClient.Id.ToString(); string ids = realEstateId + "." + clientId; byte[] buff = Encoding.UTF8.GetBytes(ids); stream.Write(buff, 0, buff.Length); tmpClient.Status = Status.Waiting; tmpRealEstate.Status = Status.Waiting; db.SaveChanges(); } } catch (Exception) { } }