Пример #1
0
    public static PropertyDetailInfo getPropertyDetailInfo(int propid)
    {
        PropertyDetailInfo detail = new PropertyDetailInfo();

        //  adapter.Fill(customers, "Customers");
        try
        {
            using (SqlConnection con = new SqlConnection(connString))
            {
                /*   @keyword nvarchar(200) ='',
                 * @proptype int= 0,
                 * @roomnum int= 0,
                 * @amenityid int= 0
                 */
                con.Open();
                SqlCommand cmd = new SqlCommand("uspGetPropertiesDetailIno", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@propid", SqlDbType.NVarChar, 200).Value = propid;

                //   @pagenum int =0,
                //@ratesort int= 0
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    PropertyInfo[] props = detail.GetType().GetProperties();
                    foreach (PropertyInfo prop_info in props)
                    {
                        prop_info.SetValue(detail, Convert.ChangeType(reader[prop_info.Name], prop_info.PropertyType), null);
                    }
                }

                reader.Close();
                con.Close();
            }
        }
        catch (Exception ex)
        {
        }
        return(detail);
    }
Пример #2
0
    public static AjaxPropListSet getAjaxAllPropListSetWithCityID(int cityid, int proptype, int amenitytype, int roomnum, int sorttype)
    {
        AjaxPropListSet prop_set = new AjaxPropListSet();
        //prop_set.allnums = getNumbersOfCityID(cityid, proptype, amenitytype, roomnum);
        List <PropertyAmenityInfo> propertyList = new List <PropertyAmenityInfo>();

        List <PropertyDetailInfo> prop_detail = new List <PropertyDetailInfo>();


        //  adapter.Fill(customers, "Customers");
        try
        {
            using (SqlConnection con = new SqlConnection(connString))
            {
                /*   @keyword nvarchar(200) ='',
                 * @proptype int= 0,
                 * @roomnum int= 0,
                 * @amenityid int= 0
                 */
                con.Open();
                SqlCommand cmd = new SqlCommand("uspGetAllPropertiesWithCityID", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@cityid", SqlDbType.Int).Value    = cityid;
                cmd.Parameters.Add("@proptype", SqlDbType.Int).Value  = proptype;
                cmd.Parameters.Add("@roomnum", SqlDbType.Int).Value   = roomnum;
                cmd.Parameters.Add("@amenityid", SqlDbType.Int).Value = amenitytype;
                cmd.Parameters.Add("@ratesort", SqlDbType.Int).Value  = sorttype;
                //   @pagenum int =0,
                //@ratesort int= 0
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    PropertyDetailInfo tmp   = new PropertyDetailInfo();
                    PropertyInfo[]     props = tmp.GetType().GetProperties();
                    foreach (PropertyInfo prop_info in props)
                    {
                        prop_info.SetValue(tmp, Convert.ChangeType(reader[prop_info.Name], prop_info.PropertyType), null);
                    }
                    prop_detail.Add(tmp);
                }

                con.Close();
            }
        }
        catch (Exception ex)
        {
        }

        foreach (PropertyDetailInfo propinfo in prop_detail)
        {
            PropertyAmenityInfo propamenity = new PropertyAmenityInfo();
            propamenity.detail = propinfo;
            try
            {
                using (SqlConnection con = new SqlConnection(connString))
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("uspGetAmenity", con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@propid", SqlDbType.Int).Value = propinfo.ID;

                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        AmenityInfo tmp = new AmenityInfo();
                        tmp.ID      = Convert.ToInt32(reader["ID"]);
                        tmp.Amenity = reader["Amenity"].ToString();
                        propamenity.amenity.Add(tmp);
                    }

                    con.Close();
                }
            }
            catch (Exception ex)
            {
            }
            propertyList.Add(propamenity);
        }
        prop_set.propertyList = propertyList;
        prop_set.allnums      = propertyList.Count;
        return(prop_set);
    }