public frChiTietTour() { InitializeComponent(); TrangThai = "AddTour"; this.Text = "Thêm Tour"; listDiaDiem = DalDiaDiem.GetAllDiaDiem(); listDiaDiem_Tour = new List <DiaDiem>(); HienThiThongTin(); }
private void btXoa_Click(object sender, EventArgs e) { if (curDiaDiem.KiemtraXoa()) { curDiaDiem.Delete(); if (listDiaDiem.Count > 0) { curDiaDiem = listDiaDiem[0]; } listDiaDiem = DalDiaDiem.GetAllDiaDiem(); loadData(); } else { MessageBox.Show("Dia dieem da duoc su dung nen khong the xoa", "Lỗi: Dia diem da duoc su dung!!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } }
private void btLuu_Click(object sender, EventArgs e) { if (txTen.Text.Trim() == "") { MessageBox.Show("Tên bị rỗng", "Lỗi: Tên không được rỗng!!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } DiaDiem temp = new DiaDiem() { Id = int.Parse(txId.Text), Ten = txTen.Text, GhiChu = txGHichu.Text }; if (temp.Id != -1) { temp.updated = true; } temp.Save(); MessageBox.Show("Lưu thành công địa điểm mã:" + temp.Id, "Thành công: Lưu thành công!!", MessageBoxButtons.OK, MessageBoxIcon.Information); KhoaChinhSua(); listDiaDiem = DalDiaDiem.GetAllDiaDiem(); loadData(); }
void loadDiaDiem() { listDiaDiem = DalDiaDiem.GetAllDiaDiem(); listBoxPhai.Items.Clear(); listBoxTrai.Items.Clear(); if (TrangThai == "AddTour") { foreach (DiaDiem diaDiem in listDiaDiem) { if (!listDiaDiem_Tour.Contains(diaDiem)) { listBoxTrai.Items.Add(diaDiem); } } listBoxTrai.DisplayMember = "Ten"; listBoxTrai.ValueMember = "Id"; listBoxPhai.DisplayMember = "Ten"; listBoxPhai.ValueMember = "Id"; } else { listDiaDiem_Tour = DalTour.GetDiaDiemByTour(curTour); foreach (DiaDiem diaDiem in listDiaDiem_Tour) { listBoxPhai.Items.Add(diaDiem); listDiaDiem.RemoveAll(s => s.Id == diaDiem.Id); } foreach (DiaDiem diaDiem in listDiaDiem) { if (!listDiaDiem_Tour.Contains(diaDiem)) { listBoxTrai.Items.Add(diaDiem); } } listBoxTrai.DisplayMember = "Ten"; listBoxTrai.ValueMember = "Id"; listBoxPhai.DisplayMember = "Ten"; listBoxPhai.ValueMember = "Id"; if (listBoxTrai.Items.Count > 0) { listBoxTrai.SetSelected(0, true); } if (listBoxPhai.Items.Count > 0) { listBoxPhai.SetSelected(0, true); } } //listĐiaiemBindings = new BindingList<DiaDiem>(listDiaDiem); // listBoxTrai.DataSource = listĐiaiemBindings; /* listBoxTrai.DisplayMember = "Ten"; * listBoxTrai.ValueMember = "Id";*/ //listBoxTrai.SelectedValue = 3; //mattour = 1 /*if (Id != 0) * { * * }*/ }
private void DanhSachDiaDiem_Load(object sender, EventArgs e) { listDiaDiem = DalDiaDiem.GetAllDiaDiem(); loadData(); }