ConfigurationManager.ConnectionStrings["ConnData"].ConnectionString;
using System; using System.Windows.Forms; using System.Collections.Generic; using System.ComponentModel; using System.Net; using System.Data.Sql; using System.Configuration; using System.Collections.Specialized; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Data; using System.Data.SqlClient; using System.Text.RegularExpressions; using System.Runtime.InteropServices; namespace Proj.Data { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class Login : Window { public Login() { InitializeComponent(); new SplashWindow().ShowDialog(); } private void Window_Loaded(object sender, RoutedEventArgs e) { } private void Exit_Click(object sender, RoutedEventArgs e) { this.Close(); } private void Button1_Click(object sender, RoutedEventArgs e) { if ((textBox1.Text != "") && (passwordbox1.Password != "")) { string connstring = ConfigurationManager.ConnectionStrings["ConnData"].ConnectionString; SqlConnection con = new SqlConnection(connstring); string q = "select * from Login where UserId = @Username and Password = @Password "; SqlCommand cmd = new SqlCommand(q, con); cmd.Parameters.AddWithValue("@Username", this.textBox1.Text); cmd.Parameters.AddWithValue("@Password", this.passwordbox1.Password); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { if (dr.HasRows == true) { System.Windows.MessageBox.Show("Login Successfully Done"); } } if (dr.HasRows == false) { textBlock5.Visibility = System.Windows.Visibility.Visible; } else { textBlock5.Visibility = System.Windows.Visibility.Visible; } } } private void textBox1_TextChanged(object sender, TextChangedEventArgs e) { textBlock5.Visibility = System.Windows.Visibility.Hidden; if (Keyboard.GetKeyStates(Key.CapsLock) == KeyStates.Toggled) { textBlock4.Visibility = System.Windows.Visibility.Visible; } else { textBlock4.Visibility = System.Windows.Visibility.Hidden; } } private void passwordbox1_PasswordChanged(object sender, RoutedEventArgs e) { textBlock5.Visibility = System.Windows.Visibility.Hidden; if (Keyboard.GetKeyStates(Key.CapsLock) == KeyStates.Toggled) { textBlock4.Visibility = System.Windows.Visibility.Visible; } else { textBlock4.Visibility = System.Windows.Visibility.Hidden; } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)