Exemplo n.º 1
0
        protected void cboProductCode_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (cboProductCode.Items.Count == 0)
                return;

            if (cboProductCode.Items.Count == 1 && cboProductCode.SelectedValue == Constants.ZERO_STRING)
                return;

            DataClass clsDataClass = new DataClass();
            long ProductID = Convert.ToInt64(cboProductCode.SelectedItem.Value);

            ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix();
            cboVariation.DataTextField = "MatrixDescription";
            cboVariation.DataValueField = "MatrixID";
            cboVariation.DataSource = clsProductVariationsMatrix.BaseListSimpleAsDataTable(ProductID, SortField: "VariationDesc").DefaultView;
            cboVariation.DataBind();

            if (cboVariation.Items.Count == 0)
            { cboVariation.Items.Add(new ListItem("No Variation", Constants.ZERO_STRING)); }
            cboVariation.SelectedIndex = cboVariation.Items.Count - 1;

            ProductUnitsMatrix clsUnitMatrix = new ProductUnitsMatrix(clsProductVariationsMatrix.Connection, clsProductVariationsMatrix.Transaction);
            cboProductUnit.DataTextField = "BottomUnitCode";
            cboProductUnit.DataValueField = "BottomUnitID";
            cboProductUnit.DataSource = clsUnitMatrix.ListAsDataTable(ProductID, "a.MatrixID", SortOption.Ascending).DefaultView;
            cboProductUnit.DataBind();

            Products clsProduct = new Products(clsProductVariationsMatrix.Connection, clsProductVariationsMatrix.Transaction);
            ProductDetails clsDetails = clsProduct.Details(ProductID);
            ProductPurchasePriceHistory clsProductPurchasePriceHistory = new ProductPurchasePriceHistory(clsProductVariationsMatrix.Connection, clsProductVariationsMatrix.Transaction);
            System.Data.DataTable dtProductPurchasePriceHistory = clsProductPurchasePriceHistory.ListAsDataTable(ProductID, DateTime.Now.AddMonths(-6), "PurchasePrice", SortOption.Ascending);

            clsProductVariationsMatrix.CommitAndDispose();

            string strPurchasePriceHistory = string.Empty;
            foreach (System.Data.DataRow dr in dtProductPurchasePriceHistory.Rows)
            {
                DateTime dtePurchaseDate = DateTime.Parse(dr["PurchaseDate"].ToString());
                decimal decPurchasePrice = decimal.Parse(dr["PurchasePrice"].ToString());
                long lngSupplierID = long.Parse(dr["SupplierID"].ToString());
                string strSupplierName = "" + dr["SupplierName"].ToString();
                if (lngSupplierID == long.Parse(lblSupplierID.Text))
                    clsDetails.PurchasePrice = decPurchasePrice;

                strPurchasePriceHistory += dtePurchaseDate.ToString("ddMMMyyyy HH:mm") + ": " + decPurchasePrice.ToString("#,##0.##0").PadLeft(10) + " " + strSupplierName + "\r\n<br />" + Environment.NewLine;
            }
            lblPurchasePriceHistory.Text = "<br />" + strPurchasePriceHistory;

            cboProductUnit.Items.Insert(0, new ListItem(clsDetails.BaseUnitCode, clsDetails.BaseUnitID.ToString()));

            cboProductUnit.SelectedIndex = cboProductUnit.Items.IndexOf(new ListItem(clsDetails.BaseUnitCode, clsDetails.BaseUnitID.ToString()));
            txtPrice.Text = clsDetails.PurchasePrice.ToString("#####0.##0");
            txtSellingPrice.Text = clsDetails.Price.ToString("#####0.##0");
            txtOldSellingPrice.Text = clsDetails.Price.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");
            txtVAT.Text = clsDetails.VAT.ToString("#,##0.##0");
            txtEVAT.Text = clsDetails.EVAT.ToString("#,##0.##0");
            txtLocalTax.Text = clsDetails.LocalTax.ToString("#,##0.##0");

            if (clsDetails.VAT > 0) chkIsTaxable.Checked = true;
            else chkIsTaxable.Checked = false;

            if (cboProductUnit.Items.Count == 0)
            { cboProductUnit.Items.Add(new ListItem("No Unit", "0")); }
            cboVariation.SelectedIndex = cboVariation.Items.Count - 1;

            ComputeItemAmount();
            cboVariation_SelectedIndexChanged(null, null);
            lstItemFixCssClass();
        }
