4.4数据库需求分析
数据库的设计通常是以一个已经存在的数据库管理系统为基础的,常用的数据库管理系统有MYSQL,SQL Server, Oracle等。我采用了SQL server2000数据库管理系统,建立的数据库名为FinancialManagement。
4.5 数据库结构设计
4.5.1 F_Money (财务信息表)
主要用于保存财务的基本信息,该表的结构如表2所示
4.5.2 Users (家庭人员信息表)
主要用于保存家庭人员的基本信息,该表的结构如表2所示
4.5.3 Type (记账类型信息表)
主要用于保存记账类型的基本信息,该表的结构如表2所示
4.6功能模块
4.6.1用户登陆模块
家庭成员需要登陆才能使用系统。
涉及到的代码有:
private void chkUser() {
if (TxtUserName.Text == \ && TxtPassword.Text == \) {
Alert.AlertAndRedirect(\没有输入账号和密码!\, \);
} else {
dr = data.GetDataReader(\ + TxtUserName.Text.Trim() + \ + TxtPassword.Text.Trim() + \); if (dr.Read()) {
Session[\] = dr[\].ToString();
Response.Redirect(\);
}
else {
Alert.AlertAndRedirect(\账号或者密码不对请重新登陆!\, \); } } }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) {
chkUser(); }
protected void ImageButton2_Click(object sender, ImageClickEventArgs e) {
TxtPassword.Text = \; TxtUserName.Text = \; }
protected void LinkButton1_Click(object sender, EventArgs e) {
Response.Redirect(\);
}
4.6.2 账目管理模块
查看,修改,删除 管理账目信息。
涉及到的代码有:
protected void gvFilms_RowDeleting(object sender, GridViewDeleteEventArgs e) {
SqlHelper mydata = new SqlHelper();
string ID = gvFilms.DataKeys[e.RowIndex].Values[0].ToString(); try {
mydata.RunSql(\ + ID + \);
Label4.Text = \删除成功!\; gvFilms.EditIndex = -1; Get_Article(); } catch {
Label4.Text = \删除失败!\; } }
private void Get_Article() { try {
gvFilms.DataSource = GetCodeBy(0); gvFilms.DataBind(); } catch {
} }
protected void gvFilms_PageIndexChanging(object sender, GridViewPageEventArgs e) {
gvFilms.PageIndex = e.NewPageIndex; Get_Article(); }
protected void gvFilms_RowDataBound(object sender, GridViewRowEventArgs e) {
//鼠标移动变色
if (e.Row.RowType == DataControlRowType.DataRow) {
//当鼠标放上去的时候 先保存当前行的背景颜色 并给附一颜色 e.Row.Attributes.Add(\,
\tWeight='';\);
//当鼠标离开的时候 将背景颜色还原的以前的颜色 e.Row.Attributes.Add(\,
\); }
//单击行改变行背景颜色
if (e.Row.RowType == DataControlRowType.DataRow) {
e.Row.Attributes.Add(\, \this.style.color='buttontext';this.style.cursor='default';\); } }
public DataSet GetCodeBy(int iCount) {
SqlHelper date = new SqlHelper(); string strTop = \; if (iCount > 1) {
strTop = \ + iCount.ToString(); }
string sql = \ + strTop + \; SqlConnection con = new SqlConnection(SqlHelper.connstring); SqlCommand cmd = new SqlCommand(sql, con);
SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = null; try {
con.Open(); ds = new DataSet(); da.Fill(ds);
}
catch (SqlException ex) {
throw ex; }
catch (Exception ex) {