private void ChangeQuantity() { int iRow = dgItems.CurrentRowIndex; if (iRow >= 0) { if (dgItems[iRow, 8].ToString() != "VOID") { Data.SalesTransactionItemDetails Details = getCurrentRowItemDetails(); decimal decOldQuantity = Details.Quantity; decimal decScannedQty = Details.ScannedQty; ChangeQuantityWnd QtyWnd = new ChangeQuantityWnd(); QtyWnd.Details = Details; QtyWnd.ShowDialog(this); DialogResult result = QtyWnd.Result; Details = QtyWnd.Details; QtyWnd.Close(); QtyWnd.Dispose(); if (result == DialogResult.OK && decScannedQty != Details.Quantity) { // ChangeQuantityWnd referenced is Quantity column thus need to overwrite with the olf value. Details.ScannedQty = Details.Quantity; Details.Quantity = decOldQuantity; ApplyChangeQuantityPriceAmountDetails(iRow, Details); } } } }
private void ChangeQuantity() { int iOldRow = dgItems.CurrentRowIndex; int iRow = dgItems.CurrentRowIndex; if (iRow >= 0) { if (dgItems[iRow, 8].ToString() != "VOID") { if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto) { MessageBox.Show("Sorry you cannot change quantity if Auto-print is ON.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } DialogResult loginresult = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.ChangeQuantity); if (loginresult == DialogResult.OK) { Data.SalesTransactionItemDetails Details = getCurrentRowItemDetails(); decimal oldQuantity = Details.Quantity; ChangeQuantityWnd QtyWnd = new ChangeQuantityWnd(); QtyWnd.Details = Details; QtyWnd.TerminalDetails = mclsTerminalDetails; QtyWnd.ShowDialog(this); DialogResult result = QtyWnd.Result; Details = QtyWnd.Details; QtyWnd.Close(); QtyWnd.Dispose(); if (result == DialogResult.OK && oldQuantity != Details.Quantity) { Data.Products clsProduct = new Data.Products(mConnection, mTransaction); mConnection = clsProduct.Connection; mTransaction = clsProduct.Transaction; if (mboIsRefund == false) { if (lblCustomer.Text.Trim().ToUpper() != Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER) { if (Details.TransactionItemStatus != TransactionItemStatus.Return) { Data.ProductDetails det = clsProduct.Details(Details.ProductID, Details.VariationsMatrixID, mclsTerminalDetails.BranchID); decimal decProductCurrentQuantity = det.Quantity - det.ReservedQuantity + oldQuantity; // 04Sep2014 : Include exception for CreditPayment if (decProductCurrentQuantity < Details.Quantity && mclsTerminalDetails.ShowItemMoreThanZeroQty && Details.BarCode != Data.Products.DEFAULT_CREDIT_PAYMENT_BARCODE && Details.BarCode != Data.Products.DEFAULT_ADVANTAGE_CARD_MEMBERSHIP_FEE_BARCODE && Details.BarCode != Data.Products.DEFAULT_ADVANTAGE_CARD_RENEWAL_FEE_BARCODE && Details.BarCode != Data.Products.DEFAULT_ADVANTAGE_CARD_REPLACEMENT_FEE_BARCODE && Details.BarCode != Data.Products.DEFAULT_CREDIT_CARD_MEMBERSHIP_FEE_BARCODE && Details.BarCode != Data.Products.DEFAULT_CREDIT_CARD_RENEWAL_FEE_BARCODE && Details.BarCode != Data.Products.DEFAULT_SUPER_CARD_MEMBERSHIP_FEE_BARCODE && Details.BarCode != Data.Products.DEFAULT_SUPER_CARD_RENEWAL_FEE_BARCODE && Details.BarCode != Data.Products.DEFAULT_SUPER_CARD_REPLACEMENT_FEE_BARCODE) { clsProduct.CommitAndDispose(); MessageBox.Show("Sorry the quantity you entered is greater than the current stock. " + Environment.NewLine + "Current Stock: " + decProductCurrentQuantity.ToString("#,##0.#0"), "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } } } if (!mboIsRefund) { if (Details.TransactionItemStatus != TransactionItemStatus.Return) { Data.ProductUnit clsProductUnit = new Data.ProductUnit(mConnection, mTransaction); mConnection = clsProductUnit.Connection; mTransaction = clsProductUnit.Transaction; decimal decNewQuantity = clsProductUnit.GetBaseUnitValue(Details.ProductID, Details.ProductUnitID, oldQuantity); clsProduct.SubtractReservedQuantity(mclsTerminalDetails.BranchID, Details.ProductID, Details.VariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.DEDUCT_QTY_RESERVE_AND_COMMIT_CHANGE_QTY), DateTime.Now, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); } } mbodgItemRowClick = true; if (mboIsRefund) ApplyChangeQuantityPriceAmountDetails(iRow, Details, "Change Quantity"); else { Details = ApplyPromo(Details); ApplyChangeQuantityPriceAmountDetails(iRow, Details, "Change Quantity"); System.Data.DataTable dt = (System.Data.DataTable)dgItems.DataSource; for (int x = iRow + 1; x < dt.Rows.Count; x++) { dgItems.CurrentRowIndex = x; Details = getCurrentRowItemDetails(); System.Data.DataRow dr = dt.Rows[x]; if (dr["Quantity"].ToString() != "VOID" && dr["Quantity"].ToString().IndexOf("RETURN") == -1 && dr["Quantity"].ToString().IndexOf("DEMO") == -1 && dr["ProductID"].ToString() == Details.ProductID.ToString()) { Details = ApplyPromo(Details); ApplyChangeQuantityPriceAmountDetails(x, Details, "Change Quantity"); } } if (iOldRow >= 0) { dgItems.CurrentRowIndex = iOldRow; dgItems.Select(iOldRow); } } Details = getCurrentRowItemDetails(); // Added May 7, 2011 to Cater Reserved and Commit functionality // Details.Quantity = -oldQuantity + Details.Quantity; // Jul 26, 2011 Change the AddQuantity and SubtractQuantity ReservedAndCommitItem(Details, Details.TransactionItemStatus); clsProduct.CommitAndDispose(); mbodgItemRowClick = false; DisplayItemToTurretDelegate DisplayItemToTurretDel = new DisplayItemToTurretDelegate(DisplayItemToTurret); DisplayItemToTurretDel.BeginInvoke(Details.Description, Details.ProductUnitCode, Details.Quantity, Details.Price, Details.Discount, Details.PromoApplied, Details.Amount, Details.VAT, Details.EVAT, null, null); } } } } }