Ejemplo n.º 1
0
 /// <summary>
 /// delete function
 /// </summary>
 public void Delete()
 {
     try
     {
         if (PublicVariables.isMessageDelete)
         {
             if (Messages.DeleteMessage())
             {
                 TaxInfo infoTax = new TaxInfo();
                 TaxSP spTax = new TaxSP();
                 TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo();
                 TaxDetailsSP spTaxDetails = new TaxDetailsSP();
                 AccountLedgerSP spAccountLedger = new AccountLedgerSP();
                 bool isExist = spTax.TaxReferenceCheck(decTaxId);
                 if (!isExist)
                 {
                     if ((spTax.TaxReferenceDelete(decTaxId,decLedgerId)) == -1)
                     {
                         Messages.ReferenceExistsMessage();
                     }
                     else
                     {
                         spTaxDetails.TaxDetailsDeleteWithTaxId(decTaxId);
                         spAccountLedger.AccountLedgerDelete(decLedgerId);
                         Messages.DeletedMessage();
                         TaxSearchGridFill();
                         TaxSelectionGridFill();
                         Clear();
                         SearchClear();
                     }
                 }
                 else
                 {
                     Messages.ReferenceExistsMessage();
                 }
             }
         }
         else
         {
             TaxInfo infoTax = new TaxInfo();
             TaxSP spTax = new TaxSP();
             TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo();
             TaxDetailsSP spTaxDetails = new TaxDetailsSP();
             bool isExist = spTax.TaxReferenceCheck(decTaxId);
             if (!isExist)
             {
                 if ((spTax.TaxReferenceDelete(decTaxId,decLedgerId)) == -1)
                 {
                     Messages.ReferenceExistsMessage();
                 }
                 else
                 {
                     spTaxDetails.TaxDetailsDeleteWithTaxId(decTaxId);
                     Messages.DeletedMessage();
                     TaxSearchGridFill();
                     TaxSelectionGridFill();
                     Clear();
                     SearchClear();
                 }
             }
             else
             {
                 Messages.ReferenceExistsMessage();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("TC11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Ejemplo n.º 2
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();
                TaxSP spTax = new TaxSP();
                TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo();
                TaxDetailsSP spTaxDetails = new TaxDetailsSP();
                infoTax = spTax.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;
                DataTable dtbl = new DataTable();
                dtbl = spTax.TaxIdForTaxSelectionUpdate(decTaxId);
                foreach (DataRow dr in dtbl.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;
                        }
                    }
                }

                AccountLedgerSP spAccountLedger = new AccountLedgerSP();
                decLedgerId = spAccountLedger.AccountLedgerIdGetByName(txtTaxName.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("TC10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// update function
 /// </summary>
 public void EditFunction()
 {
     try
     {
         TaxInfo infoTax = new TaxInfo();
         TaxSP spTax = new TaxSP();
         TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo();
         TaxDetailsSP spTaxDetails = new TaxDetailsSP();
         infoTax.TaxName = txtTaxName.Text.Trim();
         infoTax.Rate = Convert.ToDecimal(txtRate.Text.ToString());
         infoTax.ApplicableOn = cmbApplicableFor.SelectedItem.ToString();
         if (cmbCalculationMode.Enabled != true)
         {
             infoTax.CalculatingMode = string.Empty;
         }
         else
         {
             infoTax.CalculatingMode = cmbCalculationMode.SelectedItem.ToString();
         }
         infoTax.Narration = txtNarration.Text.Trim();
         if (cbxActive.Checked)
         {
             infoTax.IsActive = true;
         }
         else
         {
             infoTax.IsActive = false;
         }
         infoTax.Extra1 = string.Empty;
         infoTax.Extra2 = string.Empty;
         if (txtTaxName.Text.ToString() != strTaxName)
         {
             if (spTax.TaxCheckExistence(decTaxIdForEdit, txtTaxName.Text.Trim()) == false)
             {
                 infoTax.TaxId = decTaxId;
                 spTax.TaxEdit(infoTax);
                 //-- Delete And Add Tax details --//
                 spTaxDetails.TaxDetailsDeleteWithTaxId(decTaxId);
                 if (dgvTaxSelection.RowCount > 0)
                 {
                     bool isOk = false;
                     foreach (DataGridViewRow dgvRow in dgvTaxSelection.Rows)
                     {
                         isOk = Convert.ToBoolean(dgvRow.Cells["dgvcbxSelect"].Value);
                         if (isOk)
                         {
                             infoTaxDetails.TaxId = decTaxId;
                             infoTaxDetails.SelectedtaxId = Convert.ToDecimal(dgvRow.Cells["dgvtxtTaxId"].Value.ToString());//dgvRow.Cells[0].Value.ToString();
                             infoTaxDetails.ExtraDate = DateTime.Now;
                             infoTaxDetails.Extra1 = string.Empty;
                             infoTaxDetails.Extra2 = string.Empty;
                             spTaxDetails.TaxDetailsAddWithoutId(infoTaxDetails);
                         }
                     }
                 }
                 LedgerEdit();
                 Messages.UpdatedMessage();
                 Clear();
             }
             else
             {
                 Messages.InformationMessage(" Tax or ledger already exist");
                 txtTaxName.Focus();
             }
         }
         else
         {
             infoTax.TaxId = decTaxId;
             spTax.TaxEdit(infoTax);
             spTaxDetails.TaxDetailsDeleteWithTaxId(decTaxId);
             if (dgvTaxSelection.RowCount > 0)
             {
                 bool isOk = false;
                 foreach (DataGridViewRow dgvRow in dgvTaxSelection.Rows)
                 {
                     isOk = Convert.ToBoolean(dgvRow.Cells["dgvcbxSelect"].Value);
                     if (isOk)
                     {
                         infoTaxDetails.TaxId = decTaxId;
                         infoTaxDetails.SelectedtaxId = Convert.ToDecimal(dgvRow.Cells["dgvtxtTaxId"].Value.ToString());//dgvRow.Cells[0].Value.ToString();
                         infoTaxDetails.ExtraDate = DateTime.Now;
                         infoTaxDetails.Extra1 = string.Empty;
                         infoTaxDetails.Extra2 = string.Empty;
                         spTaxDetails.TaxDetailsAddWithoutId(infoTaxDetails);
                     }
                 }
             }
             LedgerEdit();
             Messages.UpdatedMessage();
             Clear();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("TC5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// save function
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         TaxInfo infoTax = new TaxInfo();
         TaxSP spTax = new TaxSP();
         TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo();
         TaxDetailsSP spTaxDetails = new TaxDetailsSP();
         infoTax.TaxName = txtTaxName.Text.Trim();
         infoTax.Rate = Convert.ToDecimal(txtRate.Text.ToString());
         infoTax.ApplicableOn = cmbApplicableFor.SelectedItem.ToString();
         if (cmbCalculationMode.Enabled != true)
         {
             infoTax.CalculatingMode = string.Empty;
         }
         else
         {
             infoTax.CalculatingMode = cmbCalculationMode.SelectedItem.ToString();
         }
         infoTax.Narration = txtNarration.Text.Trim();
         if (cbxActive.Checked)
         {
             infoTax.IsActive = true;
         }
         else
         {
             infoTax.IsActive = false;
         }
         infoTax.Extra1 = string.Empty;
         infoTax.Extra2 = string.Empty;
         if (spTax.TaxCheckExistence(0, txtTaxName.Text.Trim()) == false)
         {
             decTaxId = spTax.TaxAddWithIdentity(infoTax);
             decIdForOtherForms = decTaxId;
             if (dgvTaxSelection.RowCount > 0)
             {
                 bool isOk = false;
                 foreach (DataGridViewRow dgvRow in dgvTaxSelection.Rows)
                 {
                     isOk = Convert.ToBoolean(dgvRow.Cells["dgvcbxSelect"].Value);
                     if (isOk)
                     {
                         infoTaxDetails.TaxId = decTaxId;
                         infoTaxDetails.SelectedtaxId = Convert.ToDecimal(dgvRow.Cells["dgvtxtTaxId"].Value.ToString());//dgvRow.Cells[0].Value.ToString();
                         infoTaxDetails.ExtraDate = DateTime.Now;
                         infoTaxDetails.Extra1 = string.Empty;
                         infoTaxDetails.Extra2 = string.Empty;
                         spTaxDetails.TaxDetailsAddWithoutId(infoTaxDetails);
                     }
                 }
             }
             CreateLedger();
             Messages.SavedMessage();
             Clear();
             SearchClear();
         }
         else
         {
             Messages.InformationMessage(" Tax or ledger already exist");
             txtTaxName.Focus();
         }
         if (frmProductCreationObj != null)
         {
             this.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("TC4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Ejemplo n.º 5
0
 /// <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;
     TaxDetailsSP spTaxDetails = new TaxDetailsSP();
     DataTable dtbl = new 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());
                         dtbl = spTaxDetails.TaxDetailsViewallByTaxId(decTaxId);
                         foreach (DataGridViewRow dgvRow2 in dgvSalesInvoiceTax.Rows)
                         {
                             foreach (DataRow drow in dtbl.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;
 }
Ejemplo n.º 6
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());
                         DataTable dtbl = new DataTable();
                         TaxDetailsSP spTaxDetails = new TaxDetailsSP();
                         dtbl = spTaxDetails.TaxDetailsViewallByTaxId(decTaxId);
                         foreach (DataGridViewRow dgvRow2 in dgvPOSTax.Rows)
                         {
                             foreach (DataRow drow in dtbl.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);
     }
 }