public void UpdateVendor()
        {
            if (!ValidateVendorDetails())
            {
                return;
            }
            VendorPost vendorPost = new VendorPost();

            vendorPost.ID           = int.Parse(m_UIControl.tb_vendorId.Text.Trim());
            vendorPost.CompanyName  = m_UIControl.tb_companyName.Text.Trim();
            vendorPost.Address      = m_UIControl.tb_address.Text.Trim();
            vendorPost.Email        = m_UIControl.tb_email.Text.Trim();
            vendorPost.MobileNumber = m_UIControl.tb_mobileNumber.Text.Trim();
            vendorPost.City         = m_UIControl.tb_city.Text.Trim();
            vendorPost.State        = m_UIControl.tb_state.Text.Trim();

            var vendorGet = DataService.GetVendorDataController().Put(vendorPost);

            if (vendorGet == null)
            {
                Assert.Do("Failed to edit vendor");
                return;
            }
            MessageBox.Show("Vendor Updated Successfully");
            ResetTextBoxes();
            m_UIControl.DialogResult = DialogResult.OK;

            // fire vendor updated event
            Event_EntryUpdated e = new Event_EntryUpdated(DBEntityType.VENDOR, vendorGet.ID);

            EventBroadcaster.Get().BroadcastEvent(e);
        }
        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();
        }
示例#3
0
        public void UpdateProductDetails()
        {
            if (!ValidateProductDetails())
            {
                return;
            }

            string barcode = m_UIControl.tf_ProductDetails_Barcode.Text.Trim();

            if (CheckIfBarcodeAlreadyInUse(barcode))
            {
                m_UIControl.lbl_Error.Text = "This Barcode is already in use!";
                return;
            }

            string name = m_UIControl.tf_ProductDetails_ProductName.Text.Trim();

            if (CheckIfProductNameAlreadyInUse(name))
            {
                m_UIControl.lbl_Error.Text = "This Name is already in use!";
                return;
            }

            ProductGet existingProduct = m_Product;

            ProductPost product = new ProductPost(existingProduct);

            product.ID             = int.Parse(m_UIControl.tf_ProductDetails_ProductID.Text.Trim());
            product.Barcode        = barcode;
            product.Name           = name;
            product.Description    = m_UIControl.tf_ProductDetails_Description.Text.Trim();
            product.Unit           = ProductUnit.GetUnitFromText(m_UIControl.cb_Unit.Text);
            product.RetailPrice    = int.Parse(m_UIControl.tf_ProductDetails_RetailPrice.Text.Trim());
            product.WholeSalePrice = int.Parse(m_UIControl.tf_ProductDetails_WholesalePrice.Text.Trim());
            product.Discount       = double.Parse(m_UIControl.tf_ProductDetails_Discount.Text.Trim());
            product.CGST           = double.Parse(m_UIControl.tf_ProductDetails_CGST.Text.Trim());
            product.SGST           = double.Parse(m_UIControl.tf_ProductDetails_SGST.Text.Trim());

            string categoryName = m_UIControl.cb_ProductDetails_Category.Text.Trim();

            product.CategoryID = DataService.GetCategoryDataController().GetByName(categoryName).ID;

            bool imageModified = false;

            if (m_UIControl.pictureBox_ProductImage.Tag != null)
            {
                product.ImagePath = m_UIControl.pictureBox_ProductImage.Tag.ToString();
                imageModified     = true;
            }

            m_Product = DataService.GetProductDataController().Put(product, imageModified);
            string message = (m_Product == null) ? "Failed to Update Product Details!" : "Product Details updated successfully!";

            MessageBox.Show(m_UIControl, message);

            // fire entry updated event
            Event_EntryUpdated e = new Event_EntryUpdated(DBEntityType.PRODUCT, m_Product.ID);

            EventBroadcaster.Get().BroadcastEvent(e);
        }
示例#4
0
        private void HandleEvent_EntryUpdated(Event_EntryUpdated e)
        {
            DBEntityType entityType = e.GetEntityType();

            if (entityType == DBEntityType.CUSTOMER)
            {
                m_Controller.InitializeComboBox_CustomerName();
            }
        }
