public void SendSavedEmail(int ShowId, int UserId, String userRefNo)
        {
            Shows show = new Shows(ShowId);
            User currentUser = new User(UserId);

            //
            // if entered show, send email saying entered show
            String htmlContents = readTemplate("SavedShows", "html", show, userRefNo);
            String plainContents = readTemplate("SavedShows", "txt", show, userRefNo);

            MailMessage mm = new MailMessage();

            String Classes_entered_html = "<table>";
            String Classes_entered_plain = "";
            List<ShowClasses> classList = ShowClasses.GetAllClassesForShow(ShowId);
            List<Dogs> dogList = Dogs.GetAllDogsForHandler(UserId, show.ShowDate);
            foreach (Dogs d in dogList)
            {
                DogClasses dogClasses = new DogClasses(d.ID, ShowId);
                dogClasses.getDogsClasses(ShowId);
                if (d.Grade != 0)
                {
                    bool dogEntered = false;
                    foreach (ShowClasses cls in classList)
                    {
                        int clsIndex = dogClasses.Classlist.IndexOf(cls.ID);
                        if (clsIndex > -1)
                        {
                            if (!dogEntered)
                            {
                                Classes_entered_html += String.Format("<tr style='font-weight:bold;'><td colspan='3'><b>{0} (Grade {1}) {2}</b></td></tr>", d.PetName, d.Grade, (dogClasses.Lho == 0 ? "" : "Entered lower height option"));
                                Classes_entered_plain += String.Format("{1}{0}{1}--------------------------------{1} (Grade {2}) {3}", d.PetName, Environment.NewLine, d.Grade, (dogClasses.Lho == 0 ? "" : "Entered lower height option"));
                            }
                            Classes_entered_html += "<tr>";
                            Classes_entered_html += String.Format("<td style='width:25px'></td><td>{0}</td><td>{1} {2} {3} {4} {5}</td>", cls.ClassNo, cls.longHeight, cls.LongClassName, cls.ClassName, cls.longCatagory, cls.getGrades);
                            Classes_entered_plain += String.Format("{0} - {1} {2} {3} {4} {5} {6}", cls.ClassNo, cls.longHeight, cls.LongClassName, cls.ClassName, cls.longCatagory, cls.getGrades, Environment.NewLine);
                            Classes_entered_html += "</tr>";
                            dogEntered = true;
                        }
                    }
                }
            }
            Classes_entered_html += "</table>";
            Classes_entered_plain += Environment.NewLine;

            htmlContents = htmlContents.Replace("[CLOSING_DATE]", show.ClosingDate.ToString("ddd, dd MMM yyyy"));
            plainContents = plainContents.Replace("[CLOSING_DATE]", show.ClosingDate.ToString("ddd, dd MMM yyyy"));

            htmlContents = htmlContents.Replace("[CLASSES_ENTERED]", Classes_entered_html);
            plainContents = plainContents.Replace("[CLASSES_ENTERED]", Classes_entered_plain);

            string campingdetails_html = "";
            string campingdetails_plain = "";
            var usershowid = Convert.ToInt32(userRefNo);
            var uc = new UserCamping(usershowid);
            if (uc.ID > -1)
            {
                campingdetails_html =
                    $"<h3>Camping Details</h3><div>Party Name: <b>{uc.PitchDetails[0].PartyName}</b><br>{uc.PitchDetails[0].CampingDays}</div>";
                campingdetails_plain = $"Party Name: {uc.PitchDetails[0].PartyName}\n\r{uc.PitchDetails[0].CampingDays}";
            }
            htmlContents = htmlContents.Replace("[CAMPING_DETAILS]", campingdetails_html);
            plainContents = plainContents.Replace("[CAMPING_DETAILS]", campingdetails_plain);

            var helpingdetailsHtml = "";
            var helpersList = Helpers.HelperForShow(ShowId, UserId);
            if (helpersList.Count > 0)
            {
                helpingdetailsHtml += "<div id='helperdetails' class='infoText'><h3>Helping Details</h3>";
                foreach (Helpers helper in helpersList)
                {
                    String judge = "";
                    if (helper.JudgeID > -1)
                    {
                        var j = new Judge(helper.JudgeID);
                        judge = "Judge: " + j.Name;
                    }
                    String ring = "";
                    if (helper.RingNo > 0)
                    {
                        ring = "Ring No:" + helper.RingNo.ToString();
                    }
                    helpingdetailsHtml +=
                        $"<div >{helper.HelpDate:ddd dd MMM} - {helper.expandJob()} {judge} {ring}</div>";
                    String.Format("{0:ddd dd MMM} - {1} {2} {3}", helper.HelpDate, helper.expandJob(), judge, ring);
                }
                helpingdetailsHtml += "</div>";
                helpingdetailsHtml += "\n";
            }

            htmlContents = htmlContents.Replace("[HELPING_DETAILS]", helpingdetailsHtml);
            plainContents = plainContents.Replace("[HELPING_DETAILS]", helpingdetailsHtml);

            Decimal totals = 0;
            String table = CreateTotalsSummaryEmail(ShowId, UserId, ref totals);
            //htmlContents = htmlContents.Replace("[PAYMENT_NOTE]", table);

            AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlContents, null, MediaTypeNames.Text.Html);
            //htmlView.LinkedResources.Add(logoImage);
            AlternateView plainView = AlternateView.CreateAlternateViewFromString(plainContents, null, MediaTypeNames.Text.Plain);

            mm.AlternateViews.Add(plainView);
            mm.AlternateViews.Add(htmlView);

            Business.Audit.Entry(ShowId, UserId, plainContents);

            try
            {
                var client = new SmtpClient();
                mm.From = new MailAddress("*****@*****.**", "First Place Processing");
                mm.To.Add(new MailAddress(currentUser.EmailAddress, currentUser.Name));
                mm.Bcc.Add(new MailAddress("*****@*****.**", "saved show entry"));
                mm.Subject = $"Entry Confirmation {show.ShowName} ({show.ShowDate:dd MMM yyyy})";

                client.Send(mm);
            }
            catch (Exception e)
            {
                AppException.LogEvent("Error SendSaved:" + e.Message + "-" + e.StackTrace);
            }
        }
        public void SendEntryEmail(int ShowId, int UserId, String userRefNo)
        {
            Shows show = new Shows(ShowId);
            User currentUser = new User(UserId);

            //
            // if entered show, send email saying entered show
            String htmlContents = readTemplate("EnteredShow", "html", show, userRefNo);
            String plainContents = readTemplate("EnteredShow", "txt", show, userRefNo);

            MailMessage mm = new MailMessage();

            String classesEnteredHtml = "<table>";
            String Classes_entered_plain = "";
            List<ShowClasses> classList = ShowClasses.GetAllClassesForShow(ShowId);
            List<Dogs> dogList = Dogs.GetAllDogsForHandler(UserId, show.ShowDate);

            var multiClasses = TeamPairsManager.GetTeamPairClasses(ShowId);
            var multiTeams = TeamPairsManager.GetTeamPairsForShow(ShowId, multiClasses);

            foreach (Dogs d in dogList)
            {
                DogClasses dogClasses = new DogClasses(d.ID, ShowId);
                dogClasses.getDogsClasses(ShowId);
                if (d.Grade != 0)
                {
                    bool dogEntered = false;
                    foreach (ShowClasses cls in classList)
                    {
                        int clsIndex = dogClasses.Classlist.IndexOf(cls.ID);
                        if (clsIndex > -1)
                        {
                            if (!dogEntered)
                            {
                                classesEnteredHtml += String.Format("<tr style='font-weight:bold;'><td colspan='3'><b>{0} ({1}) {2}  </b></td></tr>", d.PetName, d.Grade, (dogClasses.Lho == 0 ? "" : "Entered lower height option"));
                                Classes_entered_plain += String.Format("{1}{0}{1}--------------------------------{1} ({2}) {3}", d.PetName, Environment.NewLine, d.Grade, (dogClasses.Lho == 0 ? "" : "Entered lower height option"));
                            }
                            classesEnteredHtml += "<tr>";

                            classesEnteredHtml += String.Format("<td style='width:25px'></td><td>{0}</td><td>{1} {2} {3} {4} {5}</td>", cls.ClassNo, cls.NormalName(withClassNo: false));
                            Classes_entered_plain += String.Format("{0} - {1} {2} {3} {4} {5} {6}", cls.ClassNo, cls.NormalName(withClassNo: false), Environment.NewLine);
                            classesEnteredHtml += "</tr>";
                            dogEntered = true;
                        }
                    }

                }
            }

            foreach (var team in multiTeams.Where(t => t.UserId == UserId))
            {
                if (team.Team)
                {
                    classesEnteredHtml += $@"
            <tr style='height:25px' ><td colspan='3'></td><tr>
            <td>Team Name<br>{team.TeamDetails.TeamName.Replace("&#39;", "'")}</td>
            <td colspan='2'>Captain<br/>{team.TeamDetails.Captain.Replace("&#39;", "'")}</td>
            </tr>";
                    Classes_entered_plain +=
                        $@"Team Name:{team.TeamDetails.TeamName.Replace("&#39;", "'")}  Team Captain:{team.TeamDetails
                            .Captain.Replace("&#39;", "'")}{Environment.NewLine}";

                    foreach (var member in team.Members)
                    {

                        classesEnteredHtml += $@"
            <tr>
            <td>&nbsp;&nbsp;&nbsp;{member.HandlerName.Replace("&#39;", "'")}</td>
            <td colspan='2'>{member.DogName.Replace("&#39;", "'")}</td>
            </tr><tr>
            ";
                        Classes_entered_plain += $@"
            {member.HandlerName.Replace("&#39;", "'")}, {member.DogName.Replace("&#39;", "'")}{Environment.NewLine}";

                    }
                }
            }

            classesEnteredHtml += " </table>";
            Classes_entered_plain += Environment.NewLine;

            htmlContents = htmlContents.Replace("[CLOSING_DATE]", show.ClosingDate.ToString("ddd, dd MMM yyyy"));
            plainContents = plainContents.Replace("[CLOSING_DATE]", show.ClosingDate.ToString("ddd, dd MMM yyyy"));

            htmlContents = htmlContents.Replace("[CLASSES_ENTERED]", classesEnteredHtml);
            plainContents = plainContents.Replace("[CLASSES_ENTERED]", Classes_entered_plain);

            string campingdetails_html = "";
            string campingdetails_plain = "";
            var usershowid = Convert.ToInt32(userRefNo);
            var uc = new UserCamping(usershowid);
            if (uc.ID > -1)
            {
                campingdetails_html =
                    $"<h3>Camping Details</h3><div>Party Name: <b>{uc.PitchDetails[0].PartyName}</b><br>{uc.PitchDetails[0].CampingDays}</div>";
                campingdetails_plain = $"Party Name: {uc.PitchDetails[0].PartyName}\n\r{uc.PitchDetails[0].CampingDays}";
            }
            htmlContents = htmlContents.Replace("[CAMPING_DETAILS]", campingdetails_html);
            plainContents = plainContents.Replace("[CAMPING_DETAILS]", campingdetails_plain);

            var helpingdetailsHtml = "";
            var helpersList = Helpers.HelperForShow(ShowId, UserId);
            if (helpersList.Count > 0)
            {
                helpingdetailsHtml += "<div id='helperdetails' class='infoText'><h3>Helping Details</h3>";
                foreach (var helper in helpersList)
                {
                    var judge = "";
                    if (helper.JudgeID > -1)
                    {
                        var j = new Judge(helper.JudgeID);
                        judge = "Judge: " + j.Name;
                    }
                    var ring = "";
                    if (helper.RingNo > 0)
                    {
                        ring = "Ring No:" + helper.RingNo.ToString();
                    }
                    helpingdetailsHtml +=
                        $"<div >{helper.HelpDate:ddd dd MMM} - {helper.expandJob()} {judge} {ring}</div>";
                }
                helpingdetailsHtml += "</div>";
                helpingdetailsHtml += "\n";
            }

            htmlContents = htmlContents.Replace("[HELPING_DETAILS]", helpingdetailsHtml);
            plainContents = plainContents.Replace("[HELPING_DETAILS]", helpingdetailsHtml);

            var totals = 0m;
            var table = CreateTotalsSummaryEmail(ShowId, UserId, ref totals);

            var htmlView = AlternateView.CreateAlternateViewFromString(htmlContents, null, MediaTypeNames.Text.Html);
            var plainView = AlternateView.CreateAlternateViewFromString(plainContents, null, MediaTypeNames.Text.Plain);

            mm.AlternateViews.Add(plainView);
            mm.AlternateViews.Add(htmlView);

            var client = new SmtpClient();
            mm.From = new MailAddress("*****@*****.**", "First Place Processing");
            mm.To.Add(new MailAddress(currentUser.EmailAddress, currentUser.Name));
            mm.Subject = $"Entry Confirmation {show.ShowName} ({show.ShowDate:dd MMM yyyy})";
            try
            {
                client.Send(mm);
            }
            catch (Exception e)
            {
                AppException.LogError("Error SendEntry:" + e.Message + "-" + e.StackTrace);
            }
        }
        public StatusCls GetEntryForm(int ShowId, int UserId, int handlerType)
        {
            StatusCls status = new StatusCls {
                MultiDogClasses = new List<MultiDogClasses>()
            };
            Shows thisShow = new Shows(ShowId);
            User currentUser = new User(UserId);
            List<ShowClasses> classList = ShowClasses.GetAllClassesForShow(ShowId).Where(sc => sc.Part == 0).ToList();
            var lhoLabel = false;
            var fouthHeightLabel = false;
            if (classList.Any(x => x.Lho > 0))
            {
                lhoLabel = true;
                if (classList.Any(x => x.Lho == 3))
                {
                    lhoLabel = false;
                    fouthHeightLabel = true;
                }
            }

            status.MultiDogClasses = TeamPairsManager.GetTeamPairClasses(ShowId);

            UserShows us = new UserShows(UserId, ShowId);
            //
            // if user entering a new show then set up the handler type, cos that is pasted in
            if (us.ID == -1)
            {
                us.HandlerType = handlerType;
            }
            //
            // add check to see if this person is on the judging list.
            // and there are not a member as members override the judging discounts.
            if (Judge.isJudgeAtShow(UserId, ShowId) && handlerType == 0)
            {
                handlerType = 2;
                us.HandlerType = 2;
            }
            else
            {
                //
                // check if alt handlers are judging
                //
                List<AltHandler> altHList = AltHandler.GetAllAltHandlersList(us.Userid);
                foreach (AltHandler alt in altHList)
                {
                    if (Judge.isJudgeAtShow(alt.AltHandlerID, ShowId))
                    {
                        handlerType = 2;
                        us.HandlerType = 2;
                    }
                }
            }

            Dogs dog = new Dogs();
            List<Dogs> dogs = Dogs.GetAllDogsForHandler(UserId, thisShow.ShowDate);

            String html = $"<input type='hidden' name='handlertype' id='handlertype' value='{us.HandlerType}' />";
            String header = "<div class='dogRow group header'><div class='petName header'>&nbsp;</div>";
            Boolean headerCompleted = false;
            String rowClass = "dogRowAlt";
            foreach (Dogs d in dogs.Where(d => d.Grade > 0 ) )
            {
                String buttons = "";
                DogClasses dc = new DogClasses(d.ID);
                dc.getDogsClasses(ShowId);
                if (d.Grade != 0)
                {
                    buttons = "<div class='buttons'><a href='#tick'><img title='Select All Single Classes' class='tickcross tickimg' src='/Content/Assets/tickv2.png' /></a><a href='#cross'><img title='Clear All Classes' class='tickcross crossimg' src='/Content/Assets/crossv1.png' /></a>";
                    buttons += "</div>";
                    if (lhoLabel)
                    {
                        buttons += @"<div class='lho'><label for='cklho_" + d.ID + "'>Lower height<input type='checkbox' value='1' id='cklho_" + d.ID + "' " + (dc.Lho == 1 ? "checked='checked'" : "") + "   /></label></div>";
                    }
                    if (fouthHeightLabel)
                    {
                        buttons += @"<div class='ext'><label for='cklho_" + d.ID + "'>4th height<input type='checkbox' value='1' id='cklho_" + d.ID + "' " + (dc.Lho == 1 ? "checked='checked'" : "") + "   /></label></div>";
                    }
                    buttons += "<div class='infoText'>Handler:</div>";
                    if (d.AltHandlerID == -1)
                    {
                        buttons += currentUser.Name;
                    }
                    else
                    {
                        User altHandler = new User(d.AltHandlerID);
                        buttons += altHandler.Name;
                    }
                }
                html += String.Format("<div class='{2} group themeBorder-t' dogid='{0}' grade='{4}'><div class='petName'><div class='lbl'>{1}<p class='grade'>{4}</p></div>{3}</div>", d.ID, d.PetName, rowClass, buttons, d.DisplayGrade);
                rowClass = (rowClass == "dogRowAlt" ? "dogRow" : "dogRowAlt");

                String classTable = "";
                String dayName = "";
                String lastDay = "";
                Boolean classesForDog = true;
                foreach (ShowClasses cls in classList)
                {
                    if (dayName != cls.Showdate.ToString("dddd, dd MMM"))
                    {

                        if (dayName != "")
                        {
                            if (!classesForDog)
                            {
                                classTable += String.Format("<div class='clsNo' ><span class='naCls'>n/a</span></div>");
                            }
                            classTable += "</div>";
                        }
                        classesForDog = false;
                        lastDay = dayName;
                        dayName = cls.Showdate.ToString("dddd, dd MMM");

                        ShowDetails showDetails = new ShowDetails(cls.ShowDetailsID);
                        classTable += String.Format("<div class='day' classlimit='{0}'>", showDetails.ClassLimit);

                        if (!headerCompleted)
                        {
                            header += String.Format("<div class='day header' >{0}</div>", dayName);
                        }
                    }

                    //
                    //  cls.EntryType == (int)EntryType.EntryTypes.ABC &&
                    //

                    if (isDogInClass(cls, d))
                    {
                        int otherDogs = 0;
                        int reserves = 0;
                        bool teamName = false;
                        String ticked = "";
                        String altHandlerInfo = "<img class='handler' src='/Content/Assets/AddHandler.png'  width='16' height='14' />";
                        int clsIndex = dc.Classlist.IndexOf(cls.ID);
                        if (clsIndex > -1)
                        {
                            ticked = "tick";
                            if (dc.AltHandlerList[clsIndex] > 0)
                            {
                                User u = new User(dc.AltHandlerList[clsIndex]);
                                altHandlerInfo = "<img class='handler changed' width='16' height='14' src='/Content/Assets/AddHandler.png' data-althandlerid='" + dc.AltHandlerList[clsIndex].ToString() + "' title='Handler:" + u.Name + "' />";
                            }
                        }
                        classesForDog = true;

                        if (otherDogs > 0)
                        {
                            String iconType = "mdSet.png";
                            var multiDogs = "";
                            classTable += String.Format("<div {12} {13} {14} {15} class='clsNo " + ticked + "' classno='{15}' classcount='{11}' clsid='{0}' chargeType='{2}' classType='{3}' entryType='{4}' otherdogs='{5}' reserves='{9}' team='{10}' ><span class='chghandlemenu'>[+]</span>{6}<a class='otherdogs' title='Enter other dogs'><img src='/Content/Assets/{8}' >{7}</img></a><span class='clickable'><img class='tickHolder ' src='/Content/Assets/tickv2.png' /><span class='ah'>*</span><span class='clsname'>{1}</span></span></div>",
                                cls.ID, ShortenName(cls), cls.ChargeType, cls.ClassType, cls.EntryType,
                                otherDogs, altHandlerInfo, multiDogs, iconType, reserves, teamName, cls.ClassCount,
                                cls.Anysize == 1 ? "anysize" : "", cls.Veteran == 1 ? "veteran" : "",  ShowLhoModifier( cls.Lho ), cls.ClassNo, cls.AwardByHeight > 0 ? "AH" : "");

                        }
                        else
                        {
                            if (cls.EntryType == 10)
                            {
                                var hasChampDogsIcon = "mdNotSet.png";
                                var allDetailsCheck = 0;

                                var wins = DogHistory.GetRecordedWins(d.ID);
                                var h = "<span class='wins'>";
                                foreach (var dogH in wins) {
                                    h += string.Format("<span class='champ-wins' data-upgradetype='{4}'  data-winid='{3}'  data-showname='{0}' data-showdate='{1:dd-MM-yy}' data-showclass='{2}'></span>",
                                        dogH.ShowName, dogH.DateOfWin, dogH.ClassWon, dogH.Id, dogH.UpgradeType);
                                    allDetailsCheck += (dogH.ShowName.Length > 0 && dogH.ClassWon.Length > 0) ? 1 : 0;
                                }
                                if (allDetailsCheck == 4)
                                {
                                    hasChampDogsIcon = "mdSet.png";
                                }
                                h += "</span>";
                                classTable += String.Format("<div class='clsNo " + ticked + "' clsid='{0}' chargeType='{2}' classType='{3}' entryType='{4}' classCount='{8}'><span class='chghandlemenu'>[+]</span>{5}<a class='champ-dogs " + (allDetailsCheck == 4 ? " all-wins-entered " : "") + "' href='' title='Enter Your Wins' ><img src='/Content/Assets/{6}' /></a><span class='clickable'><img class='tickHolder ' src='/Content/Assets/tickv2.png' /><span class='clsname'>{1}</span></span>{7}</div>",
                                    cls.ID, ShortenName(cls), cls.ChargeType, cls.ClassType, cls.EntryType, altHandlerInfo, hasChampDogsIcon, h, cls.ClassCount);
                            }
                            else if (cls.EntryType == 11)
                            {
                                var hasJuniorDetails = "mdNotSet.png";
                                var allDetailsCheck = false;

                                var jnr= new Juniors(cls.ID, d.ID);
                                var h = "";
                                if (jnr != null && jnr.ID > 0)
                                {
                                    h += string.Format("<span class='junior-details' data-id='{2}' data-dob='{0:dd-MM-yyyy}' data-ykcnumber='{1}'></span>",
                                                jnr.DoB, jnr.YKCNumber, jnr.ID);
                                    hasJuniorDetails = "mdSet.png";
                                    allDetailsCheck = true;
                                }
                                h += "";
                                classTable += String.Format("<div {9} {10} {11} {12} class='clsNo " + ticked + "' clsid='{0}' chargeType='{2}' classType='{3}' entryType='{4}' classCount='{8}'  ><span class='chghandlemenu'>[+]</span>{5}<a class='ykc " + (allDetailsCheck  ? " all-entered " : "") + "' href='' title='Enter YKC Details' ><img src='/Content/Assets/{6}' /></a><span class='clickable'><img class='tickHolder ' src='/Content/Assets/tickv2.png' /><span class='ah'>*</span><span class='clsname'>{1}</span></span>{7}</div>",
                                    cls.ID, ShortenName(cls), cls.ChargeType, cls.ClassType, cls.EntryType, altHandlerInfo,
                                    hasJuniorDetails, h, cls.ClassCount, cls.Anysize == 1 ? "anysize" : "", cls.Veteran == 1 ? "veteran" : "", ShowLhoModifier(cls.Lho), cls.AwardByHeight > 0 ? "AH" : "");
                            }
                            else
                            {
                                //                                lhoclass = (cls.Lho == 0 && dc.Lho == 1 ? " hidecls ": "");

                                var lhoclass = "";
                                if (cls.Lho == 0 )
                                {
                                    lhoclass = (dc.Lho == 1 ? " hidecls " : "");
                                }
                                else
                                {
                                    if (cls.Lho < 3)
                                    {
                                        lhoclass = ""; // (dc.Lho == 1 ? "" : " hidecls ");
                                    }
                                    else
                                    {
                                        lhoclass = (dc.Lho == 0 ? " hidecls " : "");
                                    }

                                }

                                classTable += String.Format("<div {7} {8} {9} {10}  class='clsNo " + ticked + " " + lhoclass + "' clsid='{0}' chargeType='{2}' classType='{3}' entryType='{4}' classCount='{6}'><span class='chghandlemenu'>[+]</span>{5}<a class='nootherdogs'><img class='nootherdogs' src='/Content/Assets/infov1.png' /></a><span class='clickable'><img class='tickHolder ' src='/Content/Assets/tickv2.png' /><span class='ah'>*</span><span class='clsname'>{1}</span></span></div>",
                                    cls.ID, ShortenName(cls), cls.ChargeType, cls.ClassType, cls.EntryType, altHandlerInfo, cls.ClassCount, cls.Anysize == 1 ? "anysize" : "", cls.Veteran == 1 ? "veteran" : "", ShowLhoModifier(cls.Lho), cls.AwardByHeight > 0 ? "AH" : "");
                            }
                        }
                    }
                }

                headerCompleted = true;
                if (!classesForDog)
                {
                    classTable += String.Format("<div class='clsNo nohover'><span class='naCls'>n/a</span></div>");
                }
                html += classTable + "</div>";
                html += "</div>";
            }

            header += "</div>";

            String showDetailsBox = "";
            showDetailsBox += "<div class='showDetails themeText'>";
            showDetailsBox += "<div class='title'  style=' width: 375px;white-space: nowrap;overflow: hidden;text-overflow: clip;'>" + thisShow.ShowName + "</div>";
            showDetailsBox += "<div class='showdate'>" + thisShow.ShowDate.ToString("dd MMM yyyy") + "</div>";
            showDetailsBox += "</div >";

            showDetailsBox += "<div class='helpBox themeNoticeText themeBorder'>";
            showDetailsBox += "<div><span class='legend themeBackgroundColor'>Help Information</span></div>";
            showDetailsBox += "<div><img src='/Content/Assets/tickv2.png' /><span class='afterImgAdj'> To select all classes</span></div>";
            showDetailsBox += "<div><img src='/Content/Assets/crossv1.png' /><span class='afterImgAdj'>  To unselect all classes</span></div>";
            showDetailsBox += "<div><img src='/Content/Assets/mdNotSet.png' /><span class='afterImgAdj'>  Missing details</span></div>";
            showDetailsBox += "<div><img src='/Content/Assets/mdSet.png' /><span class='afterImgAdj'> All detail entered</span></div>";
            showDetailsBox += "<div><span style='color:#fff;'>[+]</span><span ><span> To Add Handler</span></div>";
            showDetailsBox += "<div><span class='ah' style='color:#fff;display:inline;margin: 0px 7px;top:4px'>*</span><span ><span>Awards By Height</span></div>";
            showDetailsBox += "</div>";

            String totalsBox = "";
            totalsBox += "<div class='totals themeBorder' ><div class='showTotals short themeBackgroundColor themeBorder'>";
            totalsBox += "<div class='clsTypeRow group fulltotal'>";
            totalsBox += "<div class='clsTypePaymentInfo themeBorder-t'></div>";
            totalsBox += "<div class='clsTypeTotal themeBorder-t themeBorder-l'>0.00</div>";
            totalsBox += "</div >";
            totalsBox += "</div>";
            totalsBox += "<div class='ctrlButtons'>";

            if (thisShow.Status == (int)Shows.SHOW_STATUS.PUBLISHED)
            {
                if (us.Status != (int)UserShows.UserStatus.STATUS_ENTERED_NOT_PAID
                    && us.Status != (int)UserShows.UserStatus.STATUS_ENTERED_AND_PAID)
                {
                    totalsBox += "<input type='button' id='btnSaveEntry' value='Save Details' />";
                }
            }

            HttpCookie cookie = HttpContext.Current.Request.Cookies[".FPPAUTH"];
            if (cookie != null)
            {
                FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value);

                String[] lists = ticket.UserData.Split(':');
                int userid = Convert.ToInt32(lists[1]);
                if ((lists[0].Contains("showadmin") && thisShow.Status == (int)Shows.SHOW_STATUS.NOT_PUBLISHED)
                    || thisShow.Status == (int)Shows.SHOW_STATUS.PUBLISHED)
                {
                    totalsBox += "<input type='button' id='btnDoEntry' value='Enter Show' />";
                }
            }

            totalsBox += "<input type='button' id='btnCancel' value='Close' /></div>";
            totalsBox += "</div >";
            status.Status = 0;
            status.UserID = currentUser.ID;
            status.Data = "<input id='ShowID' type='hidden' value='" + ShowId.ToString() + "' /><div class='enterform themeBorder' showid='" + ShowId.ToString() + "'><div class='vscroll'>" + header + "<div class='hscroll'>" + html + "</div></div></div>" + showDetailsBox + totalsBox;
            status.Extra = AltHandler.GetAllAltHandlers(UserId);

            status.TransactionSummaryData = TransactionSummary.getTransactionSummary(ShowId, currentUser.ID);

            status.Camping = new Camping(ShowId);
            status.CampingSummary = UserCamping.GetCampingSummary(ShowId, 0);
            if (!status.CampingSummary.Any())
            {
                for (DateTime dt = status.Camping.Startdate; dt <= status.Camping.Enddate; dt = dt.AddDays(1))
                {
                    status.CampingSummary.Add(new Core.Dto.CampingSummary
                    {
                        CampingDay = dt,
                        Count = 0
                    });
                }
            }
            else
            {
                status.CampingFull = status.CampingSummary.Where(x => x.Count >= status.Camping.Limit).Count() == status.CampingSummary.Count();
            }
            status.PaymentSummary = CreatePaymentSummary(us, false, status.CampingFull);
            if (status.Camping.ID > -1 && !status.CampingFull)
            {
                status.UserCamping = new UserCamping(us.ID);
            }
            status.UserShow = us;

            status.MultiDogEntries = TeamPairsManager.GetTeamPairs(ShowId, UserId, status.MultiDogClasses);

            status.Lho = lhoLabel;
            status.fouthHeight = fouthHeightLabel;

            return status;
        }
        // From Admin Site
        public UserDogDetails GetDetails(int ShowId, int UserId, int handlerType)
        {
            var userDetails = new UserDogDetails();
            userDetails.MultiDogClasses = new List<MultiDogClasses>();
            List<ShowClasses> classList = ShowClasses.GetAllClassesForShow(ShowId).Where(sc => sc.Part == 0).ToList();
            userDetails.MultiDogClasses = TeamPairsManager.GetTeamPairClasses(ShowId);
            userDetails.Juniors = new List<Juniors>();
            var us = new UserShows(UserId, ShowId);
            //
            // if user entering a new show then set up the handler type, cos that is pasted in
            if (us.ID == -1)
            {
                us.HandlerType = handlerType;
                if (handlerType == 0)
                {
                    if (Judge.isJudgeAtShow(UserId, ShowId))
                    {
                        handlerType = 2;
                        us.HandlerType = 2;
                    }
                    else
                    {
                        //
                        // check if alt handlers are judging
                        //
                        List<AltHandler> altHList = AltHandler.GetAllAltHandlersList(us.Userid);
                        foreach (AltHandler alt in altHList)
                        {
                            if (Judge.isJudgeAtShow(alt.AltHandlerID, ShowId))
                            {
                                handlerType = 2;
                                us.HandlerType = 2;
                            }
                        }
                    }
                }
            }
            var discountTotal = 0M;
            var addNewTransation = 0;
            var singleEntryId = getSingleEntry(ShowId);
            userDetails.Camping = new Camping(ShowId);
            userDetails.CampingSummary = UserCamping.GetCampingSummary(us.ShowID, us.Userid);
            var totals = calcNewTotalForEntry(us, userDetails.Camping, singleEntryId, ref discountTotal, ref addNewTransation);
            if (!userDetails.CampingSummary.Any())
            {
                for (DateTime dt = userDetails.Camping.Startdate; dt <= userDetails.Camping.Enddate; dt = dt.AddDays(1))
                {
                    userDetails.CampingSummary.Add(new Core.Dto.CampingSummary
                    {
                        CampingDay = dt,
                        Count = 0
                    });
                }
            }
            else
            {
                userDetails.CampingFull = userDetails.CampingSummary.Where(x => x.Count >= userDetails.Camping.Limit).Count() == userDetails.CampingSummary.Count();
            }

            userDetails.PaymentSummary = CreatePaymentSummary(us, true, userDetails.CampingFull);
            userDetails.AltHandlers = AltHandler.GetAllAltHandlers(UserId);
            if (us.ID > 0)
            {
                userDetails.ShowTransactions = Transaction.getTransactionForShowUser(us.ID.ToString("000000"));
            }
            else
            {
                userDetails.ShowTransactions = new List<Transaction>();
            }
            userDetails.helperDetails = Business.Helpers.HelperForShow(ShowId, UserId);

            Shows thisShow = new Shows(ShowId);
            Dogs dog = new Dogs();
            userDetails.DogDetails = Dogs.GetAllDogsForHandler(UserId, thisShow.ShowDate);
            userDetails.UserDetails = new User(UserId);

            userDetails.HandlerType = us.HandlerType;
            userDetails.UserShowID = us.ID.ToString("000000");
            userDetails.Optout = us.Optout;
            userDetails.SaveStatus = us.Status;

            userDetails.MultiDogEntries = TeamPairsManager.GetTeamPairs(ShowId, UserId, userDetails.MultiDogClasses);

            String html = "";
            List<validClassesForDog> validDogClasses = new List<validClassesForDog>();
            if (true)
            {

                html = "<input type='hidden' name='ShowId' value='" + ShowId.ToString() + "' /><input type='hidden' name='userid' value='" + UserId.ToString() + "' /><div class='entryAdminLeft'><table class='dogsToEnter'>";
                html += @"<tr>
                        <th class='dogName'>Dog Name</th>
                        <th class='lho-handler'>LHO</th>
                        <th class='classNos'>Classes</th>";
                foreach (Dogs d in userDetails.DogDetails)
                {
                    validClassesForDog vc4d = new validClassesForDog(d.ID);
                    validDogClasses.Add(vc4d);
                    DogClasses dc = new DogClasses(d.ID, ShowId);
                    dc.getDogsClasses(ShowId);
                    String tmpNFC = d.Grade.ToString();
                    if (d.Grade == 0)
                    {
                        tmpNFC = "NFC";
                    }
                    else if (d.Grade == 99)
                    {
                        tmpNFC = "Vet";
                    }
                    html += String.Format("<tr class='dogClass' lho='{6}' dogid='{0}' height='{3}' grade='{2}'><td class='dogName'><div ><b>[{4}] </b>{1}</div><div class='altHandler'>{5}</div></td>", d.ID, d.KCName, d.Grade, d.Height, tmpNFC, d.AltHandlerName, dc.Lho);
                    html += "<td class='lho'><input type='checkbox' class='lho' value='1' " + (dc.Lho == 1 ? "checked" : "") + "    /></td>";
                    //html += "<td class='vet'><input type='checkbox' class='vet' value='1' " + (dc.Veteran == 1 ? "checked" : "") + "    /></td>";
                    //html += "<td class='any'><input type='checkbox' class='any' value='1' " + (dc.Anysize == 1 ? "checked" : "") + "    /></td>";
                    String classesEntered = "";
                    foreach (ShowClasses cls in classList)
                    {
                        int otherDogs = 0;
                        int reserves = 0;
                        bool teamName = false;
                        if (cls.EntryType == 4 || cls.EntryType == 8) { otherDogs = 1; }
                        else if (cls.EntryType == 5) { otherDogs = 3; reserves = 2; teamName = true; }
                        else if (cls.EntryType == 9) { otherDogs = 2; reserves = 2; teamName = true; }

                        int clsIndex = dc.Classlist.IndexOf(cls.ID);
                        if (clsIndex > -1)
                        {
                            classesEntered += String.Format("<span entrytype='{1}' chargetype='{2}' classtype='{3}' classno='{0}' clsid='{4}' class='classNumber  ", cls.ClassNo, cls.EntryType, cls.ChargeType, cls.ClassType, cls.ID);
                            if (dc.AltHandlerList[clsIndex] > 0)
                            {
                                var jnrHtml = "";
                                if (cls.EntryType == 11)
                                {
                                    var jnr = new Juniors(cls.ID, d.ID);
                                    if (jnr != null && jnr.ID > 0)
                                    {
                                        jnrHtml += string.Format("<span class='junior-details' data-id='{2}' data-dob='{0:dd-MM-yyyy}' data-ykcnumber='{1}'></span>",
                                                    jnr.DoB, jnr.YKCNumber, jnr.ID);
                                    }
                                }
                                classesEntered += String.Format("althandler ykc' data-althandlerid='{1}'>{0}{2}</span>", cls.ClassNo, dc.AltHandlerList[clsIndex], jnrHtml);
                            }
                            else
                            {
                                if (otherDogs > 0)
                                {
                                    classesEntered += String.Format("'  data-otherdogs='{1}' data-reserves='{2}' data-team='{3}' >{0}", cls.ClassNo, otherDogs, reserves, teamName);
                                    classesEntered += "<img class='otherdogs' src='/Content/Assets/mdSet.png' />";
                                    classesEntered += "</span>";
                                }
                                else
                                {
                                    var extrahtml = "";
                                    if (cls.EntryType == 10)
                                    {
                                        var wins = DogHistory.GetRecordedWins(d.ID);
                                        foreach (var dogH in wins)
                                        {
                                            extrahtml += string.Format("<span class='champ-details' data-upgradetype='{4}' data-winid='{3}' data-showname='{0}' data-showdate='{1:dd-MM-yy}' data-showclass='{2}'></span>",
                                                dogH.ShowName, dogH.DateOfWin, dogH.ClassWon, dogH.Id, dogH.UpgradeType);
                                        }
                                        classesEntered += String.Format("' >{0}{1}</span>", cls.ClassNo, extrahtml);
                                    }
                                    else if (cls.EntryType == 11 || cls.EntryType == 3)
                                    {
                                        var jnr = new Juniors(cls.ID, d.ID);
                                        if (jnr != null && jnr.ID > 0)
                                        {
                                            extrahtml += string.Format("<span class='junior-details' data-id='{2}' data-dob='{0:dd-MM-yyyy}' data-ykcnumber='{1}'></span>",
                                                        jnr.DoB, jnr.YKCNumber, jnr.ID);
                                        }
                                        classesEntered += String.Format("ykc' >{0}{1}</span>", cls.ClassNo, extrahtml);
                                    }
                                    else
                                    {
                                        classesEntered += String.Format("' >{0}</span>", cls.ClassNo);

                                    }
                                }
                            }
                        }

                        if (isDogInClass(cls, d))
                        {
                            vc4d.addClassDetails(cls);
                        }
                    }
                    html += "<td class='classNos'><div >" + classesEntered + "</div></td></tr>";
                }
                html += "</table></div><div class='entryAdminRight'></div>";
            }
            userDetails.Data = html;
            userDetails.ValidClassesForDogs = validDogClasses;
            userDetails.TransactionSummaryData = TransactionSummary.getTransactionSummary(ShowId, UserId);
            userDetails.UserCamping = new UserCamping(us.ID);
            if (us.ID > 0)
            {
                userDetails.ShowTransList = ShowTransaction.getTransactionForShowRef(us.ID);
            }
            else
            {
                userDetails.ShowTransList = new List<ShowTransaction>();
            }

            return userDetails;
        }
        public StatusCls AdminPayForShow(ShowEntry showEntry)
        {
            StatusCls status = new StatusCls();
            var currentUser = new User(showEntry.UserId);
            var thisShow = new Shows(showEntry.ShowId);
            var us = new UserShows(showEntry.UserId, showEntry.ShowId);
            us.Status = us.Status = (int)UserShows.UserStatus.STATUS_ENTERED_AND_PAID;
            us.Save();
            status.Data = us.ID.ToString().PadLeft(6, '0');
            var transactions = Transaction.getTransactionForShowRef(us.ID);
            var transID = Transaction.Add(status.Data, TransactionTypes.ShowEntryPayment, showEntry.Cheque, showEntry.PaymentType + " Payment", showEntry.ShowId, showEntry.UserId, DateTime.Now, showEntry.Cheque);
            Transaction.SetEnteredBy(transID, Transaction.ENTERED_BY.SHOW_ADMIN_ENTRY);

            if (thisShow.Status == 0)
            {
                return status;
            }

            if (currentUser.EmailAddress.Length > 0)
            {
                // if entered show, send email saying entered show
                String htmlContents = readTemplate("AdminEnteredShowMessage", "html", thisShow, status.Data);
                String plainContents = readTemplate("AdminEnteredShowMessage", "txt", thisShow, status.Data);

                String Classes_entered_html = "<table>";
                String Classes_entered_plain = "";

                List<ShowClasses> classList = ShowClasses.GetAllClassesForShow(showEntry.ShowId);
                List<Dogs> dogList = Dogs.GetAllDogsForHandler(showEntry.UserId, thisShow.ShowDate);
                foreach (Dogs d in dogList)
                {

                    DogClasses dogClasses = new DogClasses(d.ID, showEntry.ShowId);
                    dogClasses.getDogsClasses(showEntry.ShowId);
                    string dogClassesPlain = String.Format("{1}{0}{1}--------------------------------{1}", d.PetName, Environment.NewLine);
                    string dogClassesHtml = String.Format("<tr style='font-weight:bold;'><td colspan='3'><b>{0}</b></td></tr>", d.PetName);
                    bool dogEntered = false;
                    foreach (ShowClasses cls in classList)
                    {
                        int clsIndex = dogClasses.Classlist.IndexOf(cls.ID);
                        if (clsIndex > -1)
                        {
                            dogEntered = true;
                            dogClassesHtml += "<tr>";
                            dogClassesHtml += String.Format("<td style='width:25px'></td><td>{0}</td><td>{1} {2} {3} {4}</td>", cls.ClassNo, cls.longHeight, cls.LongClassName, cls.longCatagory, cls.getGrades);
                            dogClassesHtml += "</tr>";
                            dogClassesPlain += String.Format("{0} - {1} {2} {3} {4} {5}", cls.ClassNo, cls.longHeight, cls.LongClassName, cls.longCatagory, cls.getGrades, Environment.NewLine);
                        }
                    }

                    if (dogEntered)
                    {
                        Classes_entered_html += dogClassesHtml;
                        Classes_entered_plain += dogClassesPlain;
                    }
                }
                Classes_entered_html += "</table>";
                Classes_entered_plain += Environment.NewLine;

                htmlContents = htmlContents.Replace("[CLASSES_ENTERED]", Classes_entered_html);
                plainContents = plainContents.Replace("[CLASSES_ENTERED]", Classes_entered_plain);

                String underPayment_html = "";
                String underPayment_plain = "";
                if (showEntry.Cheque < showEntry.Total)
                {
                    if (Math.Abs(showEntry.Total - showEntry.Cheque) >= 5)
                    {
                        underPayment_html = String.Format("<h2>Please note that you entry was underpaid by £{0:.00}. Please send the balance to the Show Processor ASAP.</h2>", Math.Abs(showEntry.Total - showEntry.Cheque));
                        underPayment_plain = String.Format("Please note that you entry was underpaid by £{0:.00}. Please send the balance to the Show Processor ASAP.", Math.Abs(showEntry.Total - showEntry.Cheque));
                    }
                    else
                    {
                        underPayment_html = String.Format("<h2>Please note that you entry was underpaid by £{0:.00}. Please pay the outstanding balance at the show.</h2>", Math.Abs(showEntry.Total - showEntry.Cheque));
                        underPayment_plain = String.Format("Please note that you entry was underpaid by £{0:.00}. Please pay the outstanding balance at the show.", Math.Abs(showEntry.Total - showEntry.Cheque));
                    }
                }

                htmlContents = htmlContents.Replace("[PAYMENT_NOTE]", underPayment_html);
                plainContents = plainContents.Replace("[PAYMENT_NOTE]", underPayment_plain);

                String camping_html = "";
                String camping_plain = "";
                UserCamping userCamping = new UserCamping(us.ID);
                if (userCamping.ID > -1)
                {
                    String[] daysSplit = userCamping.PitchDetails[0].CampingDays.Split(',');
                    String Days = "";
                    foreach (String day in daysSplit)
                    {
                        DateTime dt = Convert.ToDateTime(day);
                        if (Days.Length > 1) Days += ", ";
                        Days += dt.ToString("ddd");
                    }
                    camping_html = String.Format("<h3>Camping Confirmation</h3><p>Camping Group Name: <b>{0}</b></p><p>Nights Camping: <b>{1}</b></p><p>Number Of Pitches: <b>{2}</b></p>", userCamping.PitchDetails[0].PartyName, Days, userCamping.PitchDetails.Count());
                    camping_plain = String.Format("Camping Confirmation{3}--------------------{3}Camping Group Name:{0}{3}Nights Camping:{1}{3}Number Of Pitches: {2}{3}", userCamping.PitchDetails[0].PartyName, Days, userCamping.PitchDetails.Count(), Environment.NewLine);

                }
                htmlContents = htmlContents.Replace("[CAMPING]", camping_html);
                plainContents = plainContents.Replace("[CAMPING]", camping_plain);

                if (currentUser.firstTime)
                {
                    String prelogon = Guid.NewGuid().ToString();
                    prelogon = "?verify=" + prelogon.Substring(0, prelogon.Length - 4) + showEntry.UserId.ToString().PadLeft(4, '0');

                    htmlContents = htmlContents.Replace("[PRELOGON]", prelogon);
                    plainContents = plainContents.Replace("[PRELOGON]", prelogon);
                }
                else
                {
                    String prelogon = Guid.NewGuid().ToString();
                    prelogon = "?quick=" + prelogon.Substring(0, prelogon.Length - 4) + showEntry.UserId.ToString().PadLeft(4, '0');

                    htmlContents = htmlContents.Replace("[PRELOGON]", prelogon);
                    plainContents = plainContents.Replace("[PRELOGON]", prelogon);
                }
                MailMessage mm = new MailMessage();

                AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlContents, null, MediaTypeNames.Text.Html);
                LinkedResource logoImage = new LinkedResource(HttpContext.Current.Server.MapPath("/Content/Assets/logo.gif"), MediaTypeNames.Image.Gif);
                logoImage.ContentId = "LogoImage";
                //htmlView.LinkedResources.Add(logoImage);

                AlternateView plainView = AlternateView.CreateAlternateViewFromString(plainContents, null, MediaTypeNames.Text.Plain);
                mm.Body = plainContents;
                mm.AlternateViews.Add(htmlView);

                try
                {
                    SmtpClient client = new SmtpClient();
                    mm.From = new MailAddress("*****@*****.**", "First Place Processing");
                    mm.To.Add(new MailAddress(currentUser.EmailAddress, currentUser.Name));
                    mm.Subject = String.Format("Show Confirmation - {0} ({1:dd MMM yyyy})", thisShow.ShowName, thisShow.ShowDate);
                    client.Send(mm);
                }
                catch (Exception e)
                {
                    AppException.LogEvent("Error Sending Email from AdminEntered Show:" + e.Message + "-" + e.StackTrace);
                }
            }

            return status;
        }
        private String getEntrySummary(UserShows us)
        {
            Shows thisShow = new Shows(us.ShowID);
            UserDogDetails userDetails = new UserDogDetails();
            Dogs dog = new Dogs();
            userDetails.DogDetails = Dogs.GetAllDogsForHandler(us.Userid, thisShow.ShowDate);
            userDetails.UserDetails = new User(us.Userid);

            UserCamping userCamping = new UserCamping(us.ID);
            List<Business.Helpers> helpersList = Business.Helpers.HelperForShow(us.ShowID, us.Userid);

            List<ShowClasses> classList = ShowClasses.GetAllClassesForShow(us.ShowID);

            String html = "<input type='hidden' name='showid' value='" + us.ShowID.ToString() + "' /><input type='hidden' name='userid' value='" + us.Userid.ToString() + "' /><div class='entryAdminLeft'>";

            html += "<div id='showEntryDetails'><ul>";
            html += "<li><a href='#showdetails'>Show Details</a></li>";
            html += "<li><a href='#entrydetails'>Entry Details</a></li>";
            if (userCamping.ID > -1)
            {
                html += "<li><a href='#campingdetails'>Camping Details</a></li>";
            }
            if (helpersList.Count > 0)
            {
                html += "<li><a href='#helperdetails'>Helper Details</a></li>";
            }

            html += "</ul>";

            String schedule = "../Schedules/" + thisShow.ShowDate.ToString("yyyy") + "/";
            String entryForm = schedule;
            String filename = thisShow.ShowName.Replace(' ', '_');
            String fthing = thisShow.ShowDate.ToString("dd_yyyy");
            schedule += filename + fthing + "Schedule.pdf";
            entryForm += filename + fthing + "EntryForm.pdf";

            html += "<div id='showdetails'>";
            html += "<h2>" + thisShow.ShowName + "</h2>" +
                    "<p>Start Date:" + thisShow.ShowDate.ToString("dd MMM yyyy") + "</p>" +
                    "<p>Closing Date:" + thisShow.ClosingDate.ToString("dd MMM yyyy") + "</p>";
            html += "<p>Venue:" + thisShow.Venue + "</p>" +
                    "<p>" + thisShow.VenuePostcode + "(<a target='_blank' href='https://maps.google.co.uk/maps?q=" + thisShow.VenuePostcode + "'>map</a>)</p>";

            var showDocs = ShowDocuments.getShowDocumentsFor(us.ShowID);
            foreach (var doc in showDocs)
            {
                html += string.Format("<div><a class='scheduleLocation' target='_blank' href='../Schedules/{2}/{1}'>{0}</a></div>", doc.Name, doc.Url, thisShow.ShowDate.ToString("yyyy"));
            }
            html += "</div>";

            html += "<div id='entrydetails'>";
            html += "<table class='dogsToEnter themeBorder'>";
            html += "<tr><th class='dogName'>Dog Name</th><th class='classNos'>Classes</th>";
            List<validClassesForDog> validDogClasses = new List<validClassesForDog>();
            int dogCnt = 0;
            foreach (Dogs d in userDetails.DogDetails.Where(d => d.Grade > 0))
            {
                validClassesForDog vc4d = new validClassesForDog(d.ID);
                validDogClasses.Add(vc4d);
                DogClasses dc = new DogClasses(d.ID, us.ShowID);
                dc.getDogsClasses(us.ShowID);
                String altBackground = "infoTextBackground";
                if (dogCnt % 2 == 0) altBackground = "infoTextBackgroundAlt";
                html += String.Format("<tr class='dogClass {4}' dogid='{0}' height='{3}' grade='{2}'><td valign='top'><div >{1}</div>{5}</td>", d.ID, d.KCName, d.Grade, d.Height, altBackground, (dc.Lho == 0 ? "": "**** Entered lower height option"));
                String classesEntered = "";
                foreach (ShowClasses cls in classList)
                {
                    int clsIndex = dc.Classlist.IndexOf(cls.ID);
                    if (clsIndex > -1)
                    {
                        if (classesEntered.Length > 0) { classesEntered += "<br>"; }
                        if (dc.AltHandlerList[clsIndex] > 0)
                        {
                            classesEntered += String.Format("<span class='classNumber althandler' data-althandlerid='{1}'>{0}</span>", cls.ClassNo, dc.AltHandlerList[clsIndex]);
                        }
                        else
                        {
                            //classesEntered += String.Format("<span class='classNumber' style='padding:5px'>{0}</span>", cls.ClassNo);
                            classesEntered += String.Format("<span class='classNumber' style='padding:5px'>{0}</span> {1} {2} {3} {4}", cls.ClassNo, cls.longHeight, cls.LongClassName, cls.longCatagory, cls.getGrades);

                        }

                    }
                    //
                    // if veterans/anysize or anything that is valid for that dog, add to list;
                    if (d.Grade == 99)
                    {
                        if (cls.EntryType == 2)
                        {
                            vc4d.addClassDetails(cls);
                        }
                    }
                    else
                    {
                        if (cls.EntryType == 2 || (d.Height == cls.Height && cls.Grades.Contains(d.Grade.ToString())))
                        {
                            vc4d.addClassDetails(cls);
                        }
                    }
                }
                dogCnt++;
                html += "<td class=''><div class='classNos'><div class='classContainer'>" + classesEntered + "</div></div></td></tr>";
            }
            html += "</table>";
            html += "</div>";
            if (userCamping.ID > -1)
            {
                String[] campDays = userCamping.PitchDetails[0].CampingDays.Split(',');

                html += "<div id='campingdetails' class='infoText'>";
                html += "<h2>Camping Days Booked</h2><ul>";
                foreach (String cdays in campDays.Where(x => x.Length > 0))
                {
                    html += "<li>" + CampDateFormat(cdays) + "</li>";
                }
                html += "</ul>";
                html += "<p>No of pitches:<span style='color:#fff'>" + userCamping.PitchDetails.Count + "</span></p>";
                html += "<p>Camping With:<span style='color:#fff'>" + userCamping.PitchDetails[0].PartyName + "</span></p>";
                html += "<p>Special Requests:<span style='color:#fff'>" + userCamping.PitchDetails[0].Comments + "</span></p>";
                html += "</div>";
            }

            if (helpersList.Count > 0)
            {
                html += "<div id='helperdetails' class='infoText'>";
                html += "<h2>Helping Details</h2>";
                var helperComment = "";
                foreach (Business.Helpers helper in helpersList)
                {
                    String judge = "";
                    if (helper.JudgeID > -1)
                    {
                        Judge j = new Judge(helper.JudgeID);
                        judge = "Judge: " + j.Name;
                    }
                    String ring = "";
                    if (helper.RingNo > 0)
                    {
                        ring = "Ring No:" + helper.RingNo.ToString();
                    }
                    html += String.Format("<div >{0:ddd dd MMM} - {1} {2} {3}</div>", helper.HelpDate, helper.expandJob(), judge, ring);
                    helperComment = helper.Comments;
                }
                if (helperComment.Length > 0)
                {
                    html += string.Format("<p>{0}</p>", helperComment);
                }
                html += "</div>";
            }
            html += "</div>";
            return html;
        }
        private ShowEntry GetCurrentEntry(int ShowId, int UserId, int handlerType)
        {
            var currentEntry = new ShowEntry();
            var us = new UserShows(UserId, ShowId);
            currentEntry.HandlerType = us.HandlerType;
            currentEntry.OptOut = us.Optout;
            currentEntry.EnterData = "";

            Shows thisShow = new Shows(ShowId);
            Dogs dog = new Dogs();
            var DogDetails = Dogs.GetAllDogsForHandler(UserId, thisShow.ShowDate);
            var UserDetails = new User(UserId);

            var classList = ShowClasses.GetAllClassesForShow(ShowId);
            List<validClassesForDog> validDogClasses = new List<validClassesForDog>();
            foreach (Dogs d in DogDetails)
            {
                if (currentEntry.EnterData.Length > 0) currentEntry.EnterData += ",";

                validClassesForDog vc4d = new validClassesForDog(d.ID);
                validDogClasses.Add(vc4d);
                DogClasses dc = new DogClasses(d.ID, ShowId);
                dc.getDogsClasses(ShowId);
                currentEntry.EnterData += String.Format("{0}:", d.ID);
                foreach (ShowClasses cls in classList)
                {
                    if (dc.Classlist.IndexOf(cls.ID) > -1)
                    {
                        currentEntry.EnterData += cls.ID + ".";
                    }
                }
            }
            var userCamping = UserCamping.GetUserShow(us.ID);
            if (userCamping.ID > -1)
            {
                currentEntry.CampingDays = userCamping.PitchDetails[0].CampingDays;
                currentEntry.CampingParty = userCamping.PitchDetails[0].PartyName;
                currentEntry.CampComments = userCamping.PitchDetails[0].Comments;
                currentEntry.Plots = userCamping.PitchDetails.Count();
            }

            return currentEntry;
        }