Exemplo n.º 2
0
		private void AddItemToInventory(long POID)
		{

			PODetails clsPODetails = Details(POID);
            ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
			ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

			POItem clsPOItem = new POItem(base.Connection, base.Transaction);
            ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
            Products clsProduct = new Products(base.Connection, base.Transaction);
            ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);
            ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);

			Inventory clsInventory = new Inventory(base.Connection, base.Transaction);
            InventoryDetails clsInventoryDetails;

            ProductPackagePriceHistoryDetails clsProductPackagePriceHistoryDetails;

			//MySqlDataReader myReader = clsPOItem.List(POID, "POItemID", SortOption.Ascending);
            System.Data.DataTable dt = clsPOItem.ListAsDataTable(POID, "POItemID", SortOption.Ascending);

			//while (myReader.Read())
            foreach (System.Data.DataRow dr in dt.Rows)
			{
                long lngProductID = Convert.ToInt64(dr["ProductID"]);
                int intProductUnitID = Convert.ToInt16(dr["ProductUnitID"]);

                decimal decItemQuantity = Convert.ToDecimal(dr["Quantity"]);
                decimal decQuantity = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long lngVariationMatrixID = Convert.ToInt64(dr["VariationMatrixID"]);
                string strMatrixDescription = dr["MatrixDescription"].ToString();
                string strProductCode = dr["ProductCode"].ToString();
                string strProductUnitCode = dr["ProductUnitCode"].ToString();
                decimal decUnitCost = Convert.ToDecimal(dr["UnitCost"]);
                decimal decItemCost = Convert.ToDecimal(dr["Amount"]);
                decimal decSellingPrice = Convert.ToDecimal(dr["SellingPrice"]);
                decimal decVAT = Convert.ToDecimal(dr["VAT"]);
                decimal decEVAT = Convert.ToDecimal(dr["EVAT"]);
                decimal decLocalTax = Convert.ToDecimal(dr["LocalTax"]); 

                /*******************************************
				 * Add in the Price History
				 * ****************************************/
                // Update ProductPackagePriceHistory first to get the history
                clsProductPackagePriceHistoryDetails = new ProductPackagePriceHistoryDetails();
                clsProductPackagePriceHistoryDetails.UID = clsPODetails.PurchaserID;
                clsProductPackagePriceHistoryDetails.PackageID = clsProductPackage.GetPackageID(lngProductID, intProductUnitID);
                clsProductPackagePriceHistoryDetails.ChangeDate = DateTime.Now;
                clsProductPackagePriceHistoryDetails.PurchasePrice = (decItemQuantity * decUnitCost) / decQuantity;
                clsProductPackagePriceHistoryDetails.Price = decSellingPrice;
                clsProductPackagePriceHistoryDetails.VAT = decVAT;
                clsProductPackagePriceHistoryDetails.EVAT = decEVAT;
                clsProductPackagePriceHistoryDetails.LocalTax = decLocalTax;
                clsProductPackagePriceHistoryDetails.Remarks = "Based on PO #: " + clsPODetails.PONo;
                ProductPackagePriceHistory clsProductPackagePriceHistory = new ProductPackagePriceHistory(base.Connection, base.Transaction);
                clsProductPackagePriceHistory.Insert(clsProductPackagePriceHistoryDetails);


				/*******************************************
				 * Add to Inventory
				 * ****************************************/
                //clsProduct.AddQuantity(lngProductID, decQuantity);
                //if (lngVariationMatrixID != 0) { clsProductVariationsMatrix.AddQuantity(lngVariationMatrixID, decQuantity); }
                // July 26, 2011: change the above codes to the following
                clsProduct.AddQuantity(clsPODetails.BranchID, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.ADD_PURCHASE) + " @ " + decUnitCost.ToString("#,##0.#0") + "/" + strProductUnitCode, DateTime.Now, clsPODetails.PONo, clsPODetails.PurchaserName);

                /*******************************************
				 * Update Purchasing Information
                 * 
                 * 30May2013 Include variation in the package.
				 * ****************************************/
                int iBaseUnitID = clsProduct.get_BaseUnitID(lngProductID);
                if (iBaseUnitID != intProductUnitID)
                {
                    clsProduct.UpdatePurchasing(lngProductID, lngVariationMatrixID, clsPODetails.SupplierID, iBaseUnitID, (decItemQuantity * decUnitCost) / decQuantity);
                }
                clsProduct.UpdatePurchasing(lngProductID, lngVariationMatrixID, clsPODetails.SupplierID, intProductUnitID, decUnitCost);

				/*******************************************
				 * Add to Inventory Analysis
				 * ****************************************/
				clsInventoryDetails = new InventoryDetails();
                clsInventoryDetails.BranchID = clsPODetails.BranchID;
				clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
				clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
				clsInventoryDetails.PostingDate = clsPODetails.DeliveryDate;
				clsInventoryDetails.ReferenceNo = clsPODetails.PONo;
				clsInventoryDetails.ContactID = clsPODetails.SupplierID;
				clsInventoryDetails.ContactCode = clsPODetails.SupplierCode;
                clsInventoryDetails.ProductID = lngProductID;
                clsInventoryDetails.ProductCode = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                clsInventoryDetails.MatrixDescription = strMatrixDescription;
				clsInventoryDetails.PurchaseQuantity = decQuantity;
                clsInventoryDetails.PurchaseCost = decItemCost - decVAT;
                clsInventoryDetails.PurchaseVAT = decItemCost;	// Purchase Cost with VAT

				clsInventory.Insert(clsInventoryDetails);

                /*******************************************
				 * Added Jan 1, 2010 4:20PM
                 * Update Selling Information when PO is posted
				 * ****************************************/
                clsProduct.UpdateSellingPrice(lngProductID, lngVariationMatrixID, clsPODetails.SupplierID, intProductUnitID, Convert.ToDecimal(dr["SellingPrice"]), -1, -1, -1, -1, -1);

                /*******************************************
				 * Added Mar 8, 2010 4:20PM
                 * Update the purchase price history to check who has the lowest price.
				 * ****************************************/
                ProductPurchasePriceHistoryDetails clsProductPurchasePriceHistoryDetails = new ProductPurchasePriceHistoryDetails();
                clsProductPurchasePriceHistoryDetails.ProductID = lngProductID;
                clsProductPurchasePriceHistoryDetails.MatrixID = lngVariationMatrixID;
                clsProductPurchasePriceHistoryDetails.SupplierID = clsPODetails.SupplierID;
                clsProductPurchasePriceHistoryDetails.PurchasePrice = decUnitCost;
                clsProductPurchasePriceHistoryDetails.PurchaseDate = clsPODetails.PODate;
                clsProductPurchasePriceHistoryDetails.Remarks = clsPODetails.PONo;
                clsProductPurchasePriceHistoryDetails.PurchaserName = clsPODetails.PurchaserName;
                ProductPurchasePriceHistory clsProductPurchasePriceHistory = new ProductPurchasePriceHistory(base.Connection, base.Transaction);
                clsProductPurchasePriceHistory.AddToList(clsProductPurchasePriceHistoryDetails);
			}
			//myReader.Close();

		}
