public frmDetailHouse(frmMain afrmMain, int IDPlayer, int IDPlot) {
     InitializeComponent();
     PlayerHouses aPlayHouse = new PlayerHouses();
     this.afrmMain = afrmMain;
     this.IDPlayer = IDPlayer;
     this.IDPlot = IDPlot;
     pawn = this.afrmMain.aListPlotInfo.Find(b => b.ID == IDPlot).Pawn;
     lblPlotName.Text = this.afrmMain.aListPlotInfo.Find(b => b.ID == IDPlot).Name;
     lblColor.BackColor = System.Drawing.ColorTranslator.FromHtml(this.afrmMain.aListPlotInfo.Find(b => b.ID == IDPlot).Color);
     lblOwner.Text = this.afrmMain.aListPlayer.Find(b => b.ID == IDPlayer).Name;
     aPlayHouse = this.afrmMain.aListPlayer.Find(b => b.ID == IDPlayer).ListHouses.Find(c => c.IDPlot == IDPlot);
     lblPaid.Text = aPlayHouse.Spent.ToString();
     if(aPlayHouse.Apartments == 5) {
         lblSize.Text = "Nhà hàng";
     }
     else {
         lblSize.Text = aPlayHouse.Apartments.ToString() + " căn";
     }
     int money = 0;
     PlotInfo aPlotInfo = this.afrmMain.aListPlotInfo.Find(b => b.ID == IDPlot);
     if(aPlayHouse.Apartments == 0) {
         money = aPlotInfo.LeaseLand;
     }
     else {
         if(aPlayHouse.Apartments == 1) {
             money = aPlotInfo.LeaseOneHouse;
         }
         else {
             if(aPlayHouse.Apartments == 2) {
                 money = aPlotInfo.LeaseTwoHouses;
             }
             else {
                 if(aPlayHouse.Apartments == 3) {
                     money = aPlotInfo.LeaseThreeHouses;
                 }
                 else {
                     if(aPlayHouse.Apartments == 4) {
                         money = aPlotInfo.LeaseFourHouses;
                     }
                     else {
                         if(aPlayHouse.Apartments == 5) {
                             money = aPlotInfo.LeaseRes;
                         }
                     }
                 }
             }
         }
     }
     lblLease.Text = money.ToString();
     lblPawn.Text = aPlotInfo.Pawn.ToString();
     if(aPlayHouse.Status == 1) {
         lblStatus.Text = "Bình thường";
     }
     else {
         if(aPlayHouse.Status == 0) {
             lblStatus.Text = "Đang cầm cố";
             pboRedeem.Visible = true;
         }
     }
 }
        private void pboBuy_Click(object sender, EventArgs e) {
            if(this.afrmMain.aListPlayer.Find(b => b.ID == this.afrmMain.turnPlayer).Money >= int.Parse(lblTotalMoney.Text)) {
                PlayerHouses aPlayHouse = new PlayerHouses();
                if(aPlotInfo.ID <= 11) {
                    aPlayHouse.HouseLabel.Location = new Point(aPlotInfo.X1Coord + 9, aPlotInfo.Y1Coord - 25);
                }
                else {
                    if(aPlotInfo.ID >= 32) {
                        aPlayHouse.HouseLabel.Location = new Point(aPlotInfo.X1Coord - 32, aPlotInfo.Y1Coord + 11);
                    }
                    else {
                        if(aPlotInfo.ID > 11 && aPlotInfo.ID <= 20) {
                            aPlayHouse.HouseLabel.Location = new Point(aPlotInfo.X2Coord + 2, aPlotInfo.Y2Coord - 40);
                        }
                        else {
                            aPlayHouse.HouseLabel.Location = new Point(aPlotInfo.X2Coord - 46, aPlotInfo.Y2Coord);
                        }
                    }
                }
                if(cbbHouse.SelectedIndex == 5) {
                    aPlayHouse.HouseLabel.Text = "1";
                    aPlayHouse.HouseLabel.Appearance.Image = global::MonopolyProject.Properties.Resources.hotel_icon;

                }
                else {
                    aPlayHouse.HouseLabel.Text = cbbHouse.SelectedIndex.ToString();
                    aPlayHouse.HouseLabel.Appearance.Image = global::MonopolyProject.Properties.Resources.house_icon;
                }
                aPlayHouse.IDPlot = aPlotInfo.ID;
                aPlayHouse.Name = aPlotInfo.Name + "("+cbbHouse.Text+")";
                aPlayHouse.Apartments = cbbHouse.SelectedIndex;
                aPlayHouse.Spent = int.Parse(lblTotalMoney.Text);
                aPlayHouse.Status = 1;
                string nameHouseLabel = this.afrmMain.turnPlayer.ToString() + this.aPlotInfo.ID.ToString();
                aPlayHouse.HouseLabel.Name = nameHouseLabel;
                aPlayHouse.HouseLabel.Appearance.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold);
                aPlayHouse.HouseLabel.ImageAlignToText = DevExpress.XtraEditors.ImageAlignToText.RightCenter;
                aPlayHouse.HouseLabel.Size = new System.Drawing.Size(40, 20);
                aPlayHouse.HouseLabel.ToolTip = "Nhà của " + this.afrmMain.aListPlayer.Find(b => b.ID == this.afrmMain.turnPlayer).Name;
                aPlayHouse.HouseLabel.Appearance.ForeColor = System.Drawing.ColorTranslator.FromHtml(aPlotInfo.Color);
                this.afrmMain.aListPlayer.Find(b => b.ID == this.afrmMain.turnPlayer).ListHouses.Add(aPlayHouse);
                this.afrmMain.Controls.Add(aPlayHouse.HouseLabel);
                aPlayHouse.HouseLabel.Show();
                this.afrmMain.aListPlayer.Find(b => b.ID == this.afrmMain.turnPlayer).Money -= int.Parse(lblTotalMoney.Text);
                this.afrmMain.bankMoney += int.Parse(lblTotalMoney.Text);
                this.afrmMain.aListPlotInfo.Find(b => b.ID == this.aPlotInfo.ID).Status = 1;
                this.afrmMain.Refresh();
                this.afrmMain.DisplayChangeMoneyPlayer(this.afrmMain.turnPlayer, int.Parse(lblTotalMoney.Text), false);
                this.afrmMain.terCountdownClock_Start();
                this.afrmMain.EnableDice();
                this.Close();
            }
            else {
                MessageBox.Show("Bạn không đủ tiền để xây nhà.", "Mua nhà", MessageBoxButtons.OK);
            }
        }
 private void pboSale_Click(object sender, EventArgs e) {
     PlayerHouses aPlayerHouse = new PlayerHouses();
     aPlayerHouse = this.afrmMain.aListPlayer.Find(b => b.ID == IDPlayer).ListHouses.Find(c => c.IDPlot == IDPlot);
     if(rdoSale.SelectedIndex == 0) {
         DialogResult result = MessageBox.Show("Bạn có chắc chắn muốn cầm cố miếng đất này cho Ngân hàng?", "Bán nhà", MessageBoxButtons.YesNoCancel);
         if(result == DialogResult.Yes) {
             this.afrmMain.bankMoney -= int.Parse(lblClosingPrice.Text);
             this.afrmMain.aListPlayer.Find(b => b.ID == IDPlayer).Money += int.Parse(lblClosingPrice.Text);
             this.afrmMain.aListPlayer.Find(b => b.ID == IDPlayer).ListHouses.Find(c => c.IDPlot == IDPlot).Status = 0;
             string nameHouseLabel = IDPlayer.ToString() + IDPlot.ToString();
             this.afrmMain.Controls.Find(nameHouseLabel, false).First().Visible = false;
             this.afrmMain.DisplayChangeMoneyPlayer(IDPlayer, int.Parse(lblClosingPrice.Text), true);
         }
     }
     else {
         if(rdoSale.SelectedIndex == 1) {
             if(this.afrmMain.aListPlayer.Find(b => b.Name == cbbBuyer.Text).Money < int.Parse(lblClosingPrice.Text)) {
                 string contentMessageBox = cbbBuyer.Text + " không đủ tiền để mua lại mảnh đất này!";
                 MessageBox.Show(contentMessageBox, "Bán nhà", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 return;
             }
             else {
                 string contentDialog = "Bạn có chắc chắn muốn bán miếng đất này cho " + cbbBuyer.Text + "?";
                 DialogResult result = MessageBox.Show(contentDialog, "Bán nhà", MessageBoxButtons.YesNoCancel);
                 if(result == DialogResult.Yes) {
                     contentDialog = cbbBuyer.Text + ", bạn có chắc chắn muốn mua mảnh đất này của "
                         + this.afrmMain.aListPlayer.Find(b => b.ID == IDPlayer).Name + " với giá " + int.Parse(lblClosingPrice.Text) + "?";
                     DialogResult finalResult = MessageBox.Show(contentDialog, "Bán nhà", MessageBoxButtons.YesNoCancel);
                     if(finalResult == DialogResult.Yes) {
                         this.afrmMain.aListPlayer.Find(b => b.ID == IDPlayer).Money += int.Parse(lblClosingPrice.Text);
                         this.afrmMain.aListPlayer.Find(b => b.ID == IDPlayer).ListHouses.Remove(aPlayerHouse);
                         aPlayerHouse.Spent = int.Parse(lblClosingPrice.Text);
                         string nameHouseLabel = IDPlayer.ToString() + IDPlot.ToString();
                         LabelControl temp = new LabelControl();
                         temp = (LabelControl)this.afrmMain.Controls[nameHouseLabel];
                         this.afrmMain.Controls.RemoveByKey(nameHouseLabel);
                         nameHouseLabel = this.afrmMain.aListPlayer.Find(b => b.Name == cbbBuyer.Text).ID + IDPlot.ToString();
                         temp.Name = nameHouseLabel;
                         temp.ToolTip = "Nhà của " + cbbBuyer.Text;
                         this.afrmMain.Controls.Add(temp);
                         aPlayerHouse.HouseLabel = temp;
                         this.afrmMain.aListPlayer.Find(b => b.Name == cbbBuyer.Text).ListHouses.Add(aPlayerHouse);
                         this.afrmMain.aListPlayer.Find(b => b.Name == cbbBuyer.Text).Money -= int.Parse(lblClosingPrice.Text);
                         this.afrmMain.DisplayChangeMoneyPlayer(IDPlayer, int.Parse(lblClosingPrice.Text), true);
                         this.afrmMain.DisplayChangeMoneyPlayer(this.afrmMain.aListPlayer.Find(b => b.Name == cbbBuyer.Text).ID, int.Parse(lblClosingPrice.Text), false);
                     }
                 }
             }
         }
     }
     this.afrmMain.Refresh();
     this.afrmMain.terCountdownClock_Start();
     this.afrmMain.EnableDice();
     this.Close();
 }