Ejemplo n.º 1
0
 /// <summary>
 /// Function to get tax grid total amount calculation
 /// </summary>
 public void TaxGridAmountCalculation()
 {
     decimal dTotal = 0;
     decimal decTaxId = 0;
     decimal decTaxRate = 0;
     decimal dcTCessTotal = 0;
     decimal decTaxTotal;
     try
     {
         TaxAmountForTaxType();
         foreach (DataGridViewRow dgvrow in dgvPointOfSales.Rows)
         {
             if (dgvrow.Cells["dgvtxtTotalAmount"].Value != null && dgvrow.Cells["dgvtxtTotalAmount"].Value.ToString() != string.Empty)
             {
                 dTotal = dTotal + Convert.ToDecimal(dgvrow.Cells["dgvtxtTotalAmount"].Value.ToString());
             }
         }
         foreach (DataGridViewRow dgvrowTax in dgvPOSTax.Rows)
         {
             if (dgvrowTax.Cells["dgvtxttax"].Value != null)
             {
                 if (dgvrowTax.Cells["dgvtxtTaxApplicableOn"].Value != null && dgvrowTax.Cells["dgvtxttaxCalculateMode"].Value != null)
                 {
                     if (dgvrowTax.Cells["dgvtxtTaxApplicableOn"].Value.ToString() == "Bill" && dgvrowTax.Cells["dgvtxttaxCalculateMode"].Value.ToString() == "Bill Amount")
                     {
                         decTaxRate = Convert.ToDecimal(dgvrowTax.Cells["dgvtxttaxrate"].Value.ToString());
                         decTaxTotal = (dTotal * decTaxRate / 100);
                         dgvrowTax.Cells["dgvtxtTaxAmt"].Value = Math.Round(decTaxTotal, PublicVariables._inNoOfDecimalPlaces);
                     }
                 }
             }
         }
         foreach (DataGridViewRow dgvRow1 in dgvPOSTax.Rows)
         {
             if (dgvRow1.Cells["dgvtxttax"].Value != null)
             {
                 if (dgvRow1.Cells["dgvtxtTaxApplicableOn"].Value != null && dgvRow1.Cells["dgvtxttaxCalculateMode"].Value != null)
                 {
                     if (dgvRow1.Cells["dgvtxtTaxApplicableOn"].Value.ToString() == "Bill" && dgvRow1.Cells["dgvtxttaxCalculateMode"].Value.ToString() == "Tax Amount")
                     {
                         decTaxId = Convert.ToDecimal(dgvRow1.Cells["dgvtxttax"].Value.ToString());
                         List<DataTable> ListObj = new List<DataTable>();
                         TaxBll bllTax = new TaxBll();
                         ListObj = bllTax.TaxDetailsViewallByTaxId(decTaxId);
                         foreach (DataGridViewRow dgvRow2 in dgvPOSTax.Rows)
                         {
                             foreach (DataRow drow in ListObj[0].Rows)
                             {
                                 if (dgvRow2.Cells["dgvtxtTaxAmt"].Value != null)
                                 {
                                     decimal deca = 0;
                                     deca = Convert.ToDecimal(dgvRow2.Cells["dgvtxtTaxAmt"].Value.ToString());
                                     if (dgvRow2.Cells["dgvtxttax"].Value != null && deca != 0)
                                     {
                                         if (dgvRow2.Cells["dgvtxttax"].Value.ToString() == drow.ItemArray[0].ToString())
                                         {
                                             decTaxRate = Convert.ToDecimal(dgvRow1.Cells["dgvtxttaxrate"].Value.ToString());
                                             dTotal = Convert.ToDecimal(dgvRow2.Cells["dgvtxtTaxAmt"].Value.ToString());
                                             dcTCessTotal = (dTotal * decTaxRate / 100);
                                             dgvRow1.Cells["temp"].Value = Math.Round(dcTCessTotal, PublicVariables._inNoOfDecimalPlaces);
                                             if (dgvRow1.Cells["dgvtxttax"].Value.ToString() == decTaxId.ToString())
                                             {
                                                 dgvRow1.Cells["dgvtxtTaxAmt"].Value = dgvRow1.Cells["temp"].Value;
                                             }
                                         }
                                     }
                                 }
                                 else
                                 {
                                     dgvRow1.Cells["dgvtxtTaxAmt"].Value = 0;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("POS:38" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Get the total tax amount applicable on bill calculation( to get Final total amount)
 /// </summary>
 /// <returns></returns>
 public decimal TaxAmountApplicableOnBill()
 {
     decimal decTaxId = 0;
     decimal decTaxRate = 0;
     decimal decTaxOnBill = 0;
     decimal decTotalTaxOnBill = 0;
     decimal decTaxOnTax = 0;
     decimal decTotalTaxOnTax = 0;
     decimal decTotalAmount = 0;
     decimal decTotalTax = 0;
     TaxBll bllTax = new TaxBll();
     List<DataTable> ListObj = new List<DataTable>();
     try
     {
         TaxAmountForTaxType();
         if (txtTotalAmount.Text != string.Empty)
         {
             decTotalAmount = Convert.ToDecimal(txtTotalAmount.Text);
         }
         foreach (DataGridViewRow dgvRow in dgvSalesInvoiceTax.Rows)
         {
             if (dgvRow.Cells["dgvtxtTtaxId"].Value != null)
             {
                 if (dgvRow.Cells["dgvtxtTApplicableOn"].Value != null && dgvRow.Cells["dgvtxtTCalculatingMode"].Value != null)
                 {
                     if (dgvRow.Cells["dgvtxtTApplicableOn"].Value.ToString() == "Bill" && dgvRow.Cells["dgvtxtTCalculatingMode"].Value.ToString() == "Bill Amount")
                     {
                         decTaxRate = Convert.ToDecimal(dgvRow.Cells["dgvtxtTTaxRate"].Value.ToString());
                         decTaxOnBill = (decTotalAmount * decTaxRate / 100);
                         dgvRow.Cells["dgvtxtTtaxAmount"].Value = Math.Round(decTaxOnBill, PublicVariables._inNoOfDecimalPlaces);
                         decTotalTaxOnBill = decTotalTaxOnBill + decTaxOnBill;
                     }
                 }
             }
         }
         foreach (DataGridViewRow dgvRow1 in dgvSalesInvoiceTax.Rows)
         {
             if (dgvRow1.Cells["dgvtxtTtaxId"].Value != null)
             {
                 if (dgvRow1.Cells["dgvtxtTApplicableOn"].Value != null && dgvRow1.Cells["dgvtxtTCalculatingMode"].Value != null)
                 {
                     if (dgvRow1.Cells["dgvtxtTApplicableOn"].Value.ToString() == "Bill" && dgvRow1.Cells["dgvtxtTCalculatingMode"].Value.ToString() == "Tax Amount")
                     {
                         decTaxId = Convert.ToDecimal(dgvRow1.Cells["dgvtxtTtaxId"].Value.ToString());
                         ListObj = bllTax.TaxDetailsViewallByTaxId(decTaxId);
                         foreach (DataGridViewRow dgvRow2 in dgvSalesInvoiceTax.Rows)
                         {
                             foreach (DataRow drow in ListObj[0].Rows)
                             {
                                 if (dgvRow2.Cells["dgvtxtTtaxId"].Value != null)
                                 {
                                     if (dgvRow2.Cells["dgvtxtTtaxId"].Value.ToString() == drow.ItemArray[0].ToString())
                                     {
                                         decTaxRate = Convert.ToDecimal(dgvRow1.Cells["dgvtxtTTaxRate"].Value.ToString());
                                         decTotalAmount = Convert.ToDecimal(dgvRow2.Cells["dgvtxtTtaxAmount"].Value.ToString());
                                         decTaxOnTax = (decTotalAmount * decTaxRate / 100);
                                         dgvRow1.Cells["dgvtxtTtaxAmount"].Value = Math.Round(decTaxOnTax, PublicVariables._inNoOfDecimalPlaces);
                                         decTotalTaxOnTax = decTotalTaxOnTax + decTaxOnTax;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SI: 45" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     decTotalTax = decTotalTaxOnBill + decTotalTaxOnTax;
     return decTotalTax;
 }