示例#1
0
 /// <summary>
 /// save function
 /// </summary>
 public void SaveFunction()
 {
     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 (bllTax.TaxCheckExistence(0, txtTaxName.Text.Trim()) == false)
         {
             decTaxId = bllTax.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;
                         bllTax.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);
     }
 }