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 = AvailableFilteredPointProgram.Where(p => p.ProgramName.Equals(functioninput.Text, StringComparison.OrdinalIgnoreCase)).ToList().Count; int IncludedGroupCount = IncludedPointProgram.Where(p => p.ProgramName.Equals(functioninput.Text, StringComparison.OrdinalIgnoreCase)).ToList().Count; if (IncludedGroupCount > 0) { string alertMessage = Copient.PhraseLib.Lookup("term.pointsprogram", 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.pointsprogram", LanguageID).ToLower() + ": " + Name + " " + Copient.PhraseLib.Lookup("offer.message", LanguageID).ToLower(); ScriptManager.RegisterStartupScript(UpdatePanelMain, UpdatePanelMain.GetType(), "AlertMessage", " AlertMessage('" + alertMessage + "');", true); //First remove the selected point if exist any IncludedPointProgram.Clear(); IncludedPointProgram.Add(AvailableFilteredPointProgram.Where(p => p.ProgramName.Equals(functioninput.Text, StringComparison.OrdinalIgnoreCase)).FirstOrDefault()); SetAvailableData(); SetButtons(); } else { IncludedPointProgram.Clear(); //Then add newly created points program to the selected list IncludedPointProgram.Add(CreatePointsProgram()); SetAvailableData(); SetButtons(); } } else { string alertMessage = Copient.PhraseLib.Lookup("term.enter", LanguageID) + " " + Copient.PhraseLib.Lookup("term.valid", LanguageID).ToLower() + " " + Copient.PhraseLib.Lookup("term.pointsprogram", LanguageID).ToLower() + " " + Copient.PhraseLib.Lookup("term.name", LanguageID).ToLower(); ScriptManager.RegisterStartupScript(UpdatePanelMain, UpdatePanelMain.GetType(), "AlertMessage", " AlertMessage('" + alertMessage + "');", true); } }
private void SetAvailableData() { GetAllPointsProgram(); AvailableFilteredPointProgram = AllPointsProgram.Where(p => !IncludedPointProgram.Any(inc => inc.ProgramID == p.ProgramID)).ToList(); string strFilter = functioninput.Text; if (functionradio1.Checked) { AvailableFilteredPointProgram = AvailableFilteredPointProgram.Where(p => p.ProgramName.StartsWith(strFilter, StringComparison.OrdinalIgnoreCase)).ToList(); } else { AvailableFilteredPointProgram = AvailableFilteredPointProgram.Where(p => p.ProgramName.IndexOf(strFilter, StringComparison.OrdinalIgnoreCase) >= 0).ToList(); } lstSelected.DataSource = IncludedPointProgram; lstSelected.DataBind(); lstAvailable.DataSource = AvailableFilteredPointProgram; lstAvailable.DataBind(); }