public static bool UpdateVoucherTemplate(VoucherTemplateDto voucherTemplate)
        {
            try
            {
                var entity = new tVoucherTemplate
                {
                    CompanyId = voucherTemplate.CompanyId,
                    CreditAccount = voucherTemplate.CreditAccountCode,
                    DebitAccount = voucherTemplate.DebitAccountCode,
                    Narration = voucherTemplate.Narration,
                    ShortCode = voucherTemplate.ShortCode,
                };

                var result = AccountingDataProvider.UpdateVoucherTemplate(entity);

                if (result == 1)
                {
                    return true;
                }
                return false;
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
        }
        public static IEnumerable<VoucherTemplateDto> GetAllVoucherTemplates()
        {
            try
            {
                var vouchers = (List<tVoucherTemplate>)AccountingDataProvider.GetAllVoucherTemplates();
                var voucherViewModel = new List<VoucherTemplateDto>();
                VoucherTemplateDto model;

                if (vouchers != null)
                {
                    vouchers.ForEach(delegate(tVoucherTemplate voucherTemplate)
                                         {
                                             model = new VoucherTemplateDto
                                                         {
                                                             CompanyId = voucherTemplate.CompanyId,
                                                             CompanyName = "",
                                                             CreditAccountCode = voucherTemplate.CreditAccount,
                                                             CreditAccountName = AccountingDataProvider.GetAccountByCode(voucherTemplate.CompanyId, voucherTemplate.CreditAccount).AccountName,
                                                             DebitAccountCode = voucherTemplate.DebitAccount,
                                                             DebitAccountName = AccountingDataProvider.GetAccountByCode(voucherTemplate.CompanyId, voucherTemplate.DebitAccount).AccountName,
                                                             Narration = voucherTemplate.Narration,
                                                             ShortCode = voucherTemplate.ShortCode,

                                                         };
                                             voucherViewModel.Add(model);
                                         }
                        );

                    return voucherViewModel;
                }
            }

            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }

            return null;
        }
        public static VoucherTemplateDto GetlVoucherTemplateByCode(string shortCode, int companyId)
        {
            try
            {

                var voucherTemplate = AccountingDataProvider.GetVoucherTemplateByCode(shortCode, companyId);

                var viewModel = new VoucherTemplateDto
                {
                    CompanyId = voucherTemplate.CompanyId,
                    CompanyName = "",
                    CreditAccountCode = voucherTemplate.CreditAccount,
                    CreditAccountName = AccountingDataProvider.GetAccountByCode(voucherTemplate.CompanyId, voucherTemplate.CreditAccount).AccountName,
                    DebitAccountCode = voucherTemplate.DebitAccount,
                    DebitAccountName = AccountingDataProvider.GetAccountByCode(voucherTemplate.CompanyId, voucherTemplate.DebitAccount).AccountName,
                    Narration = voucherTemplate.Narration,
                    ShortCode = voucherTemplate.ShortCode,

                };

                return viewModel;
            }

            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
        }
 private void UpdateFields(VoucherTemplateDto template)
 {
     txtShortCode.Text = template.ShortCode;
     cboDebitAccount.SelectedValue = template.DebitAccountCode.ToString();
     cboCreditAccount.SelectedValue = template.CreditAccountCode.ToString();
     txtNarration.Text = template.Narration;
 }