示例#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);
     }
 }