public async Task <int> DeleteProductFromInventory(string iID, string pID, byte[] error)
        {
            int status = 10;

            status = await Task.Run(() => Warehouse_Wrapper.deleteProductFromInventory(iID, pID, error, _ConnectionString));

            return(status);
        }
        public async Task <int> EditProductInInventory(ProductInInventory entity, byte[] error)
        {
            int status = 0;
            ProductInInventory product = (ProductInInventory)(object)(entity);

            status = await Task.Run(() => Warehouse_Wrapper.editProductInInventory(product, error, _ConnectionString));

            return(status);
        }
示例#3
0
        public async Task <int> EditOrder(Order entity, byte[] error)
        {
            int   status = 0;
            Order order  = (Order)(object)(entity);

            status = await Task.Run(() => Warehouse_Wrapper.editOrder(order, error, _ConnectionString));

            return(status);
        }
示例#4
0
        public async Task <int> AddPayment(Payment entity, byte[] error)
        {
            int status = 0;

            Payment payment = (Payment)(object)(entity);

            status = await Task.Run(() => Warehouse_Wrapper.addPayment(payment, error, _ConnectionString));

            return(status);
        }
        public async Task <int> AddPotentialProduct(ProductInOrder entity, byte[] error)
        {
            int status = 0;

            ProductInOrder product = (ProductInOrder)(object)(entity);

            status = await Task.Run(() => Warehouse_Wrapper.addPotentialProduct(product, error, _ConnectionString));

            return(status);
        }
示例#6
0
        public async Task <int> Create(T entity, byte[] error)
        {
            int status = 0;

            if (typeof(T) == typeof(Inventory))
            {
                Inventory inventory = (Inventory)(object)(entity);
                status = await Task.Run(() => Warehouse_Wrapper.addInventory(inventory, error, _ConnectionString));
            }
            if (typeof(T) == typeof(ProductInInventory))
            {
                ProductInInventory product = (ProductInInventory)(object)(entity);
                status = await Task.Run(() => Warehouse_Wrapper.addProductToInventory(product, error, _ConnectionString));
            }
            if (typeof(T) == typeof(Product))
            {
                Product product = (Product)(object)(entity);
                status = await Task.Run(() => Warehouse_Wrapper.addProduct(product, error, _ConnectionString));
            }

            if (typeof(T) == typeof(Order))
            {
                Order order = (Order)(object)(entity);
                status = await Task.Run(() => Warehouse_Wrapper.addOrder(order, error, _ConnectionString));
            }

            if (typeof(T) == typeof(ProductInOrder))
            {
                ProductInOrder product = (ProductInOrder)(object)(entity);
                status = await Task.Run(() => Warehouse_Wrapper.addProductToOrder(product, error, _ConnectionString));
            }

            if (typeof(T) == typeof(Customer))
            {
                Customer customer = (Customer)(object)entity;
                if (_ConnectionString != null)
                {
                    status = await Task.Run(() => Crm_Wrapper.AddCustomer(customer, error, _ConnectionString));
                }
            }

            if (typeof(T) == typeof(Opportunity))
            {
                Opportunity opportunity = (Opportunity)(object)(entity);
                status = await Task.Run(() => Crm_Wrapper.AddOpportunity(opportunity, error, _ConnectionString));
            }

            if (typeof(T) == typeof(OpportunityProduct))
            {
                OpportunityProduct product = (OpportunityProduct)(object)(entity);
                status = await Task.Run(() => Crm_Wrapper.AddOpportunityProduct(product, error, _ConnectionString));
            }

            return(status);
        }
