protected void btnsubmit_Click(object sender, EventArgs e)
        {
            //if (Program.con.State.Equals(ConnectionState.Closed))
            //{
            //    Program.con.Open();

            //}


            //SqlCommand cmd = new SqlCommand("update [User] set uname='" + txtname.Text + "',uemail='" + email_txt.Text + "',uphone='" + txtname.Text + "',ulocation='" + txtlocation.Text + "' where uid=1", Program.con);
            //cmd.ExecuteNonQuery();
            //Program.con.Close();
            DataLink.User u = DataLink.UserData.GetUserDetailsByID((int)Session["ID"]);

            string Name, Email, Location = "", Phone;

            if (txtName.Text == "")
            {
                Name = u.Name;
            }
            else
            {
                Name = txtName.Text;
            }

            if (txtEmail.Text == "")
            {
                Email = u.Email;
            }
            else
            {
                Email = txtEmail.Text;
            }

            if (ddCity.SelectedIndex == 1 && ddArea.SelectedIndex == 0)
            {
                Location = u.Location;
            }
            else
            {
                //Location= ddCity.Text + "," + ddArea.SelectedIndex.;
                //txtLocation.Text;
                Location = ddArea.SelectedItem.Text + ", " + ddCity.SelectedItem.Text;
            }

            if (txtPhone.Text == "")
            {
                Phone = u.Phone;
            }
            else
            {
                Phone = txtPhone.Text;
            }

            DataLink.UserData.UpdateUserData(Name, Email, Location, Phone, (int)Session["ID"]);

            if (myupload.HasFile)
            {
                string folder_path = Server.MapPath("//images//");
                myupload.SaveAs(folder_path + "TempImage.jpg");

                System.Drawing.Image UploadImage = System.Drawing.Image.FromFile(folder_path + "TempImage.jpg");
                DataLink.UserData.SaveUserImage(UploadImage, (int)Session["ID"]);
                UploadImage.Dispose();
                File.Delete(folder_path + "TempImage.jpg");
            }

            Response.Redirect("UserProfile.aspx");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["ID"] != null)
                {
                    lblUserName.InnerText = "Logged in as " + DataLink.UserData.GetUserNameByID((int)Session["ID"]);
                    userpanel.Attributes.Add("style", "display:block; height:50px");
                    logoutbtn.Attributes.Add("style", "display:block; height:50px");
                    ImageButton1.Attributes.Add("src", @"/dist/img/button.png");
                    loginlink.Attributes.Add("style", "display:none");
                    registerlink.Attributes.Add("style", "display:none");
                    adlink.Attributes.Add("style", "display:block");
                    profilelink.Attributes.Add("style", "display:block");
                }
            }

            if (Request.QueryString["type"] == null || Request.QueryString["id"] == null)
            {
                Response.Redirect("Index.aspx");
            }

            string PropertyType = (string)Request.QueryString["type"];
            int    Id           = int.Parse(Request.QueryString["id"]);



            if (PropertyType == "plot")
            {
                DataLink.Plot p = DataLink.PropertyData.GetPlotDetails(Id);
                DataLink.User u = DataLink.UserData.GetUserDetailsByID(p.Owner);

                lblPropertyTitle.Text    = p.Name;
                lblPropertyType.Text     = "Plot";
                lblPropertyMode.Text     = "Sell";
                lblPropertyUnitSize.Text = p.Size + " " + p.SizeUnit;
                lblPropertArea.Text      = DataLink.PropertyData.GetAreaNameByPropertyID(Id);
                lblPropertyPrice.Text    = p.Price.ToString();
                txtdesc.Value            = p.Description;

                lblUName.Text        = u.Name;
                lblUserEmail.Text    = Check(u.Email);
                lblUserNumber.Text   = Check(u.Phone);
                lblUserLocation.Text = u.Location;

                AddListItem("Leased", LeasedValue(p.Leased));

                //HtmlGenericControl LeasedItem = new HtmlGenericControl("li");
                //LeasedItem.Attributes.Add("class", "list-group-item");

                //HtmlGenericControl lblLeased = new HtmlGenericControl("b");
                //lblLeased.InnerText = "Leased";

                //HtmlGenericControl LeasedValueAnchor = new HtmlGenericControl("a");
                //LeasedValueAnchor.Attributes.Add("class", "pull-right");

                //Label LeasedValue = new Label();
                //LeasedValue.Text = p.Leased.ToString();

                //LeasedItem.Controls.Add(lblLeased);

                //LeasedValueAnchor.Controls.Add(LeasedValue);
                //LeasedItem.Controls.Add(LeasedValueAnchor);

                //AdDetails.Controls.Add(LeasedItem);

                string LocalHostPath = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + "//userimages//";
                UserImage.Attributes.Add("src", DataLink.UserData.GetUserImage(LocalHostPath, p.Owner));

                LoadImages(Id);
            }

            else if (PropertyType == "appartment")
            {
                DataLink.Appartment ap = DataLink.PropertyData.GetAppartmentDetails(Id);
                DataLink.User       u  = DataLink.UserData.GetUserDetailsByID(ap.Owner);

                lblPropertyTitle.Text    = ap.Name;
                lblPropertyType.Text     = "Appartment";
                lblPropertyMode.Text     = "For " + ap.ApptType;
                lblPropertArea.Text      = DataLink.PropertyData.GetAreaNameByPropertyID(Id);
                lblPropertyUnitSize.Text = ap.Size + " " + ap.SizeUnit;
                lblPropertyPrice.Text    = ap.Price.ToString();
                txtdesc.Value            = ap.Description;

                lblUName.Text        = u.Name;
                lblUserEmail.Text    = Check(u.Email);
                lblUserNumber.Text   = Check(u.Phone);
                lblUserLocation.Text = u.Location;

                AddListItem("Floor", ap.ApptFloor.ToString());
                AddListItem("Rooms", ap.ApptRooms.ToString());

                SetCondition(ap.ApptFurnished);

                string LocalHostPath = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + "//userimages//";
                UserImage.Attributes.Add("src", DataLink.UserData.GetUserImage(LocalHostPath, ap.Owner));

                LoadImages(Id);
            }

            else if (PropertyType == "house_full")
            {
                DataLink.House_Full h = DataLink.PropertyData.GetHouse_FullDetails(Id);
                DataLink.User       u = DataLink.UserData.GetUserDetailsByID(h.Owner);

                lblPropertyTitle.Text    = h.Name;
                lblPropertyType.Text     = "Appartment";
                lblPropertyMode.Text     = "For " + h.Type;
                lblPropertyUnitSize.Text = h.Size + " " + h.SizeUnit;
                lblPropertArea.Text      = DataLink.PropertyData.GetAreaNameByPropertyID(Id);
                lblPropertyPrice.Text    = h.Price.ToString();
                txtdesc.Value            = h.Description;

                lblUName.Text        = u.Name;
                lblUserEmail.Text    = Check(u.Email);
                lblUserNumber.Text   = Check(u.Phone);
                lblUserLocation.Text = u.Location;

                AddListItem("Floors", h.Floors.ToString());
                AddListItem("Rooms", h.Rooms.ToString());

                SetCondition(h.Furnished);

                string LocalHostPath = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + "//userimages//";
                UserImage.Attributes.Add("src", DataLink.UserData.GetUserImage(LocalHostPath, h.Owner));

                LoadImages(Id);
            }

            else if (PropertyType == "house_portion")
            {
                DataLink.House_Portion h = DataLink.PropertyData.GetHouse_PortionDetails(Id);
                DataLink.User          u = DataLink.UserData.GetUserDetailsByID(h.Owner);

                lblPropertyTitle.Text    = h.Name;
                lblPropertyType.Text     = "Appartment";
                lblPropertyMode.Text     = "For " + h.Type;
                lblPropertyUnitSize.Text = h.Size + " " + h.SizeUnit;
                lblPropertArea.Text      = DataLink.PropertyData.GetAreaNameByPropertyID(Id);
                lblPropertyPrice.Text    = h.Price.ToString();
                txtdesc.Value            = h.Description;

                lblUName.Text        = u.Name;
                lblUserEmail.Text    = Check(u.Email);
                lblUserNumber.Text   = Check(u.Phone);
                lblUserLocation.Text = u.Location;

                AddListItem("Floor", h.Floor.ToString());
                AddListItem("Rooms", h.Rooms.ToString());

                SetCondition(h.Furnished);

                string LocalHostPath = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + "//userimages//";
                UserImage.Attributes.Add("src", DataLink.UserData.GetUserImage(LocalHostPath, h.Owner));

                LoadImages(Id);
            }
        }