protected void Page_Load(object sender, EventArgs e) { MessageLabel.Text = string.Empty; GetCommon(); if (!string.IsNullOrEmpty(Common.Current_Dog_ID)) { Current_Dog_ID = Common.Current_Dog_ID; divGetDog.Visible = false; divChangeDog.Visible = true; divDogDetails.Visible = true; if (!string.IsNullOrEmpty(btnReturn.PostBackUrl)) DivReturn.Visible = true; } else { divGetDog.Visible = true; divChangeDog.Visible = false; divDogDetails.Visible = false; } if (!string.IsNullOrEmpty(Common.Owner_ID)) { Owner_ID = Common.Owner_ID; AddOwnerToList(Owner_ID); Owner_ID = null; Common.Owner_ID = Owner_ID; } if (Common.DogOwnerList != null && Common.DogOwnerList.Count != 0) { divOwnerList.Visible = true; DogOwnerList ownerList = new DogOwnerList(); ownerList.MyDogOwnerList = Common.DogOwnerList; PopulateOwnerGridView(ownerList.MyDogOwnerList); } else { divOwnerList.Visible = false; } if (!string.IsNullOrEmpty(Common.Breeder_ID)) { Breeder_ID = Common.Breeder_ID; AddBreederToList(Breeder_ID); Breeder_ID = null; Common.Breeder_ID = Breeder_ID; } if (Common.DogBreederList != null && Common.DogBreederList.Count != 0) { divBreederList.Visible = true; DogBreederList breederList = new DogBreederList(); breederList.MyDogBreederList = Common.DogBreederList; PopulateBreederGridView(breederList.MyDogBreederList); } else { divBreederList.Visible = false; } if (!string.IsNullOrEmpty(Common.Dam_ID)) { Dam_ID = Common.Dam_ID; PopulateDam(); } else { divGetDam.Visible = true; divChangeDam.Visible = false; divDamDetails.Visible = false; } if (!string.IsNullOrEmpty(Common.Sire_ID)) { Sire_ID = Common.Sire_ID; PopulateSire(); } else { divGetSire.Visible = true; divChangeSire.Visible = false; divSireDetails.Visible = false; } if (!Page.IsPostBack) { if (!string.IsNullOrEmpty(Common.Current_Dog_ID)) { PopulateDog(); PopulateOwnerList(); PopulateBreederList(); string returnChars = Request.QueryString["return"]; btnReturn.PostBackUrl = Common.ReturnPath(Request.QueryString, returnChars, ""); } } }
protected void AddBreederToList(string breeder_ID) { Guid new_Breeder_ID = new Guid(breeder_ID); People person = new People(new_Breeder_ID); DogBreederList breederList = new DogBreederList(); breederList.MyDogBreederList = Common.DogBreederList; People pp = null; if (breederList.MyDogBreederList != null) pp = breederList.MyDogBreederList.Find(delegate(People p) { return p.Person_ID == new_Breeder_ID; }); if (pp == null) { int breederCount = breederList.AddBreeder(person); PopulateBreederGridView(breederList.MyDogBreederList); Common.DogBreederList = breederList.MyDogBreederList; } }
protected void BreederGridView_RowDeleting(object sender, GridViewDeleteEventArgs e) { string breeder_id = BreederGridView.DataKeys[e.RowIndex]["Person_ID"].ToString(); DogBreederList breederList = new DogBreederList(); breederList.MyDogBreederList = Common.DogBreederList; int breederCount = breederList.DeleteDogBreeder(e.RowIndex); PopulateBreederGridView(breederList.MyDogBreederList); Common.DogBreederList = breederList.MyDogBreederList; }