Ejemplo n.º 1
0
        public int getAttributeValueID(int attributeID, string value)
        {
            AttributeBL attributeBL = new AttributeBL();
            List<AttributeValue> attributeValues = attributeBL.GetAttributeValues(attributeID);
            int attributeValueID = 0;
            bool exists = false;

            if (attributeValues != null)
            {
                for (int i = 0; i < attributeValues.Count; i++)
                    if (attributeValues[i].Value == value)
                    {
                        attributeValueID = attributeValues[i].AttributeValueID;
                        exists = true;
                        break;
                    }
            }

            if (!exists)
            {
                AttributeValue attributeValue = new AttributeValue(-1, value, attributeID, 0, string.Empty, 0);
                attributeValueID = attributeBL.SaveAttributeValue(attributeValue, false);
            }
            return attributeValueID;
        }
Ejemplo n.º 2
0
        protected void btnAddValue_Click(object sender, EventArgs e)
        {
            AttributeValue attributeValue = new AttributeValue();
            attributeValue.Value = txtValue.Text;
            attributeValue.AttributeID = int.Parse(lblAttributeID.Value);

            AttributeBL attributeBL = new AttributeBL();
            attributeBL.SaveAttributeValue(attributeValue, false);

            loadValues();
        }
Ejemplo n.º 3
0
 public int SaveAttributeValue(AttributeValue attributeValue, bool isKimtec)
 {
     AttributeDL attributeDL = new AttributeDL();
     return attributeDL.SaveAttributeValue(attributeValue, isKimtec);
 }
Ejemplo n.º 4
0
        public int SaveAttributeValue(AttributeValue attributeValue, bool isKimtec)
        {
            int attributeValueID = 0;
            using (SqlConnection objConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["eshopConnectionString"].ConnectionString))
            {
                using (SqlCommand objComm = new SqlCommand("INSERT INTO attributeValue (attributeID, value, kimtecValue) VALUES (@attributeID, @value, @kimtecValue);SELECT SCOPE_IDENTITY()", objConn))
                {
                    try
                    {
                        objConn.Open();
                        objComm.Parameters.Add("@attributeID", SqlDbType.Int).Value = attributeValue.AttributeID;
                        objComm.Parameters.Add("@value", SqlDbType.NVarChar, 100).Value = attributeValue.Value;
                        objComm.Parameters.Add("@kimtecValue", SqlDbType.NVarChar, 200);
                        objComm.Parameters[2].Value = isKimtec ? (object)attributeValue.Value : DBNull.Value;

                        attributeValueID = int.Parse(objComm.ExecuteScalar().ToString());
                    }
                    catch (SqlException ex)
                    {
                        ErrorLog.LogError(ex);
                        throw new DLException("Error while saving attribute value.", ex);
                    }
                }
            }
            return attributeValueID;
        }