private void Button_Click(object sender, RoutedEventArgs e) { // remove_error(); loginmodel lm = new loginmodel(txtname.Text, pbpassword.Password, txtaddress.Text, txtphone.Text); error = lm.checkvalid(); if (lm.insert()) { Window1 NewWindow = new Window1(); NewWindow.Show(); this.Hide(); System.Windows.MessageBox.Show("Account created"); } else { // lm.showerror(error,t); } }