示例#1
0
 private void Setdata_Click(object sender, RoutedEventArgs e)
 {
     setdata.Cursor = Cursors.Wait;
     try {
         if ((password.Text == repeatpassword.Text) && (login.Text != ""))
         {
             string     hash           = GetMD.Getmd(GetMD.Getmd(GetMD.Getmd(GetMD.Getmd(password.Text))));
             string     sqlchek        = "Select id from userdata where username='******'";
             string     insert         = "insert into userdata (username,password) values ('{0}','{1}')";
             string     formatedinsert = string.Format(insert, login.Text, hash);
             SqlCommand ins            = new SqlCommand(formatedinsert, Connection.MyConnection);
             SqlCommand cmd            = new SqlCommand(sqlchek, Connection.MyConnection);
             Connection.On(0);
             SqlDataReader rd   = cmd.ExecuteReader();
             int           chek = 0;
             while (rd.Read())
             {
                 chek = rd.GetInt32(0);
             }
             if (chek == 0)
             {
                 setdata.Cursor = Cursors.Arrow;
                 ins.ExecuteNonQuery();
                 Connection.Off();
                 bdrWelcomeMessage.Visibility = Visibility.Visible;
                 UserName.Text = login.Text;
             }
             else
             {
                 setdata.Cursor = Cursors.Arrow;
                 Connection.Off();
                 ettention.Content = "This username is taken";
             }
         }
         else
         {
             setdata.Cursor    = Cursors.Arrow;
             ettention.Content = "Passwords must match";
         }
     }
     catch (System.InvalidOperationException) {
         setdata.Cursor  = Cursors.Arrow;
         ettentions.Text = "No connection established, but you can use offline mod from login menu";
         bdrEttentionMessage.Visibility = Visibility.Visible;
     }
 }
示例#2
0
 public void butlog_Click(object sender, RoutedEventArgs e)
 {
     butlog.Cursor = Cursors.Wait;
     try{
         if (login.Text != "")
         {
             string     hash    = GetMD.Getmd(GetMD.Getmd(GetMD.Getmd(GetMD.Getmd(password.Text))));
             string     sqlchek = "Select id from userdata where username='******' and password='******'";
             SqlCommand cmd     = new SqlCommand(sqlchek, Connection.MyConnection);
             Connection.On(0);
             int           chek = 0;
             SqlDataReader rd   = cmd.ExecuteReader();
             while (rd.Read())
             {
                 chek = rd.GetInt32(0);
             }
             Connection.Off();
             if (chek != 0)
             {
                 butlog.Cursor   = Cursors.Arrow;
                 ettentions.Text = "Сonnection is ok, you can enter online mod by using this account";
                 UserName.Text   = login.Text;
                 bdrWelcomeMessage.Visibility = Visibility.Visible;
             }
             else
             {
                 butlog.Cursor     = Cursors.Arrow;
                 ettention.Content = "wrong username / password";
             }
         }
         else
         {
             butlog.Cursor     = Cursors.Arrow;
             ettention.Content = "login string is empty!";
         }
     }
     catch (System.InvalidOperationException) {
         butlog.Cursor   = Cursors.Arrow;
         ettentions.Text = "Сonnection is not established, but you can enter offline mod by using entered username";
         UserName.Text   = login.Text;
         bdrWelcomeMessage.Visibility = Visibility.Visible;
     }
 }