//Author: Amin Aden public static bool InsertProduct(string prodName, int supplierId) { string sql = " insert into Products (ProdName) values (@ProdName) "; SqlCommand command = new SqlCommand(sql); command.Parameters.AddWithValue("@ProdName", prodName); return(DB.updateRow(command)); }
//Author: Amin Aden public static bool UpdateProduct(int productId, string prodName /*, int supplierId*/) { string sql = " update Products set ProdName = (@ProdName) where ProductId = (@ProdID) ;"; SqlCommand command = new SqlCommand(sql); command.Parameters.AddWithValue("@ProdName", prodName); command.Parameters.AddWithValue("@ProdID", productId); return(DB.updateRow(command)); }
//Author: Mustafa Warsama public static bool UpdateSupplier(int supplierId, string supName) { // this is the query and specific filed to preform an update operation // this was done by Mustafa Warsama string sql = "UPDATE Suppliers SET SupName = @SupName WHERE SupplierId = @SupplierId"; SqlCommand command = new SqlCommand(sql); command.Parameters.AddWithValue("@SupplierId", supplierId); command.Parameters.AddWithValue("@SupName", supName); return(DB.updateRow(command)); }
//Author: Abdulwahab Alansari /// <summary> /// Add product to package /// </summary> /// <param name="productId"></param> /// <param name="supplierId"></param> /// <param name="packageId"></param> /// <returns></returns> public static bool AddProductToPackage(int productId, int supplierId, int packageId) { int productSupplierId = GetProductSupplierId(productId, supplierId); string sql = "INSERT INTO Packages_Products_Suppliers "; sql += "(PackageId, ProductSupplierId) VALUES (@packageId, @productSupplierId)"; SqlCommand command = new SqlCommand(sql); command.Parameters.AddWithValue("@productSupplierId", productSupplierId); command.Parameters.AddWithValue("@packageId", packageId); return(DB.updateRow(command)); }
//Author: Abdulwahab Alansari /// <summary> /// Add new package /// </summary> /// <param name="PkgName"></param> /// <param name="PkgStartDate"></param> /// <param name="PkgEndDate"></param> /// <param name="PkgDesc"></param> /// <param name="PkgBasePrice"></param> /// <param name="PkgAgencyCommission"></param> /// <returns></returns> public static bool InsertPackage(string PkgName, DateTime PkgStartDate, DateTime PkgEndDate, string PkgDesc, decimal PkgBasePrice, decimal PkgAgencyCommission) { string sql = "INSERT INTO Packages (PkgName, PkgStartDate, PkgEndDate, PkgDesc, PkgBasePrice, PkgAgencyCommission) "; sql += "VALUES (@PkgName, @PkgStartDate, @PkgEndDate, @PkgDesc, @PkgBasePrice, @PkgAgencyCommission)"; SqlCommand command = new SqlCommand(sql); command.Parameters.AddWithValue("@PkgName", PkgName); command.Parameters.AddWithValue("@PkgStartDate", PkgStartDate); command.Parameters.AddWithValue("@PkgEndDate", PkgEndDate); command.Parameters.AddWithValue("@PkgDesc", PkgDesc); command.Parameters.AddWithValue("@PkgBasePrice", PkgBasePrice); command.Parameters.AddWithValue("@PkgAgencyCommission", PkgAgencyCommission); return(DB.updateRow(command)); }
//Author: Mustafa Warsama public static bool InsertSupplier(int SupplierID, string supName) { //this part add supplier in to the database //this was done by Mustafa Warsama //get current maximum id, so I can add 1 later string getmax = "SELECT MAX(SupplierId) FROM Suppliers"; SqlCommand max = new SqlCommand(getmax); int maxid; maxid = DB.DoScalar(max); string sql = "INSERT into Suppliers (SupplierId, SupName) values ( @supplierId,@supName)"; SqlCommand command = new SqlCommand(sql); command.Parameters.AddWithValue("@supplierId", maxid + 1);//add 1 so the new ID is quaranteed to be unique () command.Parameters.AddWithValue("@supName", supName); return(DB.updateRow(command)); }