Exemple #1
0
        public DataTable Search(string productName, string sku, string brand)
        {
            var data = new Data();

            var pName  = new SqlParameter("@pName", productName);
            var pSku   = new SqlParameter("@pSku", sku);
            var pBrand = new SqlParameter("@pBrand", brand);

            var allParams = new SqlParameter[] { pName, pSku, pBrand };

            if (string.IsNullOrEmpty(productName) && string.IsNullOrEmpty(sku) && string.IsNullOrEmpty(brand))
            {
                return(data.ShowDataTable("SELECT * FROM Product", null));
            }
            else
            {
                return(data.ShowDataTable("SELECT * FROM Product WHERE name = ISNULL(@pName,name) OR sku = ISNULL(@pSku,sku) OR brand = ISNULL(@pBrand, brand)", allParams));
            }
        }
Exemple #2
0
        public DataTable GetProductBySku(string sku)
        {
            var data = new Data();

            var pSku = new SqlParameter("@pSku", sku);

            var allParams = new SqlParameter[] { pSku };

            return(data.ShowDataTable("SELECT TOP 1 * FROM Product WHERE sku = @pSku", allParams));
        }
Exemple #3
0
        public DataTable GetUserByInputData(string userName, string password)
        {
            var data = new Data();

            var firstParameter  = new SqlParameter("@pUserName", userName);
            var secondParameter = new SqlParameter("@pPassword", password);

            var allParams = new SqlParameter[] { firstParameter, secondParameter };

            return(data.ShowDataTable("SELECT TOP 1 * FROM Users WHERE user_name = @pUserName AND password = @pPassword", allParams));
        }
Exemple #4
0
        public DataTable ShowList()
        {
            var data = new Data();

            return(data.ShowDataTable("SELECT * FROM Product", null));
        }