我们正在使用ASP.Net和C#.Net开发ERP。现在,我希望将应用程序与Tally集成。因此,生成的凭证将作为XML格式传输到Tally。这该怎么做?我需要你所有的宝贵贡献。
答案 0 :(得分:4)
请点击此链接www.rtslink.com。
产品:RTSlink DLL 平台:Windows 2000及更高版本 理货:版本6.3及以上 类别:DLL以编程方式从Tally Accounting Software推送[导入和导出]数据
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>
答案 1 :(得分:1)
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();
}
}
答案 2 :(得分:0)