using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using Test.IDAL;
using Maticsoft.DBUtility;//请先添加引用
namespace Test.SQLServerDAL
{
/// <summary>
/// 数据访问类Employees。
/// </summary>
public class Employees:IEmployees
{
public Employees()
{}
#region 成员方法
/// <summary>
/// 是否存在该记录
/// </summary>
public bool Exists(int ID)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select count(1) from TABLE1");
strSql.Append(" where ID=@ID ");
SqlParameter[] parameters = {
new SqlParameter("@ID", SqlDbType.Int,4)};
parameters[0].Value = ID;
return DbHelperSQL.Exists(strSql.ToString(),parameters);[color=#FF0000][/color] }
/// <summary>
/// 增加一条数据
/// </summary>
public int Add(Test.Model.Employees model)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("insert into TABLE1(");
strSql.Append("Emp_No,Emp_Name,Sex,Birthday,Wage,Picture)");
strSql.Append(" values (");
strSql.Append("@Emp_No,@Emp_Name,@Sex,@Birthday,@Wage,@Picture)");
strSql.Append(";select @@IDENTITY");
SqlParameter[] parameters = {
new SqlParameter("@Emp_No", SqlDbType.Char,10),
new SqlParameter("@Emp_Nam
DAL层的代码
最新推荐文章于 2020-06-17 22:26:50 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)