private void button2_Click(object sender, EventArgs e) { if (!check()) { MessageBox.Show("Thông tin thiếu hoặc không hợp lệ !"); } else { Tour = _tourRepository.getById(_id, ""); Tour.MaTour = matourtb.Text; Tour.Ten = tentourtb.Text; LoaiHinhDL item = new LoaiHinhDL(); item = (LoaiHinhDL)loaicbb.SelectedItem; Tour.LHDLId = item.LHDLId; Tour.CTTours.Clear(); foreach (ListViewItem dd in diadiemlist.CheckedItems) { CTTour newcttour = new CTTour(); newcttour.DDId = Convert.ToInt32(dd.SubItems[0].Text); newcttour.TourId = Tour.TourId; //_cTTourRepository.Add(newcttour); Tour.CTTours.Add(newcttour); } _tourRepository.Update(Tour); MessageBox.Show("Cập nhật thành công!"); Program.Form.TabRefresh(ListTab.Tour); } }
public int Sua(object a) { try { if (a.GetType().ToString().IndexOf("Tour") > 1) { Tour temp = (Tour)a; temp = db.Tours.Where(s => s.Id == temp.Id).FirstOrDefault(); db.Entry(temp).CurrentValues.SetValues(a); } else if (a.GetType().ToString().IndexOf("TinhThanh") > 1) { TinhThanh temp = (TinhThanh)a; temp = db.TinhThanhs.Where(s => s.Id == temp.Id).First(); db.Entry(temp).CurrentValues.SetValues(a); } else if (a.GetType().ToString().IndexOf("DiaDiem") > 1) { DiaDiem temp = (DiaDiem)a; temp = db.DiaDiems.Where(s => s.Id == temp.Id).First(); db.Entry(temp).CurrentValues.SetValues(a); } else if (a.GetType().ToString().IndexOf("LoaiDL") > 1) { LoaiDL temp = (LoaiDL)a; temp = db.LoaiDLs.Where(s => s.Id == temp.Id).First(); db.Entry(temp).CurrentValues.SetValues(a); } else if (a.GetType().ToString().IndexOf("CTTour") > 1) { CTTour temp = (CTTour)a; temp = db.CTTours.Where(s => s.Id == temp.Id).First(); db.Entry(temp).CurrentValues.SetValues(a); } else if (a.GetType().ToString().IndexOf("GiaTour") > 1) { GiaTour temp = (GiaTour)a; temp = db.GiaTours.Where(s => s.Id == temp.Id).First(); db.Entry(temp).CurrentValues.SetValues(a); } db.SaveChanges(); return(1); } catch { return(0); } }
private void btLuuDD_Click(object sender, EventArgs e) { int tt = 1; curTour.DeleteAllChiTietTour(); foreach (DiaDiem diaDiem in listDiaDiem_Tour) { Console.WriteLine(diaDiem.Id + "%%" + diaDiem.Ten); CTTour temp = new CTTour() { MaDiaDiem = diaDiem.Id, MaTour = curTour.Id, ThuTu = tt }; tt++; temp.Save(); } MessageBox.Show("Lưu chi tiết tour", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void cbDSDDTuor_SelectedIndexChanged(object sender, EventArgs e) { var row = new DataGridViewRow(); row.CreateCells(GridDDTour); int vt = cbDSTinhTour.SelectedIndex; var dsdd = dstinh[vt].DiaDiems.ToList(); row.Cells[0].Value = GridDDTour.RowCount + 1; row.Cells[1].Value = dstinh[vt].TenTinh; row.Cells[2].Value = dsdd[cbDSDDTuor.SelectedIndex].TenDiaDiem; row.Cells[3].Value = "Hủy"; CTTour ct = new CTTour(); ct.DiaDiemId = dsdd[cbDSDDTuor.SelectedIndex].Id; dscttour.Add(ct); GridDDTour.Rows.Add(row); }
private void button1_Click(object sender, EventArgs e) { if (!check()) { MessageBox.Show("Thông tin thiếu hoặc không hợp lệ !"); } else { Tour newtour = new Tour(); newtour.CTTours = new List <CTTour>(); newtour.Gias = new List <Gia>(); Gia newgia = new Gia(); newtour.MaTour = matourtb.Text; newtour.Ten = tentourtb.Text; LoaiHinhDL item = new LoaiHinhDL(); item = (LoaiHinhDL)loaihinhcbb.SelectedItem; newtour.LHDL = item; foreach (ListViewItem dd in diadiem.CheckedItems) { CTTour newcttour = new CTTour(); newcttour.DDId = Convert.ToInt32(dd.SubItems[0].Text); newcttour.TourId = newtour.TourId; //_cTTourRepository.Add(newcttour); newtour.CTTours.Add(newcttour); } newgia.GiaTri = (int)mucgia.Value; newgia.TGBD = tungay.Value; newgia.TGKT = denngay.Value; newgia.TourId = newtour.TourId; newtour.Gias.Add(newgia); _tourRepository.Add(newtour); // _giaRepository.Add(newgia); MessageBox.Show("Thêm thành công!"); Program.Form.TabRefresh(ListTab.Tour); } }
public void Delete(CTTour entity) { _context.CTTours.Remove(entity); _context.SaveChanges(); }
public void Add(CTTour entity) { _context.CTTours.Add(entity); _context.SaveChanges(); }