Esempio n. 1
0
        /// <summary>
        /// Method to check that the username doesn't already exist
        /// </summary>
        /// <param name="rbo"></param>
        /// <returns></returns>
        public int validate_user(CommonBO rbo)
        {
            try
            {
                cmd = new SqlCommand("validateuserdata", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@UserName", rbo.username);
                cmd.Parameters.AddWithValue("@Password", rbo.password);
                conn.Open();

                SqlDataReader read = cmd.ExecuteReader();
                read.Read();
                if (read.HasRows)
                {
                    return 1;
                }
                else
                {
                    return 0;
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Methos to resister a new user
 /// </summary>
 /// <param name="rbo"></param>
 /// <returns></returns>
 public int register_DAL(CommonBO rbo)
 {
     int result = 6;
     try
     {
         cmd = new SqlCommand("insertuserdata", conn);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@FirstName", rbo.firstname);
         cmd.Parameters.AddWithValue("@LastName", rbo.lastname);
         cmd.Parameters.AddWithValue("@UserName", rbo.username);
         cmd.Parameters.AddWithValue("@Password", rbo.password);
         cmd.Parameters.AddWithValue("@Cpassword", rbo.cpassword);
         cmd.Parameters.AddWithValue("@emailID", rbo.emailid);
         cmd.Parameters.AddWithValue("@result", SqlDbType.Int).Direction = ParameterDirection.Output;
         conn.Open();
         cmd.ExecuteNonQuery();
         result = Convert.ToInt32(cmd.Parameters["@result"].Value);
         return result;
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         conn.Close();
     }
 }
Esempio n. 3
0
 public int login_BAL(CommonBO rbo)
 {
     try
     {
         return rdal.validate_user(rbo);
     }
     catch (Exception ex)
     {
         ex.GetType();
     }
     return 0;
 }
Esempio n. 4
0
 //Registration of the user
 public int register_BAL(CommonBO rbo)
 {
     try
     {
         return rdal.register_DAL(rbo);
     }
     catch (Exception ex)
     {
         ex.GetType();
     }
     return 0;
 }
        protected void Button_submitregistration_Click(object sender, EventArgs e)
        {
            CommonBO rbo = new CommonBO();
            RegistrationBAL rbal = new RegistrationBAL();
            rbo.firstname = TextBox_firstname.Text.Trim();
            rbo.lastname = TextBox_lastname.Text.Trim();
            rbo.username = TextBox_username.Text.Trim();
            rbo.password = TextBox_password.Text.Trim();
            rbo.cpassword = TextBox_cpassword.Text.Trim();
            rbo.emailid = TextBox_emailid.Text.Trim();
            int value = rbal.register_BAL(rbo);
            if (value == 0)
            {

                Response.Redirect("Loginpage.aspx");
            }

            else
            {
                Label_errormessage.Text = "Username already Exists!!!";
            }
        }
Esempio n. 6
0
        public void Loginwithwrongusername()
        {
            int expected = 0;

            string username = "******";
            string password = "******";
            CommonBO rbo = new CommonBO();
            LoginBAL rbal = new LoginBAL();
            LoginDAL rDAL = new LoginDAL();

            rbo.username = username;
            rbo.password = password;

            int Actual = rDAL.validate_user(rbo);

            Assert.AreEqual(expected, Actual);
        }
Esempio n. 7
0
        public void Loginofexistinguser()
        {
            int expected = 1;

            string username = "******";
            string password = "******";
            CommonBO rbo = new CommonBO();
            //    RegistrationBAL rbal = new RegistrationBAL();
            LoginBAL rbal = new LoginBAL();
            LoginDAL rDAL = new LoginDAL();

            rbo.username = username;
            rbo.password = password;

            int Actual = rDAL.validate_user(rbo);

            Assert.AreEqual(expected, Actual);
        }