Exemplo n.º 3
0
		protected void cboProductCode_SelectedIndexChanged(object sender, System.EventArgs e)
		{
            if (cboProductCode.Items.Count == 0)
                return;

            if (cboProductCode.Items.Count == 1 && cboProductCode.SelectedValue == Constants.ZERO_STRING)
                return;

            DataClass clsDataClass = new DataClass();
            long ProductID = Convert.ToInt64(cboProductCode.SelectedItem.Value);

            ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix();
            cboVariation.DataTextField = "MatrixDescription";
            cboVariation.DataValueField = "MatrixID";
            cboVariation.DataSource = clsProductVariationsMatrix.BaseListSimpleAsDataTable(ProductID, SortField: "VariationDesc").DefaultView;
            cboVariation.DataBind();

            if (cboVariation.Items.Count == 0)
            { cboVariation.Items.Add(new ListItem("No Variation", Constants.ZERO_STRING)); }
            cboVariation.SelectedIndex = cboVariation.Items.Count - 1;

            ProductUnitsMatrix clsUnitMatrix = new ProductUnitsMatrix(clsProductVariationsMatrix.Connection, clsProductVariationsMatrix.Transaction);
            cboProductUnit.DataTextField = "BottomUnitCode";
            cboProductUnit.DataValueField = "BottomUnitID";
            cboProductUnit.DataSource = clsUnitMatrix.ListAsDataTable(ProductID, "a.MatrixID", SortOption.Ascending).DefaultView;
            cboProductUnit.DataBind();

            Products clsProduct = new Products(clsProductVariationsMatrix.Connection, clsProductVariationsMatrix.Transaction);
            ProductDetails clsDetails = clsProduct.Details(ProductID);
            ProductPurchasePriceHistory clsProductPurchasePriceHistory = new ProductPurchasePriceHistory(clsProductVariationsMatrix.Connection, clsProductVariationsMatrix.Transaction);
            System.Data.DataTable dtProductPurchasePriceHistory = clsProductPurchasePriceHistory.ListAsDataTable(ProductID, DateTime.Now.AddMonths(-6), "PurchasePrice", SortOption.Ascending);

            clsProductVariationsMatrix.CommitAndDispose();
            
            cboProductUnit.Items.Insert(0, new ListItem(clsDetails.BaseUnitCode, clsDetails.BaseUnitID.ToString()));

            cboProductUnit.SelectedIndex = cboProductUnit.Items.IndexOf(new ListItem(clsDetails.BaseUnitCode, clsDetails.BaseUnitID.ToString()));
            txtPurchasePrice.Text = clsDetails.PurchasePrice.ToString("#####0.##0");

            if (cboProductUnit.Items.Count == 0)
            { cboProductUnit.Items.Add(new ListItem("No Unit", "0")); }
            cboVariation.SelectedIndex = cboVariation.Items.Count - 1;

            ComputeAmount();
            cboVariation_SelectedIndexChanged(null, null);

		}
