private void BindAvailableSeat() { TripInfo tripInfo = new TripInfo(); TripDetailController controller = new TripDetailController(); TripDetailCollection collection = controller.SelectDetailByTripID(lblTripID.Text); int a = 0; for (int i = 0; i < collection.Count; i++) { if (collection[i].Status == "A") { a++; } } txtAvailableSeats.Text = Convert.ToString(a); }
public void BindSeat() { TripInfo tripInfo = new TripInfo(); string TripID = Convert.ToString(tripInfo.TripID); TripDetailController tripDetailContoller = new TripDetailController(); TripDetailCollection collections = tripDetailContoller.SelectDetailByTripID(lblGetTripID.Text); pnlSeat.Controls.Clear(); int backSeat = collections.Count - 5; int backSeatNumber = (collections.Count % 2); for (int i = 0, x = 0, y = 0; i < collections.Count; i++) { Label lbl = new Label(); if (collections[i].Status == "A") { if (!string.IsNullOrEmpty(lblSeatSelectList.Text)) { string[] arr = lblSeatSelectList.Text.Split(','); string no = ""; for (int j = 0; j < arr.Length; j++) { no = arr[j]; if (no.Contains(collections[i].SeatNo)) { lbl.Image = global::BTS.UI.Properties.Resources.sbs4; lbl.Name = "lbl" + Convert.ToString(i); break; } else { lbl.Image = global::BTS.UI.Properties.Resources.sa1; lbl.Name = "Xlbl" + Convert.ToString(i); } } } else { lbl.Image = global::BTS.UI.Properties.Resources.sa1; lbl.Name = "Xlbl" + Convert.ToString(i); } } else { if (collections[i].Status == "S") { lbl.Image = global::BTS.UI.Properties.Resources.ss2; } else { lbl.Image = global::BTS.UI.Properties.Resources.sb3; } } if (i >= backSeat && backSeatNumber != 0) { lbl.Location = new System.Drawing.Point(x, (41 * y)); lbl.AutoSize = false; lbl.BorderStyle = System.Windows.Forms.BorderStyle.None; lbl.Size = new System.Drawing.Size(40, 40); lbl.Text = Convert.ToString(Convert.ToInt32(i + 1)); lbl.Name = "Xlbl" + Convert.ToString(i); lbl.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; lbl.TabIndex = 1; lbl.TabStop = false; if (collections[i].Status == "A") { lbl.MouseClick += new System.Windows.Forms.MouseEventHandler(this.lblSeat_MouseClick); } pnlSeat.Controls.Add(lbl); y++; if (y == 5) { y = 0; x = x + 45; } } else { if (y == 2 || y == 3 || y == 4) { lbl.Location = new System.Drawing.Point(x, (46 * y) + 25); } else { lbl.Location = new System.Drawing.Point(x, (46 * y)); } lbl.AutoSize = false; lbl.BorderStyle = System.Windows.Forms.BorderStyle.None; lbl.Size = new System.Drawing.Size(40, 40); if (i < 9) { lbl.Text = "0" + Convert.ToString(Convert.ToInt32(i + 1)); } else { lbl.Text = Convert.ToString(Convert.ToInt32(i + 1)); } lbl.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; lbl.TabIndex = 1; lbl.TabStop = false; if (collections[i].Status == "A") { lbl.MouseClick += new System.Windows.Forms.MouseEventHandler(this.lblSeat_MouseClick); } pnlSeat.Controls.Add(lbl); y++; if (y == 4) { y = 0; x = x + 45; } } } }