public bool insertProperty(PropertyDetailsEdit Prop)
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);

            SqlCommand cmdid = new SqlCommand("Select top 1 * from PropertyListMaster order by PropertyID desc", conn);

            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }
            SqlDataReader dr;

            dr = cmdid.ExecuteReader();
            int propertyID = 0;

            if (dr.Read())
            {
                propertyID = int.Parse(dr["PropertyID"].ToString());
            }
            dr.Close();
            propertyID++;

            SqlCommand cmdidp = new SqlCommand("Select * from ProjectMaster PM, LocationMaster LM where PM.LocationID=LM.LocationID and ProjectID=" + Prop.ProjectID, conn);

            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }
            SqlDataReader drp;

            drp = cmdidp.ExecuteReader();
            //int projectID = 0;
            string mLocation = "";
            string mproject  = "";

            if (drp.Read())
            {
                // projectID = int.Parse(dr["ProjectID"].ToString());
                mLocation = drp["Location"].ToString().Trim();
                mproject  = drp["ProjectName"].ToString().Trim();
            }
            drp.Close();
            //projectID++;
            SqlCommand cmdPT = new SqlCommand("Select * from PropertytypeMaster where PTID=" + Prop.PTID, conn);

            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }
            SqlDataReader drL;

            drL = cmdPT.ExecuteReader();
            string PropertyT = "";

            if (drL.Read())
            {
                PropertyT = drL["PropertyType"].ToString();
            }
            drL.Close();

            string propertyIDLink = mproject + "-" + mLocation + " " + PropertyT + " " + propertyID;

            propertyIDLink = propertyIDLink.Replace("  ", " ").Replace("  ", " ").Replace("  ", " ");
            propertyIDLink = propertyIDLink.Replace(" ", "-");

            SqlCommand cmd = new SqlCommand("Insert into PropertyListMaster (Estate_ID, Member_ID,ProjectID, PTID, BudgetID, Possession, StartPrice, BedRooms, BathRooms, Balconies, StoreRooms, SuperArea, CarpetArea, FaceSide, Floor, CarParking,PropertyID, Entry_date,Sales_Status) Values(@Estate_ID, 0, @ProjectID, @PTID, @BudgetID, @Possession, @StartPrice, @BedRooms, @BathRooms, @Balconies, @StoreRooms, @SuperArea, @CarpetArea, @FaceSide, @Floor, @CarParking, @PropertyID,@Created_Date,'N')", conn);

            cmd.Parameters.Add(new SqlParameter("@PropertyID", SqlDbType.Int)).Value = propertyID;
            cmd.Parameters.Add(new SqlParameter("@Estate_ID", SqlDbType.NVarChar, propertyIDLink.Trim().Length)).Value = propertyIDLink.Trim();
            cmd.Parameters.Add(new SqlParameter("@ProjectID", SqlDbType.Int)).Value = Prop.ProjectID;
            cmd.Parameters.Add(new SqlParameter("@PTID", SqlDbType.Int)).Value      = Prop.PTID;
            cmd.Parameters.Add(new SqlParameter("@BudgetID", SqlDbType.Int)).Value  = Prop.BudgetID;
            cmd.Parameters.Add(new SqlParameter("@StartPrice", SqlDbType.NVarChar, Prop.StartPrice.ToString().Trim().Length)).Value = Prop.StartPrice.ToString().Trim();
            cmd.Parameters.Add(new SqlParameter("@BedRooms", SqlDbType.NVarChar, Prop.BedRooms.ToString().Trim().Length)).Value     = Prop.BedRooms.ToString().Trim();
            cmd.Parameters.Add(new SqlParameter("@BathRooms", SqlDbType.NVarChar, Prop.BathRooms.ToString().Trim().Length)).Value   = Prop.BathRooms.ToString().Trim();
            cmd.Parameters.Add(new SqlParameter("@Balconies", SqlDbType.NVarChar, Prop.Balconies.ToString().Trim().Length)).Value   = Prop.Balconies.ToString().Trim();
            cmd.Parameters.Add(new SqlParameter("@StoreRooms", SqlDbType.NVarChar, Prop.StoreRooms.ToString().Trim().Length)).Value = Prop.StoreRooms.ToString().Trim();
            cmd.Parameters.Add(new SqlParameter("@SuperArea", SqlDbType.NVarChar, Prop.SuperArea.ToString().Trim().Length)).Value   = Prop.SuperArea.ToString().Trim();
            cmd.Parameters.Add(new SqlParameter("@CarpetArea", SqlDbType.NVarChar, Prop.CarpetArea.ToString().Trim().Length)).Value = Prop.CarpetArea.ToString().Trim();
            cmd.Parameters.Add(new SqlParameter("@FaceSide", SqlDbType.NVarChar, Prop.FaceSide.ToString().Trim().Length)).Value     = Prop.FaceSide.ToString().Trim();
            cmd.Parameters.Add(new SqlParameter("@Floor", SqlDbType.NVarChar, Prop.Floor.ToString().Trim().Length)).Value           = Prop.Floor.ToString().Trim();
            cmd.Parameters.Add(new SqlParameter("@CarParking", SqlDbType.NVarChar, Prop.CarParking.ToString().Trim().Length)).Value = Prop.CarParking.ToString().Trim();
            cmd.Parameters.Add(new SqlParameter("@Possession", SqlDbType.NVarChar, Prop.Possession.ToString().Trim().Length)).Value = Prop.Possession.ToString().Trim();
            cmd.Parameters.Add(new SqlParameter("@Created_Date", SqlDbType.DateTime)).Value = DateTime.Now.ToString("yyyy/MM/dd");
            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }
            cmd.ExecuteNonQuery();
            return(true);
        }
        public bool UpdateProperty(PropertyDetailsEdit Prop)
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);

            SqlCommand cmdid = new SqlCommand("Select * from ProjectMaster PM, LocationMaster LM where PM.LocationID=LM.LocationID and ProjectID=" + Prop.ProjectID, conn);

            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }
            SqlDataReader dr;

            dr = cmdid.ExecuteReader();
            int    projectID = 0;
            string mLocation = "";
            string mproject  = "";

            if (dr.Read())
            {
                projectID = int.Parse(dr["ProjectID"].ToString());
                mLocation = dr["Location"].ToString().Trim();
                mproject  = dr["ProjectName"].ToString().Trim();
            }
            dr.Close();
            //projectID++;
            SqlCommand cmdPT = new SqlCommand("Select * from PropertytypeMaster where PTID=" + Prop.PTID, conn);

            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }
            SqlDataReader drL;

            drL = cmdPT.ExecuteReader();
            string PropertyT = "";

            if (drL.Read())
            {
                PropertyT = drL["PropertyType"].ToString();
            }
            drL.Close();

            string propertyIDLink = mproject + "-" + mLocation + " " + PropertyT + " " + Prop.PropertyID;

            propertyIDLink = propertyIDLink.Replace("  ", " ").Replace("  ", " ").Replace("  ", " ");
            propertyIDLink = propertyIDLink.Replace(" ", "-");

            SqlCommand cmd = new SqlCommand("Update PropertyListMaster set ViewStatus=@ViewStatus, Estate_ID=@Estate_ID, ProjectID=@ProjectID, PTID=@PTID, Possession=@Possession, StartPrice=@StartPrice, BedRooms=@BedRooms, BathRooms=@BathRooms, Balconies=@Balconies, StoreRooms=@StoreRooms, SuperArea=@SuperArea, CarpetArea=@CarpetArea, FaceSide=@FaceSide, Floor=@Floor, CarParking=@CarParking where PropertyID=" + Prop.PropertyID, conn);

            cmd.Parameters.Add(new SqlParameter("@Estate_ID", SqlDbType.NVarChar, propertyIDLink.Trim().Length)).Value = propertyIDLink.Trim();
            cmd.Parameters.Add(new SqlParameter("@ProjectID", SqlDbType.Int)).Value = Prop.ProjectID;
            cmd.Parameters.Add(new SqlParameter("@PTID", SqlDbType.Int)).Value      = Prop.PTID;
            cmd.Parameters.Add(new SqlParameter("@StartPrice", SqlDbType.NVarChar, Prop.StartPrice.ToString().Trim().Length)).Value = Prop.StartPrice.ToString().Trim();
            cmd.Parameters.Add(new SqlParameter("@BedRooms", SqlDbType.NVarChar, Prop.BedRooms.ToString().Trim().Length)).Value     = Prop.BedRooms.ToString().Trim();
            cmd.Parameters.Add(new SqlParameter("@BathRooms", SqlDbType.NVarChar, Prop.BathRooms.ToString().Trim().Length)).Value   = Prop.BathRooms.ToString().Trim();
            cmd.Parameters.Add(new SqlParameter("@Balconies", SqlDbType.NVarChar, Prop.Balconies.ToString().Trim().Length)).Value   = Prop.Balconies.ToString().Trim();
            cmd.Parameters.Add(new SqlParameter("@StoreRooms", SqlDbType.NVarChar, Prop.StoreRooms.ToString().Trim().Length)).Value = Prop.StoreRooms.ToString().Trim();
            cmd.Parameters.Add(new SqlParameter("@SuperArea", SqlDbType.NVarChar, Prop.SuperArea.ToString().Trim().Length)).Value   = Prop.SuperArea.ToString().Trim();
            cmd.Parameters.Add(new SqlParameter("@CarpetArea", SqlDbType.NVarChar, Prop.CarpetArea.ToString().Trim().Length)).Value = Prop.CarpetArea.ToString().Trim();
            cmd.Parameters.Add(new SqlParameter("@FaceSide", SqlDbType.NVarChar, Prop.FaceSide.ToString().Trim().Length)).Value     = Prop.FaceSide.ToString().Trim();
            cmd.Parameters.Add(new SqlParameter("@Floor", SqlDbType.NVarChar, Prop.Floor.ToString().Trim().Length)).Value           = Prop.Floor.ToString().Trim();
            cmd.Parameters.Add(new SqlParameter("@CarParking", SqlDbType.NVarChar, Prop.CarParking.ToString().Trim().Length)).Value = Prop.CarParking.ToString().Trim();
            cmd.Parameters.Add(new SqlParameter("@Possession", SqlDbType.NVarChar, Prop.Possession.ToString().Trim().Length)).Value = Prop.Possession.ToString().Trim();
            cmd.Parameters.Add(new SqlParameter("@ViewStatus", SqlDbType.Bit)).Value = Prop.ViewStatus;

            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }
            cmd.ExecuteNonQuery();
            return(true);
        }