示例#7
0
        public async Task <T> GetById(string id, byte[] error)
        {
            if (typeof(T) == typeof(Customer))
            {
                Customer customer = null;

                await Task.Run(() =>
                {
                    IntPtr customerPtr = Crm_Wrapper.getCustomerById(id, error, _ConnectionString);
                    customer           = (Customer)Marshal.PtrToStructure(customerPtr, typeof(Customer));
                    Marshal.FreeCoTaskMem(customerPtr);
                });

                //Console.WriteLine("status = " + status);
                return((T)(object)customer);
            }

            if (typeof(T) == typeof(Order))
            {
                IntPtr orderPtr;
                int    status = 0;
                Order  order  = null;

                await Task.Run(() =>
                {
                    status = Warehouse_Wrapper.getOrderInfo(id, out orderPtr, error, _ConnectionString);
                    order  = (Order)Marshal.PtrToStructure(orderPtr, typeof(Order));
                    Marshal.FreeCoTaskMem(orderPtr);
                });

                return((T)(object)order);
            }

            if (typeof(T) == typeof(Product))
            {
                IntPtr  prodductPtr;
                int     status  = 0;
                Product product = null;
                await Task.Run(() =>
                {
                    status  = Warehouse_Wrapper.getAllProductInfo(id, out prodductPtr, error, _ConnectionString);
                    product = (Product)Marshal.PtrToStructure(prodductPtr, typeof(Product));
                    Marshal.FreeCoTaskMem(prodductPtr);
                });

                return((T)(object)product);
            }
            return(null);
        }
示例#8
0
        public async Task <int> Delete(string id, byte[] error)
        {
            int status = 10;

            if (typeof(T) == typeof(Inventory))
            {
                status = await Task.Run(() => Warehouse_Wrapper.deleteInventory(id, error, _ConnectionString));
            }
            if (typeof(T) == typeof(Product))
            {
                status = await Task.Run(() => Warehouse_Wrapper.deleteProduct(id, error, _ConnectionString));
            }
            if (typeof(T) == typeof(Order))
            {
                status = await Task.Run(() => Warehouse_Wrapper.deleteOrder(id, error, _ConnectionString));
            }
            return(status);
        }
        public async Task <List <ProductInInventory> > ShowProductsInInventory(string id, byte[] error)
        {
            List <ProductInInventory> productsInInventory = new List <ProductInInventory>();
            IntPtr ProductPtr;
            await Task.Run(() =>
            {
                int number_fields = Warehouse_Wrapper.showProductsInInventory(id, out ProductPtr, error, _ConnectionString);

                IntPtr current = ProductPtr;
                for (int i = 0; i < number_fields; ++i)
                {
                    ProductInInventory productInInventory = (ProductInInventory)Marshal.PtrToStructure(current, typeof(ProductInInventory));

                    current = (IntPtr)((long)current + Marshal.SizeOf(productInInventory));
                    productsInInventory.Add(productInInventory);
                }
                Marshal.FreeCoTaskMem(ProductPtr);
            });

            return(productsInInventory);
        }
示例#10
0
        public async Task <List <Product> > SearchProducts(string key, string value, byte[] error)
        {
            List <Product> products = new List <Product>();
            IntPtr         ProductPtr;
            await Task.Run(() =>
            {
                int number_fields = Warehouse_Wrapper.searchProducts(out ProductPtr, key, value, error, _ConnectionString);

                IntPtr current = ProductPtr;
                for (int i = 0; i < number_fields; ++i)
                {
                    Product product = (Product)Marshal.PtrToStructure(current, typeof(Product));

                    current = (IntPtr)((long)current + Marshal.SizeOf(product));
                    products.Add(product);
                }
                Marshal.FreeCoTaskMem(ProductPtr);
            });

            return((List <Product>)(object) products);
        }
示例#11
0
        public async Task <List <Order> > ShowReceipts(byte[] error)
        {
            List <Order> orders = new List <Order>();
            IntPtr       ProductPtr;
            await Task.Run(() =>
            {
                int number_fields = Warehouse_Wrapper.showReceipts(out ProductPtr, error, _ConnectionString);

                IntPtr current = ProductPtr;
                for (int i = 0; i < number_fields; ++i)
                {
                    Order order = (Order)Marshal.PtrToStructure(current, typeof(Order));

                    current = (IntPtr)((long)current + Marshal.SizeOf(order));
                    orders.Add(order);
                }
                Marshal.FreeCoTaskMem(ProductPtr);
            });

            return(orders);
        }
