运用三层架构来输入学生id使年龄加1
2012-12-03 21:08
204 查看
Bll的设计:MyStudentBll
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using sancenjiagou.sancengjia.DAL;
namespace sancenjiagou.sancengjia.Bll
{
public class MyStudentBll
{
public bool AgeAddById(int fid)
{
MyStudentDAL dal = new MyStudentDAL();
int r = dal.AgeAddById(fid);
if (r > 0)
{
return true;
}
else
{
return false;
}
}
}
}
DAL的设计:MyStudentDAL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using _11_28DataSet111;
namespace sancenjiagou.sancengjia.DAL
{
public class MyStudentDAL
{
//本方法是实现某个学生的id加1
public int AgeAddById(int fid)//建立一个方法,实现对表的操作
{
string sql = "update Mystudents set FAge=FAge+1 where
FId=@sId";
SqlParameter pms = new SqlParameter("@sId", fid);
return SqlHealper1.ExecuteNonQuery(sql, pms);
}
}
}
UI的.aspx的设计
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="sancenjiagou.sancengjia.UI.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
请输入学生的ID:<asp:TextBox ID="txtID" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="该学生的年龄加1"
Width="275px" />
</div>
</form>
</body>
</html>
UI的.aspx.cs的设计
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using sancenjiagou.sancengjia.Bll;
namespace sancenjiagou.sancengjia.UI
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
int fid = Convert.ToInt32(txtID.Text.Trim());
MyStudentBll bll = new MyStudentBll();
bool b = bll.AgeAddById(fid);
if (b)
{
Response.Write("修改成功");
}
else
{
Response.Write("修改失败");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using sancenjiagou.sancengjia.DAL;
namespace sancenjiagou.sancengjia.Bll
{
public class MyStudentBll
{
public bool AgeAddById(int fid)
{
MyStudentDAL dal = new MyStudentDAL();
int r = dal.AgeAddById(fid);
if (r > 0)
{
return true;
}
else
{
return false;
}
}
}
}
DAL的设计:MyStudentDAL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using _11_28DataSet111;
namespace sancenjiagou.sancengjia.DAL
{
public class MyStudentDAL
{
//本方法是实现某个学生的id加1
public int AgeAddById(int fid)//建立一个方法,实现对表的操作
{
string sql = "update Mystudents set FAge=FAge+1 where
FId=@sId";
SqlParameter pms = new SqlParameter("@sId", fid);
return SqlHealper1.ExecuteNonQuery(sql, pms);
}
}
}
UI的.aspx的设计
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="sancenjiagou.sancengjia.UI.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
请输入学生的ID:<asp:TextBox ID="txtID" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="该学生的年龄加1"
Width="275px" />
</div>
</form>
</body>
</html>
UI的.aspx.cs的设计
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using sancenjiagou.sancengjia.Bll;
namespace sancenjiagou.sancengjia.UI
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
int fid = Convert.ToInt32(txtID.Text.Trim());
MyStudentBll bll = new MyStudentBll();
bool b = bll.AgeAddById(fid);
if (b)
{
Response.Write("修改成功");
}
else
{
Response.Write("修改失败");
}
}
}
相关文章推荐
- 使用三层架构,实现页面中输入学生id,单机按钮后使该学生的年龄加
- 使用三层实现页面中输入学生id,单机按钮后使该学生的年龄加
- 实现页面中输入学生id,单机按钮后使该学生的年龄加。(使用三层—)
- 12-3 用三层实现 页面中输入学生id,单机按钮后使该学生的年龄加。
- 创建一个学生类(Student),包括学号和成绩,编程输入和显示学生的信息,建立一个人类(Person),包含姓名、性别和年龄,并作为学生类的基类
- 创建一个学生类(Student),包括学号成绩,编程输入和显示学生的信息。建立一个人类(Person),包含姓名、性别和年龄,并作为学生类的基类
- 编写程序:建立一个学生数据链表,每个节点的信息包括如下内容:学号,姓名,性别年龄专业。对链表做如下处理。输入一个学号(专业),如果链表中的节点包含此学号(专业),则删去该结点。
- jquery 调用wcf 的SOA架构,将三层架构运用到SOA的架构中来(第四天)
- 学生管理系统---三层架构
- NET高级开发一:用VB.net+ADO.NET+SQL Server开发三层架构的运用程序
- 用VB.net+ADO.NET+SQL Server开发三层架构的运用程序(转载)
- 学生管理系统(三层架构)
- Linux-C基础知识学习:C语言作业-输入某个学生的信息(姓名,年龄,5门功课成绩),计算平均成绩并输出。(待完善)
- 建立一个学生结构数组来记录学生信息(学号ID,姓名和C语言成绩),要求动态建立一个结构数组,数组长度从键盘输入,自行给数组元素赋值并打印学生信息,最后不要忘记释放内存。 结构st
- 运用asp2.0创建和使用三层数据架构(C#)--【第一篇:简介之建立数据访问层】
- 三层架构下的EntityFramework codefirst
- (整理)关于C语言中的输入和输出函数的一些运用
- 三层架构的知识
- 有10个学生,每个学生的数据包括学号、姓名、3门课的成绩,从键盘输入10个学生数据,要求打印出3门课总平均成绩,以及最高分的学生的数据(包括学号、姓名、3门课的成绩、平均分数)。
- 三层架构及MVC