机房重构之学生查看上机记录

来源:互联网 发布:淘宝附近的人取消了吗 编辑:程序博客网 时间:2024/06/03 18:10

      敲完查看上机记录感觉很不容易,因为登录没搞懂,直接敲查看上机记录,代码完全照着登录的来,不过敲完能运行,还是有一点点小成就感,分享给大家,代码哪有不足的地方,请大家多多指点。

UI

namespace LoginUI{    public partial class frmStudentCkeck : Form    {        public frmStudentCkeck()        {            InitializeComponent();        }        private void butquiry_Click(object sender, EventArgs e)        {             if (textBox1.Text == "")            {                MessageBox.Show("请输入卡号!");            }            else            {                string cardno = textBox1.Text.Trim();                frmStudentCkeckFacade fscf = new frmStudentCkeckFacade();//实例化外观层                DataTable list = fscf.frmCheckFacede(cardno);//接收外观层穿过来的值                if (list.Rows.Count>0)                 {                     dataGridView1.Rows[0].Cells[0].Value = list.Rows[0][1];                     dataGridView1.Rows[0].Cells[1].Value = list.Rows[0][3];                     dataGridView1.Rows[0].Cells[2].Value = list.Rows[0][6];                     dataGridView1.Rows[0].Cells[3].Value = list.Rows[0][7];                     dataGridView1.Rows[0].Cells[4].Value = list.Rows[0][8];                     dataGridView1.Rows[0].Cells[5].Value = list.Rows[0][9];                     dataGridView1.Rows[0].Cells[6].Value = list.Rows[0][11];                     dataGridView1.Rows[0].Cells[7].Value = list.Rows[0][12];                     dataGridView1.Rows[0].Cells[8].Value = list.Rows[0][13];                                     }                          else              {                MessageBox .Show ("卡号不存在!");             }            }                                  }        private void textBox1_TextChanged(object sender, EventArgs e)        {            if (textBox1.Text.Length > 6)            {                MessageBox.Show("不能超过六个字");            }            Regex reg = new Regex(@"[^0-9]");//排除性字符组(取反思想)            if (reg.IsMatch(textBox1.Text.Trim()))            {                //textBox1.Text = "请输入有效数字!";                MessageBox.Show("请输入有效数字!");                textBox1.Text = "";                textBox1.Focus();            }                          }          }}

BLL
namespace BLL{   public  class StudentCheckBLL    {        public DataTable CheckBLL(string cardno)        {            factory fac = new factory();            StudentCheckIDAL fscI = fac.CreateStudentCheck();            //Factory.frmStudentCheckFoctory fscf = new Factory.frmStudentCheckFoctory();            //IDAL.StudentCheckIDAL fscI = fscf.frmstudenFoctory();            DataTable list = fscI.frmStudent(cardno);            return list;                        }    }}
DAL
namespace DAL{    public class StudentCkeckDAL:IDAL .StudentCheckIDAL     {        public DataTable ICheckIDAL(string cardno)        {            SqlParameter ps = new SqlParameter("@cardno", cardno );            string sql = "select * from Line_info where cardno = @cardno";            //return SqlHelper.GetDataTable(sql, ps);            DataTable  list = SqlHelper .GetDataTable (sql,ps );            return list ;        }        public DataTable frmStudent(string cardno)        {            SqlParameter ps = new SqlParameter("@cardno", cardno);            string sql = "select * from Line_info where cardno = @cardno";            return SqlHelper.GetDataTable(sql, ps);        }    }}
Facade
namespace Facade{     public  class frmStudentCkeckFacade    {         public DataTable frmCheckFacede(string cardno)        {            StudentCheckBLL SCB = new StudentCheckBLL();            DataTable list = SCB.CheckBLL(cardno);            return list;         }                 }}
Factory
namespace Factory{    public class frmStudentCheckFoctory    {        public IDAL.StudentCheckIDAL CreateInstance()        {            string strDB = System.Configuration.ConfigurationManager.AppSettings["DB"]; // 读取配置文件              string name = strDB + "." + "frmStudentCkeckDAL";            IDAL.StudentCheckIDAL fscI = (IDAL.StudentCheckIDAL)Assembly.Load("DAL").CreateInstance(name);            return fscI;        }    }}
IDAL
namespace IDAL{    public  interface  StudentCheckIDAL    {        DataTable ICheckIDAL(string cardno);        DataTable frmStudent(string cardno);    }}

原创粉丝点击