登陆系统

数据库

create database Test
go

use Test;
go

create table UserInfo
(
    id int primary key identity(1,1),
    name varchar(20) not null unique,
    pwd  varchar(12) not null,
    role int default(0) check(role=0 or role=1)
)

BLL

using DAL;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BLL
{
    public class UserInfoBLL
    {
        public static UserInfo Select(string name, string pwd)
        {
            return UserInfoDAL.Select(name, pwd);
        }
    }
}

DAL

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using SqlData = System.Data.SqlClient.SqlDataAdapter;


namespace DAL
{
    public class SqlHelper
    {

        //连接字段
        private static string strConn = ConfigurationManager.ConnectionStrings["sql"].ConnectionString;

        //查询
        public static DataTable Query(string sql)
        {
            SqlData adapter = new SqlData(sql, strConn);
            DataTable table = new DataTable();
            adapter.Fill(table);
            return table;
        }

        //非查询  using     close
        public static int NonQuery(string sql)
        {
            using (SqlConnection sqlConnection = new SqlConnection(strConn))
            {
                using (SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection))
                {
                    sqlConnection.Open();
                    return sqlCommand.ExecuteNonQuery();
                }
            }
        }
    }
}

 

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using SqlData = System.Data.SqlClient.SqlDataAdapter;


namespace DAL
{
    public class SqlHelper
    {

        //连接字段
        private static string strConn = ConfigurationManager.ConnectionStrings["sql"].ConnectionString;

        //查询
        public static DataTable Query(string sql)
        {
            SqlData adapter = new SqlData(sql, strConn);
            DataTable table = new DataTable();
            adapter.Fill(table);
            return table;
        }

        //非查询  using     close
        public static int NonQuery(string sql)
        {
            using (SqlConnection sqlConnection = new SqlConnection(strConn))
            {
                using (SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection))
                {
                    sqlConnection.Open();
                    return sqlCommand.ExecuteNonQuery();
                }
            }
        }
    }
}

Model

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Model
{
    public class UserInfo
    {
        public int Id { get; set; }

        public string Name { get; set; }

        public string Pwd { get; set; }

        public int Role { get; set; }
    }
}
 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值