Пример #1
0
        public bool registerUser(userBO obj)
        {
            bool registered   = false;
            int  uidIncrement = getUserID();

            uidIncrement++;
            //Console.WriteLine(eidIncrement);

            SqlConnection s     = new SqlConnection(connectionString);
            string        query = "insert into users(uid,username,password) Values ('" + uidIncrement + "' , '" + obj.name + "','" + obj.psw + "')";
            //string query = "insert into employees (eid,name,salary,bonusRatio,tax,designation) Values ('" + eidIncrement + "','" + obj.empName + "','" + obj.empSalary + "', '" + obj.empBonusRatio + "','" + obj.empTax + "','" + obj.empDesignation + "')";
            //eidIncrement++;
            SqlCommand cmd = new SqlCommand(query, s);

            s.Open();

            int i = cmd.ExecuteNonQuery();

            if (i > 0)
            {
                registered = true;
                //Console.WriteLine("User is registered.");
            }
            else
            {
                //Console.WriteLine("User is not registered.");
                registered = false;
            }
            return(registered);
        }
Пример #2
0
        public bool loginUser(userBO obj)
        {
            SqlConnection s = new SqlConnection(connectionString);

            bool userAuth = false;

            string query = "select * from users where (userName = '******')  and (password= '******') ";

            SqlCommand cmd = new SqlCommand(query, s);

            s.Open();

            SqlDataReader dr = cmd.ExecuteReader();

            Console.WriteLine("");
            Console.WriteLine("");
            while (dr.Read())
            {
                Console.WriteLine("                         - - -Welcome User " + dr[1] + "- - -         ");
                userAuth = true;
            }

            s.Close();
            return(userAuth);
        }
        public bool registerUser(userBO obj)
        {
            bool register = false;

            makeUserPasswordEncrypted(obj);
            register = adal.registerUser(obj);
            return(register);
        }
        public bool loginUser(userBO obj)
        {
            bool loginUser = false;

            makeUserPasswordEncrypted(obj);
            loginUser = adal.loginUser(obj);
            return(loginUser);
        }
        public bool changeUserPassword(userBO obj)
        {
            bool passwordChange = false;

            makeUserPasswordEncrypted(obj);
            passwordChange = adal.changeUserPassword(obj);
            return(passwordChange);
        }
Пример #6
0
 protected void btnregister_Click(object sender, EventArgs e)
 {
     userBO ubo = new userBO();
     //ubo.username = Convert.ToString(tx)
     clsBusinessLayer bl = new clsBusinessLayer();
     int status          = bl.UserRegistration()
                           //if(status)
                           //    Response.Redirect()
 }
Пример #7
0
        private bool loginUser()
        {
            bool   loginUser = false;
            string userName = "", userPassword = "";

            Console.Write("                 Enter username: "******"                 Enter password: ");
            userPassword = Console.ReadLine();
            userBO     userBo = new userBO(userName, userPassword);
            logicLayer bll    = new logicLayer();

            loginUser = bll.loginUser(userBo);
            return(loginUser);
        }
        public void makeUserPasswordEncrypted(userBO obj)
        {
            string psw = obj.psw;

            char[] encrypt_psw = new char[25];
            int    increment   = 0;

            for (int i = 0, j = psw.Length - 1; i < j; i++, j--)
            {
                encrypt_psw[increment++] = psw.ElementAt(i);
                encrypt_psw[increment++] = psw.ElementAt(j);
            }
            string psw_encrypted = new string(encrypt_psw);

            obj.psw = psw_encrypted;
        }
Пример #9
0
        private bool changeUserPassword(int passwordTry)
        {
            bool   passwordChange  = false;
            int    id              = 0;
            string temp            = "";
            string password        = "";
            string confirmPassword = "";
            int    temp1           = 0;

            Console.Write("                 Enter ID                 :");
            temp = Console.ReadLine();
            Int32.TryParse(temp, out temp1);
            id = Convert.ToInt32(temp1);
            Console.Write("                 Enter password           :"******"                 Enter password again     :");
            confirmPassword = Console.ReadLine();
            userBO obj = new userBO(id, confirmPassword);

            Console.WriteLine("");
            Console.WriteLine("");
            if (password == confirmPassword)
            {
                passwordChange = bll.changeUserPassword(obj);
            }
            else
            {
                passwordTry++;
                if (passwordTry == 3)
                {
                    Console.WriteLine("                         ** Kindly Login again now **               ");
                    start();
                }
                Console.WriteLine("                         ** Passwords not matched **               ");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.Write("        Kindly, Try again : ");
                Console.WriteLine("");
                Console.WriteLine("");
                changeUserPassword(passwordTry);
            }
            return(passwordChange);
        }
Пример #10
0
        public bool changeUserPassword(userBO obj)
        {
            bool          passwordChange = false;
            SqlConnection s     = new SqlConnection(connectionString);
            string        query = "update users set password= '******' where uid= '" + obj.id + "' ";
            SqlCommand    cmd   = new SqlCommand(query, s);

            s.Open();

            int i = cmd.ExecuteNonQuery();

            if (i > 0)
            {
                passwordChange = true;
            }
            else
            {
                passwordChange = false;
            }
            return(passwordChange);
        }