private string SaveRegNo() { string retVal = ""; if (txtNewValue != null && !string.IsNullOrWhiteSpace(txtNewValue.Text)) { Dogs dogs = new Dogs(_connString); List <Dogs> dogList = dogs.GetDogByRegNo(txtNewValue.Text); if (dogList.Count > 0) { retVal = "A dog with this KC Registration Number already exists"; } else if (dog != null) { dog.Reg_No = txtNewValue.Text; dog.Update_Dog(dog.Dog_ID, user_ID); } } else { retVal = "You must provide a KC Registration Number"; } return(retVal); }
private Guid GetDog(ExcelDataItem item) { Dogs dog = new Dogs(Utils.ConnectionString()); List <Dogs> dogList = dog.GetDogByRegNo(item.Registered_Number); if (dogList.Count > 0) { //Get ID for existing Dog bool saveChanges = false; foreach (Dogs regDog in dogList) { if (regDog.Dog_KC_Name != item.Registered_Name) { Utils.LogToFile(string.Format("Registered Name Changed from {0} to {1} for Reg No.: {2}", regDog.Dog_KC_Name, item.Registered_Name, item.Registered_Number)); regDog.Dog_KC_Name = item.Registered_Name; saveChanges = true; } if (regDog.Date_Of_Birth != item.Date_Of_Birth) { Utils.LogToFile(string.Format("Date of Birth Changed from {0} to {1} for Reg No.: {2}", regDog.Date_Of_Birth, item.Date_Of_Birth, item.Registered_Number)); if (item.Date_Of_Birth != null && item.Date_Of_Birth != new DateTime()) { Utils.LogToFile(string.Format("Date of Birth Changed from {0} to {1} for Reg No.: {2}", regDog.Date_Of_Birth, item.Date_Of_Birth, item.Registered_Number)); regDog.Date_Of_Birth = item.Date_Of_Birth; } else { Utils.LogToFile(string.Format("Date of Birth Changed from {0} to {1} for Reg No.: {2}", regDog.Date_Of_Birth, "NULL", item.Registered_Number)); regDog.Date_Of_Birth = null; } saveChanges = true; } if (regDog.Year_Of_Birth != item.Year_Of_Birth) { Utils.LogToFile(string.Format("Year of Birth Changed from {0} to {1} for Reg No.: {2}", regDog.Year_Of_Birth, item.Year_Of_Birth, item.Registered_Number)); regDog.Year_Of_Birth = item.Year_Of_Birth; saveChanges = true; } if (saveChanges) { regDog.Update_Dog(regDog.Dog_ID, user_ID); } return(regDog.Dog_ID); } } //Create New Dog dog.Dog_KC_Name = item.Registered_Name; dog.Dog_Breed_ID = GetBreedIDFromBreedName(item.Breed); dog.Dog_Gender_ID = GetGender(item.Sex); dog.Reg_No = item.Registered_Number; if (item.Date_Of_Birth != null && item.Date_Of_Birth != new DateTime()) { dog.Date_Of_Birth = item.Date_Of_Birth; } else { dog.Date_Of_Birth = null; } if (item.Year_Of_Birth > 0) { dog.Year_Of_Birth = item.Year_Of_Birth; } dog.Merit_Points = (short)item.Merit_Points; //dog.Breeder = item.Breeder; //dog.Sire = item.Sire; //dog.Dam = item.Dam; Guid?dog_ID = dog.Insert_Dog(user_ID); return((Guid)dog_ID); }