コード例 #1
0
        protected void UploadButton_Click(object sender, EventArgs e)
        {
            // csv

            bool isLive = true;

            if (FileUpload.HasFiles)
            {
                foreach (HttpPostedFile uploadedFile in FileUpload.PostedFiles)
                {

                    string Filename = "";
                    string Extension = "";

                    Filename = uploadedFile.FileName;
                    Extension = Path.GetExtension(Filename).ToLower();

                    string thisID = Guid.NewGuid().ToString();

                    if (Extension == ".csv")
                    {

                        uploadedFile.SaveAs(System.IO.Path.Combine(Server.MapPath("~/Temp/"), thisID + Extension));

                        //MySqlConnection DBConnection;
                        //MySqlCommand DBCommand;

                        //MySqlDataReader DBResult;

                        FileHelperEngine engine = new FileHelperEngine(typeof(ContactsVerticalBar));

                        DataTable objTable = engine.ReadFileAsDT(System.IO.Path.Combine(Server.MapPath("~/Temp/"), thisID + Extension));

                        ResultsLiteral.Text += "<table><tr><th>Name</th><th>Company</th><th>Tel</th><th>Mobile</th><th>Email</th></tr>";

                        ResultsStatsLiteral.Text = "Importing " + objTable.Rows.Count + " rows...";

                        foreach (DataRow row in objTable.Rows)
                        {
                            string thisName = row["Name"].ToString();
                            string thisCompany = row["Company"].ToString();
                            string thisTel = row["Tel"].ToString();
                            string thisMobile = row["Mobile"].ToString();
                            string thisEmail = row["Email"].ToString();

                            string thisPosition = row["Position"].ToString();
                            string thisAddress = row["Address"].ToString();
                            string thisStreet = row["Street"].ToString();
                            string thisTown = row["Town"].ToString();
                            string thisCounty = row["County"].ToString();
                            string thisPostcode = row["Postcode"].ToString();
                            string thisLocationID = row["LocationID"].ToString();
                            string thisContactType = row["ContactType"].ToString();

                            string thisContactTypeText = "";

                            if (!string.IsNullOrEmpty(thisName))
                            {

                                switch (thisContactType)
                                {
                                    case "1":
                                        thisContactTypeText = "Location Owner";
                                        break;
                                    case "2":
                                        thisContactTypeText = "Project Company";
                                        break;
                                    default:
                                        thisContactTypeText = "";
                                        thisContactTypeText = "Location Owner";
                                        thisContactType = "1";
                                        break;
                                }

                                ResultsLiteral.Text += "<tr><td valign=\"top\">" + thisContactTypeText + "</td><td>" + thisName + "</td><td>" + thisCompany + "</td><td>" + thisTel + "</td><td>" + thisMobile + "</td><td>" + thisEmail + "</td></tr>";

                                ResultsLiteral.Text += "<tr><td></td><td colspan=\"5\">";

                                ResultsLiteral.Text += "<b>Notes:</b>";

                                UK_Film_Location_Class.ContactDetails objContact = new UK_Film_Location_Class.ContactDetails();

                                bool foundContact = false;

                                if (!string.IsNullOrEmpty(thisEmail))
                                {
                                    objContact.getContactFromEmail(thisEmail);

                                    if (!string.IsNullOrEmpty(objContact.ContactID))
                                    {
                                        ResultsLiteral.Text += "<p>Contact found by Email!</p>";
                                        foundContact = true;
                                    }

                                }

                                if (!foundContact && !string.IsNullOrEmpty(thisTel))
                                {
                                    objContact.getContactFromTel(thisTel);
                                    if (!string.IsNullOrEmpty(objContact.ContactID))
                                    {
                                        ResultsLiteral.Text += "<p>Contact found by Tel!</p>";
                                        foundContact = true;

                                    }
                                }

                                if (!foundContact && !string.IsNullOrEmpty(thisName))
                                {
                                    objContact.getContactFromName(thisName);
                                    if (!string.IsNullOrEmpty(objContact.ContactID))
                                    {
                                        ResultsLiteral.Text += "<p>Contact found by Name :/</p>";
                                        foundContact = true;

                                    }
                                }

                                // Compare Data on found records

                                if (foundContact)
                                {
                                    bool isMod = false;

                                    ResultsLiteral.Text += "<p><i>Updating Contact!</i></p>";

                                    if (string.IsNullOrEmpty(objContact.Company) && !string.IsNullOrEmpty(thisCompany))
                                    {
                                        objContact.Company = thisCompany.Trim();
                                        isMod = true;
                                        ResultsLiteral.Text += "<p>Updating Company!</p>";

                                    }
                                    if (string.IsNullOrEmpty(objContact.Name) && !string.IsNullOrEmpty(thisName))
                                    {
                                        objContact.Name = thisName.Trim();
                                        isMod = true;
                                        ResultsLiteral.Text += "<p>Updating Name!</p>";

                                    }
                                    if (string.IsNullOrEmpty(objContact.Tel) && !string.IsNullOrEmpty(thisTel))
                                    {
                                        objContact.Tel = thisTel.Trim();
                                        isMod = true;
                                        ResultsLiteral.Text += "<p>Updating Tel!</p>";

                                    }
                                    if (string.IsNullOrEmpty(objContact.Mobile) && !string.IsNullOrEmpty(thisMobile))
                                    {
                                        objContact.Mobile = thisMobile.Trim();
                                        isMod = true;
                                        ResultsLiteral.Text += "<p>Updating Mobile!</p>";

                                    }
                                    if (string.IsNullOrEmpty(objContact.ContactType) && !string.IsNullOrEmpty(thisContactType))
                                    {
                                        objContact.ContactType = thisContactType.Trim();
                                        isMod = true;
                                        ResultsLiteral.Text += "<p>Updating Contact Type!</p>";

                                    }
                                    if (string.IsNullOrEmpty(objContact.Email) && !string.IsNullOrEmpty(thisEmail))
                                    {
                                        objContact.Email = thisEmail.Trim();
                                        isMod = true;
                                        ResultsLiteral.Text += "<p>Updating Email Address!</p>";

                                    }

                                    if (string.IsNullOrEmpty(objContact.Address) && !string.IsNullOrEmpty(thisAddress))
                                    {
                                        objContact.Address = thisAddress.Trim();
                                        isMod = true;
                                        ResultsLiteral.Text += "<p>Updating Address!</p>";

                                    }
                                    if (string.IsNullOrEmpty(objContact.Street) && !string.IsNullOrEmpty(thisStreet))
                                    {
                                        objContact.Street = thisStreet.Trim();
                                        isMod = true;
                                        ResultsLiteral.Text += "<p>Updating Street!</p>";

                                    }
                                    if (string.IsNullOrEmpty(objContact.Town) && !string.IsNullOrEmpty(thisTown))
                                    {
                                        objContact.Town = thisTown.Trim();
                                        isMod = true;
                                        ResultsLiteral.Text += "<p>Updating Town!</p>";

                                    }
                                    if (string.IsNullOrEmpty(objContact.County) && !string.IsNullOrEmpty(thisCounty))
                                    {
                                        objContact.County = thisCounty.Trim();
                                        isMod = true;
                                        ResultsLiteral.Text += "<p>Updating County!</p>";

                                    }
                                    if (string.IsNullOrEmpty(objContact.PostCode) && !string.IsNullOrEmpty(thisPostcode))
                                    {
                                        objContact.PostCode = thisPostcode.Trim();
                                        isMod = true;
                                        ResultsLiteral.Text += "<p>Updating Postcode!</p>";

                                    }

                                    if (isMod)
                                    {
                                        if (isLive) objContact.Update();
                                        ResultsLiteral.Text += "<p>Updated!</p>";
                                    }
                                    else ResultsLiteral.Text += "<p>Up to Date!</p>";
                                }
                                else
                                {
                                    ResultsLiteral.Text += "<p>New Contact!</p>";

                                    objContact.Name = thisName.Trim();
                                    objContact.Company = thisCompany.Trim();
                                    objContact.Tel = thisTel.Trim();
                                    objContact.Mobile = thisMobile.Trim();
                                    objContact.Email = thisEmail.Trim();

                                    if (!string.IsNullOrEmpty(thisLocationID))
                                    {
                                        objContact.ContactType = "1";
                                    }
                                    else
                                    {
                                        objContact.ContactType = thisContactType.Trim();
                                    }

                                    objContact.Address = thisAddress.Trim();
                                    objContact.Street = thisStreet.Trim();
                                    objContact.Town = thisTown.Trim();
                                    objContact.County = thisCounty.Trim();
                                    objContact.PostCode = thisPostcode.Trim();

                                    if (isLive) objContact.Create();

                                }

                                // Check LocationID's

                                if (!string.IsNullOrEmpty(thisLocationID))
                                {
                                    UK_Film_Location_Class.LocationDetails objLocation = new UK_Film_Location_Class.LocationDetails();

                                    objLocation.getLocationFromID(thisLocationID);

                                    if (objLocation.RecordID > 0)
                                    {
                                        objLocation.ContactID = objContact.ContactID;
                                        if (isLive) objLocation.saveLocation();

                                        ResultsLiteral.Text += "<p>Associated contact with location " + thisLocationID + "!</p>";
                                    }
                                    else
                                    {
                                        ResultsLiteral.Text += "<p>Lcation " + thisLocationID + " NOT FOUND!</p>";
                                    }
                                }

                            }
                        }

                            ResultsLiteral.Text += "</td></tr>";

                        }
                        ResultsLiteral.Text += "</table>";

                        //var engine = new FileHelperAsyncEngine<ContactsVerticalBar>();
                        //engine.BeginReadFile(System.IO.Path.Combine(Server.MapPath("~/Temp/"), thisID + Extension));

                        // The Async engines are IEnumerable
                        //foreach (ContactsVerticalBar cust in engine)
                        //{
                        //    // your code here
                        //    ResultsLiteral.Text = cust.Name + " - " + cust.Email + "<br>";
                        //}

                }
            }
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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);

            }
        }
