Beispiel #1
0
      public void Register(UserData objUser) {
         string strQuery =
            "INSERT INTO Users (Login, Password, Email) VALUES ('" + objUser.Login + "', '" + objUser.Password + "', '" +
               objUser.Email + "' );";
         DbConnection.Open();
         SqlCommand objCommand = DbConnection.CreateCommand();
         objCommand.CommandText = strQuery;
         objCommand.ExecuteNonQuery();

         strQuery = "SELECT Id FROM users WHERE Login='******';";
         objCommand.CommandText = strQuery;
         var varDataReader = objCommand.ExecuteReader();
         string strUserId = String.Empty;
         if(varDataReader.Read() != false) {
            strUserId = varDataReader["Id"].ToString();
         }
         varDataReader.Close();
         if(strUserId != String.Empty) {
            strQuery = "INSERT INTO UsersInfo (LastName, FirstName, UserId) VALUES ('" +
               objUser.LastName + "', '" + objUser.FirstName + "'," + strUserId.ToString() + " );";
            objCommand.CommandText = strQuery;
            objCommand.ExecuteNonQuery();
         }
         DbConnection.Close();
      }
Beispiel #2
0
      public string LogIn(UserData objUser) {
         DbConnection.Open();
         string strQuery =
            "SELECT * FROM Users WHERE Login='******' AND Password='******';";
         SqlCommand objCommand = DbConnection.CreateCommand();
         objCommand.CommandText = strQuery;
         SqlDataReader objDataReader = objCommand.ExecuteReader();

         string strUserId = String.Empty;
         if(objDataReader.Read() != false) {
            strUserId=objDataReader["id"].ToString();
         }
         DbConnection.Close();
         return strUserId;
      }
Beispiel #3
0
      private void button1_Click(object sender, EventArgs e) {
         try {
            if(textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "") {
               MessageBox.Show("Fill all fields");
               return;
            }
            if(textBox2.Text != textBox3.Text) {
               MessageBox.Show("Passwords must match");
            }

            var objUser = new UserData();
            objUser.Password = textBox2.Text;
            objUser.Email = textBox1.Text;
            Program.ObjConnector.ChangePassword(objUser);
            MessageBox.Show("Password changed!");
            this.Close();
         }
         catch(Exception ex) {
            MessageBox.Show(ex.Message);
         }
      }
Beispiel #4
0
      private void button1_Click(object sender, EventArgs e) {
         try {
            label1.Text = "Searching...";
            label1.Refresh();
            progressBar1.Value = progressBar1.Minimum;
            for(int i = progressBar1.Minimum; i < progressBar1.Maximum; ++i) {
               progressBar1.Value = i;
               progressBar1.Refresh();
               Thread.Sleep(30);
            }
            progressBar1.Value = progressBar1.Minimum;


            var objUser = new UserData();
            objUser.Login = textBox1.Text;
            objUser.Password = textBox2.Text;

            string strUserId=Program.ObjConnector.LogIn(objUser);

            if (strUserId != String.Empty)
            {
               this.Hide();
               Form3 objForm3 = new Form3(Program.ObjConnector.GetUserInfo(strUserId));
               objForm3.ShowDialog();
               this.Show();
               return;
            }

            label1.ForeColor = Color.Red;
            label1.Text = "User not found";
            label1.Refresh();
         }
         catch(Exception ex) {
            MessageBox.Show(ex.Message);
         }
      }
Beispiel #5
0
 public void ChangePassword(UserData objUser) {
    DbConnection.Open();
    string strQuery =
       "UPDATE Users SET Password='******' WHERE Email='" + objUser.Email + "';";
    SqlCommand objCommand = DbConnection.CreateCommand();
    objCommand.CommandText = strQuery;
    objCommand.ExecuteNonQuery();
    DbConnection.Close();
 }