/// <summary> /// UI层的简单代码 /// </summary> void LoadStudentInfo() { BLL.PersonManager bllperson=new BLL.PersonManager(); //实例化BLL逻辑处理层 List<MODEL.Person> list = bllperson.BllStudentInfo(false); //接受从BLL层传回的返回值 this.dgvStudent.DataSource = list; }
/// <summary> /// BLL层的简单代码 /// </summary> /// <param name="isdel"></param> /// <returns></returns> public List<MODEL.Person> BllStudentInfo(bool isdel) //接受从UI层传入的参数 { DAL.PersonService dalPerson = new DAL.PersonService(); //实例化DAL数据访问层 List<MODEL.Person> list = dalPerson.DALStudentInfo(isdel); //接受从DAL层返回的数据 return list; //返回数据到UI层 }
/// <summary> /// DAL层的简单代码 /// </summary> /// <param name="isdel"></param> /// <returns></returns> public List<MODEL.Person> DALStudentInfo(bool isdel) //接受从BLL层传入的参数 { string sql = @"select * from person where pisdel=@pisdel"; //处理过程,方法都封装在SqlHelper类中,调用处理 SqlParameter[] ps ={ new SqlParameter("@pisdel",isdel) }; DataTable dt=SqlHelper.ExetcuDataTable(sql,ps); List<MODEL.Person> list = null; if(dt.Rows.Count>0) { list = new List<MODEL.Person>(); foreach (DataRow item in dt.Rows) { MODEL.Person per = new MODEL.Person(); per.PID = (int)item["PID"]; per.PCID = (int)item["PCID"]; per.PType = (int)item["PType"]; per.PLoginName = item["PLoginName"].ToString(); per.PCName = item["PCName"].ToString(); per.PPYName = item["PPYName"].ToString(); per.PPwd = item["PPwd"].ToString(); per.PGender = (bool)item["PGender"]; per.PEmail = item["PEmail"].ToString(); per.PAreas = item["PAreas"].ToString(); per.PIsDel = (bool)item["PIsDel"]; per.PAddTime = (DateTime)item["PAddTime"]; list.Add(per); } } return list; //将处理的数据返回至BLL层 }