private void SaveRecord() { Security.AccessUserDetails clsDetails = (Security.AccessUserDetails)Session["AccessUserDetails"]; DateTime dteChangeDate = DateTime.Now; Products clsProduct = new Products(); clsProduct.GetConnection(); InvAdjustment clsInvAdjustment = new InvAdjustment(clsProduct.Connection, clsProduct.Transaction); InvAdjustmentDetails clsInvAdjustmentDetails; long lngProductID = long.Parse(cboProductCode.SelectedValue); if (lstVariationMatrix.Items.Count > 0) { ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(clsProduct.Connection, clsProduct.Transaction); foreach (DataListItem e in lstVariationMatrix.Items) { HtmlInputCheckBox chkMatrixID = (HtmlInputCheckBox)e.FindControl("chkMatrixID"); Label lblVariationDesc = (Label)e.FindControl("lblVariationDesc"); Label lblUnitNameMatrix = (Label)e.FindControl("lblUnitCode"); TextBox txtQuantityBeforeMatrix = (TextBox)e.FindControl("txtQuantityBefore"); //TextBox txtDifferenceMatrix = (TextBox)e.FindControl("txtDifference"); TextBox txtQuantityNowMatrix = (TextBox)e.FindControl("txtQuantityNow"); TextBox txtMinThresholdMatrix = (TextBox)e.FindControl("txtMinThreshold"); TextBox txtMaxThresholdMatrix = (TextBox)e.FindControl("txtMaxThreshold"); decimal decQuantityBeforeMatrix = decimal.Parse(txtQuantityBeforeMatrix.Text); //decimal decDifferenceMatrix = decimal.Parse(txtDifference.Text); decimal decQuantityNowMatrix = decimal.Parse(txtQuantityNowMatrix.Text); decimal decMinThresholdMatrixBefore = decimal.Parse(txtMinThresholdMatrix.ToolTip); decimal decMinThresholdMatrixNow = decimal.Parse(txtMinThresholdMatrix.Text); decimal decMaxThresholdMatrixBefore = decimal.Parse(txtMaxThresholdMatrix.ToolTip); decimal decMaxThresholdMatrixNow = decimal.Parse(txtMaxThresholdMatrix.Text); if (decQuantityBeforeMatrix != decQuantityNowMatrix || decMinThresholdMatrixBefore != decMinThresholdMatrixNow || decMaxThresholdMatrixBefore != decMaxThresholdMatrixNow) { clsInvAdjustmentDetails = new InvAdjustmentDetails(); clsInvAdjustmentDetails.UID = clsDetails.UID; clsInvAdjustmentDetails.InvAdjustmentDate = dteChangeDate; clsInvAdjustmentDetails.ProductID = long.Parse(cboProductCode.SelectedValue); clsInvAdjustmentDetails.ProductCode = cboProductCode.SelectedItem.Text; clsInvAdjustmentDetails.Description = cboProductCode.SelectedItem.Text; clsInvAdjustmentDetails.VariationMatrixID = long.Parse(chkMatrixID.Value); clsInvAdjustmentDetails.MatrixDescription = lblVariationDesc.Text; clsInvAdjustmentDetails.UnitID = int.Parse(lblUnitNameMatrix.ToolTip); clsInvAdjustmentDetails.UnitCode = lblUnitNameMatrix.Text; clsInvAdjustmentDetails.QuantityBefore = decQuantityBeforeMatrix; clsInvAdjustmentDetails.QuantityNow = decQuantityNowMatrix; clsInvAdjustmentDetails.MinThresholdBefore = decMinThresholdMatrixBefore; clsInvAdjustmentDetails.MinThresholdNow = decMinThresholdMatrixNow; clsInvAdjustmentDetails.MaxThresholdBefore = decMaxThresholdMatrixBefore; clsInvAdjustmentDetails.MaxThresholdNow = decMaxThresholdMatrixNow; clsInvAdjustmentDetails.Remarks = txtRemarks.Text; clsInvAdjustment.Insert(clsInvAdjustmentDetails); if (decQuantityBeforeMatrix > decQuantityNowMatrix) { clsProduct.UpdateInvDetails(int.Parse(cboBranch.SelectedItem.Value), lngProductID, long.Parse(chkMatrixID.Value), decQuantityNowMatrix, decMinThresholdMatrixNow, decMaxThresholdMatrixNow, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.DEDUCT_INVENTORY_ADJUSTMENT), dteChangeDate, "SYS-ADJ" + dteChangeDate.ToString("yyyyMMddHHmmss"), clsDetails.Name); } else if (decQuantityBeforeMatrix < decQuantityNowMatrix) { clsProduct.UpdateInvDetails(int.Parse(cboBranch.SelectedItem.Value), lngProductID, long.Parse(chkMatrixID.Value), decQuantityNowMatrix, decMinThresholdMatrixNow, decMaxThresholdMatrixNow, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.ADD_INVENTORY_ADJUSTMENT), dteChangeDate, "SYS-ADJ" + dteChangeDate.ToString("yyyyMMddHHmmss"), clsDetails.Name); } } } } clsProduct.CommitAndDispose(); }