示例#12
0
        public async Task <List <Order> > SearchOrders(string key, string value, byte[] error)
        {
            List <Order> orders = new List <Order>();
            IntPtr       OrderPtr;
            await Task.Run(() =>
            {
                int number_fields = Warehouse_Wrapper.searchOrders(out OrderPtr, key, value, error, _ConnectionString);

                IntPtr current = OrderPtr;
                for (int i = 0; i < number_fields; ++i)
                {
                    Order order = (Order)Marshal.PtrToStructure(current, typeof(Order));

                    current = (IntPtr)((long)current + Marshal.SizeOf(order));
                    orders.Add(order);
                }
                Marshal.FreeCoTaskMem(OrderPtr);
            });

            return((List <Order>)(object) orders);
        }
        public async Task <List <Inventory> > SearchInventories(string key, string value, byte[] error)
        {
            List <Inventory> inventories = new List <Inventory>();
            IntPtr           InventoryPtr;
            await Task.Run(() =>
            {
                int number_fields = Warehouse_Wrapper.searchInventories(out InventoryPtr, key, value, error, _ConnectionString);

                IntPtr current = InventoryPtr;
                for (int i = 0; i < number_fields; ++i)
                {
                    Inventory inventory = (Inventory)Marshal.PtrToStructure(current, typeof(Inventory));

                    current = (IntPtr)((long)current + Marshal.SizeOf(inventory));
                    inventories.Add(inventory);
                }
                Marshal.FreeCoTaskMem(InventoryPtr);
            });

            return((List <Inventory>)(object) inventories);
        }
        public async Task <List <ProductMoves> > GetProductsMoves(byte[] error)
        {
            List <ProductMoves> products = new List <ProductMoves>();
            IntPtr ProductPtr;
            await Task.Run(() =>
            {
                int number_fields = Warehouse_Wrapper.getProductsMoves(out ProductPtr, error, _ConnectionString);

                IntPtr current = ProductPtr;
                for (int i = 0; i < number_fields; ++i)
                {
                    ProductMoves product = (ProductMoves)Marshal.PtrToStructure(current, typeof(ProductMoves));

                    current = (IntPtr)((long)current + Marshal.SizeOf(product));
                    products.Add(product);
                }
                Marshal.FreeCoTaskMem(ProductPtr);
            });

            return((List <ProductMoves>)(object) products);
        }
示例#15
0
        public async Task <Report> Reporting(byte[] error)
        {
            IntPtr reportPtr;
            int    status = 0;
            Report report = null;

            await Task.Run(() =>
            {
                try
                {
                    status = Warehouse_Wrapper.reporting(out reportPtr, error, _ConnectionString);
                    report = (Report)Marshal.PtrToStructure(reportPtr, typeof(Report));
                    Marshal.FreeCoTaskMem(reportPtr);
                }
                catch (Exception)
                {
                }
            });

            Console.WriteLine("status = " + status);
            return((Report)(object)report);
        }
        public async Task <List <CustomerProduct> > ShowCustomerProducts(string id, byte[] error)
        {
            List <CustomerProduct> customerProducts = new List <CustomerProduct>();
            IntPtr ProductPtr;
            await Task.Run(() =>
            {
                Console.WriteLine("showCustomerProducts c#");
                int number_fields = Warehouse_Wrapper.showCustomerProducts(id, out ProductPtr, error, _ConnectionString);

                IntPtr current = ProductPtr;
                for (int i = 0; i < number_fields; ++i)
                {
                    CustomerProduct customerProduct = (CustomerProduct)Marshal.PtrToStructure(current, typeof(CustomerProduct));

                    current = (IntPtr)((long)current + Marshal.SizeOf(customerProduct));
                    customerProducts.Add(customerProduct);
                }
                Marshal.FreeCoTaskMem(ProductPtr);
            });

            return(customerProducts);
        }
 public async Task <int> removeFromStock(ProductInOrder product, byte[] error)
 {
     return(await Task.Run(() => Warehouse_Wrapper.removeFromStock(product, error, _ConnectionString)));
 }
