Exemplo n.º 1
0
        public bool Login(string username, string password)
        {
            try
            {
                Dictionary <string, object> param = new Dictionary <string, object>();
                param.Add("username", username);
                Database DB = new Database("CALL `getUser`(@username)", param);

                Dictionary <string, object> result = DB.Fetch();
                DB.Done();

                if (result.Count != 0 && ComparePassword(password, result["password"].ToString()))
                {
                    FillData(result);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        public bool CreateUser()
        {
            // Check if password is compatible
            string base64 = BuildPassword(this.Password);

            if (ComparePassword(this.Password, base64) == true)
            {
                if (Type == Status.Employee)
                {
                    Dictionary <string, object> param = new Dictionary <string, object>();
                    param.Add("username", this.Username);
                    param.Add("password", base64);
                    param.Add("firstname", this.Firstname);
                    param.Add("lastname", this.Lastname);

                    Database DB     = new Database("CALL `addEmployee`(@username, @password, @firstname, @lastname)", param);
                    bool     result = DB.Success;
                    DB.Done();
                    return(result);
                }
                else
                {
                    Dictionary <string, object> param = new Dictionary <string, object>();
                    param.Add("username", this.Username);
                    param.Add("password", base64);
                    param.Add("firstname", this.Firstname);
                    param.Add("lastname", this.Lastname);

                    Database DB     = new Database("CALL `addCustomer`(@username, @password, @firstname, @lastname)", param);
                    bool     result = DB.Success;
                    DB.Done();
                    return(result);
                }
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        public bool CreateUser()
        {
            // Check if password is compatible
            string base64 = BuildPassword(this.Password);

            if (ComparePassword(this.Password, base64) == true)
            {
                if (Type == Status.Employee)
                {
                    Dictionary<string, object> param = new Dictionary<string, object>();
                    param.Add("username", this.Username);
                    param.Add("password", base64);
                    param.Add("firstname", this.Firstname);
                    param.Add("lastname", this.Lastname);

                    Database DB = new Database("CALL `addEmployee`(@username, @password, @firstname, @lastname)", param);
                    bool result = DB.Success;
                    DB.Done();
                    return result;
                }
                else
                {
                    Dictionary<string, object> param = new Dictionary<string, object>();
                    param.Add("username", this.Username);
                    param.Add("password", base64);
                    param.Add("firstname", this.Firstname);
                    param.Add("lastname", this.Lastname);

                    Database DB = new Database("CALL `addCustomer`(@username, @password, @firstname, @lastname)", param);
                    bool result = DB.Success;
                    DB.Done();
                    return result;
                }
            }
            else
            {
                return false;
            }

            
        }
Exemplo n.º 4
0
        public bool Login(string username, string password)
        {
            try
            {
                Dictionary<string, object> param = new Dictionary<string, object>();
                param.Add("username", username);
                Database DB = new Database("CALL `getUser`(@username)", param);

                Dictionary<string, object> result = DB.Fetch();
                DB.Done();

                if(result.Count != 0 && ComparePassword(password, result["password"].ToString()))
                {
                    FillData(result);
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch(Exception)
            {
                return false;
            }
        }