/// <summary>
 /// Edit function
 /// </summary>
 public void EditFunction()
 {
     try
     {
         SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
         SuffixPrefixInfo        infoSuffixPrefix        = new SuffixPrefixInfo();
         infoSuffixPrefix.FromDate = Convert.ToDateTime(txtFromDate.Text.ToString());
         infoSuffixPrefix.ToDate   = Convert.ToDateTime(txtToDate.Text.ToString());
         String strvouchertype = (cmbVoucherType.SelectedValue.ToString());
         infoSuffixPrefix.VoucherTypeId = Convert.ToDecimal(strvouchertype.ToString());
         infoSuffixPrefix.Prefix        = txtPrefix.Text.Trim();
         infoSuffixPrefix.Suffix        = txtSufix.Text.Trim();
         infoSuffixPrefix.StartIndex    = Convert.ToDecimal(txtStartIndex.Text.ToString());
         if (cbxPrefillWithZero.Checked)
         {
             infoSuffixPrefix.PrefillWithZero      = true;
             infoSuffixPrefix.WidthOfNumericalPart = Convert.ToInt32(txtWidthofNumericalPart.Text.ToString());
         }
         else
         {
             infoSuffixPrefix.PrefillWithZero      = false;
             infoSuffixPrefix.WidthOfNumericalPart = 0;
         }
         infoSuffixPrefix.Narration      = txtNarration.Text.Trim();
         infoSuffixPrefix.Extra1         = string.Empty;
         infoSuffixPrefix.Extra2         = string.Empty;
         infoSuffixPrefix.SuffixprefixId = decSuffixPrefixId;
         if (BllSuffixPrefixSettings.SuffixPrefixCheckExistenceForAdd(txtFromDate.Text.ToString(), txtToDate.Text.ToString(), Convert.ToDecimal(cmbVoucherType.SelectedValue.ToString()), decSuffixPrefixId) == false)
         {
             if (BllSuffixPrefixSettings.SuffixPrefixSettingsEdit(infoSuffixPrefix))
             {
                 Messages.UpdatedMessage();
                 Clear();
             }
             else
             {
                 Messages.ReferenceExistsMessageForUpdate();
                 cmbVoucherType.Focus();
             }
         }
         else
         {
             Messages.InformationMessage("Voucher type already exist for  dates");
             cmbVoucherType.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SPS5" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// grid double click fill the items in controll for edit
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvSuffixPrefixSettings_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex != -1)
                {
                    SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();

                    SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                    infoSuffixPrefix             = BllSuffixPrefixSettings.SuffixPrefixView(Convert.ToDecimal(dgvSuffixPrefixSettings.Rows[e.RowIndex].Cells["dgvtxtSuffixPrefixId"].Value.ToString()));
                    decSuffixPrefixId            = Convert.ToDecimal(dgvSuffixPrefixSettings.Rows[e.RowIndex].Cells["dgvtxtSuffixPrefixId"].Value.ToString());
                    txtFromDate.Text             = infoSuffixPrefix.FromDate.ToString("dd-MMM-yyyy");
                    txtToDate.Text               = infoSuffixPrefix.ToDate.ToString("dd-MMM-yyyy");
                    cmbVoucherType.SelectedValue = infoSuffixPrefix.VoucherTypeId.ToString();
                    txtStartIndex.Text           = infoSuffixPrefix.StartIndex.ToString();
                    txtStartIndex.Enabled        = false;
                    txtSufix.Text  = infoSuffixPrefix.Suffix;
                    txtPrefix.Text = infoSuffixPrefix.Prefix;
                    if (infoSuffixPrefix.PrefillWithZero == true)
                    {
                        cbxPrefillWithZero.Checked   = true;
                        txtWidthofNumericalPart.Text = infoSuffixPrefix.WidthOfNumericalPart.ToString();
                    }
                    else
                    {
                        cbxPrefillWithZero.Checked   = false;
                        txtWidthofNumericalPart.Text = infoSuffixPrefix.WidthOfNumericalPart.ToString();
                    }
                    txtNarration.Text = infoSuffixPrefix.Narration;
                    btnSave.Text      = "Update";
                    btnDelete.Enabled = true;
                    txtFromDate.Focus();
                    txtWidthofNumericalPart.Enabled = true;
                    if (cbxPrefillWithZero.Checked == true)
                    {
                        txtWidthofNumericalPart.Enabled = true;
                    }
                    else
                    {
                        txtWidthofNumericalPart.Enabled = false;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("SPS20" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// vouchertype conbofill function
 /// </summary>
 public void VoucherTypeComboFill()
 {
     try
     {
         SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
         List <DataTable>        list = new List <DataTable>();
         list = BllSuffixPrefixSettings.VoucherTypeViewAllInSuffixPrefix();
         cmbVoucherType.DataSource    = list[0];
         cmbVoucherType.ValueMember   = "voucherTypeId";
         cmbVoucherType.DisplayMember = "voucherTypeName";
         cmbVoucherType.SelectedIndex = -1;
     }
     catch (Exception ex)
     {
         MessageBox.Show("SPS1" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// delete function
 /// </summary>
 public void DeleteFunction()
 {
     try
     {
         SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
         if (BllSuffixPrefixSettings.SuffixPrefixSettingsDeleting(decSuffixPrefixId) == -1)
         {
             Messages.ReferenceExistsMessage();
         }
         else
         {
             Messages.DeletedMessage();
             Clear();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SPS7" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }