Esempio n. 1
0
        public void Get()
        {
            List <PropertiesContainer> properties = new List <PropertiesContainer>();

            string        sql = "dbo.User_Property_ChapterBasic_Get";
            SqlConnection cnn = new SqlConnection(ConnectionStrings.sqlUsers);
            SqlCommand    cmd = new SqlCommand(sql, cnn);
            SqlDataReader rdr = null;

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@UserId_ID", this.userId).SqlDbType = SqlDbType.Int;

            try
            {
                cnn.Open();
                rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                if (rdr.HasRows)
                {
                    while (rdr.Read())
                    {
                        PropertiesContainer p = new PropertiesContainer();

                        p.PropertyId = Convert.ToInt32(rdr.GetInt16(0));
                        p.CategoryId = Convert.ToInt32(rdr.GetByte(1));

                        properties.Add(p);
                    }
                }
            }
            catch (SqlException e)
            {
            }

            catch (Exception ex)
            {
            }
            finally
            {
                if (!(rdr == null))
                {
                    rdr.Close();
                    rdr.Dispose();
                }
                cnn.Close();
                cmd.Dispose();
                cnn.Dispose();
            }

            for (int i = 0; i < properties.Count; i++)
            {
                switch ((Categories)properties[i].CategoryId)
                {
                case Categories.Relationship:
                    this.Relationship.Add(properties[i].PropertyId);
                    break;

                case Categories.Kids:
                    this.Kids = properties[i].PropertyId;
                    break;

                case Categories.KidsHave:
                    this.KidsHave = properties[i].PropertyId;
                    break;

                case Categories.KidsWant:
                    this.KidsWant = properties[i].PropertyId;
                    break;

                case Categories.Status:
                    this.Status = properties[i].PropertyId;
                    break;

                case Categories.StatusPartner:
                    this.StatusPartner = properties[i].PropertyId;
                    break;
                }
            }
        }
Esempio n. 2
0
        public void Get()
        {
            List <PropertiesContainer> properties = new List <PropertiesContainer>();

            string        sql = "dbo.User_Property_ChapterLifestyle_Get";
            SqlConnection cnn = new SqlConnection(ConnectionStrings.sqlUsers);
            SqlCommand    cmd = new SqlCommand(sql, cnn);
            SqlDataReader rdr = null;

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@UserId_ID", this.userId).SqlDbType = SqlDbType.Int;

            try
            {
                cnn.Open();
                rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                if (rdr.HasRows)
                {
                    while (rdr.Read())
                    {
                        PropertiesContainer p = new PropertiesContainer();

                        p.PropertyId = Convert.ToInt32(rdr.GetInt16(0));
                        p.CategoryId = Convert.ToInt32(rdr.GetByte(1));

                        properties.Add(p);
                    }
                }
            }
            catch (SqlException e)
            {
                throw new Exception(e.Message);
            }

            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                if (!(rdr == null))
                {
                    rdr.Close();
                    rdr.Dispose();
                }
                cnn.Close();
                cmd.Dispose();
                cnn.Dispose();
            }

            for (int i = 0; i < properties.Count; i++)
            {
                switch ((Categories)properties[i].CategoryId)
                {
                case Categories.Diet:
                    this.Diet.Add(properties[i].PropertyId);
                    break;

                case Categories.FashionStyle:
                    this.FashionStyle.Add(properties[i].PropertyId);
                    break;

                case Categories.Excercise:
                    this.Exercise = properties[i].PropertyId;
                    break;

                case Categories.Drinking:
                    this.Drinking = properties[i].PropertyId;
                    break;

                case Categories.Smoking:
                    this.Smoking = properties[i].PropertyId;
                    break;
                }
            }
        }