using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Newtonsoft.Json;

namespace TaxProGSTApiWinFormsDemo
{
    public partial class frmHsnSacFinder : Form
    {
        public frmHsnSacFinder()
        {
            InitializeComponent();
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            try
            {
                TaxProGST.API.TxnHsnToolResp txnResp = new TaxProGST.API.TxnHsnToolResp();
                if(radFromHsnSacNumber.Checked)
                {
                    txnResp = TaxProGST.API.HSNTools.GetHsnSacDetailFromHsnSacNumber(txtSearchText.Text);
                }
                else if (radFromChapterNo.Checked)
                {
                    txnResp = TaxProGST.API.HSNTools.GetHsnSacDetailFromChapterNumber(txtSearchText.Text);
                }
                else if(radFromDescription.Checked)
                {
                    txnResp = TaxProGST.API.HSNTools.GetHsnSacDetailFromDescription(txtSearchText.Text);
                }

                txtAPIResponse.Text = JsonConvert.SerializeObject(txnResp, Formatting.Indented);

            }
            catch(Exception ex)
            {

                txtAPIResponse.Text = ex.Message;
            }
        }
    }
}
