private void btnUpdate_Click(object sender, EventArgs e) { DiaDiemDL dd = cbbLocal.SelectedItem as DiaDiemDL; DiemDL exited = DiemDL.Single(Code); DiemDL newUp = controls_Load(); if (exited.TenDD != newUp.TenDD || exited.MaDD != newUp.MaDD) { if (DiemDL.FindByTenD_MaDD(txtName.Text, dd.ID).Count > 0) { lblInfo.Text = "This Scenic had been exited!"; txtName.Focus(); return; } } DialogResult dlg = MessageBox.Show("Do you want to Update?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dlg == System.Windows.Forms.DialogResult.Yes) { if (DiemDL.Update(newUp)) { MessageBox.Show("Updating is sucessfull!", "Kim Nguyen's Say", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageBox.Show("Updating had been failse!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void Controls_LoadUp() { Tour t = Tour.Single(_ID); txtCode.Text = t.ID.ToString(); txtName.Text = t.TenTour; txtStartPlace.Text = t.XuatPhat; int i = 0; foreach (var item in cbbStatus.Items) { if (item.ToString() == t.TrangThai) { cbbStatus.SelectedIndex = i; break; } i++; } btnAddTour.Enabled = false; btnUpdateTour.Enabled = true; //btnDeleteTour.Enabled = true; // listScenic = new List <DiemDL>(); listDes = DiemDen.FindByMTour(ID); lvDestination.Items.Clear(); foreach (DiemDen j in listDes) { ListViewItem item = lvDestination.Items.Add(j.TenDD); item.SubItems.Add(j.TenDiem); item.SubItems.Add(j.TenKS); item.SubItems.Add(j.TenPT); item.SubItems.Add(j.TenNCC); listScenic.Add(DiemDL.Single(j.MDiemDL)); } cbbLocal_Load(DiaDiemDL.All()); cbbLocal.SelectedIndex = 0; cbbHotel.Items.Clear(); cbbHotel.Text = ""; tvHotel.Nodes.Clear(); }
private void controls_LoadUp() { DiemDL result = DiemDL.Single(Code); txtCode.Text = result.ID.ToString(); txtName.Text = result.TenDiem; txtAddress.Text = result.DiaChi; int i = 0; foreach (var item in cbbLocal.Items) { DiaDiemDL d = cbbLocal.Items[i] as DiaDiemDL; if (d.ID == result.MaDD) { break; } i++; } cbbLocal.SelectedIndex = i; }