Exemplo n.º 4
0
        protected void cboProductCode_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            int intProductBaseUnitID = 0;
            decimal decCommision = 0;
            lblProductSubGroupID.Text = "0";

            if (cboProductCode.SelectedItem.Value != Constants.ZERO_STRING)
            {
                Products clsProduct = new Products();
                try
                {
                    ProductDetails clsDetails = clsProduct.Details(Convert.ToInt64(cboProductCode.SelectedValue));
                    intProductBaseUnitID = clsDetails.BaseUnitID; decCommision = clsDetails.PercentageCommision;

                    lblProductSubGroupID.Text = clsDetails.ProductSubGroupID.ToString();
                }
                catch { }
                
                txtProductCode.ToolTip = intProductBaseUnitID.ToString();
                lblProductID.ToolTip = decCommision.ToString();
                long ProductID = Convert.ToInt64(cboProductCode.SelectedValue);

                ProductPackage clsProductPackage = new ProductPackage(clsProduct.Connection, clsProduct.Transaction);
                lstProductPackages.DataSource = clsProductPackage.ListAsDataTable(Convert.ToInt64(cboProductCode.SelectedValue)).DefaultView;
                lstProductPackages.DataBind();

                ProductPurchasePriceHistory clsProductPurchasePriceHistory = new ProductPurchasePriceHistory(clsProduct.Connection, clsProduct.Transaction);
                System.Data.DataTable dtProductPurchasePriceHistory = clsProductPurchasePriceHistory.ListAsDataTable(Convert.ToInt64(cboProductCode.SelectedValue), DateTime.Now.AddMonths(-6), "PurchasePrice", SortOption.Ascending);
                clsProduct.CommitAndDispose();

                string strPurchasePriceHistory = string.Empty;
                foreach (System.Data.DataRow dr in dtProductPurchasePriceHistory.Rows)
                {
                    DateTime dtePurchaseDate = DateTime.Parse(dr["PurchaseDate"].ToString());
                    decimal decPurchasePrice = decimal.Parse(dr["PurchasePrice"].ToString());
                    string strSupplierName = "" + dr["PurchaserName"].ToString();
                    string strPurchaserName = "" + dr["SupplierName"].ToString();

                    strPurchasePriceHistory += dtePurchaseDate.ToString("ddMMMyyyy HH:mm") + ": " + strPurchaserName.PadRight(50) + " - " + decPurchasePrice.ToString("#,##0.#0").PadLeft(10) + " " + strSupplierName + "\r\n<br />" + Environment.NewLine;
                }
                lblPurchasePriceHistory.Text = "<br /><b>PURCHASE PRICE HISTORY: </b><br /><br />" + strPurchasePriceHistory;

                lblProductPackage.Visible = true;
                lnkProductPackageAdd.Visible = true;
                lstProductPackages.Visible = true;
                imgProductHistory.Visible = true;
                imgProductPriceHistory.Visible = true;
                imgInventoryAdjustment.Visible = true;
                imgEditNow.Visible = true;
                lnkPackage.Visible = true;
                imgVariationsMatrix.Visible = true;
                imgUnitsMatrix.Visible = true;

                string stParam = "?task=" + Common.Encrypt("list", Session.SessionID) + "&prodid=" + Common.Encrypt(cboProductCode.SelectedValue, Session.SessionID);
                lnkPackage.NavigateUrl = Constants.ROOT_DIRECTORY + "/MasterFiles/_Product/_Package/Default.aspx" + stParam;

                lnkProductPackageAdd.ToolTip = "Add new package for " + cboProductCode.SelectedItem.Text;
                lnkProductPackageAdd.NavigateUrl = "_Package/Default.aspx?task=" + Common.Encrypt("add", Session.SessionID) + "&prodid=" + Common.Encrypt(cboProductCode.SelectedValue, Session.SessionID) + "&productcode=" + Common.Encrypt(cboProductCode.SelectedItem.Text, Session.SessionID);
                txtProductCode.Text = cboProductCode.SelectedItem.Text;
                lblPurchasePriceHistory.Visible = true;
            }
            else if (cboProductCode.SelectedItem.Text == Constants.ZERO_STRING)
            {
                lblProductPackage.Visible = false;
                lnkProductPackageAdd.Visible = false;
                lstProductPackages.Visible = false;
                imgProductHistory.Visible = false;
                imgProductPriceHistory.Visible = false;
                imgInventoryAdjustment.Visible = false;
                imgEditNow.Visible = false;
                lnkPackage.Visible = false;
                imgVariationsMatrix.Visible = false;
                imgUnitsMatrix.Visible = false;
                lblPurchasePriceHistory.Visible = false;
                txtProductCode.ToolTip = intProductBaseUnitID.ToString();
                lblProductID.ToolTip = decCommision.ToString(); 
            }
           
        }
