版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/MirabelleZWH/article/details/84336596
【改】
UI层
Entity.StuInfo stu = new Entity.StuInfo();
stu.UserID = txtUserID.Text.Trim();
stu.UserName = txtUserName.Text;
stu.Sex = cmbSex.Text;
stu.Department = cmbDepartment.Text;
stu.Grade = cmbGrade.Text;
stu.Class = txtClass.Text;
stu.state = cmbState.Text;
stu.Password = txtPassword.Text;
Facade.StuFacade facade = new Facade.StuFacade();
bool updateStuInfo = facade.updateStuInfo(stu);
门面层
public class StuFacade
{
public bool updateStuInfo(Entity.StuInfo stu)
{
BLL.StuBLL stuBll = new StuBLL();
bool flag = stuBll.updateStuInfo(stu);
return flag;
}
}
BLL层
public class StuBLL
{
public bool updateStuInfo(Entity.StuInfo stu)
{
Factory.LoginFactory fact = new Factory.LoginFactory();
IDAL.StuIDAL idal = fact.Student();
int result = idal.updateStuInfo(stu);
bool flag;
if (result == 0)
{
flag = false;
}
else
{
flag = true;
}
return flag;
}
}
工厂层
public class LoginFactory
{
public IDAL.StuIDAL Student()
{
string ClassName = strDB + "." + "StuDAL";
return (IDAL.StuIDAL)Assembly.Load(strDB).CreateInstance(ClassName);
}
}
IDAL层
public interface StuIDAL
{
int updateStuInfo(Entity.StuInfo stu);
}
DAL层
public class StuDAL:IDAL.StuIDAL
{
public int updateStuInfo(Entity.StuInfo stu)
{
SqlHelper sqlHelper = new SqlHelper();
string sql = "UPDATE studentInfo SET UserName=@username,Sex=@sex,Department=@department,Grade=@grade,state=@state,Password=@password,Class=@class WHERE UserID=@userid";
SqlParameter[] sqlParamters ={
new SqlParameter ("@userid",stu.UserID),
new SqlParameter("@username",stu.UserName),
new SqlParameter("@sex",stu.Sex),
new SqlParameter("@department",stu.Department),
new SqlParameter("@grade",stu.Grade),
new SqlParameter("@state",stu.state),
new SqlParameter("@password",stu.Password),
new SqlParameter("@class",stu.Class)
};
int result = sqlHelper.ExecuteNonQuery(sql, sqlParamters, CommandType.Text);
return result;
}
}