protected void SaveBtn_Click(object sender, EventArgs e)
        {
            bool isOK = true;
            UK_Film_Location_Class.RecceDates objRecceDate = new UK_Film_Location_Class.RecceDates();

            if (string.IsNullOrEmpty(RecceDate.Text))
            {
                isOK = false;
                RecceDatePanel.CssClass = "has-error";
            }
            else
            {
                RecceDatePanel.CssClass = "";
            }

            if (string.IsNullOrEmpty(RecceTime.Text))
            {
                isOK = false;
                RecceTimePanel.CssClass = "has-error";
            }
            else
            {
                RecceTimePanel.CssClass = "";
            }

            if (isOK)
            {

                if (!string.IsNullOrEmpty(Request.QueryString["RecceID"]))
                {
                    objRecceDate.getRecceAppointment(Request.QueryString["RecceID"]);
                }

                objRecceDate.RecceDate = DateTime.Parse(RecceDate.Text);
                objRecceDate.Time = RecceTime.Text;
                objRecceDate.Purpose = ReccePurposeDropDownList.SelectedValue;
                objRecceDate.Notes = RecceNotes.Text;
                if (!string.IsNullOrEmpty(Request.QueryString["OpportunityID"]))
                {
                    objRecceDate.OpportunityID = Request.QueryString["OpportunityID"];
                }

                // Save Record

                objRecceDate.Save();

                if (!string.IsNullOrEmpty(objRecceDate.OpportunityID))
                {

                    Response.Redirect("/OpportunityDetails.aspx?OpportunityID=" + objRecceDate.OpportunityID);

                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string UserEmail = "";

            HttpCookie myTestCookie = new HttpCookie("UKFilmLocationAdmin");
            myTestCookie = Request.Cookies["UKFilmLocationAdmin"];

            // Read the cookie information and display it.
            if (myTestCookie != null)
            {
                // User details collected

                UserEmail = myTestCookie.Value;

            }
            else
            {
                // No user cookie redirect to login

                Response.Redirect("/");
            }

            if (!IsPostBack)
            {

                DBConnection = new MySqlConnection(objUKFilmLocation.DBConnect);
                DBCommand = DBConnection.CreateCommand();

                string thisOpportunityID = Request.QueryString["OpportunityID"];
                string thisRecceID = Request.QueryString["RecceID"];

                UK_Film_Location_Class.RecceDates objRecceDate = new UK_Film_Location_Class.RecceDates();

                UK_Film_Location_Class.OpportunityDetails objOpportunity = new UK_Film_Location_Class.OpportunityDetails();
                UK_Film_Location_Class.LocationDetails objLocation = new UK_Film_Location_Class.LocationDetails();
                UK_Film_Location_Class.ContactDetails objLocationContact = new UK_Film_Location_Class.ContactDetails();
                UK_Film_Location_Class.ContactDetails objProjectCompany = new UK_Film_Location_Class.ContactDetails();
                UK_Film_Location_Class.ProjectDetails objProject = new UK_Film_Location_Class.ProjectDetails();

                if (!string.IsNullOrEmpty(thisRecceID))
                {
                    objRecceDate.getRecceAppointment(thisRecceID);
                    thisOpportunityID = objRecceDate.OpportunityID;

                    RecceDate.Text = UK_Film_Location_Class.UKFilmLocation.makeSQLShortDate(objRecceDate.RecceDate.ToShortDateString());
                    RecceTime.Text = objRecceDate.Time;
                    RecceNotes.Text = objRecceDate.Notes;

                }
                else
                {
                    RecceDate.Text = UK_Film_Location_Class.UKFilmLocation.makeSQLShortDate(DateTime.Now.ToShortDateString() );
                    RecceTime.Text = "00:00";
                }

                objOpportunity.getOpportunity(thisOpportunityID);

                objLocation.getLocationFromID(objOpportunity.LocationID);

                objLocationContact.getContact(objLocation.ContactID);

                objProjectCompany.getContact(objOpportunity.ContactID);

                objProject.getProjectDetails(objOpportunity.ProjectID);

                if (objRecceDate.RecordID > 0)
                {
                    ViewReccePDFLiteral.Text = " <a target=\"_blank\" href=\"http://ukfilmlocation.com/RecceAppointment.php?RecceDateID=" + objRecceDate.RecordID + "&Recipient=" + objProjectCompany.ContactID + "\" class=\"btn-default btn\">View Recce PDF&nbsp;<i class=\"fa fa-file-pdf-o\" title=\"Contact Details\"></i></a>";
                }

                JobRefLiteral.Text = "<a href=\"/OpportunityDetails.aspx?OpportunityID=" + objOpportunity.OpportunityID + "\">J" + objProject.RecordID + " / " + objOpportunity.LocationID + "&nbsp;<i class=\"fa fa-external-link-square\" title=\"Opportunity Details\"></i></a>";

                LocationLiteral.Text = "<p>Recce request for location <b><a href=\"/LocationDetails.aspx?LocationID=" + objLocation.LocationID + "\">" + objLocation.LocationID + "&nbsp;<i class=\"fa fa-external-link-square\" title=\"Location Details\"></i></a></b><br>" + objLocation.Title + "</p><br><br><p>Job Ref : <a href=\"/OpportunityDetails.aspx?OpportunityID=" + objOpportunity.OpportunityID + "\">J" + objProject.RecordID + " - " + objProject.WorkingTitle + "&nbsp;<i class=\"fa fa-external-link-square\" title=\"Opportunity Details\"></i></a></p><p>Location Contact : <a href=\"/ContactDetails.aspx?ContactID=" + objLocationContact.ContactID + "\">" + objLocationContact.Name + "&nbsp;<i class=\"fa fa-external-link-square\" title=\"Contact Details\"></i></a><br>Tel : " + objLocationContact.Tel + "<br>Mobile : " + objLocationContact.Mobile + "<br>Email : " + objLocationContact.Email + "</p><br><br><p>Project Company Contact : <a href=\"/ContactDetails.aspx?ContactID=" + objProjectCompany.ContactID + "\">" + objProjectCompany.Name + "&nbsp;<i class=\"fa fa-external-link-square\" title=\"Contact Details\"></i></a><br>Tel : " + objProjectCompany.Tel + "<br>Mobile : " + objProjectCompany.Mobile + "<br>Email : " + objProjectCompany.Email + "</p>";

                // Populate  Purpose Drop down

                DBConnection.Open();

                DBCommand.CommandText = "select RecordID, value from ReccePurposes;";

                DBResult = DBCommand.ExecuteReader();

                DataTable myData = new DataTable();

                myData.Load(DBResult);

                DataView myview = myData.DefaultView;
                myview.Sort = "RecordID asc";

                DBResult.Close();

                DBConnection.Close();

                ReccePurposeDropDownList.DataSource = myview;
                ReccePurposeDropDownList.DataTextField = "Value";
                ReccePurposeDropDownList.DataValueField = "Value";
                ReccePurposeDropDownList.DataBind();

                ReccePurposeDropDownList.SelectedValue = objRecceDate.Purpose;

                //ListItem list = new ListItem();

                //list = new ListItem();
                //list.Text = "Other";
                //list.Value = "";

                //ReccePurposeDropDownList.Items.Add(list);

            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string thisID = Request.QueryString["RecceID"];

            if (!string.IsNullOrEmpty(thisID))
            {
                string Message = "";

                HttpCookie myTestCookie = new HttpCookie("UKFilmLocationAdmin");
                myTestCookie = Request.Cookies["UKFilmLocationAdmin"];

                UK_Film_Location_Class.UserDetails objUser = new UK_Film_Location_Class.UserDetails();
                objUser.getUserFromEmail(myTestCookie.Value);

                UK_Film_Location_Class.RecceDates objRecce = new UK_Film_Location_Class.RecceDates();
                objRecce.getRecceAppointment(thisID);

                UK_Film_Location_Class.OpportunityDetails objOpportunity = new UK_Film_Location_Class.OpportunityDetails();
                objOpportunity.getOpportunity(objRecce.OpportunityID);

                UK_Film_Location_Class.ContactDetails objProductionContact = new UK_Film_Location_Class.ContactDetails();
                objProductionContact.getContact(objOpportunity.ContactID);

                UK_Film_Location_Class.LocationDetails objLocation = new UK_Film_Location_Class.LocationDetails();
                objLocation.getLocationFromID(objOpportunity.LocationID);

                UK_Film_Location_Class.ContactDetails objLocationContact = new UK_Film_Location_Class.ContactDetails();
                objLocationContact.getContact(objLocation.ContactID);

                // Check Fields

                // Update or Create Record

                DBConnection = new MySqlConnection(objUKFilmLocation.DBConnect);
                DBCommand = DBConnection.CreateCommand();

                // Location Address

                string thisAddress = "";

                if (!string.IsNullOrEmpty(objLocation.Address)) thisAddress += objLocation.Address;
                if (!string.IsNullOrEmpty(objLocation.Street)) thisAddress += ", " + objLocation.Street;
                if (!string.IsNullOrEmpty(objLocation.Town)) thisAddress += ", " + objLocation.Town;
                if (!string.IsNullOrEmpty(objLocation.County)) thisAddress += ", " + objLocation.County;
                if (!string.IsNullOrEmpty(objLocation.Postcode)) thisAddress += ", " + objLocation.Postcode;

                DBConnection.Open();

                // Update Record
                DBCommand.CommandText = "update Tasks set IsComplete = '1', DateComplete = '" + UK_Film_Location_Class.UKFilmLocation.makeSQLDate(DateTime.Now.ToString()) + "' where TaskAttributes = '" + thisID + "' and TaskAction = 'RECCE REQUEST'";

                DBCommand.ExecuteNonQuery();

                DBConnection.Close();

                DBConnection.Open();

                // Update Record
                DBCommand.CommandText = "update RecceDates set EmailSent = '" + UK_Film_Location_Class.UKFilmLocation.makeSQLDate(DateTime.Now.ToString()) + "' where RecordID = '" + thisID + "'";

                DBCommand.ExecuteNonQuery();

                DBConnection.Close();

                // Send Owner Email

                Message = "<p>" + objLocationContact.Name + ", we are pleased to confirm the date(s) of the recce for " + objProductionContact.Name + " at location " + objLocation.LocationID + ". </p>";

                Message += "<p>";

                Message += "Below are the details of the confirmed recce booking. You can also view all your recce requests on our website, <a href=\"http://ukfilmlocation.dev/MyRecces.aspx\">click here</a>. If you have any questions please let us know, telephone 0844 669 5245.</p>";

                Message += "<p>You can download a PDF version of this appointment by <a target=\"_blank\" href=\"http://" + UK_Film_Location_Class.UKFilmLocation.DefaultWebsite + "/RecceAppointment.php?RecceDateID=" + thisID + "&Recipient=" + objLocationContact.ContactID + "\">clicking here</a>.</p>";

                Message += "<h2>Recce Details</h2>";

                Message += "<p>Location Ref : <a href=\"http://" + UK_Film_Location_Class.UKFilmLocation.DefaultWebsite + "/Location.aspx?LocationID=" + objLocation.LocationID + "\">" + objLocation.LocationID + "</a><br>";

                Message += "Address : " + thisAddress + "</p>";

                Message += "<p>";
                //        Message += "<p>Date Of Recce : " + DateTime.Parse(RecceDateLiteral.Text).ToShortDateString() + "<br>";
                //    Message += "Time Of Recce : " + RecceTimeLiteral.Text + "<br>";
                Message += "Contact : " + objProductionContact.Name + "<br>";
                Message += "Contact Tel : " + objProductionContact.Tel + "<br>";
                Message += "Contact Mobile : " + objProductionContact.Mobile + "<br>";
                //    Message += "Notes : " + RecceNotesTextBox.Text;
                Message += "</p>";

                Message += "<h2>Recce Details</h2>";

                Message += "<p>";
                if (!string.IsNullOrEmpty(objRecce.RecceDate.ToShortDateString())) Message += "Date Of Recce : " + objRecce.RecceDate.ToShortDateString().Replace(" 00:00:00", "") + "<br>";
                if (!string.IsNullOrEmpty(objRecce.Time)) Message += "Time Of Recce : " + objRecce.Time + "<br>";

                if (!string.IsNullOrEmpty(objOpportunity.TypeOfShoot)) Message += "Type Of Shoot : " + objOpportunity.TypeOfShoot + "<br>";
                //if (!string.IsNullOrEmpty(AgreedRateTextBox.Text)) Message += "Agreed Agency Rate % : " + AgreedRateTextBox.Text + "<br>";
                if (!string.IsNullOrEmpty(objRecce.Notes)) Message += "Notes : " + objRecce.Notes.Replace("\n", "<br>");
                Message += "</p>";

                Message += "<p>Agent : " + objUser.FirstName + " " + objUser.LastName + "<br>";
                Message += "Agent Email : " + objUser.Email + "<br>";
                Message += "Agent Tel : 0844 669 5245 / 01782 388090</p>";

                Message += "<p>We appreciate your feedback, please let us know how it went.</p>";

                Message += "<p><i>UKFilmLocation.com</i><br>";
                Message += "Tel 0844 669 5245</p>";

                UK_Film_Location_Class.UKFilmLocation.sendEmail(objLocationContact.Email, objUser.FirstName + " " + objUser.LastName, objUser.Email, "UKFilmLocation.com - Recce Confirmation for Location: " + objLocation.LocationID + " (" + UK_Film_Location_Class.LocationDetails.getTitleFromID(objLocation.LocationID) + ")", Message);

                // Send Project Company Email

                // Send emails

                Message = "<p>" + objProductionContact.Name + ", we are pleased to confirm the date(s) of your recce at location " + objLocation.LocationID + ". We hope the location lives up to your expectations.</p><p>You can download a printable PDF for this location by <a href=\"http://" + UK_Film_Location_Class.UKFilmLocation.DefaultWebsite + "/LocationPDF.php?LocationID=" + objLocation.LocationID + "\" target=\"_blank\">clicking here</a>.</p>";

                Message += "<p>";

                Message += "Below are the details of the confirmed recce booking. You can also view all your recce requests on our website, <a href=\"http://ukfilmlocation.dev/MyRecces.aspx\">click here</a>. If you have any questions please let us know, telephone 0844 669 5245.</p>";

                Message += "<p>You can download a PDF version of this appointment by <a target=\"_blank\" href=\"http://" + UK_Film_Location_Class.UKFilmLocation.DefaultWebsite + "/RecceAppointment.php?RecceDateID=" + thisID + "&Recipient=" + objProductionContact.ContactID + "\">clicking here</a>.</p>";

                Message += "<h2>Recce Details</h2>";

                Message += "<p>Location Ref : <a href=\"http://" + UK_Film_Location_Class.UKFilmLocation.DefaultWebsite + "/Location.aspx?LocationID=" + objLocation.LocationID + "\">" + objLocation.LocationID + "</a><br>";
                Message += "Address : " + thisAddress + "</p>";

                Message += "<p>";
                // Date Of Recce : " + DateTime.Parse(RecceDateLiteral.Text).ToShortDateString() + "<br>";
                // Message += "Time Of Recce : " + RecceTimeLiteral.Text + "<br>";
                Message += "Owner : " + objLocationContact.Name + "<br>";
                Message += "Owner Tel : " + objLocationContact.Tel + "<br>";
                Message += "Owner Mobile : " + objLocationContact.Mobile + "<br>";
                // Message += "Notes : " + RecceNotesTextBox.Text;
                Message += "</p>";

                Message += "<h2>Recce Details</h2>";

                Message += "<p>";
                if (!string.IsNullOrEmpty(objRecce.RecceDate.ToShortDateString())) Message += "Date Of Recce : " + objRecce.RecceDate.ToShortDateString().Replace(" 00:00:00", "") + "<br>";
                if (!string.IsNullOrEmpty(objRecce.Time)) Message += "Time Of Recce : " + objRecce.Time + "<br>";

                if (!string.IsNullOrEmpty(objOpportunity.TypeOfShoot)) Message += "Type Of Shoot : " + objOpportunity.TypeOfShoot + "<br>";
                //if (!string.IsNullOrEmpty(AgreedRateTextBox.Text)) Message += "Agreed Agency Rate % : " + AgreedRateTextBox.Text + "<br>";
                if (!string.IsNullOrEmpty(objRecce.Notes)) Message += "Notes : " + objRecce.Notes.Replace("\n", "<br>");
                Message += "</p>";

                Message += "<p>Agent : " + objUser.FirstName + " " + objUser.LastName + "<br>";
                Message += "Agent Email : " + objUser.Email + "<br>";
                Message += "Agent Tel : 0844 669 5245 / 01782 388090</p>";

                Message += "<p><i>UKFilmLocation.com</i><br>";
                Message += "Tel 0844 669 5245</p>";

                UK_Film_Location_Class.UKFilmLocation.sendEmail(objProductionContact.Email, objUser.FirstName + " " + objUser.LastName, objUser.Email, "UKFilmLocation.com - Recce Confirmation for Location: " + objLocation.LocationID + " (" + UK_Film_Location_Class.LocationDetails.getTitleFromID(objLocation.LocationID) + ")", Message);

                Response.Redirect("/OpportunityDetails.aspx?OpportunityID=" + objOpportunity.OpportunityID);
            }

            DBConnection.Dispose();
        }