コード例 #4
0
        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("/");
            }

            string SelectedContact = "";

            if (!string.IsNullOrEmpty(Request.QueryString["ContactID"]))
            {
                // Contact has been pre-selected!
                SelectedContact = Request.QueryString["ContactID"];
            }

            if (!IsPostBack)
            {

                OptionsListBox = (from x in dc.OptionsTables select x).ToList();
                var itemsToAdd = OptionsListBox.Select(c => GetListItem(c)).ToArray();
                LocationTypeListBox.Items.AddRange(itemsToAdd);
            }

            UK_Film_Location_Class.LocationDetails objLocation = new UK_Film_Location_Class.LocationDetails();

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

            // Get Agents

            DBConnection.Open();

            DBCommand.CommandText = "select * from UserDetails order by FirstName asc, LastName asc;";

            DBResult = DBCommand.ExecuteReader();

            ListItem newItem = new ListItem();
            newItem.Text = "<Select Agent>";
            newItem.Value = "";
            AgentID.Items.Add(newItem);

            while (DBResult.Read())
            {
                newItem = new ListItem();
                newItem.Text = DBResult["FirstName"].ToString() + " " + DBResult["LastName"].ToString();
                newItem.Value = DBResult["UserID"].ToString();
                AgentID.Items.Add(newItem);
            }

            DBResult.Close();
            DBConnection.Close();

            string thisLocationID = "";

            // Is Existing User?
            if (!IsPostBack)
            {
                RecordID.Value = Request.QueryString["RecordID"];
                thisLocationID = Request.QueryString["LocationID"];

                // Location Types
                if (!string.IsNullOrEmpty(RecordID.Value))
                {
                    objLocation.getLocationFromRecordID(RecordID.Value);
                //    NewContactLiteral.Text = "[ <a href=\"/contactdetails.aspx?Op=/LocationDetails.aspx?RecordID=" + RecordID.Value + "\">Create New Contact</a> ]";
                }
                else
                {
                    if (!string.IsNullOrEmpty(thisLocationID))
                    {
                        objLocation.getLocationFromID(thisLocationID);
                 //       NewContactLiteral.Text = "[ <a href=\"/contactdetails.aspx?Op=/LocationDetails.aspx?LocationID=" + thisLocationID + "\">Create New Contact</a> ]";
                    }

                }

                if (!string.IsNullOrEmpty(objLocation.ContactID))
                {
                    ContactNameLiteral.Text = "<a class=\"btn-default btn\" href=\"/ContactDetails.aspx?ContactID=" + objLocation.ContactID + "&Op=" + Request.QueryString["Op"] + "\">View Contact Details</a>";
                }

                string AddOp = "";

                if (objLocation.RecordID == 0)
                {
                    // do nothing

                    if (!string.IsNullOrEmpty(Request.QueryString["ContactID"]))
                    {

                        UK_Film_Location_Class.ContactDetails objContact = new UK_Film_Location_Class.ContactDetails();

                        objContact.getContact(Request.QueryString["ContactID"]);

                        objLocation.Address = objContact.Address;
                        objLocation.Street = objContact.Street;
                        objLocation.Town = objContact.Town;
                        objLocation.County = objContact.County;
                        objLocation.Postcode = objContact.PostCode;
                        objLocation.Country = objContact.Country;
                        objLocation.Company = objContact.Company;
                        objLocation.ContactID = objContact.ContactID;
                        objLocation.ContactName = objContact.Name;
                        objLocation.Tel = objContact.Tel;
                        objLocation.LocationTel = objContact.Tel;
                        objLocation.Company = objContact.Company;
                        objLocation.Email = objContact.Email;
                        objLocation.Mobile = objContact.Mobile;
                        objLocation.AgentID = objContact.AgentID;
                    }
                }
                else
                {
                    AddOp = "&amp;Op=/LocationDetails.aspx?RecordID=" + objLocation.RecordID;

                    PromoteButton.Visible = true;
                }

                LocationID.Text = objLocation.LocationID;

                if (!string.IsNullOrEmpty(objLocation.LocationID))
                {
                    EmailDetailsLiteral.Text = " <a class=\"btn-default btn\" href=\"/EmailLocationPDF.aspx?LocationID=" + objLocation.LocationID + "\">Email PDF&nbsp;<i class=\"fa fa-file-pdf-o\"></i></a>";
                    SuggestRecceLiteral.Text = " <a class=\"btn-default btn\" href=\"/SuggestRecce.aspx?LocationID=" + objLocation.LocationID + "\">Suggest Location</a>";
                    ShowreelPanel.Visible = true;

                    // get locations associated with showreel

                    Locations.Text = "";

                    DBConnection.Open();

                    DBCommand.CommandText = "select ShowreelLocations.LocationID, ShowreelLocations.ShowreelID, showreel.title, showreel.url from ShowreelLocations left join showreel on showreel.showreelid = showreellocations.showreelid where ShowreelLocations.LocationID = '" + objLocation.LocationID + "' order by ShowreelLocations.recordid desc;";

                    DBResult = DBCommand.ExecuteReader();

                    while (DBResult.Read())
                    {
                        string thisImage = "";
                        string thisVideoID = "";

                        if (DBResult["URL"].ToString().Contains("youtube"))
                        {
                            thisVideoID = DBResult["URL"].ToString().Replace("http://", "").Replace("https://", "").Replace("www.", "").Replace("youtube.com/", "").Replace("watch?v=", "");

                            thisImage = "http://img.youtube.com/vi/" + thisVideoID + "/hqdefault.jpg";
                        }
                        else if (DBResult["URL"].ToString().Contains("youtu.be"))
                        {
                            thisVideoID = DBResult["URL"].ToString().Replace("http://", "").Replace("https://", "").Replace("youtu.be/", "");

                            thisImage = "http://img.youtube.com/vi/" + thisVideoID + "/hqdefault.jpg";

                        }
                        else if (DBResult["URL"].ToString().Contains("vimeo"))
                        {
                            thisVideoID = DBResult["URL"].ToString().Replace("http://", "").Replace("https://", "").Replace("player.", "").Replace("www.", "").Replace("vimeo.com/", "").Replace("video/", "");

                            thisImage = GetMediumVimeoThumbnail(thisVideoID);

                        }
                        else if (DBResult["URL"].ToString().Contains("vevo"))
                        {
                            thisVideoID = DBResult["URL"].ToString().Replace("http://", "").Replace("https://", "").Replace("www.", "").Replace("vevo.com/", "").Replace("watch/", "");
                            thisImage = "/images/camera.jpg";
                        }

                        Showreel.Text += "<tr><td><img src=\"" + thisImage + "\" width=\"64\"></td><td>" + DBResult["Title"].ToString() + "</td><td><a class=\"btn-default btn\" href=\"/ShowreelDetails.aspx?ShowreelID=" + DBResult["ShowreelID"].ToString() + "\">View</a></td></tr>";

                    }

                    DBConnection.Close();

                }

                JSLiteral.Text = "<script>function changeContact() { e = document.getElementById('ContentPlaceHolder1_ContactsDropDownList'); document.getElementById('ViewContactHolder').innerHTML='<a class=\"btn-default btn\" href=\"ContactDetails.aspx?ContactID=' + e.options[e.selectedIndex].value + '" + AddOp + "\">View Contact Details</a>'; } </script>";

                StatsLiteral.Text = "<p>Created : " + objLocation.CreatedDate + "<br>Views : " + objLocation.Counter + "</p>";

                foreach (ListItem item in LocationTypeListBox.Items)
                {

                    if (objLocation.TypeID.Contains(item.Value))
                    {
                        item.Selected = true;
                    }
                }

                // get locations associated with showreel

                Locations.Text = "";

                DBConnection.Open();

                DBCommand.CommandText = "select ShowreelLocations.LocationID, ShowreelLocations.ShowreelID, locations.title, (select LocationImages.Image from LocationImages where LocationImages.LocationID = ShowreelLocations.LocationID order by imageorder asc limit 0, 1) as LocationImage from ShowreelLocations left join locations on locations.locationid = showreellocations.locationid where ShowreelLocations.LocationID = '" + Request.QueryString["LocationID"] + "' order by ShowreelLocations.recordid desc;";

                DBResult = DBCommand.ExecuteReader();

                while (DBResult.Read())
                {
                    Locations.Text = "<tr><td><img src=\"/Locations/" + DBResult["LocationID"].ToString() + "/" + DBResult["LocationImage"].ToString().Replace(".jpg", "-64x64.jpg") + "\"></td><td>" + DBResult["LocationID"].ToString() + "</td><td>" + DBResult["Title"].ToString() + "</td><td><a class=\"btn-default btn\" href=\"/LocationDetails.aspx?LocationID=" + DBResult["LocationID"].ToString() + "\">View</a></td></tr>";

                }

                DBConnection.Close();

                // Contacts

                DBConnection.Open();

                DBCommand.CommandText = "select ContactID, Name, Company from Contacts  order by Name Asc;";

                DBResult = DBCommand.ExecuteReader();

                ListItem list = new ListItem();
                list.Text = "Select Contact";
                list.Value = "";

                ContactsDropDownList.Items.Add(list);

                while (DBResult.Read())
                {

                    list = new ListItem();
                    list.Text = DBResult["Name"].ToString() + " (" + DBResult["Company"].ToString() + ")";
                    list.Value = DBResult["ContactID"].ToString();

                    ContactsDropDownList.Items.Add(list);

                }

                DBResult.Close();

                DBConnection.Close();

                // TravelZoneDropDownList

                DBConnection.Open();

                DBCommand.CommandText = "select * from TravelZones order by Value Asc;";

                DBResult = DBCommand.ExecuteReader();

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

                TravelZoneDropDownList.Items.Add(list);

                while (DBResult.Read())
                {

                    TravelZoneDropDownList.Items.Add(DBResult["Value"].ToString());

                }

                DBResult.Close();

                DBConnection.Close();

                // Countries

                DBConnection.Open();

                DBCommand.CommandText = "select Country from Countries order by Country Asc;";

                DBResult = DBCommand.ExecuteReader();

                list = new ListItem();
                list.Text = "Select Country";
                list.Value = "";

                Country.Items.Add(list);

                while (DBResult.Read())
                {

                    Country.Items.Add(DBResult["Country"].ToString());

                }

                DBResult.Close();

                DBConnection.Close();

                // Counties

                DBConnection.Open();

                DBCommand.CommandText = "select Counties.RecordID, Counties.County, ParentCounties.County as ParentCounty from Counties left join Counties as ParentCounties on ParentCounties.RecordID = Counties.Parent where not Counties.Parent = '0' order by Counties.Parent Asc, Counties.County Asc;";

                DBResult = DBCommand.ExecuteReader();

                DataTable myData = new DataTable();

                myData.Load(DBResult);

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

                DBResult.Close();

                DBConnection.Close();

                CountyDDL.DataSource = myview;
                CountyDDL.DataTextField = "County";
                CountyDDL.DataValueField = "County";
                CountyDDL.DataGroupField = "ParentCounty";
                CountyDDL.DataBind();

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

                CountyDDL.Items.Add(list);

                // Populate Checkbox lists

                // Facilities

                DBConnection.Open();

                DBCommand.CommandText = "select * from facilities order by Value asc;";

                DBResult = DBCommand.ExecuteReader();

                while (DBResult.Read())
                {
                    FacilitiesCheckBoxList.Items.Add(DBResult["Value"].ToString());
                }

                DBResult.Close();
                DBConnection.Close();

                // ParkingCheckBoxList

                DBConnection.Open();

                DBCommand.CommandText = "select * from parking order by Value asc;";

                DBResult = DBCommand.ExecuteReader();

                while (DBResult.Read())
                {
                    ParkingCheckBoxList.Items.Add(DBResult["Value"].ToString());
                }

                DBResult.Close();
                DBConnection.Close();

                // Kitchen Types

                DBConnection.Open();

                DBCommand.CommandText = "select * from kitchentypes order by Value asc;";

                DBResult = DBCommand.ExecuteReader();

                while (DBResult.Read())
                {
                    KitchenTypeCheckBoxList.Items.Add(DBResult["Value"].ToString());
                }

                DBResult.Close();
                DBConnection.Close();

                // Bedroom Types

                DBConnection.Open();

                DBCommand.CommandText = "select * from bedroomtypes order by Value asc;";

                DBResult = DBCommand.ExecuteReader();

                while (DBResult.Read())
                {
                    BedroomTypeCheckBoxList.Items.Add(DBResult["Value"].ToString());
                }

                DBResult.Close();
                DBConnection.Close();

                // Bathroom Types

                DBConnection.Open();

                DBCommand.CommandText = "select * from Bathroomtypes order by Value asc;";

                DBResult = DBCommand.ExecuteReader();

                while (DBResult.Read())
                {
                    BathroomTypeCheckBoxList.Items.Add(DBResult["Value"].ToString());
                }

                DBResult.Close();
                DBConnection.Close();

                // Rooms Types

                DBConnection.Open();

                DBCommand.CommandText = "select * from Rooms order by Value asc;";

                DBResult = DBCommand.ExecuteReader();

                while (DBResult.Read())
                {
                    RoomsCheckBoxList.Items.Add(DBResult["Value"].ToString());
                }

                DBResult.Close();
                DBConnection.Close();

                // KitchenFacilities Types

                DBConnection.Open();

                DBCommand.CommandText = "select * from KitchenFacilities order by Value asc;";

                DBResult = DBCommand.ExecuteReader();

                while (DBResult.Read())
                {
                    KitchenFacilitiesCheckBoxList.Items.Add(DBResult["Value"].ToString());
                }

                DBResult.Close();
                DBConnection.Close();

                // Interior Features

                DBConnection.Open();

                DBCommand.CommandText = "select * from InteriorFeatures order by Value asc;";

                DBResult = DBCommand.ExecuteReader();

                while (DBResult.Read())
                {
                    InteriorFeaturesCheckBoxList.Items.Add(DBResult["Value"].ToString());
                }

                DBResult.Close();
                DBConnection.Close();

                // Floors

                DBConnection.Open();

                DBCommand.CommandText = "select * from Floors order by Value asc;";

                DBResult = DBCommand.ExecuteReader();

                while (DBResult.Read())
                {
                    FloorsCheckBoxList.Items.Add(DBResult["Value"].ToString());
                }

                DBResult.Close();
                DBConnection.Close();

                // WallsAndWindows

                DBConnection.Open();

                DBCommand.CommandText = "select * from WindowsAndWalls order by Value asc;";

                DBResult = DBCommand.ExecuteReader();

                while (DBResult.Read())
                {
                    WallsAndWindowsCheckBoxList.Items.Add(DBResult["Value"].ToString());
                }

                DBResult.Close();
                DBConnection.Close();

                // Views

                DBConnection.Open();

                DBCommand.CommandText = "select * from Views order by Value asc;";

                DBResult = DBCommand.ExecuteReader();

                while (DBResult.Read())
                {
                    ViewsCheckBoxList.Items.Add(DBResult["Value"].ToString());

                }

                DBResult.Close();
                DBConnection.Close();

                // ExteriorFeatures

                DBConnection.Open();

                DBCommand.CommandText = "select * from ExteriorTypes order by Value asc;";

                DBResult = DBCommand.ExecuteReader();

                while (DBResult.Read())
                {
                    ExteriorFeaturesCheckBoxList.Items.Add(DBResult["Value"].ToString());
                }

                DBResult.Close();
                DBConnection.Close();

                if (objLocation.Removed == "1")
                {
                    RestoreBTN.Visible = true;
                    RemoveBtn.Visible = false;
                }

                //if (string.IsNullOrEmpty(objLocation.LocationID))
                //{
                //    RemoveBtn.Visible = false;

                //}

                Notes.Text = objLocation.Notes;
                InteriorDescription.Text = objLocation.InteriorDescription;
                ExteriorDescription.Text = objLocation.ExteriorDescription;
                NoBedrooms.Text = objLocation.NoBedrooms.ToString();
                NoBathrooms.Text = objLocation.NoBathrooms.ToString();

                LocationTitle.Text = objLocation.Title;
                LocationID.Text = objLocation.LocationID;
                RecordID.Value = objLocation.RecordID.ToString();
                KitchenDescription.Text = objLocation.KitchenDescription.ToString();
                Keywords.Text = objLocation.Keywords;

                Address.Text = objLocation.Address;
                Street.Text = objLocation.Street;
                Town.Text = objLocation.Town;
                Postcode.Text = objLocation.Postcode;
                CountyDDL.SelectedValue = objLocation.County;
                Country.SelectedValue = objLocation.Country;

                AgentID.SelectedValue = objLocation.AgentID;

                AvgDayRate.Text = objLocation.AvgDayRate.ToString();

                LocationVideo.Text = objLocation.LocationVideo;

                if (objLocation.RecordID == 0)
                {
                    objLocation.ContactID = SelectedContact;
                }

                ContactsDropDownList.SelectedValue = objLocation.ContactID;

                TravelZoneDropDownList.SelectedValue = objLocation.TravelZone;

                ShortDescription.Text = objLocation.ShortDescription;

                LocationCompany.Text = objLocation.LocationCompany;
                LocationTel.Text = objLocation.LocationTel;

                TelLiteral.Text = objLocation.Tel;
                MobileLiteral.Text = objLocation.Mobile;
                CompanyLiteral.Text = objLocation.Company;

                if (objLocation.VATRegistered == "1")
                {
                    VATRegisteredLiteral.Text = "Yes";
                }
                else
                {
                    VATRegisteredLiteral.Text = "No";
                }

                EmailLiteral.Text = "<a href=\"mailto:" + objLocation.Email + "\">" + objLocation.Email + "&nbsp;<i class=\"fa fa-envelope\" title=\"Contact Details\"></i></a>";

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

                CopyContactDetailsLiteral.Text = "<script>";
                CopyContactDetailsLiteral.Text += "function doCopyContactDetails()";
                CopyContactDetailsLiteral.Text += "{";
                if (!string.IsNullOrEmpty(objContactDetails.Tel)) CopyContactDetailsLiteral.Text += "document.getElementById('ContentPlaceHolder1_LocationTel').value = '" + objContactDetails.Tel + "';";
                if (!string.IsNullOrEmpty(objContactDetails.Company)) CopyContactDetailsLiteral.Text += "document.getElementById('ContentPlaceHolder1_LocationCompany').value = '" + objContactDetails.Company + "';";
                if (!string.IsNullOrEmpty(objContactDetails.Address)) CopyContactDetailsLiteral.Text += "document.getElementById('ContentPlaceHolder1_Address').value = '" + objContactDetails.Address + "';";
                if (!string.IsNullOrEmpty(objContactDetails.Street)) CopyContactDetailsLiteral.Text += "document.getElementById('ContentPlaceHolder1_Street').value = '" + objContactDetails.Street + "';";
                if (!string.IsNullOrEmpty(objContactDetails.Town)) CopyContactDetailsLiteral.Text += "document.getElementById('ContentPlaceHolder1_Town').value = '" + objContactDetails.Town + "';";

                if (!string.IsNullOrEmpty(objContactDetails.County)) CopyContactDetailsLiteral.Text += "document.getElementById('ContentPlaceHolder1_CountyDDL').value = '" + objContactDetails.County + "';";

                if (!string.IsNullOrEmpty(objContactDetails.PostCode)) CopyContactDetailsLiteral.Text += "document.getElementById('ContentPlaceHolder1_Postcode').value = '" + objContactDetails.PostCode + "';";
                if (!string.IsNullOrEmpty(objContactDetails.Country)) CopyContactDetailsLiteral.Text += "document.getElementById('ContentPlaceHolder1_Country').value = '" + objContactDetails.Country + "';";
                CopyContactDetailsLiteral.Text += "}";
                CopyContactDetailsLiteral.Text += "</script>";

                if (objLocation.WithInM25 == "Yes" || objLocation.WithInM25 == "True")
                {
                    WithInM25.Checked = true;
                }

                if (objLocation.Featured == "Yes")
                {
                    Featured.Checked = true;
                }

                if (objLocation.Approved == "1" || objLocation.Approved == "True")
                {
                    Approved.Checked = true;

                    DateTime DateResult;

                    if (!string.IsNullOrEmpty(objLocation.ApprovedDate))
                    {
                        if (DateTime.TryParse(objLocation.ApprovedDate, out DateResult))
                        {
                            ApprovedDate.Text = DateResult.ToShortDateString();
                        }
                        else
                        {
                            ApprovedDate.Text = DateTime.Now.ToShortDateString();
                        }
                    }
                    else
                    {
                        ApprovedDate.Text = DateTime.Now.ToShortDateString();
                    }

                }

                string thisPath = Server.MapPath("~/Locations/") + "/" + LocationID.Text;

                if (!Directory.Exists(thisPath))
                {
                    System.IO.Directory.CreateDirectory(thisPath);
                }

                if (string.IsNullOrEmpty(LocationID.Text) && objLocation.RecordID > 0)
                {
                    LocationID.ReadOnly = false;
                }

                /////////////////////////////////////////////////////////////////////////////

                // Select Options

                foreach (ListItem item in FacilitiesCheckBoxList.Items)
                {

                    if (objLocation.Facilities.Contains(item.Value))
                    {
                        item.Selected = true;
                    }
                }

                foreach (ListItem item in ParkingCheckBoxList.Items)
                {

                    if (objLocation.Parking.Contains(item.Value))
                    {
                        item.Selected = true;
                    }
                }

                foreach (ListItem item in KitchenTypeCheckBoxList.Items)
                {

                    if (objLocation.KitchenType.Contains(item.Value))
                    {
                        item.Selected = true;
                    }
                }

                foreach (ListItem item in BedroomTypeCheckBoxList.Items)
                {

                    if (objLocation.BedroomTypes.Contains(item.Value))
                    {
                        item.Selected = true;
                    }
                }

                foreach (ListItem item in BathroomTypeCheckBoxList.Items)
                {

                    if (objLocation.BathroomTypes.Contains(item.Value))
                    {
                        item.Selected = true;
                    }
                }

                foreach (ListItem item in RoomsCheckBoxList.Items)
                {

                    if (objLocation.Rooms.Contains(item.Value))
                    {
                        item.Selected = true;
                    }
                }

                foreach (ListItem item in KitchenFacilitiesCheckBoxList.Items)
                {

                    if (objLocation.KitchenFacilities.Contains(item.Value))
                    {
                        item.Selected = true;
                    }
                }

                foreach (ListItem item in InteriorFeaturesCheckBoxList.Items)
                {

                    if (objLocation.InteriorFeatures.Contains(item.Value))
                    {
                        item.Selected = true;
                    }
                }

                foreach (ListItem item in FloorsCheckBoxList.Items)
                {

                    if (objLocation.Floors.Contains(item.Value))
                    {
                        item.Selected = true;
                    }
                }

                foreach (ListItem item in WallsAndWindowsCheckBoxList.Items)
                {

                    if (objLocation.WallsAndWindows.Contains(item.Value))
                    {
                        item.Selected = true;
                    }
                }

                foreach (ListItem item in ViewsCheckBoxList.Items)
                {

                    if (objLocation.Views.Contains(item.Value))
                    {
                        item.Selected = true;
                    }
                }

                foreach (ListItem item in ExteriorFeaturesCheckBoxList.Items)
                {

                    if (objLocation.ExteriorFeatures.Contains(item.Value))
                    {
                        item.Selected = true;
                    }
                }

            }

            if (!string.IsNullOrEmpty(objLocation.LocationID))
            {
                UploadPanel.Visible = true;
            }

            // Get Images

            //    GalleryLiteral.Text = "";

            // gallery

            DBCommand = DBConnection.CreateCommand();

            if (!IsPostBack)
            {

                ArrayList values = new ArrayList();
                DBConnection.Open();

                DBCommand.CommandText = "select Image, IsResultImage, Target from LocationImages where LocationID = '" + UK_Film_Location_Class.UKFilmLocation.makeSQLSafe(LocationID.Text) + "' order by ImageOrder asc;";

                DBResult = DBCommand.ExecuteReader();

                DataTable dt = new DataTable();

                dt.Columns.Add("ID");
                dt.Columns.Add("Data");
                dt.Columns.Add("Image");

                int myCnt  = 0;

                while (DBResult.Read())
                {
                    string isResult = "";
                    string RadioBTN = "";

                    if (DBResult["IsResultImage"].ToString() == "1")
                    {
                        isResult = " checked ";
                    }

                    string thisMod = "";

                    myCnt++;

                    //RadioBTN = "<select onchange=\"doImageTarget('" + DBResult["Image"].ToString() + "', this.value);\">";

                    //if (DBResult["Target"].ToString() == "") thisMod = " selected ";
                    //else thisMod = "";
                    //RadioBTN += "<option " + thisMod + " value=\"\">None</option>";

                    //if (DBResult["Target"].ToString() == "Kitchen") thisMod = " selected ";
                    //else thisMod = "";
                    //RadioBTN += "<option " + thisMod + " value=\"Kitchen\">Kitchen</option>";

                    //if (DBResult["Target"].ToString() == "Warehouse") thisMod = " selected ";
                    //else thisMod = "";
                    //RadioBTN += "<option " + thisMod + " value=\"Warehouse\">Warehouse</option>";

                    //RadioBTN += "</select>";

                    string thisTarget = "";
                    thisTarget = DBResult["Target"].ToString();
                    if (string.IsNullOrEmpty(thisTarget)) thisTarget = "None";

                    RadioBTN = "<script>function do" + myCnt + "() { if (document.getElementById('Droplist_" + myCnt + "').style.display == 'block') document.getElementById('Droplist_" + myCnt + "').style.display = 'none'; else document.getElementById('Droplist_" + myCnt + "').style.display = 'block'; }</script><div onclick=\"do" + myCnt + "();\"  id=\"TargetSelector_" + myCnt + "\" style=\"height: 25px; width: 100%; display: block; background-color: #ffffff; border-width: 1px; border-color: #000000; border-style: solid; cursor: pointer;\"><i class=\"fa fa-arrow-circle-o-down\"></i> " + thisTarget + "</div><div id=\"Droplist_" + myCnt + "\" style=\"display: none; background-color: #ffffff; width: 100%; height: 100px; overflow-y: scroll; overflow-x: hidden; font-size: 12px;\">";

                    if (DBResult["Target"].ToString() == "") thisMod = " checked ";
                    else thisMod = "";

                    RadioBTN += "<input " + thisMod + " onclick=\"doImageTarget('" + DBResult["Image"].ToString() + "', ''); document.getElementById('TargetSelector_" + myCnt + "').innerHTML = 'None'; document.getElementById('Droplist_" + myCnt + "').style.display = 'none';\" type=\"radio\" id=\"" + DBResult["Image"].ToString() + "_None\" name=\"" + DBResult["Image"].ToString() + "\" value=\"\">None";

                    // Exterior

                    if (DBResult["Target"].ToString() == "Exterior") thisMod = " checked ";
                    else thisMod = "";

                    RadioBTN += "<br /><input " + thisMod + " onclick=\"doImageTarget('" + DBResult["Image"].ToString() + "', 'Exterior'); document.getElementById('TargetSelector_" + myCnt + "').innerHTML = 'Exterior'; document.getElementById('Droplist_" + myCnt + "').style.display = 'none';\" type=\"radio\" id=\"" + DBResult["Image"].ToString() + "_Exterior\" name=\"" + DBResult["Image"].ToString() + "\" value=\"Exterior\">Exterior";
                    // Gardens

                    if (DBResult["Target"].ToString() == "Gardens") thisMod = " checked ";
                    else thisMod = "";

                    RadioBTN += "<br /><input " + thisMod + " onclick=\"doImageTarget('" + DBResult["Image"].ToString() + "', 'Gardens'); document.getElementById('TargetSelector_" + myCnt + "').innerHTML = 'Gardens'; document.getElementById('Droplist_" + myCnt + "').style.display = 'none';\" type=\"radio\" id=\"" + DBResult["Image"].ToString() + "_Gardens\" name=\"" + DBResult["Image"].ToString() + "\" value=\"Gardens\">Gardens";

                    // Livingroom

                    if (DBResult["Target"].ToString() == "Livingroom") thisMod = " checked ";
                    else thisMod = "";

                    RadioBTN += "<br /><input " + thisMod + " onclick=\"doImageTarget('" + DBResult["Image"].ToString() + "', 'Livingroom'); document.getElementById('TargetSelector_" + myCnt + "').innerHTML = 'Livingroom'; document.getElementById('Droplist_" + myCnt + "').style.display = 'none';\" type=\"radio\" id=\"" + DBResult["Image"].ToString() + "_Livingroom\" name=\"" + DBResult["Image"].ToString() + "\" value=\"Livingroom\">Livingroom";

                    // Kitchen

                    if (DBResult["Target"].ToString() == "Kitchen") thisMod = " checked ";
                    else thisMod = "";

                    RadioBTN += "<br /><input " + thisMod + " onclick=\"doImageTarget('" + DBResult["Image"].ToString() + "', 'Kitchen'); document.getElementById('TargetSelector_" + myCnt + "').innerHTML = 'Kitchen'; document.getElementById('Droplist_" + myCnt + "').style.display = 'none';\" type=\"radio\" id=\"" + DBResult["Image"].ToString() + "_Kitchen\" name=\"" + DBResult["Image"].ToString() + "\" value=\"Kitchen\">Kitchen";

                    // Bedroom

                    if (DBResult["Target"].ToString() == "Bedroom") thisMod = " checked ";
                    else thisMod = "";

                    RadioBTN += "<br /><input " + thisMod + " onclick=\"doImageTarget('" + DBResult["Image"].ToString() + "', 'Bedroom'); document.getElementById('TargetSelector_" + myCnt + "').innerHTML = 'Bedroom'; document.getElementById('Droplist_" + myCnt + "').style.display = 'none';\" type=\"radio\" id=\"" + DBResult["Image"].ToString() + "_Bedroom\" name=\"" + DBResult["Image"].ToString() + "\" value=\"Bedroom\">Bedroom";

                    // Bathroom

                    if (DBResult["Target"].ToString() == "Bathroom") thisMod = " checked ";
                    else thisMod = "";

                    RadioBTN += "<br /><input " + thisMod + " onclick=\"doImageTarget('" + DBResult["Image"].ToString() + "', 'Bathroom'); document.getElementById('TargetSelector_" + myCnt + "').innerHTML = 'Bathroom'; document.getElementById('Droplist_" + myCnt + "').style.display = 'none';\" type=\"radio\" id=\"" + DBResult["Image"].ToString() + "_Bathroom\" name=\"" + DBResult["Image"].ToString() + "\" value=\"Bathroom\">Bathroom";

                    // Corridor

                    if (DBResult["Target"].ToString() == "Corridor") thisMod = " checked ";
                    else thisMod = "";

                    RadioBTN += "<br /><input " + thisMod + " onclick=\"doImageTarget('" + DBResult["Image"].ToString() + "', 'Corridor'); document.getElementById('TargetSelector_" + myCnt + "').innerHTML = 'Corridor'; document.getElementById('Droplist_" + myCnt + "').style.display = 'none';\" type=\"radio\" id=\"" + DBResult["Image"].ToString() + "_Corridor\" name=\"" + DBResult["Image"].ToString() + "\" value=\"Corridor\">Corridor";

                    // Stairway

                    if (DBResult["Target"].ToString() == "Stairway") thisMod = " checked ";
                    else thisMod = "";

                    RadioBTN += "<br /><input " + thisMod + " onclick=\"doImageTarget('" + DBResult["Image"].ToString() + "', 'Stairway'); document.getElementById('TargetSelector_" + myCnt + "').innerHTML = 'Stairway'; document.getElementById('Droplist_" + myCnt + "').style.display = 'none';\" type=\"radio\" id=\"" + DBResult["Image"].ToString() + "_Corridor\" name=\"" + DBResult["Image"].ToString() + "\" value=\"Stairway\">Stairway";

                    // Restaurant

                    if (DBResult["Target"].ToString() == "Restaurant") thisMod = " checked ";
                    else thisMod = "";

                    RadioBTN += "<br /><input " + thisMod + " onclick=\"doImageTarget('" + DBResult["Image"].ToString() + "', 'Restaurant'); document.getElementById('TargetSelector_" + myCnt + "').innerHTML = 'Restaurant'; document.getElementById('Droplist_" + myCnt + "').style.display = 'none';\" type=\"radio\" id=\"" + DBResult["Image"].ToString() + "_Restaurant\" name=\"" + DBResult["Image"].ToString() + "\" value=\"Restaurant\">Restaurant";

                    // Shop

                    if (DBResult["Target"].ToString() == "Shop") thisMod = " checked ";
                    else thisMod = "";

                    RadioBTN += "<br /><input " + thisMod + " onclick=\"doImageTarget('" + DBResult["Image"].ToString() + "', 'Shop'); document.getElementById('TargetSelector_" + myCnt + "').innerHTML = 'Shop'; document.getElementById('Droplist_" + myCnt + "').style.display = 'none';\" type=\"radio\" id=\"" + DBResult["Image"].ToString() + "_Shop\" name=\"" + DBResult["Image"].ToString() + "\" value=\"Shop\">Shop";

                    // Pub / Bar

                    if (DBResult["Target"].ToString() == "Pub / Bar") thisMod = " checked ";
                    else thisMod = "";

                    RadioBTN += "<br /><input " + thisMod + " onclick=\"doImageTarget('" + DBResult["Image"].ToString() + "', 'Pub / Bar'); document.getElementById('TargetSelector_" + myCnt + "').innerHTML = 'Pub / Bar'; document.getElementById('Droplist_" + myCnt + "').style.display = 'none';\" type=\"radio\" id=\"" + DBResult["Image"].ToString() + "_Pub_Bar\" name=\"" + DBResult["Image"].ToString() + "\" value=\"Pub / Bar\">Pub / Bar";

                    // Office

                    if (DBResult["Target"].ToString() == "Office") thisMod = " checked ";
                    else thisMod = "";

                    RadioBTN += "<br /><input " + thisMod + " onclick=\"doImageTarget('" + DBResult["Image"].ToString() + "', 'Office'); document.getElementById('TargetSelector_" + myCnt + "').innerHTML = 'Office'; document.getElementById('Droplist_" + myCnt + "').style.display = 'none';\" type=\"radio\" id=\"" + DBResult["Image"].ToString() + "_Office\" name=\"" + DBResult["Image"].ToString() + "\" value=\"Office\">Office";

                    // Studio

                    if (DBResult["Target"].ToString() == "Studio") thisMod = " checked ";
                    else thisMod = "";

                    RadioBTN += "<br /><input " + thisMod + " onclick=\"doImageTarget('" + DBResult["Image"].ToString() + "', 'Studio'); document.getElementById('TargetSelector_" + myCnt + "').innerHTML = 'Studio'; document.getElementById('Droplist_" + myCnt + "').style.display = 'none';\" type=\"radio\" id=\"" + DBResult["Image"].ToString() + "_Studio\" name=\"" + DBResult["Image"].ToString() + "\" value=\"Studio\">Studio";

                    // Warehouse

                    if (DBResult["Target"].ToString() == "Warehouse") thisMod = " checked ";
                    else thisMod = "";

                    RadioBTN += "<br /><input " + thisMod + " onclick=\"doImageTarget('" + DBResult["Image"].ToString() + "', 'Warehouse'); document.getElementById('TargetSelector_" + myCnt + "').innerHTML = 'Warehouse'; document.getElementById('Droplist_" + myCnt + "').style.display = 'none';\" type=\"radio\" id=\"" + DBResult["Image"].ToString() + "_Warehouse\" name=\"" + DBResult["Image"].ToString() + "\" value=\"Warehouse\">Warehouse";

                    // Bunker

                    if (DBResult["Target"].ToString() == "Bunker") thisMod = " checked ";
                    else thisMod = "";

                    RadioBTN += "<br /><input " + thisMod + " onclick=\"doImageTarget('" + DBResult["Image"].ToString() + "', 'Bunker'); document.getElementById('TargetSelector_" + myCnt + "').innerHTML = 'Bunker'; document.getElementById('Droplist_" + myCnt + "').style.display = 'none';\" type=\"radio\" id=\"" + DBResult["Image"].ToString() + "_Bunker\" name=\"" + DBResult["Image"].ToString() + "\" value=\"Bunker\">Bunker";

                    // Swimming pool

                    if (DBResult["Target"].ToString() == "Swimming-pool") thisMod = " checked ";
                    else thisMod = "";

                    RadioBTN += "<br /><input " + thisMod + " onclick=\"doImageTarget('" + DBResult["Image"].ToString() + "', 'Swimming-pool'); document.getElementById('TargetSelector_" + myCnt + "').innerHTML = 'Swimming-pool'; document.getElementById('Droplist_" + myCnt + "').style.display = 'none';\" type=\"radio\" id=\"" + DBResult["Image"].ToString() + "_Swimming-pool\" name=\"" + DBResult["Image"].ToString() + "\" value=\"Swimming-pool\">Swimming-pool";

                    // Ruins

                    if (DBResult["Target"].ToString() == "Ruins") thisMod = " checked ";
                    else thisMod = "";

                    RadioBTN += "<br /><input " + thisMod + " onclick=\"doImageTarget('" + DBResult["Image"].ToString() + "', 'Ruins'); document.getElementById('TargetSelector_" + myCnt + "').innerHTML = 'Ruins'; document.getElementById('Droplist_" + myCnt + "').style.display = 'none';\" type=\"radio\" id=\"" + DBResult["Image"].ToString() + "_Ruins\" name=\"" + DBResult["Image"].ToString() + "\" value=\"Ruins\">Ruins";

                    // Open-space

                    if (DBResult["Target"].ToString() == "Open-space") thisMod = " checked ";
                    else thisMod = "";

                    RadioBTN += "<br /><input " + thisMod + " onclick=\"doImageTarget('" + DBResult["Image"].ToString() + "', 'Open-space'); document.getElementById('TargetSelector_" + myCnt + "').innerHTML = 'Open-space'; document.getElementById('Droplist_" + myCnt + "').style.display = 'none';\" type=\"radio\" id=\"" + DBResult["Image"].ToString() + "_Open-space\" name=\"" + DBResult["Image"].ToString() + "\" value=\"Open-space\">Open-space";

                    // Car-park

                    if (DBResult["Target"].ToString() == "Car-park") thisMod = " checked ";
                    else thisMod = "";

                    RadioBTN += "<br /><input " + thisMod + " onclick=\"doImageTarget('" + DBResult["Image"].ToString() + "', 'Car-park'); document.getElementById('TargetSelector_" + myCnt + "').innerHTML = 'Car-park'; document.getElementById('Droplist_" + myCnt + "').style.display = 'none';\" type=\"radio\" id=\"" + DBResult["Image"].ToString() + "_Car-park\" name=\"" + DBResult["Image"].ToString() + "\" value=\"Car-park\">Car-park";

                    // Castle

                    if (DBResult["Target"].ToString() == "Castle") thisMod = " checked ";
                    else thisMod = "";

                    RadioBTN += "<br /><input " + thisMod + " onclick=\"doImageTarget('" + DBResult["Image"].ToString() + "', 'Castle'); document.getElementById('TargetSelector_" + myCnt + "').innerHTML = 'Castle'; document.getElementById('Droplist_" + myCnt + "').style.display = 'none';\" type=\"radio\" id=\"" + DBResult["Image"].ToString() + "_Castle\" name=\"" + DBResult["Image"].ToString() + "\" value=\"Castle\">Castle";

                    // Rooftop

                    if (DBResult["Target"].ToString() == "Rooftop") thisMod = " checked ";
                    else thisMod = "";

                    RadioBTN += "<br /><input " + thisMod + " onclick=\"doImageTarget('" + DBResult["Image"].ToString() + "', 'Rooftop'); document.getElementById('TargetSelector_" + myCnt + "').innerHTML = 'Rooftop'; document.getElementById('Droplist_" + myCnt + "').style.display = 'none';\" type=\"radio\" id=\"" + DBResult["Image"].ToString() + "_Rooftop\" name=\"" + DBResult["Image"].ToString() + "\" value=\"Rooftop\">Rooftop";

                    RadioBTN += "</div>";

                    dt.Rows.Add(DBResult["Image"].ToString(), "<div id=\"" + DBResult["Image"].ToString() + "ImageContainer\"><div style=\"margin-right: 5px; margin-bottom: 5px; width: 128px; height: 128px; float: left;\"><a href=\"/Locations/" + LocationID.Text + "/" + DBResult["Image"].ToString().Replace(".jpg", "-800.jpg") + "\"><img src=\"/Locations/" + LocationID.Text + "/" + DBResult["Image"].ToString().Replace(".jpg", "-128x128.jpg") + "\"></a></div><img style=\"margin-left:  -40px; margin-top: 3px;\" onclick=\"if (confirm('Remove Image?')) { executeRemoteCmd('/RemoveImage.aspx?LocationID=" + LocationID.Text + "&Image=" + DBResult["Image"].ToString() + "'); document.getElementById('" + DBResult["Image"].ToString() + "ImageContainer').style.display= 'none'; }\" style=\"padding-top: 8px;\" src=\"/images/trash-32x32.png\"><input " + isResult + " id=\"" + DBResult["Image"].ToString() + "CheckBox\"  type=\"checkbox\" style=\"margin-left:  -115px;\" onclick=\"doImageSelection('" + DBResult["Image"].ToString() + "', '" + DBResult["Image"].ToString() + "CheckBox');\">&nbsp;<a href=\"/Locations/" + LocationID.Text + "/" + DBResult["Image"].ToString().Replace(".jpg", "-original.jpg") + "\" target=\"_blank\"><i class=\"fa fa-cloud-download\" style=\"color: white;\"></i></a><div style=\"position: absolute;\">" + RadioBTN + "</div></div>", DBResult["Image"].ToString().Replace(".jpg", "")); // Also on 1920

                }

                DBResult.Close();
                DBConnection.Close();

                Gallery.DataSource = dt;
                Gallery.DataBind();
            }

            // Get bookings

            BookingsLabel.Text = "";

            DBConnection.Open();

            DBCommand.CommandText = "select BookingDetails.BookingID, BookingDetails.OpportunityID, opportunitydetails.locationid, locations.title, (select count(*) from BookingDates where BookingDates.BookingID = BookingDetails.BookingID) as NumDays from BookingDetails left join OpportunityDetails on OpportunityDetails.OpportunityID = BookingDetails.OpportunityID left join locations on locations.locationid = opportunitydetails.locationid where OpportunityDetails.locationid = '" + UK_Film_Location_Class.UKFilmLocation.makeSQLSafe(LocationID.Text ) + "' order by BookingDetails.recordid desc;";

            DBResult = DBCommand.ExecuteReader();

            Locations.Text = "";

            while (DBResult.Read())
            {

                // Check Image Exists

                BookingsLabel.Text += "<tr><td>" + DBResult["LocationID"].ToString() + " : " + DBResult["Title"].ToString() + "</td><td>" + DBResult["NumDays"].ToString() + "</td><td><a href=\"/BookLocation.aspx?BookingID=" + DBResult["BookingID"].ToString() + "\" class=\"btn-default btn\">View Booking</a></td></tr>";

            }

            DBResult.Close();
            DBConnection.Close();

            // opportunities

            DBConnection.Open();

            DBCommand.CommandText = "select OpportunityDetails.OpportunityID, OpportunityDetails.ProjectID, OpportunityDetails.LocationID, (select Projectdetails.workingtitle from projectdetails where projectdetails.projectid = opportunitydetails.projectid) as WorkingTitle, OpportunityDetails.RequestDate, OpportunityDetails.ContactID, (select Contacts.Name from Contacts where Contacts.ContactID = OpportunityDetails.ContactID limit 0,1) as ContactName, (select Locations.Title from Locations where Locations.LocationID = OpportunityDetails.LocationID) as locationTitle, (select count(*) as reccount from reccedates where reccedates.opportunityID = OpportunityDetails.OpportunityID) as numrecces from OpportunityDetails where OpportunityDetails.LocationID = '" + objLocation.LocationID + "' order by RecordID desc;";

            DBResult = DBCommand.ExecuteReader();

            Locations.Text = "";

            while (DBResult.Read())
            {
                string isApproved = "";
                string thisRecceDate = "";
                string thisCount = "0";

                if (string.IsNullOrEmpty(DBResult["RequestDate"].ToString()))
                {
                    isApproved = "<i class=\"fa fa-star icon-state-warning\"></i>";
                }
                else
                {
                    thisRecceDate = DBResult["RequestDate"].ToString();
                }

                if (!string.IsNullOrEmpty(DBResult["NumRecces"].ToString()))
                {
                    thisCount = DBResult["NumRecces"].ToString();
                }

                // Check Image Exists

                Locations.Text += "<tr><td scope=\"row\">" + isApproved + "</td><td>" + thisRecceDate + "</td><td><a href=\"/ProjectDetails.aspx?ProjectID=" + DBResult["ProjectID"].ToString() + "\">" + DBResult["WorkingTitle"].ToString() + "&nbsp;<i class=\"fa fa-external-link-square\" title=\"Project Details\"></i></a></td><td><a href=\"/ContactDetails.aspx?ContactID=" + DBResult["ContactID"].ToString() + "\">" + DBResult["ContactName"].ToString() + "&nbsp;<i class=\"fa fa-external-link-square\" title=\"Contact Details\"></i></a></td><td>" + thisCount + "</td><td><a href=\"/OpportunityDetails.aspx?OpportunityID=" + DBResult["OpportunityID"].ToString() + "\" class=\"btn-default btn\">View</a></td></tr>";

            }

            DBResult.Close();
            DBConnection.Close();

            DBConnection.Open();

            DBCommand.CommandText = "select DISTINCT(Query) as ThisQuery, (select count(*) from LocationQueries where LocationID = '" + objLocation.LocationID + "' and LocationQueries.Query = ThisQuery) as NumRecs from LocationQueries where LocationID = '" + objLocation.LocationID + "' order by NumRecs desc limit 0, 10;";

            DBResult = DBCommand.ExecuteReader();

            TopQueries.Text = "<br><h4>Top 10 Queries</h4><ol>";

            while (DBResult.Read())
            {
                TopQueries.Text += "<li>" + DBResult["ThisQuery"] + " (" + DBResult["NumRecs"] + ")</li>";
            }

            TopQueries.Text += "</ol>";

            DBResult.Close();
            DBConnection.Close();

            DBConnection.Dispose();
        }
