Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Code problem

  • 27-02-2011 6:02pm
    #1
    Registered Users, Registered Users 2 Posts: 1,857 ✭✭✭


    Hey just wondering if someone can tell me the right line of code to use.

    Basically my product codes for an ecommerce site all begin with three letters and an '/' sign

    e.g ABC/1234 would map to the brand ABC in my excell file(product upload mapping)

    This was done as the csv generating from my POS database wasnt generating brand names.

    See line in code it basically says that after the first three letters that are separated with the '/' symbol they will map the brand name right.

    Now we have changed 2 products to contain a '-' symbol instead of '/'

    ABC-1234 instead of ABC/1234.

    I need the right sql code to say anything with a - is added just like the / sign.
     public static string GetBrandNameFromStockref(string StockRef)
            {
                String strb = String.Empty;
                Hashtable brand = new Hashtable();
                brand.Add("ABC", "ABC PRODUCT");
    
     IDictionaryEnumerator iEnum = brand.GetEnumerator();
              [COLOR="Blue"]  string[] fbrand = StockRef.Split('/');[/COLOR]
                while (iEnum.MoveNext())
                {
                    if (iEnum.Key.ToString().ToLower() == fbrand[0].ToLower())
                    {
                        strb = iEnum.Value.ToString();
                        break;
                    }
                }
                if (strb == "")
                    return fbrand[0];
                else
                    return strb;
            }
            public static string GetProductNameFromStockref(string StockRef)
            {
                string[] prdName = StockRef.Split('_');
                return prdName[0];
            }
        }
    }
    
    

    The line in question is this line string[] fbrand = StockRef.Split('/');

    My friend said just need to change the regex string to work for either "/" or "-" but i cant get it working, any ideas?


Comments

Advertisement