Beispiel #1
0
        private void loadAttribute(int attributeID)
        {
            AttributeBL attributeBL = new AttributeBL();

            eshopBE.Attribute attribute = attributeBL.GetAttribute(attributeID);

            txtName.Text             = attribute.Name;
            lblAttributeID.Value     = attribute.AttributeID.ToString();
            Page.Title               = attribute.Name + " | Admin panel";
            chkIsDescription.Checked = attribute.IsDescription;

            loadValues();
        }
Beispiel #2
0
        protected void btnSaveAttribute_Click(object sender, EventArgs e)
        {
            eshopBE.Attribute attribute = new eshopBE.Attribute();
            attribute.Name = txtName.Text;
            attribute.IsDescription = chkIsDescription.Checked;
            if (lblAttributeID.Value != string.Empty)
                attribute.AttributeID = int.Parse(lblAttributeID.Value);

            AttributeBL attributeBL = new AttributeBL();
            attributeBL.SaveAttribute(attribute);

            Response.Redirect("/administrator/attributes.aspx");
        }
Beispiel #3
0
        protected void btnSaveAttribute_Click(object sender, EventArgs e)
        {
            eshopBE.Attribute attribute = new eshopBE.Attribute();
            attribute.Name          = txtName.Text;
            attribute.IsDescription = chkIsDescription.Checked;
            if (lblAttributeID.Value != string.Empty)
            {
                attribute.AttributeID = int.Parse(lblAttributeID.Value);
            }

            AttributeBL attributeBL = new AttributeBL();

            attributeBL.SaveAttribute(attribute);

            Response.Redirect("/" + ConfigurationManager.AppSettings["webshopAdminUrl"] + "/attributes.aspx");
        }
Beispiel #4
0
        protected void btnSaveAttribute_Click(object sender, EventArgs e)
        {
            eshopBE.Attribute attribute = new eshopBE.Attribute();
            attribute.Name          = txtName.Text;
            attribute.IsDescription = chkIsDescription.Checked;
            if (lblAttributeID.Value != string.Empty)
            {
                attribute.AttributeID = int.Parse(lblAttributeID.Value);
            }

            AttributeBL attributeBL = new AttributeBL();

            attributeBL.SaveAttribute(attribute);

            Response.Redirect("/administrator/attributes.aspx");
        }
Beispiel #5
0
        private int addAttribute(int categoryID, string attributeName)
        {
            AttributeBL attributeBL = new AttributeBL();
            eshopBE.Attribute attribute = new eshopBE.Attribute();
            attribute.Name = attributeName;
            attribute.Filter = false;
            int attributeID = attributeBL.SaveAttribute(attribute);

            CategoryBL categoryBL = new CategoryBL();
            attributeBL.SaveAttributeForCategory(categoryID, attributeID);

            return attributeID;
        }
Beispiel #6
0
        private List<eshopBE.Attribute> GetAttributesList(int attributeID, string name, int categoryID)
        {
            List<eshopBE.Attribute> attributesList = null;
            eshopBE.Attribute attribute;

            using (SqlConnection objConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["eshopConnectionString"].ConnectionString))
            {
                using (SqlCommand objComm = new SqlCommand("SELECT attribute.attributeID, name, isDescription FROM attribute"))
                {
                    try
                    {
                        objConn.Open();
                        objComm.Connection = objConn;

                        if (attributeID > 0)
                        {
                            objComm.CommandText += " WHERE attributeID=@attributeID";
                            objComm.Parameters.Add("@attributeID", SqlDbType.Int).Value = attributeID;
                        }
                        else if (name != string.Empty)
                        {
                            objComm.CommandText += " WHERE name=@name";
                            objComm.Parameters.Add("@name", SqlDbType.NVarChar, 50).Value = name;
                        }
                        else if (categoryID > 0)
                        {
                            objComm.CommandText += " INNER JOIN categoryAttribute ON attribute.attributeID=categoryAttribute.attributeID WHERE categoryID=@categoryID";
                            objComm.Parameters.Add("@categoryID", SqlDbType.Int).Value = categoryID;
                        }

                        objComm.CommandText += " ORDER BY name";

                        using (SqlDataReader reader = objComm.ExecuteReader())
                        {
                            if (reader.HasRows)
                                attributesList = new List<eshopBE.Attribute>();
                            while (reader.Read())
                            {
                                attribute = new eshopBE.Attribute();
                                attribute.AttributeID = reader.GetInt32(0);
                                attribute.Name = reader.GetString(1);
                                attribute.IsDescription = Convert.IsDBNull(reader[2]) == false ? reader.GetBoolean(2) : false;
                                attribute.Filter = false;
                                //attribute.Values = GetAttributeValues(attribute.AttributeID);

                                attributesList.Add(attribute);
                            }
                        }
                    }
                    catch (SqlException ex)
                    {
                        ErrorLog.LogError(ex);
                        throw new DLException("Error while loading attributes list", ex);
                    }
                }
            }

            return attributesList;
        }
Beispiel #7
0
        public List<eshopBE.Attribute> GetAttributeListForFilter(string categoryUrl)
        {
            List<eshopBE.Attribute> attributes = null;
            eshopBE.Attribute attribute = null;

            using (SqlConnection objConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["eshopConnectionString"].ConnectionString))
            {
                using (SqlCommand objComm = new SqlCommand("SELECT attribute.attributeID, attribute.name FROM attribute INNER JOIN categoryAttribute ON attribute.attributeID=categoryAttribute.attributeID INNER JOIN category ON categoryAttribute.categoryID=category.categoryID WHERE category.url=@categoryUrl AND filter=1 ORDER BY attribute.name", objConn))
                {
                    objConn.Open();
                    objComm.Parameters.Add("@categoryUrl", SqlDbType.NVarChar, 50).Value = categoryUrl;
                    using (SqlDataReader reader = objComm.ExecuteReader())
                    {
                        if (reader.HasRows)
                            attributes = new List<eshopBE.Attribute>();
                        while (reader.Read())
                        {
                            attribute = new eshopBE.Attribute();
                            attribute.AttributeID = reader.GetInt32(0);
                            attribute.Name = reader.GetString(1);
                            attribute.Filter = true;
                            attribute.Values = GetAttributeValuesForFilter(attribute.AttributeID);

                            attributes.Add(attribute);
                        }
                    }
                }
            }
            return attributes;
        }