Esempio n. 1
0
 /// <summary>
 /// update function
 /// </summary>
 public void EditFunction()
 {
     try
     {
         TaxInfo infoTax = new TaxInfo();
         TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo();
         TaxBll bllTax = new TaxBll();
         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 (bllTax.TaxCheckExistence(decTaxIdForEdit, txtTaxName.Text.Trim()) == false)
             {
                 infoTax.TaxId = decTaxId;
                 bllTax.TaxEdit(infoTax);
                 //-- Delete And Add Tax details --//
                 bllTax.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;
                             bllTax.TaxDetailsAddWithoutId(infoTaxDetails);
                         }
                     }
                 }
                 LedgerEdit();
                 Messages.UpdatedMessage();
                 Clear();
             }
             else
             {
                 Messages.InformationMessage(" Tax or ledger already exist");
                 txtTaxName.Focus();
             }
         }
         else
         {
             infoTax.TaxId = decTaxId;
             bllTax.TaxEdit(infoTax);
             bllTax.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;
                         bllTax.TaxDetailsAddWithoutId(infoTaxDetails);
                     }
                 }
             }
             LedgerEdit();
             Messages.UpdatedMessage();
             Clear();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("TC5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// delete function
 /// </summary>
 public void Delete()
 {
     try
     {
         if (PublicVariables.isMessageDelete)
         {
             if (Messages.DeleteMessage())
             {
                 TaxInfo infoTax = new TaxInfo();
                 TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo();
                 TaxBll bllTax = new TaxBll();
                 AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
                 bool isExist = bllTax.TaxReferenceCheck(decTaxId);
                 if (!isExist)
                 {
                     if ((bllTax.TaxReferenceDelete(decTaxId,decLedgerId)) == -1)
                     {
                         Messages.ReferenceExistsMessage();
                     }
                     else
                     {
                         bllTax.TaxDetailsDeleteWithTaxId(decTaxId);
                         bllAccountLedger.AccountLedgerDelete(decLedgerId);
                         Messages.DeletedMessage();
                         TaxSearchGridFill();
                         TaxSelectionGridFill();
                         Clear();
                         SearchClear();
                     }
                 }
                 else
                 {
                     Messages.ReferenceExistsMessage();
                 }
             }
         }
         else
         {
             TaxInfo infoTax = new TaxInfo();
             TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo();
             TaxBll bllTax = new TaxBll();
             bool isExist = bllTax.TaxReferenceCheck(decTaxId);
             if (!isExist)
             {
                 if ((bllTax.TaxReferenceDelete(decTaxId,decLedgerId)) == -1)
                 {
                     Messages.ReferenceExistsMessage();
                 }
                 else
                 {
                     bllTax.TaxDetailsDeleteWithTaxId(decTaxId);
                     Messages.DeletedMessage();
                     TaxSearchGridFill();
                     TaxSelectionGridFill();
                     Clear();
                     SearchClear();
                 }
             }
             else
             {
                 Messages.ReferenceExistsMessage();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("TC11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }