Example #1
0
        public int saveOrder(Order theOrder)
        {
            DBSelector selector = new DBSelector();

            return(selector.getRow <int>("INSERT INTO \"Order\" (\"ConfirmationNumber\", \"OrderDateTime\", \"TotalPrice\", \"UserID\") VALUES ('" +
                                         theOrder.ConfirmationNumber + "','" + theOrder.OrderDateTime + "','" + theOrder.TotalPrice + "','" + theOrder.UserID + "')" +
                                         "RETURNING \"OrderID\""));
        }
Example #2
0
        public int saveLoginInfo(string username, string password)
        {
            DBModifier modder = new DBModifier();

            modder.modifyRows("INSERT INTO \"Login\" (\"UserName\", \"Password\") VALUES ('" + username + "','" + password + "')");

            DBSelector selector = new DBSelector();

            Login newLogin = selector.getRow <Login>("SELECT * FROM \"Login\" WHERE " +
                                                     "\"UserName\" = '" + username + "' AND \"Password\" = '" + password + "'");

            return(newLogin.ID);
        }
Example #3
0
        public void addItem(Item theItem, Vendor theVendor)
        {
            DBModifier modder   = new DBModifier();
            DBSelector selector = new DBSelector();

            //put the item in the DB
            modder.modifyRows("INSERT INTO \"Item\"(\"RetailPrice\",\"StockQuantity\",\"ItemName\",\"CostPrice\",\"Category\") VALUES(" +
                              theItem.RetailPrice + "," + theItem.StockQuantity + ",'" + theItem.ItemName + "'," + theItem.CostPrice + ",'" +
                              theItem.Category + "')");

            Item newitem = selector.getRow <Item>("SELECT * FROM \"Item\" WHERE \"RetailPrice\" = " + theItem.RetailPrice +
                                                  " AND \"StockQuantity\" = " + theItem.StockQuantity +
                                                  " AND \"ItemName\" = '" + theItem.ItemName +
                                                  "' AND \"CostPrice\" = " + theItem.CostPrice +
                                                  " AND \"Category\" = '" + theItem.Category + "'");

            //add it to the vedor
            modder.modifyRows("INSERT INTO \"Vendor_Items\"(\"VendorID\",\"ItemID\") VALUES( " +
                              theVendor.VendorID + "," + newitem.ItemID + ")");
        }
Example #4
0
        public Login getLoginByUserID(int userID)
        {
            DBSelector selector = new DBSelector();

            return(selector.getRow <Login>("SELECT * FROM \"Public.Login\" WHERE \"ID\" = '" + userID + "'"));
        }
Example #5
0
        public User getUserByID(int ID)
        {
            DBSelector selector = new DBSelector();

            return(selector.getRow <User>("SELECT * FROM \"User\" WHERE \"ID\"= '" + ID + "'"));
        }
Example #6
0
        public Item getItemByID(int ID)
        {
            DBSelector selector = new DBSelector();

            return(selector.getRow <Item>("SELECT * FROM \"Item\" WHERE \"ItemID\"= '" + ID + "'"));
        }
Example #7
0
        public Order getOrderByID(int ID)
        {
            DBSelector selector = new DBSelector();

            return(selector.getRow <Order>("SELECT * FROM \"Order\" WHERE \"OrderID\"= '" + ID + "'"));
        }
Example #8
0
        public Vendor getVendorByID(int id)
        {
            DBSelector selector = new DBSelector();

            return(selector.getRow <Vendor>("SELECT * FROM \"Vendor\" WHERE \"VendorName\"='" + id + "'"));
        }
Example #9
0
        public Vendor getVendorByName(string name)
        {
            DBSelector selector = new DBSelector();

            return(selector.getRow <Vendor>("SELECT * FROM \"Vendor\" WHERE \"VendorName\"='" + name + "'"));
        }