/// <summary> /// To check the status of the product /// </summary> public void QuantityStatusCheck() { try { int inRowConsumption = dgvConsumption.RowCount; int inRowProduction = dgvProduction.RowCount; if (rbtnTransfer.Checked == true) { if (inRowConsumption - 1 == 0) { Messages.InformationMessage("Can't save Stock Journal without atleast one product with complete details"); dgvConsumption.Focus(); goto Exit; } if (inRowProduction - 1 == 0) { Messages.InformationMessage("Can't save Stock Journal without atleast one product with complete details"); dgvProduction.Focus(); goto Exit; } } decimal decProductId = 0; decimal decBatchId = 0; decimal decCalcQty = 0; StockPostingSP spStockPosting = new StockPostingSP(); SettingsSP spSettings = new SettingsSP(); string strStatus = spSettings.SettingsStatusCheck("NegativeStockStatus"); bool isNegativeLedger = false; int inRowCount = dgvConsumption.RowCount; for (int i = 0; i < inRowCount - 1; i++) { if (dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductId"].Value != null && dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductId"].Value.ToString() != string.Empty) { decProductId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductId"].Value.ToString()); if (dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value != null && dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value.ToString() != string.Empty) { decBatchId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value.ToString()); } decimal decCurrentStock = spStockPosting.StockCheckForProductSale(decProductId, decBatchId); if (dgvConsumption.Rows[i].Cells["dgvtxtConsumptionQty"].Value != null && dgvConsumption.Rows[i].Cells["dgvtxtConsumptionQty"].Value.ToString() != string.Empty) { decCalcQty = decCurrentStock - Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionQty"].Value.ToString()); } if (decCalcQty < 0) { isNegativeLedger = true; break; } } } if (isNegativeLedger) { if (strStatus == "Warn") { if (MessageBox.Show("Negative Stock balance exists,Do you want to Continue", "Open miracle", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { SaveOrEdit(); } } else if (strStatus == "Block") { MessageBox.Show("Cannot continue ,due to negative stock balance", "Open miracle", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { SaveOrEdit(); } } else { SaveOrEdit(); } Exit: ; } catch (Exception ex) { MessageBox.Show("SJ:39" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to check Negative Stock at the time of saving and updating /// </summary> public bool SaveOrEditCheck() { bool isOk = false; try { decimal decProductId = 0; decimal decBatchId = 0; decimal decCalcQty = 0; StockPostingSP spStockPosting = new StockPostingSP(); SettingsSP spSettings = new SettingsSP(); string strStatus = spSettings.SettingsStatusCheck("NegativeStockStatus"); bool isNegativeLedger = false; DataTable dtblPurchaseMasterViewById = new DataTable(); PurchaseReturnMasterSP SPPurchaseReturnMaster = new PurchaseReturnMasterSP(); dgvPurchaseReturn.ClearSelection(); int inRow = dgvPurchaseReturn.RowCount; if (txtReturnNo.Text.Trim() == string.Empty) { Messages.InformationMessage("Enter Return number"); txtReturnNo.Focus(); } else if (SPPurchaseReturnMaster.PurchaseReturnNumberCheckExistence(txtReturnNo.Text.Trim(), decPurchaseReturnVoucherTypeId) == true && btnSave.Text == "Save") { Messages.InformationMessage("Return number already exist"); txtReturnNo.Focus(); } else if ((btnSave.Text == "Update") && (txtReturnNo.Text != strReturnNo) && (SPPurchaseReturnMaster.PurchaseReturnNumberCheckExistence(txtReturnNo.Text.Trim(), decPurchaseReturnVoucherTypeId) == true)) { Messages.InformationMessage("Return number already exist"); txtReturnNo.Focus(); } else if (txtDate.Text.Trim() == string.Empty) { Messages.InformationMessage("Select a date in between financial year"); txtDate.Focus(); } else if (cmbInvoiceNo.Visible == true && cmbInvoiceNo.SelectedValue == null) { Messages.InformationMessage("Select a invoice no"); cmbInvoiceNo.Focus(); } else { if (RemoveIncompleteRowsFromGrid()) { int inRowCount = dgvPurchaseReturn.RowCount; if (inRowCount > 1) { for (int i = 0; i < inRowCount - 1; i++) { if (dgvPurchaseReturn.Rows[i].Cells["dgvtxtproductId"].Value != null && dgvPurchaseReturn.Rows[i].Cells["dgvtxtproductId"].Value.ToString() != string.Empty) { decProductId = Convert.ToDecimal(dgvPurchaseReturn.Rows[i].Cells["dgvtxtproductId"].Value.ToString()); if (dgvPurchaseReturn.Rows[i].Cells["dgvcmbBatch"].Value != null && dgvPurchaseReturn.Rows[i].Cells["dgvcmbBatch"].Value.ToString() != string.Empty) { decBatchId = Convert.ToDecimal(dgvPurchaseReturn.Rows[i].Cells["dgvcmbBatch"].Value.ToString()); } decimal decCurrentStock = spStockPosting.StockCheckForProductSale(decProductId, decBatchId); if (dgvPurchaseReturn.Rows[i].Cells["dgvtxtqty"].Value != null && dgvPurchaseReturn.Rows[i].Cells["dgvtxtqty"].Value.ToString() != string.Empty) { decCalcQty = decCurrentStock - Convert.ToDecimal(dgvPurchaseReturn.Rows[i].Cells["dgvtxtqty"].Value.ToString()); } if (decCalcQty < 0) { isNegativeLedger = true; break; } } } if (isNegativeLedger) { if (strStatus == "Warn") { if (MessageBox.Show("Negative Stock balance exists,Do you want to Continue", "Open miracle", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { isOk = true; } } else if (strStatus == "Block") { MessageBox.Show("Cannot continue ,due to negative stock balance", "Open miracle", MessageBoxButtons.OK, MessageBoxIcon.Stop); isOk = false; } else { isOk = true; } } else { isOk = true; } } else { isOk = false; } } } } catch (Exception ex) { MessageBox.Show("PR:48" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return isOk; }
/// <summary> /// Save or edit function to checking the negative stock status /// </summary> public void SaveOrEditFunction() { try { decimal decProductId = 0; decimal decBatchId = 0; decimal decCalcQty = 0; StockPostingSP spStockPosting = new StockPostingSP(); SettingsSP spSettings = new SettingsSP(); string strStatus = spSettings.SettingsStatusCheck("NegativeStockStatus"); bool isNegativeLedger = false; int inRowCount = dgvSalesInvoice.RowCount; for (int i = 0; i < inRowCount - 1; i++) { if (dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceProductId"].Value != null && dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceProductId"].Value.ToString() != string.Empty) { decProductId = Convert.ToDecimal(dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceProductId"].Value.ToString()); if (dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceBatch"].Value != null && dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceBatch"].Value.ToString() != string.Empty) { decBatchId = Convert.ToDecimal(dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceBatch"].Value.ToString()); } decimal decCurrentStock = spStockPosting.StockCheckForProductSale(decProductId, decBatchId); if (dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceQty"].Value != null && dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceQty"].Value.ToString() != string.Empty) { decCalcQty = decCurrentStock - Convert.ToDecimal(dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceQty"].Value.ToString()); } if (decCalcQty < 0) { isNegativeLedger = true; break; } } } if (isNegativeLedger) { if (strStatus == "Warn") { if (MessageBox.Show("Negative Stock balance exists,Do you want to Continue", "Open miracle", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { SaveOrEdit(); } } else if (strStatus == "Block") { MessageBox.Show("Cannot continue ,due to negative stock balance", "Open miracle", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { SaveOrEdit(); } } else { SaveOrEdit(); } } catch (Exception ex) { MessageBox.Show("SI : 68" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to Quantity Status Check /// </summary> public void QuantityStatusCheck() { try { decimal decProductId = 0; decimal decBatchId = 0; decimal decCalcQty = 0; StockPostingSP spStockPosting = new StockPostingSP(); SettingsSP spSettings = new SettingsSP(); string strStatus = spSettings.SettingsStatusCheck("NegativeStockStatus"); bool isNegativeLedger = false; if (cmbItem.SelectedIndex != -1) { decProductId = Convert.ToDecimal(cmbItem.SelectedValue.ToString()); batchcombofill(); decBatchId = Convert.ToDecimal(cmbBatch.SelectedValue.ToString()); decimal decCurrentStock = spStockPosting.StockCheckForProductSale(decProductId, decBatchId); if (txtQuantity.Text != null || txtQuantity.Text != string.Empty) { decCalcQty = decCurrentStock - Convert.ToDecimal(txtQuantity.Text.Trim().ToString()); } if (decCalcQty < 0) { isNegativeLedger = true; } } if (isNegativeLedger) { if (strStatus == "Warn") { if (MessageBox.Show("Negative Stock balance exists,Do you want to Continue", "Open miracle", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { AddToGrid(); } else { cmbItem.Focus(); } } else if (strStatus == "Block") { MessageBox.Show("Cannot continue ,due to negative stock balance", "Open miracle", MessageBoxButtons.OK, MessageBoxIcon.Stop); cmbItem.Focus(); } else { AddToGrid(); } } else { AddToGrid(); } } catch (Exception ex) { MessageBox.Show("POS :42 " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }