Beispiel #1
0
        private void ProductTaxForm_Load(object sender, EventArgs e)
        {
            this.Text = _product.Name + " - " + _product.Code;
            var allTaxes = taxController.All().Where(t => t.Status == "Active");

            foreach (var tax in allTaxes)
            {
                ComboboxItem item = new ComboboxItem();
                item.Text  = $"{tax.Type} - {tax.Value}";
                item.Value = tax.ID;
                comboTax.Items.Add(item);
                comboTax.SelectedIndex = 0;
            }
        }
Beispiel #2
0
        public void PopulateProduct(Guid ID)
        {
            var product = productController.FindById(ID);

            txtName.Text      = product.Name;
            txtSku.Text       = product.SKU;
            txtCode.Text      = product.Code;
            txtDesc.Text      = product.Description;
            chkStatus.Checked = product.Status == "Active";
            ProductID         = product.ID;

            lblTitle.Text = "Update Product";
            btnSave.Text  = "Update";

            pnlTax.Visible = true;


            var allProductTax = productTaxController.All().Where(t => t.ProductID == ID && t.Status == "Active").ToList();
            var allTax        = taxController.All();

            DataTable dt = new DataTable();

            dt.Columns.Add("ProductTaxID", typeof(Guid));
            dt.Columns.Add("Tax");

            foreach (var productTax in allProductTax)
            {
                DataRow tax = dt.NewRow();
                tax["ProductTaxID"] = productTax.ID;
                tax["Tax"]          = allTax.Where(t => t.ID == productTax.TaxId).Select(t => $"{t.Type} - {t.Value}%").FirstOrDefault();
                dt.Rows.Add(tax);
            }

            grdTax.DataSource         = dt;
            grdTax.Columns[0].Visible = false;
            btnDeleteTax.Visible      = false;
        }