/// <summary>
 /// Function to save
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         CounterInfo infoCounter = new CounterInfo();
         CounterBll  bllCounter  = new CounterBll();
         infoCounter.CounterName = txtCounterName.Text.Trim();
         infoCounter.Narration   = txtNarration.Text.Trim();
         infoCounter.Extra1      = string.Empty;
         infoCounter.Extra2      = string.Empty;
         if (bllCounter.CounterCheckIfExist(txtCounterName.Text.Trim(), 0) == false)
         {
             decLedgerId = bllCounter.CounterAddWithIdentity(infoCounter);
             Messages.SavedMessage();
             Clear();
             decIdForOtherForms = decLedgerId;
         }
         else
         {
             Messages.InformationMessage("Counter name already exist");
             txtCounterName.Focus();
         }
         if (frmPOSObj != null)
         {
             this.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("CT3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to edit
 /// </summary>
 public void EditFunction()
 {
     try
     {
         CounterInfo infoCounter = new CounterInfo();
         CounterBll  bllCounter  = new CounterBll();
         infoCounter.CounterName = txtCounterName.Text.Trim();
         infoCounter.Narration   = txtNarration.Text.Trim();
         infoCounter.Extra1      = string.Empty;
         infoCounter.Extra2      = string.Empty;
         infoCounter.CounterId   = Convert.ToDecimal(dgvCounter.CurrentRow.Cells["dgvtxtcounterId"].Value.ToString());
         if (txtCounterName.Text.ToString() != strCounterName)
         {
             if (bllCounter.CounterCheckIfExist(txtCounterName.Text.Trim(), decCounterId) == false)
             {
                 if (bllCounter.CounterEditParticularField(infoCounter))
                 {
                     Messages.UpdatedMessage();
                     Clear();
                 }
                 else if (infoCounter.CounterId == 1)
                 {
                     Messages.InformationMessage("Cannot update");
                     Clear();
                     txtCounterName.Focus();
                 }
             }
             else
             {
                 Messages.InformationMessage("Counter name already exist");
                 txtCounterName.Focus();
             }
         }
         else
         {
             bllCounter.CounterEditParticularField(infoCounter);
             Messages.UpdatedMessage();
             Clear();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("CT4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }