Beispiel #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("ID: ");
            int id = Int32.Parse(Console.ReadLine());

            // Take a Category ID and name
            CategoryClient client = new CategoryClient();

            client.Open();
            Console.WriteLine(client.GetCategoryID(id));
            Console.WriteLine("\r\n");
            Console.WriteLine(client.GetCategoryName(id));
            client.Close();

            ProductsClient productClient = new ProductsClient();

            productClient.Open();
            Console.WriteLine(productClient.GetCategoryName(id));
            Console.WriteLine("\r\n");
            Console.WriteLine(productClient.GetProductName(id));
            Console.WriteLine("\r\n");
            Console.WriteLine(productClient.GetProductQty(id));
            Console.WriteLine("\r\n");
            Console.WriteLine(productClient.GetCategoryID(id));
            productClient.Close();

            Console.ReadKey();
        }
        /* CheckAllCategorie Method
         * This method will get all categories at hte database, store it in a string
         * and return it as a string when invoked
         */
        private string CheckAllCategories()
        {
            var client = new CategoryClient();
            var result = "";

            try
            {
                var alcat = client.GetCategories();
                var sb    = new StringBuilder();
                sb.Append("*** List of All Categories ***");
                sb.Append("\r\n");

                foreach (var Category in alcat)
                {
                    sb.Append("ID# " + Category.Category_ID + " ");
                    sb.Append("Category: " + Category.Category_Name);
                    sb.Append("\r\n");
                }
                result = sb.ToString();
            }
            catch (Exception ex)
            {
                result = "Exception: " + ex.Message;
            }

            return(result);
        }
        public frmCategory()
        {
            InitializeComponent();
            svCategory = new CategoryClient();

            bindData();
        }
        private void btncreatecategory_Click(object sender, EventArgs e)
        {
            CreateUpdateClient.CategoryServiceProxy.Category category = new CreateUpdateClient.CategoryServiceProxy.Category();
            //Category category = new Category();
            var client = new CategoryClient();
            var result = "";

            try
            {
                //Move text field values to object properties
                category.Category_Name        = categorynamebox.Text;
                category.Category_Description = categorydescriptionbox.Text;

                //Call service method
                client.Create_Category(category);

                var sb = new StringBuilder();
                sb.Append("New Category is created successfully" + "\r\n");
                sb.Append("Category_Name: " + category.Category_Name + "\r\n");
                sb.Append("Category_Description: " + category.Category_Description + "\r\n");

                result = sb.ToString();
            }
            catch (Exception ex)
            {
                result = "Exception:" + ex.Message.ToString();
            }

            //Set text box with output
            allcategoriesbox.Text = result;
        }
        public frmCategory()
        {
            InitializeComponent();
            svCategory = new CategoryClient();

            bindData();
        }
Beispiel #6
0
 public ActionResult AddCategory(CategoryClient cat)
 {
     using (var db = new ApplicationDbContext())
     {
         db.CategoryClients.Add(cat);
         db.SaveChanges();
     }
     return(RedirectToAction("Category"));
 }
 private void threadInit_DoWork(object sender, DoWorkEventArgs e)
 {
     sv       = new ProductClient();
     svCat    = new CategoryClient();
     products = sv.findAll();
     threadInit.ReportProgress(60);
     categories = svCat.findAll();
     threadInit.ReportProgress(100);
 }
 public void frmProductInit()
 {
     sv         = new ProductClient();
     svCat      = new CategoryClient();
     products   = sv.findAll();
     categories = svCat.findAll();
     initComboBox();
     showProduct(0);
     bindData(products);
 }
Beispiel #9
0
 public ActionResult EditCategory(CategoryClient cat)
 {
     using (var db = new ApplicationDbContext())
     {
         var c = db.CategoryClients.Find(cat.Id);
         c.Name = cat.Name;
         db.SaveChanges();
     }
     return(RedirectToAction("Category"));
 }
 public void frmProductInit()
 {
     sv = new ProductClient();
     svCat = new CategoryClient();
     products = sv.findAll();
     categories = svCat.findAll();
     initComboBox();
     showProduct(0);
     bindData(products);
 }
