public static bool DoesStringContainsDigit(string str) { try { foreach (char item in str) { if (ValidateText.IsNumber(item.ToString())) { return(true); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return(false); }
private void BtnSave_Click(object sender, EventArgs e) { if (ValidateText.Text(this.txtPhone.Text)) { if (ValidateText.IsNumber(this.txtPhone.Text)) { string sql; if (this.Phone == null) { sql = "insert into id_phone values (" + this.Id + ", '" + this.txtPhone.Text + "');"; } else { sql = "update id_phone set phone='" + this.txtPhone.Text + "' where id=" + this.Id + " and phone = '" + this.Phone + "';"; } try { DataAccess.ExecuteUpdateQuery(sql); MessageBox.Show("Saved!!"); if (this.Phone != null) { sql = @"select * from id_phone where id=" + this.Id + ";"; this.CI.PopulateData(sql); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { this.Dispose(); } } else { MessageBox.Show("Not a valid Phone no"); } } }
private bool Validation() { bool flag = false; try { if (ValidateText.Text(this.txtPhone1.Text)) { if (ValidateText.IsNumber(this.txtPhone1.Text)) { flag = true; } else { flag = false; MessageBox.Show("Number Cannot contain alphabets", "Warning!!!"); } } if (ValidateText.Text(this.txtPhone2.Text)) { if (ValidateText.IsNumber(this.txtPhone2.Text)) { flag = true; } else { flag = false; MessageBox.Show("Number Cannot contain alphabets", "Warning!!!"); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return(flag); }