How to integrate Tally with Asp.Net Web Application?

15,700

Solution 1

Kindly go through this link www.rtslink.com .

Product : RTSlink DLL Platform : Windows 2000 and above Tally : Version 6.3 and above Category : DLL to programmatically push and pull [Import and Export] data from Tally Accounting Software

XML stands for EXtensible Markup Language. XML is a markup language like HTML, but is designed to describe data and focus on what data is. XML tags are not pre-defined, you must define your own tags. XML is used to Exchange data XML Tags are case-sensitive Comments in XML are similar to that of HTML. Example

XML has a shorthand for empty elements: A sole tag ending with /> signals that the element has no contents.

Escape Sequences An escape sequence causes an escape from the normal interpretation. A C/C++ programmer might have used the following escape sequences frequently viz.

'\n’ - New Line '\r’ - Carriage return '\t ’ - Tab

Example XML Tags for Tally:

<ENVELOPE> 
<HEADER>
<TALLYREQUEST>Import Data</TALLYREQUEST>
</HEADER>
<BODY>
<IMPORTDATA>
<REQUESTDESC>
<REPORTNAME>All Masters</REPORTNAME>
</REQUESTDESC>
<REQUESTDATA>
<TALLYMESSAGE xmlns:UDF="TallyUDF">

<!— TO DO: Specify the company Name as it appears in Tally -->
<COMPANY NAME="DEMO" ACTION="Alter">
<!—  enable Maintain Multiple Godown -->
<ISMULTIGODOWNON>Yes</ISMULTIGODOWNON>
<!—  enable Use Debit/Credit Notes -->
<ISDCNOTEON>Yes</ISDCNOTEON>
<!—  enable Use Invoice mode for Credit Notes -->
<DNOTEASINVOICE>Yes</DNOTEASINVOICE>
<!—  enable Use Invoice mode for Debit notes -->
<CNOTEASINVOICE>Yes</CNOTEASINVOICE>
<!—  enable Use 0 valued entries in vouchers -->
<USEZEROENTRIES>Yes</USEZEROENTRIES>

</COMPANY>
</TALLYMESSAGE>
</REQUESTDATA>
</IMPORTDATA>
</BODY>
</ENVELOPE>

Solution 2