Exemplo n.º 5
0
        private void AddItemToInventory(long TransferInID)
        {
            try
            {
                TransferInDetails clsTransferInDetails = Details(TransferInID);
                ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
                ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

                TransferInItem clsTransferInItem = new TransferInItem(base.Connection, base.Transaction);
                ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
                Products clsProduct = new Products(base.Connection, base.Transaction);
                ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);

                Inventory clsInventory = new Inventory(base.Connection, base.Transaction);
                InventoryDetails clsInventoryDetails;

                ProductPackagePriceHistoryDetails clsProductPackagePriceHistoryDetails;

                System.Data.DataTable dt = clsTransferInItem.ListAsDataTable(TransferInID, "TransferInItemID", SortOption.Ascending);
            
                foreach(System.Data.DataRow dr in dt.Rows)
                {
                    long lngProductID = long.Parse(dr["ProductID"].ToString());
                    int intProductUnitID = int.Parse(dr["ProductUnitID"].ToString());

                    decimal decItemQuantity = decimal.Parse(dr["Quantity"].ToString());
                    decimal decQuantity = new ProductUnit().GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                    long lngVariationMatrixID = long.Parse(dr["VariationMatrixID"].ToString()); 
                    string strMatrixDescription = "" + dr["MatrixDescription"].ToString();
                    string strProductCode = "" + dr["ProductCode"].ToString();
                    decimal decUnitCost = decimal.Parse(dr["UnitCost"].ToString());
                    decimal decItemCost = decimal.Parse(dr["Amount"].ToString());
                    decimal decSellingPrice = Convert.ToDecimal(dr["SellingPrice"]);
                    decimal decVAT = Convert.ToDecimal(dr["VAT"]); // myReader.GetDecimal("VAT");
                    decimal decEVAT = Convert.ToDecimal(dr["EVAT"]);
                    decimal decLocalTax = Convert.ToDecimal(dr["LocalTax"]); 

                    /*******************************************
				     * Add in the Price History
				     * ****************************************/
                    // Update ProductPackagePriceHistory first to get the history
                    clsProductPackagePriceHistoryDetails = new ProductPackagePriceHistoryDetails();
                    clsProductPackagePriceHistoryDetails.UID = clsTransferInDetails.TransferrerID;
                    clsProductPackagePriceHistoryDetails.PackageID = new ProductPackage().GetPackageID(lngProductID, intProductUnitID);
                    clsProductPackagePriceHistoryDetails.ChangeDate = DateTime.Now;
                    clsProductPackagePriceHistoryDetails.PurchasePrice = (decItemQuantity * decUnitCost) / decQuantity;
                    clsProductPackagePriceHistoryDetails.Price = decSellingPrice;
                    clsProductPackagePriceHistoryDetails.VAT = decVAT;
                    clsProductPackagePriceHistoryDetails.EVAT = decEVAT;
                    clsProductPackagePriceHistoryDetails.LocalTax = decLocalTax;
                    clsProductPackagePriceHistoryDetails.Remarks = "Based on TransferIn #: " + clsTransferInDetails.TransferInNo;
                    ProductPackagePriceHistory clsProductPackagePriceHistory = new ProductPackagePriceHistory(base.Connection, base.Transaction);
                    clsProductPackagePriceHistory.Insert(clsProductPackagePriceHistoryDetails);

                    /*******************************************
                     * Add to Inventory
                     * ****************************************/
                    //clsProduct.AddQuantity(lngProductID, decQuantity);
                    //if (lngVariationMatrixID != 0)
                    //{
                    //    clsProductVariationsMatrix.AddQuantity(lngVariationMatrixID, decQuantity);
                    //}
                    // July 26, 2011: change the above codes to the following
                    clsProduct.AddQuantity(clsTransferInDetails.BranchID, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.ADD_TRANSFER_IN), DateTime.Now, clsTransferInDetails.TransferInNo, clsTransferInDetails.TransferrerName);

                    /*******************************************
                     * Update Purchasing Information
                     * ****************************************/
                    int iBaseUnitID = clsProduct.get_BaseUnitID(lngProductID);
                    if (iBaseUnitID != intProductUnitID)
                    {
                        clsProduct.UpdatePurchasing(lngProductID, lngVariationMatrixID, clsTransferInDetails.SupplierID, iBaseUnitID, (decItemQuantity * decUnitCost) / decQuantity);
                    }
                    clsProduct.UpdatePurchasing(lngProductID, lngVariationMatrixID, clsTransferInDetails.SupplierID, intProductUnitID, decUnitCost);

                    /*******************************************
                     * Add to Inventory Analysis
                     * ****************************************/
                    clsInventoryDetails = new InventoryDetails();
                    clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
                    clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
                    clsInventoryDetails.PostingDate = clsTransferInDetails.DeliveryDate;
                    clsInventoryDetails.ReferenceNo = clsTransferInDetails.TransferInNo;
                    clsInventoryDetails.ContactID = clsTransferInDetails.SupplierID;
                    clsInventoryDetails.ContactCode = clsTransferInDetails.SupplierCode;
                    clsInventoryDetails.ProductID = lngProductID;
                    clsInventoryDetails.ProductCode = strProductCode;
                    clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                    clsInventoryDetails.MatrixDescription = strMatrixDescription;
                    clsInventoryDetails.TransferInQuantity = decQuantity;
                    clsInventoryDetails.TransferInCost = decItemCost - decVAT;
                    clsInventoryDetails.TransferInVAT = decItemCost;	// TransferIn Cost with VAT

                    clsInventory.Insert(clsInventoryDetails);

                    /*******************************************
				     * Added April 28, 2010 4:20PM
                     * Update Selling Information when TransferIn is posted
				     * ****************************************/
                    clsProduct.UpdateSellingPrice(lngProductID, lngVariationMatrixID, clsTransferInDetails.SupplierID, intProductUnitID, decimal.Parse(dr["SellingPrice"].ToString()), -1, -1, -1, -1, -1);
                    //if (lngVariationMatrixID != 0)
                    //{
                    //    clsProductVariationsMatrix.UpdateSellingWithSameQuantityAndUnit(lngVariationMatrixID, clsPODetails.SupplierID, intProductUnitID, decimal.Parse(myReader["SellingPrice");
                    //}

                    /*******************************************
				     * Added April 28, 2010 4:20PM
                     * Update the purchase price history to check who has the lowest price.
				     * ****************************************/
                    ProductPurchasePriceHistoryDetails clsProductPurchasePriceHistoryDetails = new ProductPurchasePriceHistoryDetails();
                    clsProductPurchasePriceHistoryDetails.ProductID = lngProductID;
                    clsProductPurchasePriceHistoryDetails.MatrixID = lngVariationMatrixID;
                    clsProductPurchasePriceHistoryDetails.SupplierID = clsTransferInDetails.SupplierID;
                    clsProductPurchasePriceHistoryDetails.PurchasePrice = decUnitCost;
                    clsProductPurchasePriceHistoryDetails.PurchaseDate = clsTransferInDetails.TransferInDate;
                    clsProductPurchasePriceHistoryDetails.Remarks = clsTransferInDetails.TransferInNo;
                    ProductPurchasePriceHistory clsProductPurchasePriceHistory = new ProductPurchasePriceHistory(base.Connection, base.Transaction);
                    clsProductPurchasePriceHistory.AddToList(clsProductPurchasePriceHistoryDetails);
                }
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }

        }