private void SelectItem() { ListView.SelectedListViewItemCollection items = this.lstItems.SelectedItems; foreach (ListViewItem item in items) { mDetails.ProductPackageID = Convert.ToInt64(item.SubItems[0].Name); break; } ProductPackage clsProductPackage = new ProductPackage(); ProductPackageDetails clsDetails = clsProductPackage.Details(mDetails.ProductPackageID); clsProductPackage.CommitAndDispose(); if (mDetails.ProductPackageID != 0) { mDetails.ProductUnitID = clsDetails.UnitID; mDetails.ProductUnitCode = clsDetails.UnitCode; mDetails.Price = clsDetails.Price; mDetails.PackageQuantity = clsDetails.Quantity; mDetails.VAT = clsDetails.VAT; mDetails.LocalTax = clsDetails.LocalTax; mDetails.Amount = (mDetails.Quantity * mDetails.Price) - (mDetails.Quantity * mDetails.Discount); mDetails.PurchasePrice = clsDetails.PurchasePrice; mDetails.Amount = mDetails.Quantity * mDetails.PurchasePrice; } dialog = DialogResult.OK; this.Hide(); }
private void LoadRecord() { ProductPackage clsProductPackage = new ProductPackage(); ProductPackageDetails clsDetails = clsProductPackage.Details(Convert.ToInt64(lblPackageID.Text)); Products clsProduct = new Products(clsProductPackage.Connection, clsProductPackage.Transaction); ProductDetails clsProductDetails = clsProduct.Details(Convert.ToInt64(lblProductID.Text)); ProductBaseVariationsMatrixDetails clsProductBaseVariationsMatrixDetails = new ProductBaseVariationsMatrix(clsProductPackage.Connection, clsProductPackage.Transaction).BaseDetails(clsDetails.MatrixID, clsDetails.ProductID); clsProductPackage.CommitAndDispose(); lblProductSubGroupID.Text = clsProductDetails.ProductSubGroupID.ToString(); lblMatrixID.Text = clsDetails.MatrixID.ToString(); lblMatrixDescription.Text = clsDetails.MatrixID == 0 ? "" : "Base Matrix: " + clsProductBaseVariationsMatrixDetails.Description; cboUnit.SelectedIndex = cboUnit.Items.IndexOf(cboUnit.Items.FindByValue(clsDetails.UnitID.ToString())); txtProductPrice.Text = clsDetails.Price.ToString("#,##0.#0"); txtPrice1.Text = clsDetails.Price1.ToString("#,##0.#0"); txtPrice2.Text = clsDetails.Price2.ToString("#,##0.#0"); txtPrice3.Text = clsDetails.Price3.ToString("#,##0.#0"); txtPrice4.Text = clsDetails.Price4.ToString("#,##0.#0"); txtPrice5.Text = clsDetails.Price5.ToString("#,##0.#0"); txtWSPrice.Text = clsDetails.WSPrice.ToString("#,##0.#0"); txtPurchasePrice.Text = clsDetails.PurchasePrice.ToString("#,##0.#0"); decimal decMargin = clsDetails.Price - clsDetails.PurchasePrice; try { decMargin = decMargin / clsDetails.PurchasePrice; } catch { decMargin = 1; } decMargin = decMargin * 100; txtMargin.Text = decMargin.ToString("#,##0.##0"); decMargin = clsDetails.WSPrice - clsDetails.PurchasePrice; try { decMargin = decMargin / clsDetails.PurchasePrice; } catch { decMargin = 1; } decMargin = decMargin * 100; txtWSPriceMarkUp.Text = decMargin.ToString("#,##0.##0"); txtVAT.Text = clsDetails.VAT.ToString("#,##0.#0"); txtEVAT.Text = clsDetails.EVAT.ToString("#,##0.#0"); txtLocalTax.Text = clsDetails.LocalTax.ToString("#,##0.#0"); txtQuantity.Text = clsDetails.Quantity.ToString("#,##0.#0"); txtBarCode1.Text = clsDetails.BarCode1; txtBarCode2.Text = clsDetails.BarCode2; txtBarCode3.Text = clsDetails.BarCode3; if (clsDetails.Quantity == 1 && clsProductDetails.BaseUnitID == clsDetails.UnitID) { txtQuantity.Enabled = false; cboUnit.Enabled = false; } }