如何将 Tally 与 Asp.Net Web 应用程序集成? [关闭]

Posted

技术标签:

【中文标题】如何将 Tally 与 Asp.Net Web 应用程序集成? [关闭]【英文标题】:How to integrate Tally with Asp.Net Web Application? [closed] 【发布时间】:2012-01-25 20:05:34 【问题描述】:

我们正在使用 ASP.Net 和 C#.Net 开发 ERP。现在,我想将应用程序与 Tally 集成。这样生成的凭证将以 XML 格式传输到 Tally。这个怎么做?我需要你所有的宝贵贡献。

【问题讨论】:

【参考方案1】:

请通过此链接www.rtslink.com 。

产品:RTSlink DLL 平台:Windows 2000 及以上 Tally : 6.3 及以上版本 类别 : DLL 以编程方式从 Tally 会计软件中推送和拉取 [导入和导出] 数据

XML 代表可扩展标记语言。 XML 是一种类似于 html 的标记语言,但旨在描述数据并关注数据是什么。 XML 标签不是预定义的,您必须定义自己的标签。 XML 用于交换数据 XML 标签区分大小写 XML 中的注释类似于 HTML 中的注释。示例

XML 有一个空元素的简写:以 /> 结尾的唯一标记表示该元素没有内容。

转义序列 转义序列会导致正常解释的转义。 C/C++ 程序员可能经常使用以下转义序列。

'\n' - 换行 '\r' - 回车 '\t' - 制表符

Tally 的 XML 标签示例:

<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>

【讨论】:

嗨@Ajay270,请您帮助我们如何获取特定公司的分类帐列表?因为,我的统计中有很多公司,每家公司都有不同的分类帐。我需要明智地获得分类帐清单公司。【参考方案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();
    

【讨论】:

【参考方案3】:
<p>&nbsp;WebRequest Request = WebRequest.Create(TallyUrl.Text);<br />
string exportxml = null;<br />
int Amt = int.Parse(VCHAmount.Text);</p>

<p>exportxml = &quot;&lt;ENVELOPE&gt;&quot; +<br />
&quot;&lt;HEADER&gt;&quot; +<br />
&quot;&lt;TALLYREQUEST&gt;Export Data&lt;/TALLYREQUEST&gt;&quot; +<br />
&quot;&lt;/HEADER&gt;&quot; +<br />
&quot;&lt;BODY&gt;&quot; +<br />
. . .<br />
. . .<br />
&quot;&lt;/BODY&gt;&quot; +<br />
&quot;&lt;/ENVELOPE&gt;&quot;;<br />
<br />

Byte[] bytesToWrite = Encoding.ASCII.GetBytes(exportxml);</p>

<p>Request.Method = &quot;POST&quot;;<br />
Request.ContentLength = bytesToWrite.Length;<br />
Request.ContentType = &quot;text/xml&quot;;</p>

<p>Stream newStream = Request.GetRequestStream();<br />
newStream.Write(bytesToWrite, 0, bytesToWrite.Length);<br />
newStream.Close();</p>

<p>HttpWebResponse response = (HttpWebResponse)Request.GetResponse();<br />
Stream dataStream = response.GetResponseStream();<br />
StreamReader reader = new StreamReader(dataStream);</p>

<p>string responseFromServer = reader.ReadToEnd();<br />
string xmlresponse = responseFromServer;</p>

<p>XmlDocument xd = new XmlDocument();<br />
xd.LoadXml(xmlresponse);</p>

查看http://coimbatore-biz.com/blog/techsupport/Tally%20Integration%20Capabilitiesp0st413的更多帮助

【讨论】:

以上是关于如何将 Tally 与 Asp.Net Web 应用程序集成? [关闭]的主要内容,如果未能解决你的问题,请参考以下文章

如何将 protobuf-net 与通过 ASP.NET Web Reference 生成的类一起使用,同时避免代码重复?

如何将 ASP NET Web 应用程序客户端与 NET 框架控制台应用程序服务器连接

如何在 Windows 服务中托管一个简单的 ASP.NET Web 界面

如何在没有登录表单的情况下将摘要身份验证与 asp.net web api 和 angular js 一起使用?

如何在asp.net c# web应用程序中使用asp.net vb页面

将文件写入 Web 服务器 - ASP.NET