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)); } }
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)); }
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)); }
public DataTable ShowList() { var data = new Data(); return(data.ShowDataTable("SELECT * FROM Product", null)); }