Пример #1
0
 /// <summary>
 /// Function to Tax Amount Calculation
 /// </summary>
 public void TaxAmountCalculation()
 {
     decimal dcVatAmount = 0;
     decimal dTaxAmt = 0;
     decimal dcTotal = 0;
     decimal dcNetAmount = 0;
     dcNetAmount = Convert.ToDecimal(txtNetAmount.Text.Trim());
     TaxBll bllTax = new TaxBll();
     try
     {
         if (dcNetAmount != 0 && cmbTax.Visible && cmbTax.SelectedValue != null)
         {
             TaxInfo InfoTaxMaster = bllTax.TaxView(Convert.ToDecimal(cmbTax.SelectedValue.ToString()));
             dcVatAmount = dTaxAmt = Math.Round(((dcNetAmount * InfoTaxMaster.Rate) / (100)), PublicVariables._inNoOfDecimalPlaces);
             txtTaxAmount.Text = dTaxAmt.ToString();
         }
         else
         {
             dTaxAmt = 0;
             txtTaxAmount.Text = "0";
         }
         dcTotal = dcNetAmount + dTaxAmt;
         txtAmount.Text = dcTotal.ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show("POS:29" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 ///  Grid row total amount calculation( Including Tax)
 /// </summary>
 /// <param name="inIndexOfRow"></param>
 public void taxAndGridTotalAmountCalculation(int inIndexOfRow)
 {
     TaxBll bllTax = new TaxBll();
     try
     {
         decimal dTaxAmt = 0;
         decimal dcTotal = 0;
         decimal dcNetValue = 0;
         if (dgvSalesInvoice.Rows[inIndexOfRow].Cells["dgvtxtSalesInvoiceQty"].Value != null && dgvSalesInvoice.Rows[inIndexOfRow].Cells["dgvtxtSalesInvoiceQty"].Value.ToString() != string.Empty)
         {
             dcNetValue = Convert.ToDecimal(dgvSalesInvoice.Rows[inIndexOfRow].Cells["dgvtxtSalesInvoiceNetAmount"].Value.ToString());
             if (dcNetValue != 0 && dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible && (dgvSalesInvoice.Rows[inIndexOfRow].Cells["dgvcmbSalesInvoiceTaxName"].Value == null ? "" : dgvSalesInvoice.Rows[inIndexOfRow].Cells["dgvcmbSalesInvoiceTaxName"].Value.ToString()) != "")
             {
                 TaxInfo InfoTaxMaster = bllTax.TaxView(Convert.ToDecimal(dgvSalesInvoice.Rows[inIndexOfRow].Cells["dgvcmbSalesInvoiceTaxName"].Value.ToString()));
                 dTaxAmt = Math.Round(((dcNetValue * InfoTaxMaster.Rate) / (100)), PublicVariables._inNoOfDecimalPlaces);
                 dgvSalesInvoice.Rows[inIndexOfRow].Cells["dgvtxtSalesInvoiceTaxAmount"].Value = dTaxAmt.ToString();
             }
             else
             {
                 dTaxAmt = 0;
                 dgvSalesInvoice.Rows[inIndexOfRow].Cells["dgvtxtSalesInvoiceTaxAmount"].Value = "0.00";
             }
         }
         else
         {
             dTaxAmt = 0;
             dgvSalesInvoice.Rows[inIndexOfRow].Cells["dgvtxtSalesInvoiceTaxAmount"].Value = "0.00";
         }
         dcTotal = dcNetValue + dTaxAmt;
         dgvSalesInvoice.Rows[inIndexOfRow].Cells["dgvtxtSalesInvoiceAmount"].Value = dcTotal.ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show("SI: 44 " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #3
0
        /// <summary>
        /// fill the curresponding details for update
        /// </summary>
        public void TaxSelectionFillForUpdate()
        {
            try
            {
                int inRowCount = dgvTaxSelection.RowCount;
                for (int i = 0; i < inRowCount; i++)
                {
                    dgvTaxSelection.Rows[i].Cells["dgvcbxSelect"].Value = false;
                }
                decTaxId = Convert.ToDecimal(dgvTaxSearch.CurrentRow.Cells["dgvtxtTaxIdSearch"].Value.ToString());
                TaxInfo infoTax = new TaxInfo();
                TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo();
                TaxBll bllTax = new TaxBll();
                infoTax = bllTax.TaxView(decTaxId);
                txtTaxName.Text = infoTax.TaxName;
                txtRate.Text = infoTax.Rate.ToString();
                cmbApplicableFor.Text = infoTax.ApplicableOn;
                cmbCalculationMode.Text = infoTax.CalculatingMode;
                txtNarration.Text = infoTax.Narration;
                if (infoTax.IsActive.ToString() == "True")
                {
                    cbxActive.Checked = true;
                }
                else
                {
                    cbxActive.Checked = false;
                }
                strTaxName = infoTax.TaxName;
                decTaxIdForEdit = infoTax.TaxId;
                btnSave.Text = "Update";
                btnDelete.Enabled = true;
                List<DataTable> ListObj = new List<DataTable>();
                ListObj = bllTax.TaxIdForTaxSelectionUpdate(decTaxId);
                foreach (DataRow dr in ListObj[0].Rows)
                {
                    string strTaxId = dr["selectedtaxId"].ToString();
                    for (int i = 0; i < inRowCount; i++)
                    {
                        if (dgvTaxSelection.Rows[i].Cells["dgvtxtTaxId"].Value.ToString() == strTaxId)
                        {
                            dgvTaxSelection.Rows[i].Cells["dgvcbxSelect"].Value = true;
                        }
                    }
                }

                AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
                decLedgerId = bllAccountLedger.AccountLedgerIdGetByName(txtTaxName.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("TC10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function for Amount Calculations for Gross value, Net amount, Tax amount and Total amount
        /// </summary>
        /// <param name="columnName"></param>
        /// <param name="inIndexOfRow"></param>
        public void AmountCalculation(string columnName, int inIndexOfRow)
        {
            try
            {
                string strTaxRate = string.Empty;
                decimal decTaxAmt = 0;
                decimal decTotalAmnt = 0;
                decimal decdgvtxtgrossValue = 0, decDiscountCalc = 0, decNetAmount = 0;
                decimal decTaxPercent = 0;
                decimal decTaxId = 0;
                DataGridViewRow dgrow = dgvPurchaseReturn.Rows[inIndexOfRow];
                ProductInfo infoProduct = new ProductInfo();
                RackBll BllRack = new RackBll();
                TaxInfo infotax = new TaxInfo();
                TaxBll bllTax = new TaxBll();
                if (dgrow.Cells["dgvtxtqty"].Value != null && dgrow.Cells["dgvtxtqty"].Value.ToString() != string.Empty)
                {
                    decQty = Convert.ToDecimal(dgrow.Cells["dgvtxtqty"].Value.ToString());
                }

                if (dgrow.Cells["dgvtxtrate"].Value != null && dgrow.Cells["dgvtxtrate"].Value.ToString() != string.Empty)
                {
                    decRate = Convert.ToDecimal(dgrow.Cells["dgvtxtrate"].Value.ToString());
                    decdgvtxtgrossValue = decQty * decRate;
                    dgrow.Cells["dgvtxtgrossValue"].Value = Math.Round(decdgvtxtgrossValue, PublicVariables._inNoOfDecimalPlaces);
                }
                if (dgrow.Cells["dgvtxtgrossValue"].Value != null && dgrow.Cells["dgvtxtgrossValue"].Value.ToString() != string.Empty)
                {
                    dgrow.Cells["dgvtxtgrossValue"].Value = Math.Round(decdgvtxtgrossValue, PublicVariables._inNoOfDecimalPlaces);
                    if (dgrow.Cells["dgvtxtdiscount"].Value != null && dgrow.Cells["dgvtxtdiscount"].Value.ToString() != string.Empty)
                    {
                        decDiscountCalc = Convert.ToDecimal(dgrow.Cells["dgvtxtdiscount"].Value.ToString());
                        if (decdgvtxtgrossValue >= decDiscountCalc)
                        {
                            decNetAmount = Math.Round((decdgvtxtgrossValue - decDiscountCalc), PublicVariables._inNoOfDecimalPlaces);
                            dgrow.Cells["dgvtxtNetAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces);
                        }
                        else
                        {
                            dgrow.Cells["dgvtxtdiscount"].Value = 0;
                        }
                    }
                    else
                    {
                        dgrow.Cells["dgvtxtdiscount"].Value = 0;
                        dgrow.Cells["dgvtxtNetAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces);
                    }
                }
                if (dgrow.Cells["dgvtxtNetAmount"].Value != null && dgrow.Cells["dgvtxtNetAmount"].Value.ToString() != string.Empty)
                {
                    decNetAmount = Math.Round(decdgvtxtgrossValue - decDiscountCalc, PublicVariables._inNoOfDecimalPlaces);
                    decNetAmount = Convert.ToDecimal(dgrow.Cells["dgvtxtNetAmount"].Value.ToString());
                    dgrow.Cells["dgvtxtNetAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces);
                }
                if (dgvcmbTax.Visible)
                {
                    if (dgrow.Cells["dgvtxtproductId"].Value != null && dgrow.Cells["dgvtxtproductId"].Value.ToString() != string.Empty)
                    {
                        if (dgrow.Cells["dgvcmbTax"].Value != null && dgrow.Cells["dgvcmbTax"].Value.ToString() != string.Empty && dgrow.Cells["dgvcmbTax"].Value.ToString() != "NA")
                        {
                            decTaxId = Convert.ToDecimal(dgrow.Cells["dgvcmbTax"].Value.ToString());
                            infotax = bllTax.TaxView(decTaxId);
                            decTaxPercent = infotax.Rate;
                            if (decTaxPercent != 0)
                            {
                                if (strTaxComboFill != string.Empty)
                                {
                                    decTaxAmt = ((decNetAmount * decTaxPercent) / 100);
                                }
                                else
                                {
                                    dgrow.Cells["dgvtxttaxAmount"].Value = "0";
                                }
                                decTotalAmnt = Math.Round((decNetAmount + decTaxAmt), PublicVariables._inNoOfDecimalPlaces);
                                dgrow.Cells["dgvtxttaxAmount"].Value = Math.Round(decTaxAmt, PublicVariables._inNoOfDecimalPlaces);
                                decTaxAmt = Convert.ToDecimal(dgrow.Cells["dgvtxttaxAmount"].Value.ToString());
                                dgrow.Cells["dgvtxtAmount"].Value = Math.Round(decTotalAmnt, PublicVariables._inNoOfDecimalPlaces);
                            }
                            else
                            {
                                dgrow.Cells["dgvtxttaxAmount"].Value = "0";
                                dgrow.Cells["dgvtxtAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces);
                            }
                        }
                        else
                        {
                            decTaxPercent = 0;
                            dgrow.Cells["dgvtxttaxAmount"].Value = "0";
                            dgrow.Cells["dgvtxtAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces);
                        }
                    }
                    Calculate();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PR:34 " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// TaxAmountCalculation
 /// </summary>
 /// <param name="inRowIndex"></param>
 public void TaxAmountCalculation(int inRowIndex)
 {
     decimal dcTotal = 0;
     decimal dcVatAmount = 0;
     decimal dcNetAmount = 0;
     dcNetAmount = Convert.ToDecimal(dgvSalesReturn.Rows[inRowIndex].Cells["dgvTextNetValue"].Value.ToString());
     TaxBll bllTax = new TaxBll();
     try
     {
         if (dcNetAmount != 0 && dgvCmbTax.Visible && dgvSalesReturn.Rows[inRowIndex].Cells["dgvCmbTax"].Value != null)
         {
             TaxInfo InfoTaxMaster = bllTax.TaxView(Convert.ToDecimal(dgvSalesReturn.Rows[inRowIndex].Cells["dgvCmbTax"].Value.ToString()));
             dcVatAmount = Math.Round(((dcNetAmount * InfoTaxMaster.Rate) / (100)), PublicVariables._inNoOfDecimalPlaces);
             dgvSalesReturn.Rows[inRowIndex].Cells["dgvTextTaxAmount"].Value = dcVatAmount;
         }
         else
         {
             dgvSalesReturn.Rows[inRowIndex].Cells["dgvTextTaxAmount"].Value = "0";
         }
         dcTotal = dcVatAmount + dcNetAmount;
         dgvSalesReturn.Rows[inRowIndex].Cells["dgvTextAmount1"].Value = dcTotal;
     }
     catch (Exception ex)
     {
         MessageBox.Show("SR49:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to calculate total amount
 /// </summary>
 /// <param name="inRowIndex"></param>
 public void Calculate(int inRowIndex)
 {
     decimal decDiscount = 0;
     decimal decDiscountPercent = 0;
     decimal decGrossValue = 0;
     decimal decNetValue = 0;
     decimal decTaxAmount = 0;
     decimal decTaxPercent = 0;
     decimal decTaxId = 0;
     decimal decAmount = 0;
     decimal decTotalAmount = 0;
     decimal decProductId = 0;
     decimal decDefaultTotalAmount = 0;
     decimal decProductRate = 0;
     decimal decQuantity = 0;
     ProductInfo infoProduct = new ProductInfo();
     ProductCreationBll BllProductCreation = new ProductCreationBll();
     TaxInfo infotax = new TaxInfo();
     TaxBll bllTax = new TaxBll();
     ExchangeRateBll BllExchangeRate = new ExchangeRateBll();
     try
     {
         if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtProductId"].Value != null)
         {
             if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtProductId"].Value.ToString() != string.Empty)
             {
                 if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtRate"].Value != null)
                 {
                     if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtRate"].Value.ToString() != string.Empty && dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtRate"].Value.ToString() != ".")
                     {
                         decProductRate = Convert.ToDecimal(dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtRate"].Value.ToString());
                     }
                 }
                 if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtQuantity"].Value != null)
                 {
                     if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtQuantity"].Value.ToString() != string.Empty && dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtQuantity"].Value.ToString() != ".")
                     {
                         decQuantity = Convert.ToDecimal(dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtQuantity"].Value.ToString());
                     }
                 }
                 decGrossValue = decProductRate * decQuantity;
                 dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtGrossValue"].Value = Math.Round(decGrossValue, PublicVariables._inNoOfDecimalPlaces);
                 if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscountPercent"].Value != null)
                 {
                     if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscountPercent"].Value.ToString() != string.Empty)
                     {
                         decDiscountPercent = Convert.ToDecimal(dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscountPercent"].Value.ToString());
                     }
                     else
                     {
                         dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscountPercent"].Value = 0;
                     }
                 }
                 else
                 {
                     dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscountPercent"].Value = 0;
                 }
                 if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value != null)
                 {
                     if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value.ToString() != string.Empty)
                     {
                         decDiscount = Convert.ToDecimal(dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value.ToString());
                     }
                     else
                     {
                         dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value = 0;
                     }
                 }
                 else
                 {
                     dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value = 0;
                 }
                 /*------------------------------Calculate-----------------------------------*/
                 /*------------------------------Discount Calculation-----------------------------------*/
                 if (decGrossValue >= decDiscount)
                 {
                     dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value = Math.Round(decDiscount, PublicVariables._inNoOfDecimalPlaces);
                 }
                 else
                 {
                     dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscountPercent"].Value = 0;
                     dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value = 0;
                     decDiscount = 0;
                 }
                 decNetValue = decGrossValue - decDiscount;
                 dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtNetValue"].Value = Math.Round(decNetValue, PublicVariables._inNoOfDecimalPlaces);
                 /*------------------------------Tax Calculation-----------------------------------*/
                 if (dgvcmbTax.Visible)
                 {
                     if (dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbTax"].Value != null)
                     {
                         if (dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbTax"].Value.ToString() != string.Empty &&
                             dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbTax"].Value.ToString() != "0")
                         {
                             decTaxId = Convert.ToDecimal(dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbTax"].Value.ToString());
                             infotax = bllTax.TaxView(decTaxId);
                             decTaxPercent = infotax.Rate;
                         }
                         else
                         {
                             decTaxPercent = 0;
                         }
                     }
                     else
                     {
                         decTaxPercent = 0;
                     }
                     decProductId = Convert.ToDecimal(dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtProductId"].Value.ToString());
                     infoProduct = BllProductCreation.ProductView(decProductId);
                     if (infoProduct.TaxapplicableOn == "MRP")
                     {
                         decTaxAmount = infoProduct.Mrp * decTaxPercent / 100;
                     }
                     else
                     {
                         decTaxAmount = decNetValue * decTaxPercent / 100;
                     }
                     dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtTaxAmount"].Value = Math.Round(decTaxAmount, PublicVariables._inNoOfDecimalPlaces);
                 }
                 decAmount = decNetValue + decTaxAmount;
                 dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtAmount"].Value = Math.Round(decAmount, PublicVariables._inNoOfDecimalPlaces);
                 decTotalAmount = decTotalAmount + decAmount;
                 decDefaultTotalAmount = decTotalAmount * 1;
                 //CalculateTotalAmount();
                 //if (dgvTax.Visible)
                 //{
                 //    TotalTaxAmount();
                 //}
                 //CalculateGrandTotal();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PI84:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }