public void UpdateCategory()
        {
            m_UIControl.lbl_CategoryError.Text = string.Empty;
            if (!Validate())
            {
                MessageBox.Show("Name cannot be empty!");
                return;
            }
            var category = DataService.GetCategoryDataController().GetByName(m_UIControl.tb_categoryName.Text);

            if (category != null)
            {
                m_UIControl.lbl_CategoryError.Text = "Category with same name already exists!";
                return;
            }
            CategoryPost categoryPost = new CategoryPost();

            categoryPost.ID          = int.Parse(m_UIControl.tb_ID.Text);
            categoryPost.Name        = m_UIControl.tb_categoryName.Text;
            categoryPost.Description = m_UIControl.tb_categoryDescription.Text;

            m_Category = DataService.GetCategoryDataController().Put(categoryPost);

            string message = (m_Category == null) ? "Failed to Update Category Details!" : "Category Details updated successfully!";

            MessageBox.Show(m_UIControl, message);

            // fire category update event
            Event_EntryUpdated e = new Event_EntryUpdated(DBEntityType.CATEGORY, m_Category.ID);

            EventBroadcaster.Get().BroadcastEvent(e);

            m_UIControl.Close();
        }
        private void InitializeCategoryDetails(int categoryID)
        {
            m_Category = DataService.GetCategoryDataController().Get(categoryID);

            m_UIControl.tb_ID.Text                  = m_Category.ID.ToString();
            m_UIControl.tb_categoryName.Text        = m_Category.Name;
            m_UIControl.tb_categoryDescription.Text = m_Category.Description;
        }
Ejemplo n.º 3
0
        public void AddCategoryToTable(CategoryGet category)
        {
            var             Table  = m_UIControl.categoryDataView;
            int             Index  = Table.Rows.Add();
            DataGridViewRow NewRow = Table.Rows[Index];

            NewRow.Cells["TableColumn_Category_ID"].Value          = category.ID;
            NewRow.Cells["TableColumn_Category_Name"].Value        = category.Name;
            NewRow.Cells["TableColumn_Category_Description"].Value = category.Description;
        }
        private void HandleEvent_NewEntryAdded(Event_NewEntryAdded e)
        {
            DBEntityType entityType = e.GetEntityType();
            int          id         = e.GetID();

            if (entityType == DBEntityType.CATEGORY)
            {
                CategoryGet category = DataService.GetCategoryDataController().Get(id);
                m_Controller.AddCategoryToComboBox(category);
            }
        }
        private void btn_AddNewCategory_Click(object sender, EventArgs e)
        {
            Form_AddCategory form = new Form_AddCategory();

            form.DisableAddAnotherFunctionality();

            if (form.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            CategoryGet category = form.GetAddedCategory();

            cb_Category.Text = category.Name;
        }
        private void btn_saveCategory_Click(object sender, EventArgs eventArgs)
        {
            if (!ValidateUI())
            {
                return;
            }

            lbl_CategoryError.Text = string.Empty;
            string name = tb_categoryName.Text.Trim();
            string desc = tb_categoryDescription.Text.Trim();

            var category = DataService.GetCategoryDataController().GetByName(name);

            if (category != null)
            {
                lbl_CategoryError.Text = "Category with same name already exists!";
                return;
            }
            CategoryPost categoryPost = new CategoryPost();

            categoryPost.Name        = name;
            categoryPost.Description = desc;

            m_Category = DataService.GetCategoryDataController().Post(categoryPost);
            if (m_Category == null)
            {
                Assert.Do("Failed to add category!");
                DialogResult = DialogResult.Cancel;
                return;
            }


            // broadcast new entry added event
            Event_NewEntryAdded e = new Event_NewEntryAdded(DBEntityType.CATEGORY, m_Category.ID);

            EventBroadcaster.Get().BroadcastEvent(e);
            MessageBox.Show("Category Added successfully!");

            ResetAll();

            if (!checkBox_AddAnotherCategory.Checked)
            {
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Ejemplo n.º 7
0
        public void UpdateCategoryInTable(CategoryGet category)
        {
            var table = m_UIControl.categoryDataView;

            for (int i = 0; i < table.Rows.Count; ++i)
            {
                DataGridViewRow row = table.Rows[i];
                int             id  = int.Parse(row.Cells["TableColumn_Category_ID"].Value.ToString());

                if (category.ID == id)
                {
                    row.Cells["TableColumn_Category_ID"].Value          = category.ID;
                    row.Cells["TableColumn_Category_Name"].Value        = category.Name;
                    row.Cells["TableColumn_Category_Description"].Value = category.Description;
                    return;
                }
            }
        }
 public async Task<CategoryGet.response> CategoryGet(CategoryGet.request request, CancellationToken? token = null)
 {
     return await SendAsync<CategoryGet.response>(request.ToXmlString(), token.GetValueOrDefault(CancellationToken.None));
 }
        public bool AddNewProduct()
        {
            var UI = m_UIControl;

            UI.DialogResult = DialogResult.None;

            UI.lbl_Error.Text = string.Empty;
            if (!ValidateProductDetails())
            {
                return(false);
            }

            string      categoryName = UI.cb_Category.Text.Trim();
            CategoryGet category     = DataService.GetCategoryDataController().GetByName(categoryName);

            int unit = UI.cb_Unit.SelectedIndex + 1;

            ProductPost productPost = new ProductPost();

            productPost.Name           = UI.tb_Name.Text.Trim();
            productPost.Barcode        = UI.tb_Barcode.Text.Trim();
            productPost.Description    = UI.tb_Description.Text.Trim();
            productPost.Unit           = unit;
            productPost.RetailPrice    = int.Parse(UI.tb_RetailPrice.Text.Trim());
            productPost.WholeSalePrice = int.Parse(UI.tb_WholeSalePrice.Text.Trim());
            productPost.CategoryID     = category.ID;
            productPost.CGST           = double.Parse(UI.tb_CGST.Text.Trim());
            productPost.SGST           = double.Parse(UI.tb_CGST.Text.Trim());
            productPost.Discount       = double.Parse(UI.tb_SGST.Text.Trim());

            productPost.ImagePath = GetImagePath();

            m_Product = DataService.GetProductDataController().Post(productPost);
            if (m_Product == null)
            {
                MessageBox.Show(UI, "Failed to Add Product!");
                return(false);
            }

            // post the Default details
            StockPost stock = new StockPost();

            stock.ProductID         = m_Product.ID;
            stock.AvailableQuantity = 0;
            stock.TotalQuantity     = 0;
            var stockPost = DataService.GetStockDataController().Post(stock);

            if (stockPost == null)
            {
                MessageBox.Show(UI, "Failed to Add Stock!");
                return(false);
            }

            // Broadcast NewProductAdded Event
            Event_NewEntryAdded e = new Event_NewEntryAdded(DBEntityType.PRODUCT, m_Product.ID);

            EventBroadcaster.Get().BroadcastEvent(e);

            MessageBox.Show(UI, "Product Added Successfully!");

            if (!m_UIControl.checkBox_AddAnotherProduct.Checked)
            {
                UI.DialogResult = DialogResult.OK;
                UI.Close();
            }

            return(true);
        }
        public void AddCategoryToComboBox(CategoryGet category)
        {
            var comboBox = m_UIControl.cb_Category;

            comboBox.Items.Add(category.Name);
        }