Beispiel #11
0
        public async void RefreshAsync()
        {
            while (true)
            {
                try
                {
                    using (var httpClient = new HttpClient())
                    {
                        FoodClient foodClient = new FoodClient(httpClient);
                        Task <ICollection <Food> > allFoodTask = foodClient.GetAllFoodAsync();
                        FoodList.Clear();
                        foreach (var item in await allFoodTask)
                        {
                            FoodList.Add(item);
                        }

                        CategoryClient categoryClient = new CategoryClient(httpClient);
                        Task <ICollection <Category> > allCategoryTask = categoryClient.GetAllCategoryAsync();
                        CategoryList.Clear();
                        foreach (var item in await allCategoryTask)
                        {
                            CategoryList.Add(item);
                        }

                        StorageClient storageClient = new StorageClient(httpClient);
                        Task <ICollection <Storage> > allStorageTask = storageClient.GetAllStorageAsync();
                        StorageList.Clear();
                        foreach (var item in await allStorageTask)
                        {
                            StorageList.Add(item);
                        }

                        SlotClient slotClient = new SlotClient(httpClient);
                        Task <ICollection <Slot> > allSlotTask = slotClient.GetAllSlotAsync();
                        SlotList.Clear();
                        foreach (var item in await allSlotTask)
                        {
                            SlotList.Add(item);
                        }
                    }
                    return;
                }
                catch
                {
                    Thread.Sleep(500);
                }
            }
        }
Beispiel #12
0
 public async Task <ICollection <GeneratedService.ResponseCategory> > GetCategoriesAsync(
     [Service] CategoryClient service, CancellationToken cancellationToken, int?id, int?companyId)
 {
     if (id != null && companyId != null)
     {
         return(await service.GetNestedByParentIdAndCompanyIdAsync(id, companyId, cancellationToken));
     }
     if (companyId != null)
     {
         return(await service.GetNestedByParentIdAsync(companyId, cancellationToken));
     }
     if (id != null)
     {
         throw new ArgumentException("There no such method which supports only id");
     }
     return(await service.GetAllAsync(cancellationToken));
 }
        private void btnupdatedescription_Click(object sender, EventArgs e)
        {
            var client = new CategoryClient();
            var result = "";

            //Check if the user searched for a product and that the UPC box is populated and that the UPC is different from the existing product
            if (string.IsNullOrEmpty(categoryidbox.Text))
            {
                result = "Enter a Category ID for update first!";
            }
            else
            {
                var category = client.Get_Category_By_ID(int.Parse(categoryidbox.Text));
                if (category.Category_ID == 0)
                {
                    result = "Category ID not exsit!";
                }
                else if (string.IsNullOrEmpty(newdescriptionbox.Text))
                {
                    result = "Enter a new Category Description!";
                }
                else
                {
                    try
                    {
                        //Assign new category name to updated category object
                        category.Category_Description = newdescriptionbox.Text;

                        //Update product by ID and assign boolean to variable
                        var update_category_description = client.Update_Category_By_ID(category);

                        //Check result of update
                        var sb = new StringBuilder();
                        sb.Append("Category description was updated to: " + "\r\n" + category.Category_Description.ToString());


                        result = sb.ToString();
                    }
                    catch (Exception ex)
                    {
                        result = "Exception: " + ex.Message.ToString();
                    }
                }
            }
            updatecategoryresult.Text = result;
        }
Beispiel #14
0
        private void Form1_Load(object sender, EventArgs e)
        {
            int            id     = 1;
            CategoryClient client = new CategoryClient();

            client.Open();
            txtCategoryID.Text   = client.GetCategoryID(id).ToString();
            txtCategoryName.Text = client.GetCategoryName(id);
            client.Close();

            ProductsClient productClient = new ProductsClient();

            productClient.Open();
            txtProductID.Text           = id.ToString();
            txtProductName.Text         = productClient.GetProductName(id).ToString();
            txtProductCategoryID.Text   = productClient.GetCategoryID(id).ToString();
            txtProductCategoryName.Text = productClient.GetCategoryName(id).ToString();
            txtProductQty.Text          = productClient.GetProductQty(id).ToString();
            productClient.Close();
        }
        public AddCategory(int catId = 0)
        {
            InitializeComponent();
            sv = new CategoryClient();
            initComboBox();

            if (catId > 0)
            {

                cat = sv.findById(catId);
                txtName.Text = cat.Name;
                chbStatus.Checked = cat.Status.Value;
                for (int i = 0; i < parents.Count; i++)
                    if (parents[i].id == cat.ParentID)
                    {
                        cbParent.SelectedIndex = i;
                        break;
                    }
            }
        }
        public AddCategory(int catId = 0)
        {
            InitializeComponent();
            sv = new CategoryClient();
            initComboBox();

            if (catId > 0)
            {
                cat               = sv.findById(catId);
                txtName.Text      = cat.Name;
                chbStatus.Checked = cat.Status.Value;
                for (int i = 0; i < parents.Count; i++)
                {
                    if (parents[i].id == cat.ParentID)
                    {
                        cbParent.SelectedIndex = i;
                        break;
                    }
                }
            }
        }
Beispiel #17
0
 public CategoryService(CategoryClient client)
 {
     _client = client;
 }
 private void threadInit_DoWork(object sender, DoWorkEventArgs e)
 {
     sv = new ProductClient();
     svCat = new CategoryClient();
     products = sv.findAll();
     threadInit.ReportProgress(60);
     categories = svCat.findAll();
     threadInit.ReportProgress(100);
 }