Пример #1
0
        static void Main(string[] args)
        {
            //TODO: read input from screen ?
            DateTime effectiveDate = DateTime.Now;
            string   rateType      = "standard";
            int      resultCount   = 3;
            //TODO: get file loc from appsettings.json ?
            string fileName = "http://jsonvat.com/";

            try
            {
                string        webData       = Utilities.GetWebDataAsync(fileName).Result;
                VatRepository vatRepository = new VatRepository(webData);
                VatResolver   vatResolver   = new VatResolver(vatRepository);

                if (ValidateRateType(vatRepository.RatesValid, rateType) && vatRepository.TotalCountries > resultCount && vatRepository.TotalCountries > 0)
                {
                    OutputResults("Highest", rateType, resultCount, vatResolver.GetHighestRate(resultCount, effectiveDate, rateType));
                    OutputResults("Lowest", rateType, resultCount, vatResolver.GetLowestRate(resultCount, effectiveDate, rateType).Reverse());
                }
                else
                {
                    Console.WriteLine($"Input not valid");
                }
            }
            catch (Exception exc)
            {
                Console.WriteLine($"Exception: {exc.ToString()}");
            }
        }
Пример #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            VatRepository repository = new VatRepository();

            if (String.IsNullOrEmpty(txtVatCode.Text))
            {
                MessageBox.Show("Please Enter Vat Code.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (repository.GetVat(txtVatCode.Text) != null)
            {
                MessageBox.Show("Vat Code Provided Already exist in Database.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            Vat vat = new Vat();

            vat.VatCd         = txtVatCode.Text.ToUpper();
            vat.VatPercentage = Convert.ToDecimal(txtVatPercentage.Text);
            vat.CreatedBy     = "Admin";
            if (repository.AddVat(vat))
            {
                MessageBox.Show("Vat Saved Successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Vat1.VatCd = txtVatCode.Text;
                Close();
            }
            else
            {
                MessageBox.Show("Error Occurred", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #3
0
        private void btnEditVat_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtVatCode.Text))
            {
                MessageBox.Show("Please Enter Vat Code", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            Vat           vat        = new Vat();
            VatRepository repository = new VatRepository();

            vat = repository.GetVat(txtVatCode.Text);
            if (vat != null)
            {
                Form form = new frmEditVat(vat)
                {
                    vat1 = new Vat()
                };
                form.ShowDialog();
                txtVatCode_Leave(sender, e);
            }
            else
            {
                MessageBox.Show("Vat Code does not exist in the database", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #4
0
 private void txtVatCode_Leave(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(txtVatCode.Text))
     {
         VatRepository repository = new VatRepository();
         Vat           vat        = repository.GetVat(txtVatCode.Text);
         if (vat != null)
         {
             txtVatCode.Text       = vat.VatCd;
             txtVatPercentage.Text = vat.VatPercentage.ToString();
         }
     }
 }
Пример #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            VatRepository repository = new VatRepository();
            Vat           vat        = new Vat();

            vat.VatCd         = txtVatCode.Text;
            vat.VatPercentage = Convert.ToDecimal(txtVatPercentage.Text);
            if (repository.EditVat(vat))
            {
                MessageBox.Show("Vat Updated Successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                vat1.VatPercentage = Convert.ToDecimal(txtVatPercentage.Text);
                this.Close();
            }
        }
Пример #6
0
 private void VatTextBox_Leave(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(VatTextBox.Text))
     {
         VatRepository repository = new VatRepository();
         Vat           vat        = new Vat();
         vat = repository.GetVat(VatTextBox.Text);
         if (vat == null)
         {
             MessageBox.Show("Please Enter Valid Vat Code");
             VatTextBox.Focus();
             return;
         }
         else
         {
             VatTextBox.Text = vat.VatCd;
         }
     }
 }
Пример #7
0
        private void btnVatList_Click(object sender, EventArgs e)
        {
            VatRepository repository = new VatRepository();
            List <Vat>    vats       = repository.GetVats().ToList();

            if (vats.Count == 0)
            {
                MessageBox.Show("No Records To Display.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            ReportDocument report = new VatList();

            report.SetDataSource(vats);
            report.SetParameterValue("@Company", Properties.Settings.Default.COMPANYNAME.ToUpper());
            report.SetParameterValue("@Branch", Properties.Settings.Default.BRANCHNAME.ToUpper());
            report.SetParameterValue("@Username", Properties.Settings.Default.USERNAME.ToUpper());
            Form form = new frmPrint(report);

            form.Text = "Vat Master List";
            form.Show();
        }
Пример #8
0
 public VatResolver(VatRepository vatRepository)
 {
     this.vatRepository            = vatRepository;
     this.vatCountryDataCollection = vatRepository.GetVatCountryCollection();
 }
Пример #9
0
 public UnitTests()
 {
     vatRepository            = new VatRepository(GetMockWebData());
     vatResolver              = new VatResolver(vatRepository);
     vatCountryDataCollection = vatRepository.GetVatCountryCollection();
 }