コード例 #5
0
        protected void SaveBtn_Click(object sender, EventArgs e)
        {
            UK_Film_Location_Class.LocationDetails objLocation = new UK_Film_Location_Class.LocationDetails();

            UK_Film_Location_Class.Counties objCounty = new UK_Film_Location_Class.Counties();

            // Check Fields

            bool isOK = true;

            //if (string.IsNullOrEmpty(LocationID.Text))
            //{
            //    isOK = false;
            //    LocationIDPanel.CssClass = "has-error";
            //}

            if (string.IsNullOrEmpty(LocationTitle.Text))
            {
                isOK = false;
                TitlePanel.CssClass = "has-error";
            }
            if (string.IsNullOrEmpty(ShortDescription.Text))
            {
                isOK = false;
                ShortDescriptionPanel.CssClass = "has-error";
            }

            if (string.IsNullOrEmpty(ContactsDropDownList.SelectedValue))
            {
                isOK = false;

                ContactIDPanel.CssClass = "has-error";
            }

            if (string.IsNullOrEmpty(AvgDayRate.Text))
            {
                isOK = false;

                AvgDayRatePanel.CssClass = "has-error";
            }

            //      if (string.IsNullOrEmpty(Address.Text)) isOK = false;
            //      if (string.IsNullOrEmpty(Street.Text)) isOK = false;
            //      if (string.IsNullOrEmpty(Town.Text)) isOK = false;

            //if (string.IsNullOrEmpty(CountyDDL.SelectedValue))
            //{
            //    isOK = false;

            //    CountyPanel.CssClass = "has-error";
            //}

            if (string.IsNullOrEmpty(Country.SelectedValue))
            {
                isOK = false;

                CountryPanel.CssClass = "has-error";
            }

            //      if (string.IsNullOrEmpty(Postcode.Text)) isOK = false;

            if (!isOK) ErrorLabel.Text = "<div class=\"alert alert-danger\" role=\"alert\"><strong>Save Failed!</strong> Please check the details and try again.</div>";
            else
            {
                ErrorLabel.Text = "<div class=\"alert alert-success\" role=\"alert\"><strong>Save OK!</strong></div>";
                //if (!string.IsNullOrEmpty(CountyDDL.SelectedValue))
                //{

                //    string Ref = objCounty.getRefPrefixFromCountyID(CountyDDL.SelectedValue);

                //    objLocation.LocationID = Ref + objLocation.getNextRef();
                //    LocationID.Text = objLocation.LocationID;
                //}

                if (!string.IsNullOrEmpty(Request.QueryString["RecordID"]) && string.IsNullOrEmpty(objLocation.LocationID))
                {
                    // legacy location
                    objLocation.getLocationFromRecordID(Request.QueryString["RecordID"]);
                    objLocation.LocationID = LocationID.Text;
                }
                else
                {

                    if (!string.IsNullOrEmpty(LocationID.Text))
                    {
                        objLocation.getLocationFromID(LocationID.Text);
                    }
                    else
                    {

                        if (!string.IsNullOrEmpty(Request.QueryString["LocationID"]))
                        {
                            objLocation.getLocationFromID(Request.QueryString["LocationID"]);
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(Request.QueryString["RecordID"]))
                            {
                                objLocation.getLocationFromRecordID(Request.QueryString["RecordID"]);

                            }
                        }
                    }
                }

                objLocation.Title = LocationTitle.Text;
                // objLocation.TypeID =
                objLocation.ShortDescription = ShortDescription.Text;
                objLocation.Address = Address.Text;
                objLocation.Street = Street.Text;
                objLocation.Town = Town.Text;
                objLocation.LocationTel = LocationTel.Text;
                objLocation.LocationCompany = LocationCompany.Text;

                objLocation.County = CountyDDL.SelectedValue;
                objLocation.Postcode = Postcode.Text;
                objLocation.Country = Country.SelectedValue;
                objLocation.ContactID = ContactsDropDownList.SelectedValue;
                objLocation.TravelZone = TravelZoneDropDownList.SelectedValue;

                objLocation.Keywords = Keywords.Text;

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

                CompanyLiteral.Text = objContact.Company;
                EmailLiteral.Text = objContact.Email;
                TelLiteral.Text = objContact.Tel;
                MobileLiteral.Text = objContact.Mobile;

                objLocation.Notes = Notes.Text;
                objLocation.LocationVideo = LocationVideo.Text;
                objLocation.KitchenDescription = KitchenDescription.Text;

                objLocation.AgentID = AgentID.SelectedValue;
                objLocation.AvgDayRate = Convert.ToDouble(AvgDayRate.Text);

                // Items collection
                string myIDList = "";

                // Items collection
                foreach (ListItem item in LocationTypeListBox.Items)
                {
                    if (item.Selected)
                    {
                        myIDList += item.Value + ";";
                    }
                }

                objLocation.TypeID = myIDList;
                myIDList = "";

                foreach (ListItem item in FacilitiesCheckBoxList.Items)
                {
                    if (item.Selected)
                    {
                        myIDList += item.Value + ";";
                    }
                }
                objLocation.Facilities = myIDList;
                myIDList = "";

                foreach (ListItem item in ParkingCheckBoxList.Items)
                {
                    if (item.Selected)
                    {
                        myIDList += item.Value + ";";
                    }
                }
                objLocation.Parking = myIDList;
                myIDList = "";

                objLocation.InteriorDescription = InteriorDescription.Text;

                objLocation.ExteriorDescription = ExteriorDescription.Text;

                foreach (ListItem item in KitchenTypeCheckBoxList.Items)
                {
                    if (item.Selected)
                    {
                        myIDList += item.Value + ";";
                    }
                }
                objLocation.KitchenType = myIDList;
                myIDList = "";

                foreach (ListItem item in KitchenFacilitiesCheckBoxList.Items)
                {
                    if (item.Selected)
                    {
                        myIDList += item.Value + ";";
                    }
                }
                objLocation.KitchenFacilities = myIDList;
                myIDList = "";

                objLocation.NoBedrooms = Convert.ToInt32(NoBedrooms.Text);

                foreach (ListItem item in BedroomTypeCheckBoxList.Items)
                {
                    if (item.Selected)
                    {
                        myIDList += item.Value + ";";
                    }
                }
                objLocation.BedroomTypes = myIDList;
                myIDList = "";

                objLocation.NoBathrooms = Convert.ToInt32(NoBathrooms.Text);

                foreach (ListItem item in BathroomTypeCheckBoxList.Items)
                {
                    if (item.Selected)
                    {
                        myIDList += item.Value + ";";
                    }
                }
                objLocation.BathroomTypes = myIDList;
                myIDList = "";

                foreach (ListItem item in RoomsCheckBoxList.Items)
                {
                    if (item.Selected)
                    {
                        myIDList += item.Value + ";";
                    }
                }
                objLocation.Rooms = myIDList;
                myIDList = "";

                foreach (ListItem item in InteriorFeaturesCheckBoxList.Items)
                {
                    if (item.Selected)
                    {
                        myIDList += item.Value + ";";
                    }
                }
                objLocation.InteriorFeatures = myIDList;
                myIDList = "";

                foreach (ListItem item in FloorsCheckBoxList.Items)
                {
                    if (item.Selected)
                    {
                        myIDList += item.Value + ";";
                    }
                }
                objLocation.Floors = myIDList;
                myIDList = "";

                foreach (ListItem item in WallsAndWindowsCheckBoxList.Items)
                {
                    if (item.Selected)
                    {
                        myIDList += item.Value + ";";
                    }
                }
                objLocation.WallsAndWindows = myIDList;
                myIDList = "";

                foreach (ListItem item in ViewsCheckBoxList.Items)
                {
                    if (item.Selected)
                    {
                        myIDList += item.Value + ";";
                    }
                }
                objLocation.Views = myIDList;
                myIDList = "";

                foreach (ListItem item in ExteriorFeaturesCheckBoxList.Items)
                {
                    if (item.Selected)
                    {
                        myIDList += item.Value + ";";
                    }
                }
                objLocation.ExteriorFeatures = myIDList;
                myIDList = "";

                if (WithInM25.Checked) objLocation.WithInM25 = "Yes";
                else objLocation.WithInM25 = "No";

                if (!Featured.Checked)
                {
                    objLocation.Featured = "No";
                }
                else
                {
                    objLocation.Featured = "Yes";
                }

                if (objLocation.Approved == "1")
                {
                    if (!Approved.Checked)
                    {
                        objLocation.Approved = "0";
                        ApprovedDate.Text = "";
                    }
                }
                else
                {
                    if (objLocation.Approved == "0" && Approved.Checked)
                    {

                        objLocation.Approved = "1";
                        objLocation.ApprovedDate = DateTime.Now.ToString();
                        ApprovedDate.Text = DateTime.Parse(objLocation.ApprovedDate).ToShortDateString();

                        // Send email to contact

                        UK_Film_Location_Class.UKFilmLocation.sendEmail(objContact.Email, "UKFilmLocation.com", "*****@*****.**", "UKFilmLocation.com : Your location listing has been approved!", "<h1>Your location listing has been approved!</h1><p>Hi " + objContact.Name + ",</p><p></p><p>Your location has been approved and is now visible on our website;</p><p><a href=\"http://" + UK_Film_Location_Class.UKFilmLocation.DefaultWebsite + "/Location.aspx?LocationID=" + objLocation.LocationID + "\">http://" + UK_Film_Location_Class.UKFilmLocation.DefaultWebsite + "/Location.aspx?LocationID=" + objLocation.LocationID + "</a></p><p>You can also download a printable PDF brochure of your location by clicking here;</p><p><a href=\"http://" + UK_Film_Location_Class.UKFilmLocation.DefaultWebsite + "/LocationPDF.php?LocationID=" + objLocation.LocationID + "\">http://" + UK_Film_Location_Class.UKFilmLocation.DefaultWebsite + "/LocationPDF.php?LocationID=" + objLocation.LocationID + "</a></p><p>You can add more locations and monitor this location by logging on to our website. Recce appointments for this location and any other locations you may have registered with us can also be viewed on your personal dashboard. <a href=\"http://" + UK_Film_Location_Class.UKFilmLocation.DefaultWebsite + "/Dashboard.aspx\">Click here to login.</a></p><p><b>Thank you.</b></p>");

                        UK_Film_Location_Class.UKFilmLocation.postSocialLink(objLocation.LocationID + " : " + objLocation.Title + " #FilmLocation", objLocation.ShortDescription, "http://" + UK_Film_Location_Class.UKFilmLocation.DefaultWebsite + "/Location.aspx?LocationID=" + objLocation.LocationID + "");

                    }
                    else
                    {
                        objLocation.Approved = "0";
                        ApprovedDate.Text = "";
                    }
                }

                objLocation.saveLocation();

                LocationID.Text = objLocation.LocationID;

                Response.Redirect("/LocationDetails.aspx?LocationID=" + objLocation.LocationID);
            }
        }
