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); } }
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); } }