Пример #1
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            /*if (textBoxEmail.Text.Length == 0)
             * {
             *  errormessage.Text = "Enter an email.";
             *  textBoxEmail.Focus();
             * }
             * else
             * {
             *  string email = textBoxEmail.Text;
             *  string password = passwordBox1.Password;
             * // SqlConnection con = new SqlConnection("Data Source=TESTPURU;Initial Catalog=Data;User ID=sa;Password=wintellect");
             *  conn.Open();
             *  MySqlCommand cmd = new MySqlCommand("Select * from users where username='******'  and password='******'", conn);
             *  cmd.CommandType = CommandType.Text;
             *  MySqlDataAdapter adapter = new MySqlDataAdapter();
             *  adapter.SelectCommand = cmd;
             *  DataSet dataSet = new DataSet();
             *  adapter.Fill(dataSet);
             *  if (dataSet.Tables[0].Rows.Count > 0)
             *  {
             *      string username = dataSet.Tables[0].Rows[0]["Username"].ToString();
             *      // page.Welcome(username);//Sending value from one form to another form.
             *      //page.Welcome.Content = username;
             *      welcome.Name.Content = username;
             *      welcome.Show();
             *      Close();
             *  }
             *  else
             *  {
             *      errormessage.Text = "Sorry! Please enter existing username/password.";
             *  }
             *  conn.Close();
             * }*/
            String text = vm.CallLogin(textBoxEmail.Text, passwordBox1.Password);

            if (text == "Enter your username.")
            {
                errormessage.Text = text;
            }
            else if (text == "Sorry! Please enter existing username/password.")
            {
                errormessage.Text = text;
            }
            else
            {
                welcome.Label.Content = text;
                welcome.Show();
                Close();
            }
        }