コード例 #6
0
        protected void RestoreBTN_Click(object sender, EventArgs e)
        {
            UK_Film_Location_Class.LocationDetails objLocation = new UK_Film_Location_Class.LocationDetails();

            if (!string.IsNullOrEmpty(Request.QueryString["LocationID"]))
            {
                objLocation.getLocationFromID(Request.QueryString["LocationID"]);
            }
            else
            {
                if (!string.IsNullOrEmpty(Request.QueryString["RecordID"]))
                {
                    objLocation.getLocationFromRecordID(Request.QueryString["RecordID"]);

                }
            }

            UK_Film_Location_Class.LocationDetails.restoreLocation(objLocation.RecordID.ToString());
        }
コード例 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Check authorised user!

            string UserEmail = "";

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

            // Read the cookie information and display it.
            if (myTestCookie == null)
            {
                Response.Write("/");
            }
            else
            {
                UserEmail = myTestCookie.Value;

                // Connect to database

                DBConnection = new MySqlConnection(objUKFilmLocation.DBConnect);

                DBCommand = DBConnection.CreateCommand();

                // Perform location analysis

                MessageLiteral.Text = "<p>Location Analysis...</p>";

                int LocationsCount = 0;

                DBConnection.Open();

                DBCommand.CommandText = "select count(*) as numrecs from Locations where Address = '' or Address is null or Postcode = ''  or postcode is null;";

                DBResult = DBCommand.ExecuteReader();

                if (DBResult.Read())
                {
                    LocationsCount = Convert.ToInt32(DBResult["NumRecs"].ToString());
                }

                DBConnection.Close();

                MessageLiteral.Text += "<p>" + LocationsCount + " Locations Need Address Details!</p>";

                // Loop locations and retrieve address details from contacts

                MessageLiteral.Text += "<p>Attempting Address Lookup From Contact...</p>";

                UK_Film_Location_Class.ContactDetails objContact = new UK_Film_Location_Class.ContactDetails();
                UK_Film_Location_Class.LocationDetails objLocation = new UK_Film_Location_Class.LocationDetails();

                DBConnection.Open();

                DBCommand.CommandText = "select * from Locations where Address = '' or Address is null or Postcode = ''  or postcode is null or county = '' or county is null;";

                DBResult = DBCommand.ExecuteReader();

                int SuccessCount = 0;
                int FailCount = 0;
                int ErrorCount = 0;

                string FailMessage = "";
                string SuccessMessage = "";

                while (DBResult.Read())
                {
                    ErrorCount++;

                    objLocation.getLocationFromID(DBResult["LocationID"].ToString());
                    objContact.getContact(DBResult["ContactID"].ToString());

                    if (!string.IsNullOrEmpty(objLocation.County))
                    {
                        objContact.Address = objContact.Address.Replace(", " + objLocation.County, "").Replace("\"", "");
                        objContact.Address = objContact.Address.Replace(objLocation.County, "");
                    }

                    // Check valid contact id
                    if (string.IsNullOrEmpty(DBResult["ContactID"].ToString()))
                    {
                        FailCount += 1;
                        FailMessage += "<li><a href=\"/LocationDetails.aspx?LocationID=" + DBResult["LocationID"].ToString() + "\">" + DBResult["LocationID"].ToString() + " " + DBResult["Title"].ToString() + " does not have a contact!</a><br>";
                    }
                    else
                    {
                        // check contact has address
                        if (string.IsNullOrEmpty(objContact.Address) && string.IsNullOrEmpty(objContact.Street) && string.IsNullOrEmpty(objContact.Town) && string.IsNullOrEmpty(objContact.County) && string.IsNullOrEmpty(objContact.PostCode) )
                        {
                            FailCount += 1;
                            FailMessage += "<li><a href=\"/ContactDetails.aspx?ContactID=" + objContact.ContactID + "\">" + objContact.Name + "</a> does not have an address for location <a href=\"/LocationDetails.aspx?LocationID=" + DBResult["LocationID"].ToString() + "\">" + DBResult["LocationID"].ToString() + " " + DBResult["Title"].ToString() + "</a>!<br>";
                        }
                        else
                        {
                            // is contact address valid?  How do you tell?

                            // is Address empty?
                            if (string.IsNullOrEmpty(objContact.Address))
                            {
                                // next check

                                FailCount += 1;
                                FailMessage += "<li><a href=\"/ContactDetails.aspx?ContactID=" + objContact.ContactID + "\">" + objContact.Name + "</a> does not have an address at all! (<a href=\"/LocationDetails.aspx?LocationID=" + DBResult["LocationID"].ToString() + "\">" + DBResult["LocationID"].ToString() + " " + DBResult["Title"].ToString() + "</a>)<br>";

                            }
                            else
                            {
                                // Is Address valid?
                                if (string.IsNullOrEmpty(objLocation.LocationCompany)) objLocation.LocationCompany = objContact.Company;
                                if (string.IsNullOrEmpty(objLocation.Street)) objLocation.Address = objContact.Street;
                                if (string.IsNullOrEmpty(objLocation.Town)) objLocation.Address = objContact.Town;
                                if (string.IsNullOrEmpty(objLocation.LocationTel)) objLocation.LocationTel = objContact.Tel;

                                // Does contact have postcode?
                                if (string.IsNullOrEmpty(objContact.PostCode))
                                {
                                }
                                else objLocation.Postcode = objContact.PostCode;

                                if (string.IsNullOrEmpty(objContact.Town))
                                {
                                }
                                else objLocation.Postcode = objContact.Town;

                                if (string.IsNullOrEmpty(objContact.Town))
                                {
                                }
                                else objLocation.Postcode = objContact.Town;

                                if (string.IsNullOrEmpty(objContact.Street))
                                {
                                }
                                else objLocation.Postcode = objContact.Street;

                                if (string.IsNullOrEmpty(objLocation.Address))
                                {
                                  //  objLocation.Address = objContact.Address;
                                    SuccessMessage += "<div style=\"padding-top: 50px;\">";
                                    if (string.IsNullOrEmpty(objLocation.Postcode))
                                    {
                                        SuccessMessage += "<p>Working with >" + objContact.Address + "<</p>";

                                        // Assume Address in one line?
                                        string[] Address = objContact.Address.Split(',');

                                        if (Address.Count() > 0)
                                        {
                                            SuccessMessage += "<li><a href=\"/ContactDetails.aspx?ContactID=" + objContact.ContactID + "\">" + objContact.Name + "</a> has an address for location <a href=\"/LocationDetails.aspx?LocationID=" + DBResult["LocationID"].ToString() + "\">" + DBResult["LocationID"].ToString() + " " + DBResult["Title"].ToString() + "</a>! (Address Items Found : " + Address.Count() + ")<br>";
                                            int LineCount = 0;
                                            for (int i = Address.Count() - 1; i >= 0; i--)
                                            {
                                                LineCount++;
                                                SuccessMessage += Address[i] + "<br>";

                                                if (LineCount == 1)
                                                {
                                                    if (string.IsNullOrEmpty(objLocation.Postcode)) objLocation.Postcode = Address[i];
                                                    if (string.IsNullOrEmpty(objContact.PostCode)) objContact.PostCode = Address[i];
                                                }

                                                if (Address.Count() == 2)
                                                {

                                                    if (LineCount == 2)
                                                    {
                                                        if (string.IsNullOrEmpty(objLocation.Address)) objLocation.Address = Address[i];
                                                        objContact.Address = Address[i];
                                                    }
                                                }

                                                if (Address.Count() == 3)
                                                {
                                                    if (LineCount == 1)
                                                    {
                                                        if (string.IsNullOrEmpty(objLocation.Postcode)) objLocation.Postcode = Address[i];
                                                        if (string.IsNullOrEmpty(objContact.PostCode)) objContact.PostCode = Address[i];
                                                    }

                                                    if (LineCount == 2)
                                                    {
                                                        if (string.IsNullOrEmpty(objLocation.Street)) objLocation.Street = Address[i];
                                                        if (string.IsNullOrEmpty(objContact.Street)) objContact.Street = Address[i];
                                                    }
                                                    if (LineCount == 3)
                                                    {
                                                        if (string.IsNullOrEmpty(objLocation.Address)) objLocation.Address = Address[i];
                                                        objContact.Address = Address[i];
                                                    }
                                                }

                                                if (Address.Count() == 4)
                                                {
                                                    if (LineCount == 2)
                                                    {
                                                        if (string.IsNullOrEmpty(objLocation.Town)) objLocation.Town = Address[i];
                                                        if (string.IsNullOrEmpty(objContact.Town)) objContact.Town = Address[i];
                                                    }
                                                    if (LineCount == 3)
                                                    {
                                                        if (string.IsNullOrEmpty(objLocation.Street)) objLocation.Street = Address[i];
                                                        if (string.IsNullOrEmpty(objContact.Street)) objContact.Street = Address[i];
                                                    }
                                                    if (LineCount == 4)
                                                    {
                                                        if (string.IsNullOrEmpty(objLocation.Address)) objLocation.Address = Address[i];
                                                        objContact.Address = Address[i];
                                                    }
                                                }

                                                if (Address.Count() == 5)
                                                {
                                                    if (LineCount == 2)
                                                    {
                                                        if (string.IsNullOrEmpty(objLocation.Town)) objLocation.Town = Address[i];
                                                        if (string.IsNullOrEmpty(objContact.Town)) objContact.Town = Address[i];
                                                    }
                                                    if (LineCount == 3)
                                                    {
                                                        if (string.IsNullOrEmpty(objLocation.Street)) objLocation.Street = Address[i];
                                                        if (string.IsNullOrEmpty(objContact.Street)) objContact.Street = Address[i];
                                                    }
                                                    if (LineCount == 4)
                                                    {
                                                        if (string.IsNullOrEmpty(objLocation.Address)) objLocation.Address = Address[i];
                                                        objContact.Address = Address[i];
                                                    }
                                                    if (LineCount == 5)
                                                    {
                                                        if (string.IsNullOrEmpty(objLocation.Company)) objLocation.Company = Address[i];
                                                        if (string.IsNullOrEmpty(objContact.Company)) objContact.Company = Address[i];
                                                    }
                                                }

                                                if (Address.Count() >= 6)
                                                {

                                                    if (LineCount == 2)
                                                    {
                                                        if (string.IsNullOrEmpty(objLocation.Town)) objLocation.Town = Address[i];
                                                        if (string.IsNullOrEmpty(objContact.Town)) objContact.Town = Address[i];
                                                    }
                                                    if (LineCount == 3)
                                                    {
                                                        if (string.IsNullOrEmpty(objLocation.Street)) objLocation.Street = Address[i];
                                                        if (string.IsNullOrEmpty(objContact.Street)) objContact.Street = Address[i];
                                                    }
                                                    if (LineCount == 4)
                                                    {
                                                        if (string.IsNullOrEmpty(objLocation.Address)) objLocation.Address = Address[i];
                                                        objContact.Address = Address[i];
                                                    }
                                                    if (LineCount == 5)
                                                    {
                                                        if (string.IsNullOrEmpty(objLocation.Company)) objLocation.Company = Address[i];
                                                        if (string.IsNullOrEmpty(objContact.Company)) objContact.Company = Address[i];
                                                    }
                                                    if (LineCount >= 6)
                                                    {
                                                        objLocation.Company = Address[i] + ", " + objLocation.Company;
                                                        objContact.Company = Address[i] + ", " + objContact.Company;
                                                        SuccessMessage += "<p>Line Count 6 Envoked! -" + Address[i] + "-</p>";
                                                    }

                                                }
                                            }

                                            SuccessMessage += "<h4>New Location Address : </h4>";

                                            objLocation.Postcode = objLocation.Postcode.ToUpper();
                                            objContact.PostCode = objContact.PostCode.ToUpper();
                                            if (string.IsNullOrEmpty(objContact.County)) objContact.County = objLocation.County;

                                            SuccessMessage += "Company : " + objLocation.Company + "<br>";
                                            SuccessMessage += "Address : " + objLocation.Address + "<br>";
                                            SuccessMessage += "Street : " + objLocation.Street + "<br>";
                                            SuccessMessage += "Town : " + objLocation.Town + "<br>";
                                            SuccessMessage += "County : " + objLocation.County + "<br>";
                                            SuccessMessage += "PostCode : " + objLocation.Postcode + "<br>";

                                            SuccessMessage += "<h4>New Contact Address : </h4>";

                                            SuccessMessage += "Company : " + objContact.Company + "<br>";
                                            SuccessMessage += "Address : " + objContact.Address + "<br>";
                                            SuccessMessage += "Street : " + objContact.Street + "<br>";
                                            SuccessMessage += "Town : " + objContact.Town + "<br>";
                                            SuccessMessage += "County : " + objContact.County + "<br>";
                                            SuccessMessage += "PostCode : " + objContact.PostCode + "<br>";

                                            objLocation.saveLocation();
                                            objContact.Update();

                                            SuccessCount += 1;

                                            SuccessMessage += "<li><a href=\"/ContactDetails.aspx?ContactID=" + objContact.ContactID + "\">" + objContact.Name + "</a> has an address for location <a href=\"/LocationDetails.aspx?LocationID=" + DBResult["LocationID"].ToString() + "\">" + DBResult["LocationID"].ToString() + " " + DBResult["Title"].ToString() + "</a>!<br>";

                                       //     SuccessMessage += "<li><a href=\"/ContactDetails.aspx?ContactID=" + objContact.ContactID + "\">" + objContact.Address + "</a> is being assinged to <a href=\"/LocationDetails.aspx?LocationID=" + DBResult["LocationID"].ToString() + "\">" + DBResult["LocationID"].ToString() + " " + DBResult["Title"].ToString() + "</a>!</a><br>";
                                        }
                                        else
                                        {
                                            // Assumption incorrect!
                                            FailCount += 1;
                                            FailMessage += "<li><a href=\"/ContactDetails.aspx?ContactID=" + objContact.ContactID + "\">" + objContact.Name + "</a> does not have a full address! Postcode missing for location <a href=\"/LocationDetails.aspx?LocationID=" + DBResult["LocationID"].ToString() + "\">" + DBResult["LocationID"].ToString() + " " + DBResult["Title"].ToString() + "</a><br>";

                                        }

                                   //     objLocation.Address = objContact.Address;
                                    }

                                    SuccessMessage += "</div>";
                                }

                            }
                        }

                    }

                }

                DBConnection.Close();

                MessageLiteral.Text += "<h2>Fail!</h2>" + FailMessage;
                MessageLiteral.Text += "<h2>Success!</h2>" + SuccessMessage;

                MessageLiteral.Text += "<h3>Total Errors Detected : " + ErrorCount + "</h3>";
            }
        }