示例#5
0
        private void HandleEvent_EntryUpdated(Event_EntryUpdated e)
        {
            DBEntityType entityType = e.GetEntityType();

            if (entityType == DBEntityType.PRODUCT)
            {
                UpdateProductInTable(e.GetID());
            }
        }
        private void HandleEvent_EntryUpdated(Event_EntryUpdated e)
        {
            DBEntityType entityType = e.GetEntityType();

            if (entityType == DBEntityType.VENDOR)
            {
                m_Controller.InitializeComboBox_VendorName();
            }
        }
示例#7
0
        private void HandleEvent_EntryUpdated(Event_EntryUpdated e)
        {
            DBEntityType entityType = e.GetEntityType();

            if (entityType == DBEntityType.CUSTOMER)
            {
                CustomerGet customer = DataService.GetCustomerDataController().Get(e.GetID());
                m_Controller.UpdateCustomerInTable(customer);
            }
        }
示例#8
0
        private void HandleEvent_EntryUpdated(Event_EntryUpdated e)
        {
            DBEntityType entityType = e.GetEntityType();

            if (entityType == DBEntityType.CATEGORY)
            {
                var category = DataService.GetCategoryDataController().Get(e.GetID());
                m_Controller.UpdateCategoryInTable(category);
            }
        }
示例#9
0
        private void HandleEvent_EntryUpdated(Event_EntryUpdated e)
        {
            DBEntityType entityType = e.GetEntityType();

            if (entityType == DBEntityType.VENDOR)
            {
                VendorGet vendor = DataService.GetVendorDataController().Get(e.GetID());
                m_Controller.UpdateTableEntry_Vendor(vendor);
            }
        }
        private void HandleEvent_EntryUpdated(Event_EntryUpdated e)
        {
            var entity = e.GetEntityType();

            if (entity == DBEntityType.VENDOR)
            {
                m_Controller.InitializeComboBox_VendorName();
            }
            else if (entity == DBEntityType.PRODUCT)
            {
                m_Controller.InitializeComboBox_ProductName();
            }
        }
示例#11
0
        private void HandleEvent_EntryUpdated(Event_EntryUpdated e)
        {
            var updatedEntryType = e.GetEntityType();

            if (updatedEntryType == DBEntityType.PRODUCT)
            {
                m_Controller.InitializProductNameSearchBoxData();
            }
            else if (updatedEntryType == DBEntityType.CUSTOMER)
            {
                m_Controller.InitializeCustomerMobileNumberSearchBoxData();
                m_Controller.InitializeCustomerNameSearchBoxData();
            }
        }
        public void UpdateCustomer()
        {
            m_UIControl.lbl_customerErrorText.Text = string.Empty;

            if (!ValidateCustomerDetails())
            {
                return;
            }

            string name         = m_UIControl.tb_customerName.Text.Trim();
            string mobileNumber = m_UIControl.tb_customerMobileNumber.Text.Trim();

            if (CheckIfCustomerNameAlreadyExists(name))
            {
                m_UIControl.lbl_customerErrorText.Text = "Customer with the same Name already exists!";
                return;
            }

            if (CheckIfMobileNumberAlreadyExists(mobileNumber))
            {
                m_UIControl.lbl_customerErrorText.Text = "Customer with the same Mobile Number already exists!";
                return;
            }

            CustomerPost customerPost = new CustomerPost();

            customerPost.ID            = int.Parse(m_UIControl.tb_customerId.Text.Trim());
            customerPost.Name          = name;
            customerPost.MobileNumber  = mobileNumber;
            customerPost.Email         = m_UIControl.tb_customerEmail.Text.Trim();;
            customerPost.TotalAmount   = double.Parse(m_UIControl.tb_customerTotalPurchaseAmount.Text.Trim());
            customerPost.PendingAmount = double.Parse(m_UIControl.tb_customerPendingAmount.Text.Trim());

            m_Customer = DataService.GetCustomerDataController().Put(customerPost);
            if (m_Customer == null)
            {
                m_UIControl.DialogResult = DialogResult.No;
                return;
            }
            m_UIControl.DialogResult = DialogResult.Yes;
            ResetTextBoxes();

            // fire customer updated event
            Event_EntryUpdated e = new Event_EntryUpdated(DBEntityType.CUSTOMER, m_Customer.ID);

            EventBroadcaster.Get().BroadcastEvent(e);
        }