zoukankan      html  css  js  c++  java
  • 煤矿粉尘监控系统中心站软件3层设计

    这些天忙着其他事情好久没来博客园看了,新增一篇博客也算是对项目进度的鞭策吧。

    第一步打开文件新建一个项目为空白解决方案,选择保存位置;

    第二在解决方案名称上单击鼠标右键,在弹出的快捷菜单中选择"添加"→"新建项目",选择window应用窗体程序;

    第三同样的步骤,打开新建项目,选择类库分别建立实现数据访问层、业务逻辑访问层、模型层。

    第四三层结构的基本框架已经搭建成功,但是各层之间是独立的,只有添加依赖关系,才能让它们相互协作;

    添加表示层对业务逻辑层及模型层的依赖,业务逻辑层中添加对数据访问层和模型层的依赖,以及数据访问层对模型层的依赖。

    上图:

    到此三层结构及各层之间的依赖关系创建完毕,下面实现登录功能:

    模型层:

    View Code
     public class User
        {
            public User() { }
            public int id;
            public int Id
            {
                get { return id; }
                set { id = value; }
            }
            public string Loginname;
            private string LoginName
            {
                get { return Loginname; }
                set { Loginname = value; }
            }
            public string Loginpwd;
            private string LoginPwd
            {
                get { return Loginpwd; }
                set { Loginpwd = value; }
            }
            public string Logincount;
            private string LoginCount
            {
                get { return Logincount; }
                set { Logincount = value; }
            }
            public string Logintime;
            private string LoginTime
            {
                get { return Logintime; }
                set { Logintime = value; }
            }
            public string Loginip;
            private string LoginIp
            {
                get { return Loginip; }
                set { Loginip = value; }
            }
    
        }

    数据访问层:

    View Code
     public static User GetLoginDal(string uid,string pwd)
            {
                string strsql = "select * from [user] where username='" + uid + "' and password ='" + pwd + "'";
                using(SqlDataReader reader=Sqlhelper.GetReader(strsql))
                {
                    if (reader.Read())
                    {
                        User user = new User();
                        user.Loginname = (string)reader["username"];
                        user.Loginpwd = (string)reader["password"];
                        user.Logincount = reader["Logincount"].ToString();
                        user.Logintime = reader["Logintime"].ToString();
                        user.Loginip = (string)reader["ipaddress"];
                        reader.Close();
                        return user;
                    }
                    else
                    {
                        reader.Close();
                        return null;
                    }
                };
    
            }

    业务逻辑层:

    View Code
     public static class UserBLL
        {
            public static bool GetloginBll(string uid,string pwd)
            {
                User user = WFCenter.DAL.UserDal.GetLoginDal(uid, pwd);
                if (user.Loginpwd == pwd)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }

    应用层:

    View Code
     private void Btn1_Click(object sender, EventArgs e)
            {
                if (this.textBox1.Text.Trim().Length == 0)
                {
                    MessageBox.Show("用户名不能为空!");
                }
                if (this.textBox2.Text.Trim().Length == 0)
                {
                    MessageBox.Show("密码不能为空!");
                }
                if (UserBLL.GetloginBll(textBox1.Text, textBox2.Text))
                {
                    WFCenter wfc = new WFCenter();
                    this.Visible = false;
                    wfc.ShowDialog();
                    this.Close();
                }
    
            }

    登录界面显示界面:

    至此整个上位机3层结构设计完成,个人觉得作为一个项目负责人

    第一整个软件框架要打好,风格要确立;

    第二不要急于编码,先把功能模块化,然后分给手下做;

    第三少加点班,多看看博客园,哈哈。

    希望各位砖家抛砖引玉。。。。

    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    Docker容器监控(十)--技术流ken
    Docker跨主机通信(九)--技术流ken
    Docker多主机管理(八)--技术流ken
    Docker公共&本地镜像仓库(七)--技术流ken
    Docker镜像构建的两种方式(六)--技术流ken
    Docker网络(五)--技术流ken
    tomcat使用详解(week4_day2)--技术流ken
    haproxy使用演示--技术流ken
    xshell连接虚拟机详解--技术流ken
    grafana使用详解--技术流ken
  • 原文地址:https://www.cnblogs.com/newstart/p/2523747.html
Copyright © 2011-2022 走看看