コード例 #8
0
        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)
            {

                UK_Film_Location_Class.UserDetails objUser = new UK_Film_Location_Class.UserDetails();

                objUser.getUserFromEmail(UserEmail);

                UK_Film_Location_Class.BookingDetails objBooking = new UK_Film_Location_Class.BookingDetails();
                UK_Film_Location_Class.OpportunityDetails objOpportunity = new UK_Film_Location_Class.OpportunityDetails();

                objBooking.UserID = objUser.RecordID.ToString();
                objBooking.BookingID = Request.QueryString["BookingID"];
                objOpportunity.OpportunityID = Request.QueryString["OpportunityID"];

                if (!string.IsNullOrEmpty(objBooking.BookingID))
                {
                    objBooking.getBooking(objBooking.BookingID);
                    objOpportunity.OpportunityID = objBooking.OpportunityID;

                    CreatePanel.Visible = false;
                    BookingPanel.Visible = true;
                }
                else
                {
                    objBooking.DateBooked = DateTime.Now;

                    CreatePanel.Visible = true;
                    BookingPanel.Visible = false;

                }

                BookingID.Value = objBooking.BookingID;

                objOpportunity.getOpportunity(objOpportunity.OpportunityID);

                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);

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

                UK_Film_Location_Class.ProjectDetails objProject = new UK_Film_Location_Class.ProjectDetails();
                objProject.getProjectDetails(objOpportunity.ProjectID);

                if (!string.IsNullOrEmpty(objBooking.BookingID)) BookingRefLiteral.Text = "(" + objBooking.BookingID + ") <a class=\"btn-default btn\" target=\"_blank\" href=\"/BookingFormPDF.php?BookingID=" + objBooking.BookingID + "\">Booking Form&nbsp;<i class=\"fa fa-file-pdf-o\"></i></a>";

                if (!string.IsNullOrEmpty(objBooking.ContractTemplate)) BookingRefLiteral.Text += " <a class=\"btn-default btn\" target=\"_blank\" href=\"" + objBooking.ContractTemplate + "\">Contract&nbsp;<i class=\"fa fa-file-word-o\"></i></a>";

                BookingRefLiteral.Text += " <a class=\"btn-default btn\" target=\"_blank\" href=\"http://" + UK_Film_Location_Class.UKFilmLocation.DefaultWebsite + "/InvoicePDF.php?BookingID=" + objBooking.BookingID + "\">Preview Invoice&nbsp;<i class=\"fa fa-file-pdf-o\"></i></a>";

                BookingLocationLiteral.Text = "<table width=\"100%\">";

                BookingLocationLiteral.Text += "<tr><td width=\"150\" style=\"font-size: larger;\">Job Ref</td><td style=\"font-size: larger;\"><a href=\"/OpportunityDetails.aspx?OpportunityID=" + objOpportunity.OpportunityID + "\">" + objOpportunity.JobRef + "-" + objBooking.BookingID + "&nbsp;<i class=\"fa fa-external-link-square\" title=\"Opportunity Details\"></i></a></td></tr>";
                BookingLocationLiteral.Text += "<tr><td>Project Title</td><td><a href=\"/ProjectDetails.aspx?ProjectID=" + objProject.ProjectID + "\">" + objProject.WorkingTitle + "&nbsp;<i class=\"fa fa-external-link-square\" title=\"Project Details\"></i></a></td></tr>";
                BookingLocationLiteral.Text += "</table><br>";

                BookingLocationLiteral.Text += "<table width=\"100%\">";
                BookingLocationLiteral.Text += "<tr><td width=\"150\" style=\"font-size: larger;\">Location Ref</td><td style=\"font-size: larger;\"><a href=\"/LocationDetails.aspx?LocationID=" + objOpportunity.LocationID + "\">" + objOpportunity.LocationID + "&nbsp;<i class=\"fa fa-external-link-square\" title=\"Location Details\"></i></a></td></tr>";
                BookingLocationLiteral.Text += "<tr><td>Date Booked</td><td>" + objBooking.DateBooked.ToShortDateString() + "</td></tr>";

                BookingLocationLiteral.Text += "<tr><td>Location Contact</td><td><a href=\"/ContactDetails.aspx?ContactID=" + objLocation.ContactID + "\">" + objLocationContact.Name + "&nbsp;<i class=\"fa fa-external-link-square\" title=\"Contact Details\"></i></a></td></tr>";
                BookingLocationLiteral.Text += "<tr><td>Company</td><td>" + objLocationContact.Company + "</td></tr>";
                BookingLocationLiteral.Text += "<tr><td>Tel</td><td>" + objLocationContact.Tel + "</td></tr>";
                BookingLocationLiteral.Text += "<tr><td>Mobile</td><td>" + objLocationContact.Mobile + "</td></tr>";

                BookingLocationLiteral.Text += "</table><br>";

                BookingLocationLiteral.Text += "<table width=\"100%\">";
                BookingLocationLiteral.Text += "<tr><td width=\"150\">Project Contact</td><td><a href=\"/ContactDetails.aspx?ContactID=" + objProjectContact.ContactID + "\">" + objProjectContact.Name + "&nbsp;<i class=\"fa fa-external-link-square\" title=\"Contact Details\"></i></a></td></tr>";
                BookingLocationLiteral.Text += "<tr><td>Company</td><td>" + objProjectContact.Company + "</td></tr>";
                BookingLocationLiteral.Text += "<tr><td>Tel</td><td>" + objProjectContact.Tel + "</td></tr>";
                BookingLocationLiteral.Text += "<tr><td>Mobile</td><td>" + objProjectContact.Mobile + "</td></tr>";
                BookingLocationLiteral.Text += "</table><br>";

                if (!string.IsNullOrEmpty(objBooking.ContractTemplate))
                {
                    BookingLocationLiteral.Text += "<p>";
                    BookingLocationLiteral.Text += "Contract Generated : <a class=\"btn-default btn\" href=\"/Bookings/" + objBooking.BookingID + "/" + objBooking.BookingID + ".docx\" target=\"_blank\">Download&nbsp;<i class=\"fa fa-file-word-o\"></i></a>";
                    BookingLocationLiteral.Text += "</p>";
                }

                BookingFeesLiteral.Text += "<table width=\"100%\">";

                BookingFeesLiteral.Text += "<tr><td>Agreed Agency Rate</td><td align=\"right\">" + objOpportunity.AgreedRate + "%</td></tr>";
                BookingFeesLiteral.Text += "<tr><td>VAT Rate</td><td align=\"right\">" + objOpportunity.VATRate + "%</td></tr>";
                BookingFeesLiteral.Text += "<tr><td>Agreed Location Rate (per day)</td><td align=\"right\">£" + objOpportunity.LocationRate.ToString("0.00") + "</td></tr>";
                BookingFeesLiteral.Text += "<tr><td>Agreed Location VAT (per day)</td><td align=\"right\">£" + objOpportunity.LocationVAT.ToString("0.00") + "</td></tr>";

            //                BookingFeesLiteral.Text += "<tr><td>Agreed Agency Fee</td><td align=\"right\">£" + objOpportunity.AgencyRate.ToString("0.00") + "</td></tr>";
            //                BookingFeesLiteral.Text += "<tr><td>Agreed Agency VAT</td><td align=\"right\">£" + objOpportunity.AgencyVAT.ToString("0.00") + "</td></tr>";

                BookingFeesLiteral.Text += "<tr><td>Location Deposit</td><td align=\"right\">£" + objOpportunity.Deposit.ToString("0.00") + "</td></tr>";
                BookingFeesLiteral.Text += "<tr><td>Damage Deposit</td><td align=\"right\">£" + objOpportunity.DamageDeposit.ToString("0.00") + "</td></tr>";

                BookingFeesLiteral.Text += "</table><br>";

                // Get list of bookings

                DBConnection = new MySqlConnection(objUKFilmLocation.DBConnect);

                DBCommand = DBConnection.CreateCommand();

                // Opportunities

                DBConnection.Open();

                DBCommand.CommandText = "select BookingDates.NoCrew, BookingDates.BookingDate, BookingDates.BookingID, BookingDates.StartTime, BookingDates.EndTime, BookingDates.Notes, BookingDates.BookingDateID, BookingDates.AgreedDayRate from BookingDates where BookingDates.BookingID = '" + objBooking.BookingID + "' order by BookingDates.BookingDate asc;";

                DBResult = DBCommand.ExecuteReader();

                int noDays = 0;

                double totalDayHire = 0;

                while (DBResult.Read())
                {
                    double AgreedRate = double.Parse(DBResult["AgreedDayRate"].ToString());

                    BookingsLiteral.Text += "<tr><td><i class=\"fa fa-calendar-o fa-2x\"></i></td><td>" + DateTime.Parse(DBResult["BookingDate"].ToString()).ToShortDateString() + "</td><td>" + DBResult["StartTime"].ToString() + "</td><td>" + DBResult["EndTime"].ToString() + "</td><td>" + DBResult["NoCrew"].ToString() + "</td><td align=\"right\" width=\"150\">£" + AgreedRate.ToString("0.00") + "</td><td align=\"right\" width=\"180\"><a href=\"/BookingDateDetails.aspx?BookingDateID=" + DBResult["BookingDateID"].ToString() + "\" class=\"btn-default btn\">View / Change</a></td></tr>";

                    BookingsLiteral.Text += "<tr><td colspan=\"3\">" + DBResult["Notes"].ToString() + "</td><td></td></tr>";

                    if (!string.IsNullOrEmpty(DBResult["AgreedDayRate"].ToString()))
                    {
                        totalDayHire += double.Parse(DBResult["AgreedDayRate"].ToString());
                    }

                    noDays++;
                }

                DBResult.Close();

                DBConnection.Close();

                if (noDays > 0) GenerateContractBTN.Visible = true;

                double thisLocationVAT = 0;

                BookingFeesLiteral.Text += "<table width=\"100%\">";
                if (objLocation.VATRegistered == "1")
                {
                    BookingFeesLiteral.Text += "<tr><td>Total Location hire for " + noDays + " days</td><td align=\"right\">£" + totalDayHire.ToString("0.00") + " + VAT = £" + ((totalDayHire * (objOpportunity.VATRate / 100)) + totalDayHire).ToString("0.00") + "</td></tr>";
                    thisLocationVAT = (totalDayHire * (objOpportunity.VATRate / 100));
                }
                else
                {
                    BookingFeesLiteral.Text += "<tr><td>Total Location hire for " + noDays + " days</td><td align=\"right\">£" + totalDayHire.ToString("0.00") + "</td></tr>";
                }

                BookingFeesLiteral.Text += "</table><br>";

                BookingFeesLiteral.Text += "<table width=\"100%\">";

                double thisAgencyFee = totalDayHire * (objOpportunity.AgreedRate / 100);
                double thisAgencyVAT = thisAgencyFee * (objOpportunity.VATRate / 100);

                BookingFeesLiteral.Text += "<tr><td>Agency Fee @ " + objOpportunity.AgreedRate.ToString() + "%</td><td align=\"right\">£" + thisAgencyFee.ToString("0.00") + "</td></tr>";
                BookingFeesLiteral.Text += "<tr><td>Agency VAT</td><td align=\"right\">£" + thisAgencyVAT.ToString("0.00") + "</td></tr>";

                BookingFeesLiteral.Text += "</table><br>";

                BookingFeesLiteral.Text += "<table width=\"100%\">";

                //    BookingFeesLiteral.Text += "Day Hire = " + totalDayHire + ", AgencyFee = " + thisAgencyFee + ", AgencyVAT = " + thisAgencyVAT + ", Location VAT = " + thisLocationVAT;

                BookingFeesLiteral.Text += "<tr><td><span style=\"font-size: larger;\">Total Hire</span></td><td align=\"right\"><span style=\"font-size: larger;\">£" + (totalDayHire + thisAgencyFee + thisAgencyVAT + thisLocationVAT).ToString("0.00") + "</span></td></tr>";
                BookingFeesLiteral.Text += "<tr><td colspan=\"2\">Plus £" + (objOpportunity.Deposit + objOpportunity.DamageDeposit).ToString("0.00") + " deposit(s)</td></tr>";
                BookingFeesLiteral.Text += "<tr><td><span style=\"font-size: larger;\">Total Payable</span></td><td align=\"right\"><span style=\"font-size: larger;\"><b>£" + (totalDayHire + thisAgencyFee + thisAgencyVAT + thisLocationVAT + objOpportunity.Deposit + objOpportunity.DamageDeposit).ToString("0.00") + "</b></span></td></tr>";

                BookingFeesLiteral.Text += "</table>";

                if (objBooking.InvoiceSent.ToString() != "01/01/0001 00:00:00")
                {
                    UK_Film_Location_Class.InvoiceDetails objInvoice = new UK_Film_Location_Class.InvoiceDetails();
                    objInvoice.getInvoice(BookingID.Value);

                    BookingFeesLiteral.Text += "<p><b>";
                    BookingFeesLiteral.Text += "<br><br>Invoice Sent : " + objBooking.InvoiceSent.ToString().Substring(0, 10) + " #" + objInvoice.RecordID;
                    BookingFeesLiteral.Text += "</b></p>";
                }

                DBConnection.Dispose();
            }
        }