private void SAVEButton_Click(object sender, EventArgs e) { TypeOfTrip aType = new TypeOfTrip(); aType.TypeNo = typeNoTextBox.Text; aType.TypeName = typeNameTextBox.Text; TypeOfTripBL typeBLOBj = new TypeOfTripBL(); bool result = typeBLOBj.SaveNewTypeBL(aType); if (result) { MessageBox.Show("Succesfuly added new Location!", "Done!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.PopulateGridView(); IntitialButtonMood(); CleanTextBar(); } else { DialogResult dialog = MessageBox.Show("Please fill all the text", "ERROR", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); if (dialog == DialogResult.Cancel) { this.Close(); } } }
public TypeOfTrip CreateTypeOfTrip(TypeOfTrip newTypeOfTrip) { using (TripsDbContext db = new TripsDbContext()) { newTypeOfTrip.Id = Guid.NewGuid(); newTypeOfTrip.IsActive = true; db.TripTypes.Add(newTypeOfTrip); db.SaveChanges(); return(newTypeOfTrip); } }
public bool DeleteTypeBL(TypeOfTrip aType) { if (aType.TypeNo == "" || aType.TypeName == "") { return(false); } else { TypeOfTripDA typeDAOBj = new TypeOfTripDA(); bool result = typeDAOBj.DeleteTypeFromDB(aType); return(result); } }
public bool UpdateNewTypeBL(TypeOfTrip aType) { if (aType.TypeNo == "" || aType.TypeName == "") { return(false); } else { TypeOfTripDA typeDAOBj = new TypeOfTripDA(); bool result = typeDAOBj.UpdateNewTypeToDB(aType); return(result); } }
public TypeOfTrip UpdateTypeOfTrip(TypeOfTrip activity) { using (TripsDbContext db = new TripsDbContext()) { var currentTypeOfTrip = db.TripTypes.FirstOrDefault(t => t.Id == activity.Id); currentTypeOfTrip.Description = activity.Description; currentTypeOfTrip.ImagePath = activity.ImagePath; currentTypeOfTrip.Name = activity.Name; currentTypeOfTrip.ParentId = activity.ParentId; currentTypeOfTrip.SeoDescription = activity.SeoDescription; currentTypeOfTrip.SeoKeywords = activity.SeoKeywords; currentTypeOfTrip.Url = activity.Url; db.SaveChanges(); return(currentTypeOfTrip); } }
public bool DeleteTypeFromDB(TypeOfTrip aType) { SqlConnection connection = DataBaseConnection.OpenAnSqlConnection(); string query = "DELETE FROM TypeTable WHERE TypeNo = '" + aType.TypeNo + "'"; SqlCommand command = new SqlCommand(query, connection); int rowsAffected = command.ExecuteNonQuery(); if (rowsAffected == 1) { command.Dispose(); return(true); } else { command.Dispose(); return(false); } }
public bool UpdateNewTypeToDB(TypeOfTrip aType) { SqlConnection connection = DataBaseConnection.OpenAnSqlConnection(); string query = "UPDATE TypeTable SET TypeNo = '" + aType.TypeNo + "', TypeName = '" + aType.TypeName + "' WHERE TypeNo = '" + aType.TypeNo + "'"; SqlCommand command = new SqlCommand(query, connection); int rowsAffected = command.ExecuteNonQuery(); if (rowsAffected == 1) { command.Dispose(); return(true); } else { command.Dispose(); return(false); } }
public bool SaveNewTypeToDB(TypeOfTrip aType) { SqlConnection connection = DataBaseConnection.OpenAnSqlConnection(); string query = "INSERT INTO TypeTable VALUES('" + aType.TypeNo + "','" + aType.TypeName + "')"; SqlCommand command = new SqlCommand(query, connection); int rowsAffected = command.ExecuteNonQuery(); if (rowsAffected == 1) { command.Dispose(); return(true); } else { command.Dispose(); return(false); } }
private void deleteButton_Click(object sender, EventArgs e) { TypeOfTrip aType = new TypeOfTrip(); aType.TypeNo = typeNoTextBox.Text; aType.TypeName = typeNameTextBox.Text; TypeOfTripBL typeBLOBj = new TypeOfTripBL(); bool result = typeBLOBj.DeleteTypeBL(aType); if (result) { MessageBox.Show("Succesfuly Deleted", "Done!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.PopulateGridView(); IntitialButtonMood(); CleanTextBar(); } else { MessageBox.Show("Something wrong!", "Aleart", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public TypeOfTrip UpdateTypeOfTrip([FromBody] TypeOfTrip trip) { return(TypesOfTripService.UpdateTypeOfTrip(trip)); }