Ejemplo n.º 1
0
        public void Delete(BaseDTO dtoName)
        {
            Type currentType = dtoName.GetType();

            if (currentType.Name.Equals("ProductDTO"))
            {
                ProductsDAL deleteProduct = new ProductsDAL();
                deleteProduct.DeleteProduct((dtoName as ProductDTO).ProductNewName);
                resultMessage = deleteProduct.GetCRUDResult();
            }
            if (currentType.Name.Equals("VendorDTO"))
            {
                VendorsDAL deleteVendor = new VendorsDAL();
                deleteVendor.DeleteVendor((dtoName as VendorDTO).VendorName);
                resultMessage = deleteVendor.GetCRUDResult();
            }
            if (currentType.Name.Equals("CategoryDTO"))
            {
                CategoriesDAL deleteCategory = new CategoriesDAL();
                deleteCategory.DeleteCategory((dtoName as CategoryDTO).CategoryName);
                resultMessage = deleteCategory.GetCRUDResult();
            }
            else
            {
                //MessageBox.Show("Pone stigna do tuk v update seckciqta");
            }
        }
Ejemplo n.º 2
0
        public List <VendorDTO> GetVendors()
        {
            VendorsDAL       getVendors = new VendorsDAL();
            List <VendorDTO> allVendors = getVendors.GetAllVendors();

            return(allVendors);
        }
Ejemplo n.º 3
0
        public void Update(BaseDTO dtoName)
        {
            Type currentType = dtoName.GetType();

            if (currentType.Name.Equals("ProductDTO"))
            {
                ProductsDAL updateProduct = new ProductsDAL();
                updateProduct.UpdateProduct((dtoName as ProductDTO).ProductOldName,
                                            (dtoName as ProductDTO).ProductNewName,
                                            (dtoName as ProductDTO).CategoryName,
                                            (dtoName as ProductDTO).VendorName,
                                            (dtoName as ProductDTO).ProductPrice,
                                            (dtoName as ProductDTO).Quantity,
                                            (dtoName as ProductDTO).StoreName,
                                            (dtoName as ProductDTO).TownName);
                resultMessage = updateProduct.GetCRUDResult();
            }
            if (currentType.Name.Equals("VendorDTO"))
            {
                VendorsDAL updateVendor = new VendorsDAL();
                updateVendor.UpdateVendor((dtoName as VendorDTO).VendorOldName, (dtoName as VendorDTO).VendorName);
                resultMessage = updateVendor.GetCRUDResult();
            }
            if (currentType.Name.Equals("CategoryDTO"))
            {
                CategoriesDAL updateCategory = new CategoriesDAL();
                updateCategory.UpdateCategory((dtoName as CategoryDTO).CategoryOldName, (dtoName as CategoryDTO).CategoryName);
                resultMessage = updateCategory.GetCRUDResult();
            }
            else
            {
                //MessageBox.Show("Pone stigna do tuk v update seckciqta");
            }
        }
Ejemplo n.º 4
0
        public void Insert(BaseDTO dtoName)
        {
            Type currentType = dtoName.GetType();

            if (currentType.Name.Equals("ProductDTO"))
            {
                ProductsDAL newProduct = new ProductsDAL();
                if (newProduct.IsProductNameExistInDb((dtoName as ProductDTO).ProductNewName))
                {
                    resultMessage = BaseDAL.Messages(MessageFor.ItemExistInDatabase, "Product");
                }
                else
                {
                    newProduct.InsertNewProduct((dtoName as ProductDTO).ProductNewName,
                                                (dtoName as ProductDTO).CategoryName,
                                                (dtoName as ProductDTO).VendorName,
                                                (dtoName as ProductDTO).ProductPrice,
                                                (dtoName as ProductDTO).Quantity,
                                                (dtoName as ProductDTO).StoreName,
                                                (dtoName as ProductDTO).TownName);
                    resultMessage = newProduct.GetCRUDResult();
                }
            }
            if (currentType.Name.Equals("VendorDTO"))
            {
                VendorsDAL newVendor = new VendorsDAL();
                if (newVendor.IsVendorNameExistInDb((dtoName as VendorDTO).VendorName))
                {
                    resultMessage = BaseDAL.Messages(MessageFor.ItemExistInDatabase, "Vendor");
                }
                else
                {
                    newVendor.InsertNewVendor((dtoName as VendorDTO).VendorName);
                    resultMessage = newVendor.GetCRUDResult();
                }
            }
            if (currentType.Name.Equals("CategoryDTO"))
            {
                CategoriesDAL newCategory = new CategoriesDAL();
                if (newCategory.IsCategoryNameExistInDb((dtoName as CategoryDTO).CategoryName))
                {
                    resultMessage = BaseDAL.Messages(MessageFor.ItemExistInDatabase, "Category");
                }
                else
                {
                    newCategory.InsertNewCategory((dtoName as CategoryDTO).CategoryName);
                    resultMessage = newCategory.GetCRUDResult();
                }
            }
            else
            {
                //MessageBox.Show("Pone stigna do tuk");
            }
        }