private void SetAvailableData() { GetAllCustomerGroup(); AvailableFilteredCustomerGroup = AllGroups.Where(p => !IncludedGroup.Any(inc => inc.CustomerGroupID == p.CustomerGroupID)) .Where(p => !ExcludedGroup.Any(exc => exc.CustomerGroupID == p.CustomerGroupID)).ToList(); //Hide regular excluded customer groups for new condition if (ConditionID == 0 && ExcludedConditionGroup != null && ExcludedConditionGroup.Count > 0) { AvailableFilteredCustomerGroup = AvailableFilteredCustomerGroup.Where(p => !ExcludedConditionGroup.Any(inc => inc.CustomerGroupID == p.CustomerGroupID)).ToList(); } string strFilter = functioninput.Text; if (functionradio1.Checked) { AvailableFilteredCustomerGroup = AvailableFilteredCustomerGroup.Where(p => p.Name.StartsWith(strFilter, StringComparison.OrdinalIgnoreCase)).ToList(); } else { AvailableFilteredCustomerGroup = AvailableFilteredCustomerGroup.Where(p => p.Name.IndexOf(strFilter, StringComparison.OrdinalIgnoreCase) >= 0).ToList(); } lstSelected.DataSource = IncludedGroup; lstSelected.DataBind(); lstExcluded.DataSource = ExcludedGroup; lstExcluded.DataBind(); lstAvailable.DataSource = AvailableFilteredCustomerGroup; lstAvailable.DataBind(); }
protected void btnCreate_Click(object sender, EventArgs e) { string Name = string.Empty; if (MyCommon.Parse_Quotes(Logix.TrimAll(functioninput.Text)) != null) { Name = Convert.ToString(MyCommon.Parse_Quotes(Logix.TrimAll(functioninput.Text))); } if (!String.IsNullOrEmpty(Name)) { int AvailableListCount = AvailableFilteredCustomerGroup.Where(p => p.Name.Equals(functioninput.Text, StringComparison.OrdinalIgnoreCase)).ToList().Count; int IncludedGroupCount = IncludedGroup.Where(p => p.Name.Equals(functioninput.Text, StringComparison.OrdinalIgnoreCase)).ToList().Count; int ExcludedGroupCount = ExcludedGroup.Where(p => p.Name.Equals(functioninput.Text, StringComparison.OrdinalIgnoreCase)).ToList().Count; bool isValidText = true; if (functioninput.Text.ToLower().Equals(PhraseLib.Lookup("term.anycardholder", LanguageID).ToLower()) || functioninput.Text.ToLower().Equals(PhraseLib.Lookup("term.anycustomer", LanguageID).ToLower()) || functioninput.Text.ToLower().Equals(PhraseLib.Lookup("term.newcardholders", LanguageID).ToLower())) { isValidText = false; } if (!isValidText) { string alertMessage = Copient.PhraseLib.Lookup("term.enter", LanguageID) + " " + Copient.PhraseLib.Lookup("term.valid", LanguageID).ToLower() + " " + Copient.PhraseLib.Lookup("term.customergroup", LanguageID).ToLower() + " " + Copient.PhraseLib.Lookup("term.name", LanguageID).ToLower(); ScriptManager.RegisterStartupScript(UpdatePanelMain, UpdatePanelMain.GetType(), "AlertMessage", " AlertMessage('" + alertMessage + "'); ", true); } else if (IncludedGroupCount > 0 || ExcludedGroupCount > 0) { string alertMessage = Copient.PhraseLib.Lookup("term.customergroup", LanguageID) + ": " + Name + " " + Copient.PhraseLib.Lookup("term.is", LanguageID).ToLower() + " " + Copient.PhraseLib.Lookup("term.already", LanguageID).ToLower() + " " + Copient.PhraseLib.Lookup("term.selected", LanguageID).ToLower(); ScriptManager.RegisterStartupScript(UpdatePanelMain, UpdatePanelMain.GetType(), "AlertMessage", " AlertMessage('" + alertMessage + "');", true); } else if (AvailableListCount > 0) { string alertMessage = Copient.PhraseLib.Lookup("term.existing", LanguageID) + " " + Copient.PhraseLib.Lookup("term.customergroup", LanguageID).ToLower() + ": " + Name + " " + Copient.PhraseLib.Lookup("offer.message", LanguageID).ToLower(); ScriptManager.RegisterStartupScript(UpdatePanelMain, UpdatePanelMain.GetType(), "AlertMessage", " AlertMessage('" + alertMessage + "');", true); IncludedGroup.Add(AvailableFilteredCustomerGroup.Where(p => p.Name.Equals(functioninput.Text, StringComparison.OrdinalIgnoreCase)).FirstOrDefault()); HandleSelectedForSpecialGroup(); SetAvailableData(); SetButtons(); } else { IncludedGroup.Add(CreateCustomerGroup()); SetAvailableData(); SetButtons(); } } else { string alertMessage = Copient.PhraseLib.Lookup("term.enter", LanguageID) + " " + Copient.PhraseLib.Lookup("term.valid", LanguageID).ToLower() + " " + Copient.PhraseLib.Lookup("term.customergroup", LanguageID).ToLower() + " " + Copient.PhraseLib.Lookup("term.name", LanguageID).ToLower(); ScriptManager.RegisterStartupScript(UpdatePanelMain, UpdatePanelMain.GetType(), "AlertMessage", " AlertMessage('" + alertMessage + "');", true); } }