public partial class VoucherCreate : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void requestTally(string pGroupType)
    {
        WebRequest Request = WebRequest.Create(TallyUrl.Text);
        string exportxml = null;
        int Amt = int.Parse(VCHAmount.Text);

        if (pGroupType == "")
        {
            exportxml = "<ENVELOPE>" + 
                              "<HEADER>" + 
                                  "<TALLYREQUEST>Import Data</TALLYREQUEST>" + 
                              "</HEADER>" +  
                              "<BODY>" + 
                                  "<IMPORTDATA>" + 
                                      "<REQUESTDESC>" + 
                                          "<REPORTNAME>Vouchers</REPORTNAME>" + 
                                          "<STATICVARIABLES>" +  
                                              "<SVCURRENTCOMPANY>##SVCURRENTCOMPANY</SVCURRENTCOMPANY>" + 
                                          "</STATICVARIABLES>" + 
                                      "</REQUESTDESC>" +  
                                      "<REQUESTDATA>" + 
                                          "<TALLYMESSAGE xmlns:UDF='TallyUDF'>" +  
                                              "<VOUCHER VCHTYPE='Payment' ACTION='Create' OBJVIEW='Accounting Voucher View'>" + 
                                                  "<DATE>" + "11-Jun-2014" + "</DATE>" + "\r\n" +
                                                  "<VOUCHERTYPENAME>Payment</VOUCHERTYPENAME>" +
                                                  "<VOUCHERNUMBER>1</VOUCHERNUMBER>" +
                                                  "<PARTYLEDGERNAME>" +"Cash"+"</PARTYLEDGERNAME>" +//VchCashBankLed.Text 
                                                  "<PERSISTEDVIEW>Accounting Voucher View</PERSISTEDVIEW>" +
                                                  "<EFFECTIVEDATE>" + "11-Jun-2014" + "</EFFECTIVEDATE>" +
                                                  "<ALLLEDGERENTRIES.LIST>" +
                                                      "<LEDGERNAME>" +"Expenses"+ "</LEDGERNAME>" +// VCHLedger.Text 
                                                      "<ISDEEMEDPOSITIVE>Yes</ISDEEMEDPOSITIVE>" +
                                                      "<AMOUNT>" +500*-1 +"</AMOUNT>" +//(Amt * -1) 
                                                  "</ALLLEDGERENTRIES.LIST>" +
                                                  "<ALLLEDGERENTRIES.LIST>" +
                                                      "<LEDGERNAME>" +"Cash" +"</LEDGERNAME>" +//VchCashBankLed.Text 
                                                      "<ISDEEMEDPOSITIVE>No</ISDEEMEDPOSITIVE>" +
                                                      "<AMOUNT>" +500 +"</AMOUNT>" +//VCHAmount.Text 
                                                  "</ALLLEDGERENTRIES.LIST>" +
                                              "</VOUCHER>" +
                                          "</TALLYMESSAGE>" +
                                      "</REQUESTDATA>" +
                                  "</IMPORTDATA>" +
                              "</BODY>" +
                          "</ENVELOPE>";
                 Response.Write("<script LANGUAGE='JavaScript' >alert(''"+exportxml+"'')</script>");
                }
        else{
            exportxml = "<ENVELOPE>" +
                      "<HEADER>" +
                          "<VERSION>1</VERSION>" +
                          "<TALLYREQUEST>Export</TALLYREQUEST>" +
                          "<TYPE>Collection</TYPE>" +
                          "<ID>FilteredLedgers</ID>" +
                      "</HEADER>" +
                      "<BODY>" +
                          "<DESC>" +
                              "<TDL>" +
                                  "<TDLMESSAGE>" +
                                      "<COLLECTION NAME='FilteredLedgers' ISMODIFY='No'>" +
                                          "<SOURCECOLLECTION>Ledger</SOURCECOLLECTION>" +
                                          "<FETCH>Name</FETCH>" +
                                          "<FILTER>" + pGroupType +"</FILTER>" +
                                      "</COLLECTION>" +
                                      "<SYSTEM TYPE='Formulae' NAME='PartyExpense Filter' ISMODIFY='No'>" +
                                        "$$IsLedOfGrp:$Name:$$GroupSundryCreditors OR $$IsLedOfGrp:$Name:$$GroupIndirectExpenses OR $$IsLedOfGrp:$Name:$$GroupDirectExpenses</SYSTEM>" +
                                      "<SYSTEM TYPE='Formulae' NAME='BankCashFilter' ISMODIFY='No'>" +
                                        "$$IsLedOfGrp:$Name:$$GroupBank OR $$IsLedOfGrp:$Name:$$GroupBankOD OR $$IsLedOfGrp:$Name:$$GroupCash</SYSTEM>" +
                                  "</TDLMESSAGE>" +
                             "</TDL>" +
                          "</DESC>" +
                      "</BODY>" +
                  "</ENVELOPE>";
          }


            Byte[] bytesToWrite = Encoding.ASCII.GetBytes(exportxml);

            Request.Method = "POST";
            Request.ContentLength = bytesToWrite.Length;
            Request.ContentType = "text/xml";

            Stream newStream = Request.GetRequestStream();
            newStream.Write(bytesToWrite, 0, bytesToWrite.Length);
            newStream.Close();

            HttpWebResponse response = (HttpWebResponse)Request.GetResponse();
            Stream dataStream = response.GetResponseStream();
            StreamReader reader = new StreamReader(dataStream);

            string responseFromServer = reader.ReadToEnd();
            string xmlresponse = responseFromServer;

            XmlDocument xd = new XmlDocument();
            xd.LoadXml(xmlresponse);

            XmlNodeList xmlNameList = xd.SelectNodes("NAME");

            if (pGroupType == "PartyExpenseFilter")
            {
                DropDownList1.Items.Clear();

                for (int i = 0; i < (xmlNameList.Count - 1); i++)
                    {                        
                        DropDownList1.Items.Add(xmlNameList.Item(i).InnerText.ToString());
                    }
            }

            if (pGroupType == "BankCashFilter")
            {
                DropDownList2.Items.Clear();

                for (int i = 0; i < (xmlNameList.Count - 1); i++)
                {
                    DropDownList2.Items.Add(xmlNameList.Item(i).InnerText.ToString());
                } 
            }

    }
         protected void Button1_Click(object sender, EventArgs e)
    {
        requestTally("");
        DropDownList1.Text = "";
        DropDownList2.Text = "";
        VCHAmount.Text = "";
        DropDownList1.Focus();
    }
}
Share:
15,700
thevan
Author by

thevan

Software Engineering Senior Analyst at Accenture Solutions Private Limited, Chennai, India. Interested in ASP.Net, MVC, Web API, WCF, Web Services, ADO.Net, C#.Net, VB.Net, Entity Framework, MS SQLServer, Angular.js, JavaScript, JQuery, Ajax, HTML and CSS

Updated on June 05, 2022

Comments

  • thevan
    thevan about 2 years

    We are developing an ERP using ASP.Net and C#.Net. Now in that, I want to integrate the application with Tally. So that the vouchers produced would be transferred as XML format to the Tally. How to do this? I need all your valuable contributions.

  • dilipkumar1007
    dilipkumar1007 over 7 years
    Hi @Ajay270, Will you please help us how can I get ledger list for a particular company? As, I've many company in my tally and each company have different ledger. I need to get ledger list company by wise.