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)); }
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)); }
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)); }
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)); }
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)); }
public DataTable GetBrands() { var oData = new Data(); return(oData.GetDataTable("SELECT * FROM Brand", null)); }
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)); }