private bool Delete() { bool boRetValue = false; string stIDs = ""; foreach (DataListItem item in lstItem.Items) { HtmlInputCheckBox chkList = (HtmlInputCheckBox)item.FindControl("chkList"); if (chkList != null) { if (chkList.Checked == true) { stIDs += chkList.Value + ","; boRetValue = true; } } } if (boRetValue) { Security.AccessUserDetails clsAccessUserDetails = (Security.AccessUserDetails)Session["AccessUserDetails"]; ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(); clsProductVariationsMatrix.GetConnection(); Products clsProducts = new Products(clsProductVariationsMatrix.Connection, clsProductVariationsMatrix.Transaction); long ProductID = Int64.Parse(lblProductID.Text); string[] strIDs = stIDs.Substring(0, stIDs.Length - 1).Split(','); foreach (string ID in strIDs) { long MatrixID = long.Parse(ID); ProductDetails clsDetails = clsProducts.Details(ProductID: ProductID, MatrixID: MatrixID); InvAdjustmentDetails clsInvAdjustmentDetails = new InvAdjustmentDetails(); clsInvAdjustmentDetails.UID = clsAccessUserDetails.UID; clsInvAdjustmentDetails.InvAdjustmentDate = DateTime.Now; clsInvAdjustmentDetails.ProductID = clsDetails.ProductID; clsInvAdjustmentDetails.ProductCode = clsDetails.ProductCode; clsInvAdjustmentDetails.Description = clsDetails.ProductDesc; clsInvAdjustmentDetails.VariationMatrixID = clsDetails.MatrixID; clsInvAdjustmentDetails.MatrixDescription = clsDetails.MatrixDescription; clsInvAdjustmentDetails.UnitID = clsDetails.BaseUnitID; clsInvAdjustmentDetails.UnitCode = clsDetails.BaseUnitCode; clsInvAdjustmentDetails.QuantityBefore = clsDetails.Quantity; clsInvAdjustmentDetails.QuantityNow = 0; clsInvAdjustmentDetails.MinThresholdBefore = clsDetails.MinThreshold; clsInvAdjustmentDetails.MinThresholdNow = 0; clsInvAdjustmentDetails.MaxThresholdBefore = clsDetails.MaxThreshold; clsInvAdjustmentDetails.MaxThresholdNow = 0; clsInvAdjustmentDetails.Remarks = "deleted item."; InvAdjustment clsInvAdjustment = new InvAdjustment(clsProducts.Connection, clsProducts.Transaction); clsInvAdjustment.Insert(clsInvAdjustmentDetails); // Aug 1, 2011 : Lemu // Replaced clsProductVariationsMatrix.SynchronizeQuantity(Convert.ToInt64(lblProductID.Text)); clsProductVariationsMatrix.Delete(long.Parse(ID)); } // Aug 1, 2011 : Lemu // Deleted and replaced by subtracting each matrix in the product to include in the ProductMovement report // clsProduct.SubtractQuantity(clsProductDetails.ProductID, 0, clsBaseDetails.Quantity, Product.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.DEDUCT_PRODUCT_VARIATION_DELETE) + " : " + clsBaseDetails.Description, clsInvAdjustmentDetails.InvAdjustmentDate, "SYS-VARDEL" + clsInvAdjustmentDetails.InvAdjustmentDate.ToString(""), clsAccessUserDetails.Name); // clsProductVariationsMatrix.SynchronizeQuantity(Convert.ToInt64(lblProductID.Text)); clsProductVariationsMatrix.CommitAndDispose(); } return(boRetValue); }