/// <summary> /// Represent a method for creating travel data /// </summary> /// <param name="_title">Represent the Title (string) of the travel</param> /// <param name="_city">Represent the By (string) of the travel</param> /// <param name="_startDate">Represent the Startdato (datetime) of the travel</param> /// <param name="_endDate">Represent the Slutdato (datetime) of the travel</param> /// <param name="_price">Represent the Pris (int) of the travel</param> /// <param name="_maxparticipant">Represent the MaxAntal (string) of the travel</param> /// <param name="_describtion">Represent the Beskrivelse (string) of the travel</param> public void CreateTravel(string _title, string _city, DateTime _startDate, DateTime _endDate, int _price, string _maxparticipant, string _describtion) { //Represent a object of VikingRejserEntities called _context VikingRejserEntities _context = new VikingRejserEntities(); Rejsearrangementer _travel = new Rejsearrangementer { //Represent the Title (string) of the travel Title = _title, //Represent the By (string) of the travel By = _city, //Represent the Startdato (datetime) of the travel Stardato = _startDate, //Represent the Slutdato (datetime) of the travel Slutdato = _endDate, //Represent the Pris (int) of the travel Pris = _price, //Represent the MaxAntal (string) of the travel MaxAntal = _maxparticipant, //Represent the Beskrivelse (string) of the travel Beskrivelse = _describtion }; _context.Rejsearrangementers.Add(_travel); _context.SaveChanges(); }
/// <summary> /// Represent a method for editing travel data /// </summary> /// <param name="_id">Represnt the unique id (int) of each travel</param> /// <param name="_title">Represent the Title (string) of the travel</param> /// <param name="_city">Represent the By (string) of the travel</param> /// <param name="_startDate">Represent the Startdato (datetime) of the travel</param> /// <param name="_endDate">Represent the Slutdato (datetime) of the travel</param> /// <param name="_price">Represent the Pris (int) of the travel</param> /// <param name="_maxparticipant">Represent the MaxAntal (string) of the travel</param> /// <param name="_describtion">Represent the Beskrivelse (string) of the travel</param> public void EditTravel(int _id, string _title, string _city, DateTime _startDate, DateTime _endDate, int _price, string _maxparticipant, string _describtion) { //Represent a object of VikingRejserEntities called _context VikingRejserEntities context = new VikingRejserEntities(); Rejsearrangementer travel = context.Rejsearrangementers.First(i => i.Id == _id); //Represent the Title (string) of the travel travel.Title = _title; //Represent the By (string) of the travel travel.By = _city; //Represent the Startdato (datetime) of the travel travel.Stardato = _startDate; //Represent the Slutdato (datetime) of the travel travel.Slutdato = _endDate; //Represent the Pris (int) of the travel travel.Pris = _price; //Represent the MaxAntal (string) of the travel travel.MaxAntal = _maxparticipant; //Represent the Beskrivelse (string) of the travel travel.Beskrivelse = _describtion; context.SaveChanges(); }
/// <summary> /// Represent a method for deleting client data /// </summary> /// <param name="_Id">Represent the Id (int) of the client</param> public void DeleteClient(int _Id) { //Represent a object of VikingRejser called context VikingRejserEntities context = new VikingRejserEntities(); Kunder client = context.Kunders.First(i => i.Id == _Id); context.Kunders.Remove(client); }
/// <summary> /// Represent a method for creating travel data /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnAddTravel_Click(object sender, RoutedEventArgs e) { //Repesent a object of VikingRejserEntities called _context VikingRejserEntities _context = new VikingRejserEntities(); Create create = new Create(); create.CreateTravel(TbTravelTitle.Text, TbTravelCity.Text, Convert.ToDateTime(DPTravelStartDate.Text), Convert.ToDateTime(DPTravelEndDate.Text), Convert.ToInt32(TbTravelPrice.Text), TbTravelNumbers.Text, TbTravelDecribtion.Text); //Represent a messagebox showing that a client has been edited MessageBox.Show("Rejse oprettet"); LoadTravelDtg(); }
/// <summary> /// Represent a method for editing client data /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnEditClient_Click(object sender, RoutedEventArgs e) { //Represent a object of VikingRejserEntities called _context VikingRejserEntities _context = new VikingRejserEntities(); Edit edit = new Edit(); edit.EditClient(Convert.ToInt32(TbIdClient.Text), TbNameClient.Text, TbAddresseClient.Text, TbCellPhoneClient.Text); //Represent a messagebox showing that a client has been edited MessageBox.Show("Kunde data er blevet ændret"); LoadClientDtg(); }
/// <summary> /// Represent a method for adding client data /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnAddClient_Click(object sender, RoutedEventArgs e) { //Represent a object of VikingRejserEntities called context VikingRejserEntities context = new VikingRejserEntities(); Create create = new Create(); create.CreateClient(TbNameClient.Text, TbAddresseClient.Text, TbCellPhoneClient.Text); //Represent a messagebox showing that a client has been created MessageBox.Show("Bruger oprettet"); LoadClientDtg(); }
/// <summary> /// Represent a that loads travel data to datagrid /// </summary> public void LoadTravelDtg() { //Represent a object called _travelSource, that is used to find a resource called TraveSource CollectionViewSource _travelSource = (CollectionViewSource)this.FindResource("TravelSource"); //Represent a object of VikingRejserEntites called _context VikingRejserEntities _context = new VikingRejserEntities(); //Access the table called RejseArrangementers and load that table _context.Rejsearrangementers.Load(); //sets the CollectionViewSource object _travelSource to what data that is in Rejsearrangementer _travelSource.Source = _context.Rejsearrangementers.Local; }
/// <summary> /// Represent a method that loads client data to datagrid /// </summary> public void LoadClientDtg() { //Represent a object called _ClientSource, that is used to find a resouce called ClientSource CollectionViewSource _clientSource = (CollectionViewSource)(this.FindResource("ClientSource")); //Represent a object of VikingRejserEntities called _context VikingRejserEntities _context = new VikingRejserEntities(); //Access the table called Kunders and load that table _context.Kunders.Load(); //sets the CollectionViewSource object _clientSource to what data that is in Kunders _clientSource.Source = _context.Kunders.Local; }
/// <summary> /// Represent a method for editing travel data /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnEditTravel_Click(object sender, RoutedEventArgs e) { //Represent a object of VikingRejserEntities called context VikingRejserEntities context = new VikingRejserEntities(); Edit edit = new Edit(); edit.EditTravel(Convert.ToInt32(TbTravelId.Text), TbTravelTitle.Text, TbTravelCity.Text, Convert.ToDateTime(DPTravelStartDate.Text), Convert.ToDateTime(DPTravelEndDate.Text), Convert.ToInt32(TbTravelPrice.Text), TbTravelNumbers.Text, TbTravelDecribtion.Text); //Represent a messagebox showing that a unique travel´s data has been changed MessageBox.Show("Rejse data er blevet ændret"); LoadTravelDtg(); }
/// <summary> /// Represent a method for editing client data /// </summary> /// <param name="_Id">Represent the id (int) of the client</param> /// <param name="_Name">Represnet the name (string) of the client</param> /// <param name="_Address">Represnet the address (string) of the client</param> /// <param name="_Cellphone">Represent the cellphone number (string) of the client</param> public void EditClient(int _Id, string _Name, string _Address, string _Cellphone) { //Represent a object of VikingRejser called context VikingRejserEntities context = new VikingRejserEntities(); Kunder client = context.Kunders.First(i => i.Id == _Id); //Represent the name (string) of the client client.Navn = _Name; //Represnet the address (string) of the client client.Adresse = _Address; //Represent the cellphone number (string) of the client client.Telefon = _Cellphone; context.SaveChanges(); }
/// <summary> /// Represent a method for creating Kunder data /// </summary> /// <param name="_name">Represent the name (string) of the client</param> /// <param name="_address">Represent the adress (string) of the client</param> /// <param name="_cellphone">Represent the cellphone number (string) of the clien</param> public void CreateClient(string _name, string _address, string _cellphone) { //Represent a object of VikingRejserEntities called context VikingRejserEntities context = new VikingRejserEntities(); Kunder client = new Kunder() { //Represent the Navn (string) of the client Navn = _name, //Represent the Adresse (string) of the client Adresse = _address, //Represent the Telefon (string) of the client Telefon = _cellphone, }; context.Kunders.Add(client); context.SaveChanges(); }