private void Tripfrm_Load(object sender, EventArgs e) { cbbTours_Load(); if (_MChuyen == 0) { btnUpdate.Visible = false; listTrips = Chuyen.FindByStatus(1); cbbStatus.SelectedIndex = 0; } else { btnAdd.Visible = false; current = Chuyen.Single(MChuyen); txtCode.Text = MChuyen.ToString(); txtPrice.Text = current.Gia.ToString(); int count = cbbTours.Items.Count; for (int i = 0; i < count; i++) { if ((cbbTours.Items[i] as Tour).ID == current.MTour) { cbbTours.SelectedIndex = i; break; } } dtpStart.Value = current.NgayDi; dtpEnd.Value = current.NgayVe; if (current.TrangThai >= 1) { cbbStatus.SelectedIndex = 0; } else if (current.TrangThai == 0) { cbbStatus.SelectedIndex = 1; } else { cbbStatus.SelectedIndex = 2; } if (current.NgayDi < DateTime.Today) { cbbTours.Enabled = false; } } }
private void cbbStatus_SelectedIndexChanged(object sender, EventArgs e) { if (cbbStatus.SelectedIndex >= 0) { //lvTrips_Load(listTrip.FindAll( // delegate(Chuyen t) // { // return t.TrangThai == (cbbStatus.SelectedItem.ToString() == "Đang mở" ? 1 : cbbStatus.SelectedItem.ToString() == "Đã hủy" ? -1 : 0); // } // )); lvTrips_Load(Chuyen.FindByStatus(cbbStatus.SelectedItem.ToString() == "Đang mở" ? 1 : cbbStatus.SelectedItem.ToString() == "Đã hủy" ? -1 : 0)); } else { btnAll.PerformClick(); } }