/// <summary>
        ///Function for Save Or Edit while changing NegativeStockStatus in Settings
        /// </summary>
        public void SaveOrEditFunction()
        {
            try
            {
                decimal decProductId = 0;
                decimal decBatchId = 0;
                decimal decCalcQty = 0;
                SettingsBll BllSettings = new SettingsBll();
                string strStatus = BllSettings.SettingsStatusCheck("NegativeStockStatus");
                bool isNegativeLedger = false;
                StockPostingBll BllStockPosting = new StockPostingBll();
                //StockPostingSP spStockPosting = new StockPostingSP();
                int inRowCount = dgvProduct.RowCount;
                for (int i = 0; i < inRowCount; i++)
                {
                    if (dgvProduct.Rows[i].Cells["dgvtxtproductId"].Value != null && dgvProduct.Rows[i].Cells["dgvtxtproductId"].Value.ToString() != string.Empty)
                    {
                        decProductId = Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtproductId"].Value.ToString());

                        if (dgvProduct.Rows[i].Cells["dgvcmbBatch"].Value != null && dgvProduct.Rows[i].Cells["dgvcmbBatch"].Value.ToString() != string.Empty)
                        {
                            decBatchId = Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvcmbBatch"].Value.ToString());
                        }
                        decimal decCurrentStock = BllStockPosting.StockCheckForProductSale(decProductId, decBatchId);
                        if (dgvProduct.Rows[i].Cells["dgvtxtQty"].Value != null && dgvProduct.Rows[i].Cells["dgvtxtQty"].Value.ToString() != string.Empty)
                        {
                            decCalcQty = decCurrentStock - Convert.ToDecimal(dgvProduct.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)
                        {
                            SaveOrEdit();
                        }
                    }
                    else if (strStatus == "Block")
                    {
                        MessageBox.Show("Cannot continue ,due to negative stock balance", "Open miracle", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        // Clear();
                    }
                    else
                    {
                        SaveOrEdit();
                    }
                }
                else
                {
                    SaveOrEdit();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("DN46 :" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #2
0
 /// <summary>
 /// Function to Quantity Status Check
 /// </summary>
 public void QuantityStatusCheck()
 {
     try
     {
         decimal decProductId = 0;
         decimal decBatchId = 0;
         decimal decCalcQty = 0;
         StockPostingBll BllStockPosting = new StockPostingBll();
         SettingsBll BllSettings = new SettingsBll();
         string strStatus = BllSettings.SettingsStatusCheck("NegativeStockStatus");
         bool isNegativeLedger = false;
         if (cmbItem.SelectedIndex != -1)
         {
             decProductId = Convert.ToDecimal(cmbItem.SelectedValue.ToString());
             batchcombofill();
             decBatchId = Convert.ToDecimal(cmbBatch.SelectedValue.ToString());
             decimal decCurrentStock = BllStockPosting.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);
     }
 }
        /// <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;
                StockPostingBll BllStockPosting = new StockPostingBll();
                //StockPostingSP spStockPosting = new StockPostingSP();
                SettingsBll BllSettings = new SettingsBll();
                string strStatus = BllSettings.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 = BllStockPosting.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;
         StockPostingBll BllStockPosting = new StockPostingBll();
         //StockPostingSP spStockPosting = new StockPostingSP();
         SettingsBll BllSettings = new SettingsBll();
         string strStatus = BllSettings.SettingsStatusCheck("NegativeStockStatus");
         bool isNegativeLedger = false;
         DataTable dtblPurchaseMasterViewById = new DataTable();
         PurchaseReturnBll BllPurchaseReturn = new PurchaseReturnBll();
         dgvPurchaseReturn.ClearSelection();
         int inRow = dgvPurchaseReturn.RowCount;
         if (txtReturnNo.Text.Trim() == string.Empty)
         {
             Messages.InformationMessage("Enter Return number");
             txtReturnNo.Focus();
         }
         else if (BllPurchaseReturn.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) && (BllPurchaseReturn.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 = BllStockPosting.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>
        /// FunctionTocheckNegativebalance
        /// </summary>
        /// <returns></returns>
        public bool CheckNegativeBalance()
        {
            bool isOk = false;
            try
            {

                decimal decProductId = 0;
                decimal decBatchId = 0;
                decimal decCalcQty = 0;
                StockPostingBll BllStockPosting = new StockPostingBll();
                SettingsBll BllSettings = new SettingsBll();
                string strStatus = BllSettings.SettingsStatusCheck("NegativeStockStatus");
                bool isNegativeLedger = false;
                int inRowCount = dgvSalesReturn.RowCount;
                if (inRowCount > 1)
                {
                    for (int i = 0; i < inRowCount - 1; i++)
                    {
                        if (dgvSalesReturn.Rows[i].Cells["productId"].Value != null && dgvSalesReturn.Rows[i].Cells["productId"].Value.ToString() != string.Empty)
                        {
                            decProductId = Convert.ToDecimal(dgvSalesReturn.Rows[i].Cells["productId"].Value.ToString());
                            if (dgvSalesReturn.Rows[i].Cells["dgvCmbBatch"].Value != null && dgvSalesReturn.Rows[i].Cells["dgvCmbBatch"].Value.ToString() != string.Empty)
                            {
                                decBatchId = Convert.ToDecimal(dgvSalesReturn.Rows[i].Cells["dgvCmbBatch"].Value.ToString());
                            }
                            decimal decCurrentStock = BllStockPosting.StockCheckForProductSale(decProductId, decBatchId);
                            if (dgvSalesReturn.Rows[i].Cells["dgvTextQty"].Value != null && dgvSalesReturn.Rows[i].Cells["dgvTextQty"].Value.ToString() != string.Empty)
                            {
                                decCalcQty = decCurrentStock - Convert.ToDecimal(dgvSalesReturn.Rows[i].Cells["dgvTextQty"].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("SR15:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return isOk;
        }