protected void btnDelete_Click(object sender, EventArgs e) { BPAnimals bpAnimals = new BPAnimals(); BEAnimals dsAnimals = bpAnimals.SelectAnimalByID(AnimalID); BPPages bpPages = new BPPages(); BEPages dsPages = bpPages.SelectByPageTypeIDAndPageTypeSpecificID(PageTypeID, AnimalID); if (dsAnimals.tbl_Animals.Count > 0) { DeleteRelatedPageLinks(); dsAnimals.tbl_Animals[0].Delete(); bpAnimals.Update(dsAnimals); if (dsPages.tbl_Pages.Count > 0) { DeleteImageGallery(dsPages.tbl_Pages[0].PageID); dsPages.tbl_Pages[0].Delete(); bpPages.Update(dsPages); } } BrowseRedirect(); }
private bool FeaturedItemExists() { BPAnimals bp = new BPAnimals(); return bp.FeaturedItemExists(); }
private void SaveAnimalInfo() { bool isNew = false; BPAnimals bp = new BPAnimals(); BEAnimals dsAnimals = new BEAnimals(); BEAnimals.tbl_AnimalsRow animal = null; if (AnimalID > 0) { dsAnimals = bp.SelectAnimalByID(AnimalID); animal = dsAnimals.tbl_Animals.FindByAnimalID(AnimalID); } if (animal == null) { animal = dsAnimals.tbl_Animals.Newtbl_AnimalsRow(); isNew = true; } //page animal.AnimalTitle = txtAnimalTitle.Text.Trim(); animal.AnimalTypeID = Convert.ToInt32(ddlAnimalTypes.SelectedValue); animal.AnimalGender = rblGender.SelectedValue; if (edtAnimalDescription.Text.Trim() == "" || edtAnimalDescription.Text.Trim() == "<p> </p>") animal.SetAnimalDescriptionNull(); else animal.AnimalDescription = edtAnimalDescription.Text.Trim(); if (txtAnimalMicrochipped.Text.Trim() != "") animal.AnimalMicrochipped = txtAnimalMicrochipped.Text.Trim(); else animal.SetAnimalMicrochippedNull(); if (txtAnimalNeutered.Text.Trim() != "") animal.AnimalNeutered = txtAnimalNeutered.Text.Trim(); else animal.SetAnimalNeuteredNull(); if (txtAnimalVaccinations.Text.Trim() != "") animal.AnimalVaccinations = txtAnimalVaccinations.Text.Trim(); else animal.SetAnimalVaccinationsNull(); if (dtAnimalIntakeDate.Date != dtAnimalIntakeDate.MinDate) animal.AnimalIntakeDate = dtAnimalIntakeDate.Date; else animal.SetAnimalIntakeDateNull(); if (chkAdopted.Checked) { animal.Adopted = true; animal.Adoptable = false; } else { animal.Adopted = false; animal.Adoptable = chkIsAdoptable.Checked; } if (chkAnimalActive.Checked) { animal.AnimalActive = true; animal.FeaturedAnimal = chkFeaturedAnimal.Checked; } else { animal.AnimalActive = false; animal.FeaturedAnimal = false; } animal.DateModified = DateTime.Now; animal.ModifiedByAdminID = Convert.ToInt32(COPRUser.COPRIdentity.MemberID); if (isNew) { animal.AnimalOrder = bp.GetAnimalMaxOrder(); animal.DateCreated = DateTime.Now; dsAnimals.tbl_Animals.Addtbl_AnimalsRow(animal); } bp.Update(dsAnimals); AnimalID = animal.AnimalID; if (isNew) { //Add to main Pages table BPPages bpPages = new BPPages(); BEPages dsPages = new BEPages(); BEPages.tbl_PagesRow pageRow = dsPages.tbl_Pages.Newtbl_PagesRow(); pageRow.PageTypeID = PageTypeID; pageRow.PageTypeSpecificID = AnimalID; pageRow.SetSubTypeIDNull(); dsPages.tbl_Pages.Addtbl_PagesRow(pageRow); bpPages.Update(dsPages); PageID = pageRow.PageID; } AddUpdateImageCategory(animal.AnimalTitle); }
private void BindAnimalInfo() { if (AnimalID > 0) { BPAnimals bp = new BPAnimals(); BEAnimals ds = bp.SelectAnimalByID(AnimalID); BEAnimals.tbl_AnimalsRow animal = null; if (ds.tbl_Animals.Count > 0) { animal = ds.tbl_Animals[0]; GetPageID(); BindImageGalleryUserControl(); lblTitle.Text = "Edit " + animal.AnimalTitle; txtAnimalTitle.Text = animal.AnimalTitle; rblGender.SelectedValue = animal.AnimalGender; if (ddlAnimalTypes.Items.FindByValue(animal.AnimalTypeID.ToString()) != null) ddlAnimalTypes.SelectedValue = animal.AnimalTypeID.ToString(); if (!animal.IsAnimalDescriptionNull()) edtAnimalDescription.Text = animal.AnimalDescription; else edtAnimalDescription.Text = ""; txtAnimalMicrochipped.Text = animal.IsAnimalMicrochippedNull() ? "" : animal.AnimalMicrochipped; txtAnimalNeutered.Text = animal.IsAnimalNeuteredNull() ? "" : animal.AnimalNeutered; txtAnimalVaccinations.Text = animal.IsAnimalVaccinationsNull() ? "" : animal.AnimalVaccinations; if (!animal.IsAnimalIntakeDateNull()) dtAnimalIntakeDate.Date = animal.AnimalIntakeDate; BindSelectedRelatedPages(); if (animal.FeaturedAnimal) chkFeaturedAnimal.Enabled = true; else chkFeaturedAnimal.Enabled = !FeaturedItemExists(); chkIsAdoptable.Checked = animal.Adoptable; chkAdopted.Checked = animal.Adopted; chkFeaturedAnimal.Checked = animal.FeaturedAnimal; chkAnimalActive.Checked = animal.AnimalActive; } } else { lblTitle.Text = "Add New Animal Page"; btnDelete.Visible = false; edtAnimalDescription.Text = ""; chkFeaturedAnimal.Enabled = !FeaturedItemExists(); plcNewGalleryMessage.Visible = true; plcInactiveGalleryMessage.Visible = false; ucImageGallery.Visible = false; } }