/// <summary>
 /// Function to check quantity with reference
 /// </summary>
 /// <returns></returns>
 public int QuantityCheckWithReference()
 {
     decimal decQtySalesInvoice = 0;
     decimal decQtySalesReturn = 0;
     int inRef = 0;
     int inF1 = 1;
     decimal decSalesDetailsId = 0;
     SalesInvoiceBll BllSalesInvoice = new SalesInvoiceBll();
     try
     {
         foreach (DataGridViewRow dgvrow in dgvSalesInvoice.Rows)
         {
             if (dgvrow.Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value != null)
             {
                 if (dgvrow.Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value.ToString() != "0" || dgvrow.Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value.ToString() != string.Empty)
                 {
                     decSalesDetailsId = Convert.ToDecimal(dgvrow.Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value.ToString());
                     inRef = BllSalesInvoice.SalseMasterReferenceCheck(decSalesInvoiceIdToEdit, decSalesDetailsId);
                     if (inRef == 1)
                     {
                         if (inF1 == 1)
                         {
                             if (dgvrow.Cells["dgvtxtSalesInvoiceQty"].Value != null)
                             {
                                 if (dgvrow.Cells["dgvtxtSalesInvoiceQty"].Value.ToString() != "0" && dgvrow.Cells["dgvtxtSalesInvoiceQty"].Value.ToString() != string.Empty)
                                 {
                                     decQtySalesInvoice = Convert.ToDecimal(dgvrow.Cells["dgvtxtSalesInvoiceQty"].Value.ToString());
                                     decQtySalesReturn = Math.Round(BllSalesInvoice.SalesReturnDetailsQtyViewBySalesDetailsId(decSalesDetailsId), PublicVariables._inNoOfDecimalPlaces);
                                     if (decQtySalesInvoice >= decQtySalesReturn)
                                     {
                                         inF1 = 1;
                                     }
                                     else
                                     {
                                         inF1 = 0;
                                         Messages.InformationMessage("Quantity in row " + (dgvrow.Index + 1) + " should be greater than " + decQtySalesReturn);
                                     }
                                 }
                                 else
                                 {
                                     inF1 = 0;
                                     Messages.InformationMessage("Quantity in row " + (dgvrow.Index + 1) + " should be greater than " + decQtySalesReturn);
                                 }
                             }
                             else
                             {
                                 inF1 = 0;
                                 Messages.InformationMessage("Quantity in row " + (dgvrow.Index + 1) + " should be greater than " + decQtySalesReturn);
                             }
                         }
                     }
                     else
                     {
                         inF1 = 1;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SI35:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     return inF1;
 }