private void OnSearchCommand() { Client foundClient = null; string messageText = null; switch (SearchType) { case NameSearchType: foundClient = ClientsData.FirstOrDefault(x => x.FullName.Equals(SearchText.Trim())); messageText = foundClient?.FullName; break; case PhoneSearchType: foundClient = ClientsData.SingleOrDefault(x => x.Phone.Equals(SearchText.Trim())); messageText = foundClient?.Phone; break; case PNSearchType: foundClient = ClientsData.SingleOrDefault(x => x.PersonalNumber.Equals(SearchText.Trim())); messageText = foundClient?.PersonalNumber; break; case EmailSearchType: foundClient = ClientsData.SingleOrDefault(x => x.Email.Equals(SearchText.Trim())); messageText = foundClient?.Email; break; } if (foundClient != null) { MessageBox.Show($"The list contains person with {SearchType.ToLower()}: {messageText} / On row: {ClientsData.IndexOf(foundClient) + 1}"); } else { MessageBox.Show($"Not valid {SearchType.ToLower()}!"); } }
public override void RenderControl(HtmlTextWriter output) { if (!string.IsNullOrEmpty(WebAnalyticsFunction)) { WebAnalyticsFunction = string.Format("onsubmit=\"{0}\"", WebAnalyticsFunction); } else { WebAnalyticsFunction = ""; } output.Write(string.Format("<div class=\"leftnav-default\"><h3>{2}</h3><form {0} method=\"post\" name=\"NCSearchBox\" action=\"{1}\">", WebAnalyticsFunction, ActionURL, Title)); if (SearchType.ToLower() == "keyword_with_date") { output.Write(@"Search For:<label class=""hidden"" for=""keyword"">keyword</label> <input id=""keyword"" class=""find-news-release-keyword"" name=""keyword""> <table class=""find-news-release-dates""><tr><th colspan=""2"" scope=""col"">Between these dates:</th></tr> <tr><td> <label class=""hidden"" for=""startMonth"">select start Month</label> <select id=""startMonth"" name=""startMonth""> <option selected value=""1"">Jan.</option> <option value=""2"">Feb.</option> <option value=""3"">Mar.</option> <option value=""4"">Apr.</option> <option value=""5"">May</option> <option value=""6"">Jun.</option> <option value=""7"">Jul.</option> <option value=""8"">Aug.</option> <option value=""9"">Sept.</option> <option value=""10"">Oct.</option> <option value=""11"">Nov.</option> <option value=""12"">Dec.</option></select> </td><td> <label class=""hidden"" for=""startYear"">select start Year</label> <select id=""startYear"" name=""startYear"">{0}</select> </td></tr> <tr><td> <label class=""hidden"" for=""endMonth"">select end Month</label> <select id=""endMonth"" name=""endMonth""> {1} </select></td><td> <label class=""hidden"" for=""endYear"">select end Year</label> <select id=""endYear"" name=""endYear"">{2}</select> </td></tr></table>", GetYearListItems("startYear"), GetMonthListItems("endMonth"), GetYearListItems("endYear")); if (PageAssemblyContext.Current.PageAssemblyInstruction.Language == "es") { output.Write(@"<input alt=""Search"" src=""/images/red_buscar_button.gif"" type=""image"" class=""find-news-release-image""></form></div>"); } else { output.Write(@"<input alt=""Search"" src=""/images/red_go_button.gif"" type=""image"" class=""find-news-release-image""></form></div>"); } } else { if (PageAssemblyContext.Current.PageAssemblyInstruction.Language == "es") { output.Write(@"<label for=""keyword"" class=""palabra-title"">Palabra clave</label> <input type=""text"" id=""keyword"" name=""keyword"" class=""search-go-spanish"" /> <input type=""image"" src=""/images/buscar-left-nav.gif"" alt=""Buscar"" class=""search-go-spanish-image"" /> </form></div>" ); } else { output.Write(@"<label class=""hidden"" for=""keyword"">keyword</label> <input id=""keyword"" class=""search-go-english"" name=""keyword""><input alt=""Search"" src=""/images/red_go_button.gif"" type=""image"" class=""search-go-english-image""></form></div>"); } } }