Ejemplo n.º 1
0
        private string GetFilters()
        {
            string result = string.Empty;
            InvokeAction(() =>
            {
                List<string> attrs = new List<string>();
                foreach (var control in panel1.Controls)
                {
                    var chk = control as CheckBox;
                    if (chk == null) continue;
                    if (chk.Checked)
                    {
                        attrs.Add("'" + chk.Text + "'");
                    }
                }
                if (attrs.Count > 0) result = string.Format("Attr in({0})", string.Join(",", attrs));
                if (attrs.Count == panel1.Controls.Count) result = string.Empty;
            });

            if (textBox1.Text.Trim().Length > 0)
            {
                string input = textBox1.Text.Trim();
                var productids = new Regex(@"\D").Split(input).ToList();
                productids.RemoveAll(string.IsNullOrEmpty);
                string pids = string.Join(",", productids);
                if (result.Length > 0 && productids.Count > 0)
                {
                    result = string.Format("ProductId in({0}) and ({1})", pids, result);
                }
                else if (productids.Count > 0)
                {
                    result = string.Format("ProductId in ({0})", pids);
                }
            }

            return result;
        }