之前跟大家講過,麥田培訓學校管理軟件,具有平臺性,可以通過語法修改打印格式。今天就帶大家了解一下,如何調用數據源增加個性化字段。在日常工作中,有些校長問,如何在麥田軟件的收據憑證上顯示欠費金額呢?麥田軟件的收費模式其實是一種基于虛擬賬戶的模式,原理上相當于先充值后扣費,如果說消費單是體現扣費的過程,那么欠費顯然不屬于消費單顯示的內容,欠費而是計對學員賬戶。在麥田軟件中采用借款,還款方式來解釋欠費事務。了解了這些我們就可以著手來分析實現方法了。

(效果圖,黃色框內,即顯示欠費的地方。除打印機邊距,坐標大約是 x = 11.5cm,y = 1.5cm。 )
首先找到消費單的數據源代碼:(在說明書的第四章 功能擴展-->二、如何修改打印報表?-->報表數據庫(DataSet)-->消費單)
public static DataSet GetBill(long BillID)
{
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
OleDbCommand Comm = new OleDbCommand();
OleDbDataAdapter da = new OleDbDataAdapter();
DataSet ds = new DataSet("ds");
Comm.Parameters.Add("@BillID", OleDbType.BigInt);
Comm.Parameters["@BillID"].Value = BillID;
da.SelectCommand = Comm;
Comm.Connection = connection;
Comm.CommandText = @"Select * from Bill where BillID = @BillID";
da.Fill(ds, "Bill");
Comm.CommandText = @"Select * from BillItem where BillID = @BillID";
da.Fill(ds, "BillItem");
Comm.CommandText = @"Select Student.* from Student,Bill where Student.StudentID = Bill.StudentID and Bill.BillID = @BillID";
da.Fill(ds, "Student");
Comm.CommandText = @"Select StuClass.* from StuClass,BillItem where StuClass.StuClassID and StuClass.BillItemID = BillItem.BillItemID and BillItem.BillID=@BillID";
da.Fill(ds, "StuClass");
Comm.CommandText = @"Select Class.* from StuClass,BillItem,Class where StuClass.StuClassID and StuClass.BillItemID = BillItem.BillItemID and StuClass.ClassID = Class.ClassID and BillItem.BillID=@BillID";
da.Fill(ds, "Class");
return ds;
}
}
上面這段代碼就是消費單/退貨單的DateSet數據集,我們可以看到分別從
Bill,BillItem,Student,StuClass,Class 五張數據表上調用數據,每張表的含義請查詢數據庫手冊:
http://www.hbpufeike.com/help/swt2_db/,前面講到學員欠費是針對賬戶級的,所以重點查看Student表,我們打開數據庫手冊Student表:
Student 學員表
學員基礎信息表。
字段 |
類型 |
說明 |
StudentID |
Int |
學員編號。 |
StudentName |
VarChar |
學員姓名。 |
PYSimple |
VarChar |
拼音簡碼。 |
Byname |
VarChar |
別名。 |
Appellation |
VarChar |
稱呼。 |
Sex |
Int |
性別。(0女,1男) |
StudentType |
Int |
學員類型。(0學生,1上班族) |
Birthday |
DateTime |
出生日期。 |
SchoolID |
Int |
校區編號。 |
SchoolName |
VarChar |
校區名稱。 |
Photo |
VarBinary |
相片。 |
ExistPhoto |
Boolean |
是否存在相片。 |
Password |
VarChar |
密碼。 |
DateAndTime |
DateTime |
報名日期。 |
Tel |
VarChar |
電話。 |
MobileTel |
VarChar |
手機。 |
Email |
VarChar |
電子信箱。 |
HomeAddress |
VarChar |
家庭地址。 |
PostCode |
VarChar |
郵編。 |
School |
VarChar |
學校。 |
Grade |
VarChar |
年級。 |
Class |
VarChar |
班級。 |
Company |
VarChar |
單位。 |
Headship |
VarChar |
職務。 |
IDcard |
VarChar |
身份證號。 |
SignInID |
VarChar |
ID卡號。 |
LastClassName |
VarChar |
最后加入的班級。 |
StuClassCount |
Int |
選班數量。 |
ConsultantID |
Int |
所屬咨詢員編號。 |
ConsultantName |
VarChar |
所屬咨詢員姓名。 |
MediaID |
Int |
媒體編號。 |
MediaName |
VarChar |
媒體名稱。 |
Remark |
VarChar |
備注。 |
UserID |
Int |
錄入者編號。 |
TrueName |
VarChar |
錄入者姓名。 |
BillCount |
Int |
消費單數量。 |
ConsumedMoney |
Currency |
消費金額。 |
CreditMoney |
Currency |
欠費金額。 |
AvailableMoney |
Currency |
可用金額。 |
從上面表,我們可以看到CreditMoney字段表示欠費金額。找準了字段,我們就可以通過xsl語句讀出這個值了。實際上asp.net中DataSet就是一種存儲在內存中的XML文件。我們用這條語法操作它:
<xsl:value-of select="ds/Student/CreditMoney" />,下一步就是采用文本標簽給欠費字段定位。
<span x="11.5cm" y="1.5cm">欠費金額:<xsl:value-of select="ds/Student/CreditMoney" />元</span> 最后,我們把這段代碼加入到“消費明細單模板”(位置:分析-->打印模板-->消費明細單模板-->編輯),如下圖:

這樣消費單上顯示欠費信息就實現了:) 向大家曬曬實際打印效果呵!!