예제 #1
0
        public int Register(string username, string password)
        {
            var oData = new Data();

            var usernameSelect = new SqlParameter("@username", username);

            var usernamePar = new SqlParameter("@username", username);
            var passwordPar = new SqlParameter("@password", password);

            var selectParameters = new SqlParameter[]
            {
                usernameSelect,
            };

            var vecParams = new SqlParameter[]
            {
                usernamePar,
                passwordPar
            };

            var userExists = oData.GetDataTable("SELECT * FROM Users WHERE Username = isNull(@username, Username)", selectParameters).Rows.Count;

            if (userExists > 0)
            {
                throw new Exception("An user with that Username already exists.");
            }

            return((int)oData.ExecuteWithoutResults("INSERT INTO Users (Username, Password) VALUES (@username, @password)", vecParams));
        }
예제 #2
0
        public DataTable GetBrand(int id)
        {
            var oData     = new Data();
            var parameter = new SqlParameter("@id", id);
            var vecParams = new SqlParameter[]
            {
                parameter
            };

            return(oData.GetDataTable("SELECT * FROM Brand WHERE id = @id", vecParams));
        }
예제 #3
0
        public DataTable Login(string username)
        {
            var oData             = new Data();
            var usernameParameter = new SqlParameter("@username", username);
            var vecParams         = new SqlParameter[]
            {
                usernameParameter
            };

            return(oData.GetDataTable("SELECT * FROM Users WHERE Username = isNull(@username, Username)", vecParams));
        }
예제 #4
0
        public DataTable SearchBrands(string name)
        {
            var oData = new Data();

            var namePar   = new SqlParameter("@name", $"%{name}%");
            var vecParams = new SqlParameter[]
            {
                namePar
            };

            return(oData.GetDataTable("SELECT * FROM Brand WHERE Name LIKE isNull(@name, Name)", vecParams));
        }
예제 #5
0
        public DataTable SearchProducts(string name)
        {
            var oData = new Data();

            var namePar   = new SqlParameter("@name", $"%{name}%");
            var vecParams = new SqlParameter[]
            {
                namePar
            };

            return(oData.GetDataTable("SELECT * FROM Product WHERE Name LIKE @name", vecParams));
        }
예제 #6
0
        public DataTable GetBrands()
        {
            var oData = new Data();

            return(oData.GetDataTable("SELECT * FROM Brand", null));
        }
예제 #7
0
        public DataTable GetProducts()
        {
            var oData = new Data();

            return(oData.GetDataTable("SELECT * FROM Product", null));
        }
        public DataTable GetCategories()
        {
            var oData = new Data();

            return(oData.GetDataTable("SELECT * FROM Category", null));
        }