示例#18
0
 public async Task <int> addToStock(string id, int newUnits, byte[] error)
 {
     return(await Task.Run(() => Warehouse_Wrapper.addToStock(id, newUnits, error, _ConnectionString)));
 }
示例#19
0
        public async Task <List <T> > GetAll(byte[] error)
        {
            if (typeof(T) == typeof(Inventory))
            {
                List <Inventory> inventories = new List <Inventory>();
                IntPtr           InventoryPtr;

                await Task.Run(() =>
                {
                    int number_fields = Warehouse_Wrapper.showInventories(out InventoryPtr, error, _ConnectionString);
                    IntPtr current    = InventoryPtr;

                    for (int i = 0; i < number_fields; ++i)
                    {
                        Inventory inventory = (Inventory)Marshal.PtrToStructure(current, typeof(Inventory));

                        current = (IntPtr)((long)current + Marshal.SizeOf(inventory));
                        inventories.Add(inventory);
                    }
                    Marshal.FreeCoTaskMem(InventoryPtr);
                });

                return((List <T>)(object) inventories);
            }

            if (typeof(T) == typeof(Product))
            {
                List <Product> products = new List <Product>();
                IntPtr         ProductPtr;

                await Task.Run(() =>
                {
                    int number_fields = Warehouse_Wrapper.showProducts(out ProductPtr, error, _ConnectionString);
                    IntPtr current    = ProductPtr;

                    for (int i = 0; i < number_fields; ++i)
                    {
                        Product product = (Product)Marshal.PtrToStructure(current, typeof(Product));

                        current = (IntPtr)((long)current + Marshal.SizeOf(product));
                        products.Add(product);
                    }
                    Marshal.FreeCoTaskMem(ProductPtr);
                });

                return((List <T>)(object) products);
            }

            if (typeof(T) == typeof(Order))
            {
                List <Order> orders = new List <Order>();
                IntPtr       OrderPtr;

                await Task.Run(() =>
                {
                    int number_fields = Warehouse_Wrapper.showAllOrders(out OrderPtr, error, _ConnectionString);
                    IntPtr current    = OrderPtr;

                    for (int i = 0; i < number_fields; ++i)
                    {
                        Order order = (Order)Marshal.PtrToStructure(current, typeof(Order));

                        current = (IntPtr)((long)current + Marshal.SizeOf(order));
                        orders.Add(order);
                    }
                    Marshal.FreeCoTaskMem(OrderPtr);
                });

                return((List <T>)(object) orders);
            }

            if (typeof(T) == typeof(Customer))
            {
                List <Customer> customers = new List <Customer>();
                IntPtr          CustomerPtr;

                await Task.Run(() =>
                {
                    int number_fields = Crm_Wrapper.GetAllCustomers(out CustomerPtr, error, _ConnectionString);
                    IntPtr current    = CustomerPtr;

                    for (int i = 0; i < number_fields; ++i)
                    {
                        Customer customer = (Customer)Marshal.PtrToStructure(current, typeof(Customer));

                        current = (IntPtr)((long)current + Marshal.SizeOf(customer));
                        customers.Add(customer);
                    }
                    Marshal.FreeCoTaskMem(CustomerPtr);
                });

                return((List <T>)(object) customers);
            }

            if (typeof(T) == typeof(Opportunity))
            {
                List <Opportunity> opportunities = new List <Opportunity>();
                IntPtr             OpportunityPtr;

                await Task.Run(() =>
                {
                    int number_fields = Crm_Wrapper.GetAllOpportunities(out OpportunityPtr, error, _ConnectionString);
                    IntPtr current    = OpportunityPtr;

                    for (int i = 0; i < number_fields; ++i)
                    {
                        Opportunity opportunity = (Opportunity)Marshal.PtrToStructure(current, typeof(Opportunity));

                        current = (IntPtr)((long)current + Marshal.SizeOf(opportunity));
                        opportunities.Add(opportunity);
                    }
                    Marshal.FreeCoTaskMem(OpportunityPtr);
                });

                return((List <T>)(object) opportunities);
            }

            return(null);
        }