Esempio n. 1
0
        /// <summary>
        /// Gets the current list of brand names.
        /// </summary>
        /// <param name="user">The user making the request.</param>
        /// <returns></returns>
        public static List <string> GetBrandNameList(User user)
        {
            List <string> bnList = new List <string>();

            try
            {
                string    sCustomer  = user.Customer.SQLEscape().ToLower();
                DBConnect connection = ConnectionsMgr.GetSalesConnection(user, "sales_" + sCustomer);
                {
                    var query = connection.Query("SELECT brand FROM sl_filters GROUP BY brand ORDER BY brand");
                    while (query.Read())
                    {
                        var bn = query.Field(0, "").Trim();
                        if (bn != "")
                        {
                            bnList.Add(bn);
                        }
                    }
                }
                connection.Close();
            }
            catch (Exception e)
            {
                Log(user, nameof(GetBrandNameList), e);
            }
            return(bnList);
        }
Esempio n. 2
0
        private static Dictionary <string, ItemInfo> GetItemInfoLookup(User user, string sPartner, string dbSales, IEnumerable <string> vendList, IEnumerable <string> upcList)
        {
            Dictionary <string, ItemInfo> itemDict = new Dictionary <string, ItemInfo>();

            try
            {
                DBConnect connection = ConnectionsMgr.GetSalesConnection(user, dbSales);
                string    colVendNum = sPartner == _Partner.Thalia ?
                                       $"SUBSTR(TRIM({VendorNum}),1,11)" :
                                       $"TRIM({VendorNum})";
                using (var queryItemInfo = connection.Select("vendornum,upcnum,prodcat,deptname,prodsubcat,classdesc,subcdesc,itemdesc,colorcode,itemcolor", _Table.Sl_MasterCat, $"WHERE {colVendNum} IN {vendList.ToSqlValueList()} AND TRIM({UPCNum}) IN {upcList.ToSqlValueList()} group by vendornum,upcnum"))
                {
                    while (queryItemInfo.Read())
                    {
                        string key = queryItemInfo.FieldByName(VendorNum).Trim() + queryItemInfo.FieldByName(UPCNum).Trim();
                        if (!itemDict.ContainsKey(key))
                        {
                            itemDict.Add(key, new ItemInfo(queryItemInfo));
                        }
                    }
                }
                connection.Close();
            }
            catch (Exception e)
            {
                Log(user, nameof(GetItemInfoLookup), e);
            }
            return(itemDict);
        }