C#个人重构之简单查询

来源:互联网 发布:电气学什么软件 编辑:程序博客网 时间:2024/04/26 17:14
【人参果】

技术点:
1、泛型在U层的转换显示
【山巅远眺】
设计理念:
1、与第一次不同,这次在界面上的显示都用的lbl标签。
2、我认为在学校里,我们用的都是学号,到家都是固定用户,没有临时用户。所以我在这里就仅仅使用了固定用户。
3、我认为学生信息和卡信息应该分开,但是卡号就是学号。卡信息里有学号,两者相等,学号时外键。
两个表如下图:




【披荆斩棘】
代码:
U层:
                    Entity.CardInfo cardInfo = new Entity.CardInfo();                    cardInfo.CardID = ID;                    Facade.QueryFacade facadeCardRemainingSum = new Facade.QueryFacade();                    List<Entity.CardInfo> CardIDList = new List<Entity.CardInfo>();                    CardIDList = facadeCardRemainingSum.cardQueryInfo(CardInfo);                    #region UI显示卡信息                    lblStatetxt.Text = CardIDList[0].State.ToString();                    lblBalancetxt.Text = CardIDList[0].RemainingSum.ToString();                    lblRegisterMantxt.Text = CardIDList[0].Register.ToString();                    lblIsChecktxt.Text = CardIDList[0].IsCheck.ToString();                    #endregion
F层
        #region 查询学生余额:显示该卡号的学生信息         public List<Entity.StudentInfo> studentQueryInfo(Entity.StudentInfo StudentInfo)        {            BLL.QueryBLL bllStudentQuetyInfo = new BLL.QueryBLL();            List<Entity.StudentInfo> List = new List<Entity.StudentInfo>();            List = bllStudentQuetyInfo.studentQueryInfo(StudentInfo);            return List;        }        #endregion
B层
        #region 查询学生余额:显示该卡号的学生信息        public List<Entity.StudentInfo> studentQueryInfo(Entity.StudentInfo StudentInfo)        {            Factory.FactoryAll factoryStudentQueryInfo = new Factory.FactoryAll();             IDAL.QueryIDAL idalStudentQueryInfo = factoryStudentQueryInfo.studentQueryInfo();            List<Entity.StudentInfo> List = new List<Entity.StudentInfo>();            List = idalStudentQueryInfo.studentQueryInfo(StudentInfo);            return List;        }        #endregion
D层
        #region 查询学生余额:显示该卡号的学生信息        public List<Entity.StudentInfo> studentQueryInfo(Entity.StudentInfo StudentInfo)        {            SqlHelper.SqlHelperAll sqlHelperStudentQueryInfo = new SqlHelper.SqlHelperAll();            string sql = "select * from Student_Info where StudentID=@StudentID";            SqlParameter[] sqlParams = { new SqlParameter(@"StudentID", StudentInfo.StudentID) };            DataTable result = sqlHelperStudentQueryInfo.ExecuteNomQuery(sql, CommandType.Text, sqlParams);            ConvertHelper ct = new ConvertHelper();            List<Entity.StudentInfo> List = new List<Entity.StudentInfo>();            List = ct.convertToList<Entity.StudentInfo>(result);            return List;        }        #endregion   
【筋斗云】