Model层
using System;
namespace TSMS.Model
{
/// <summary>
/// 描述员工的在职状态
/// </summary>
[Serializable]
public partial class tb_potential
{
public tb_potential()
{}
#region Model
private int _potstuid;
private string _stuname;
private string _stupho;
private string _stuparentpho;
private string _stuadress;
private string _sturemarks;
/// <summary>
///
/// </summary>
public int potstuid
{
set{ _potstuid=value;}
get{return _potstuid;}
}
/// <summary>
///
/// </summary>
public string stuname
{
set{ _stuname=value;}
get{return _stuname;}
}
/// <summary>
///
/// </summary>
public string stupho
{
set{ _stupho=value;}
get{return _stupho;}
}
/// <summary>
///
/// </summary>
public string stuparentpho
{
set{ _stuparentpho=value;}
get{return _stuparentpho;}
}
/// <summary>
///
/// </summary>
public string stuadress
{
set{ _stuadress=value;}
get{return _stuadress;}
}
/// <summary>
///
/// </summary>
public string sturemarks
{
set{ _sturemarks=value;}
get{return _sturemarks;}
}
#endregion Model
}
}
Dal层
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TSMS.Model;
using TSMS.Common;
using System.Data.SqlClient;
using System.Data;
namespace TSMS.DAL
{
public class Dalpotential:IDalData<tb_potential>
{
SqlHelper _sqlhelper = new SqlHelper();
/// <summary>
/// 添加潜在学生
/// </summary>
/// <param name="t"></param>
/// <returns></returns>
public bool InsertItem(tb_potential t)
{
SqlParameter[] parameters =
{
new SqlParameter("@stuname",SqlDbType.NVarChar,12),
new SqlParameter("@stupho",SqlDbType.VarChar,11),
new SqlParameter("@stuparentpho",SqlDbType.VarChar,11),
new SqlParameter("@stuadress",SqlDbType.NVarChar,50),
new SqlParameter("@sturemarks",SqlDbType.NVarChar,120)
};
parameters[0].Value = t.stuname;
parameters[1].Value = t.stupho;
parameters[2].Value = t.stuparentpho;
parameters[3].Value = t.stuadress;
parameters[4].Value = t.sturemarks;
string sql = @"INSERT INTO [tb_potential] ([stuname],[stupho],[stuparentpho],[stuadress],[sturemarks])
VALUES (@stuname,@stupho,@stuparentpho,@stuadress,@sturemarks)";
return _sqlhelper.ExecuteNonQurey(sql, CommandType.Text, parameters);
}
/// <summary>
/// 修改潜在学生信息
/// </summary>
/// <param name="t"></param>
/// <returns></returns>
public bool UpdateItem(tb_potential t)
{
SqlParameter[] parameters =
{
new SqlParameter("@stuname",SqlDbType.NVarChar,12),
new SqlParameter("@stupho",SqlDbType.VarChar,11),
new SqlParameter("@stuparentpho",SqlDbType.VarChar,11),
new SqlParameter("@stuadress",SqlDbType.NVarChar,50),
new SqlParameter("@sturemarks",SqlDbType.NVarChar,120),
new SqlParameter("@potstuid",SqlDbType.Int)
};
parameters[0].Value = t.stuname;
parameters[1].Value = t.stupho;
parameters[2].Value = t.stuparentpho;
parameters[3].Value = t.stuadress;
parameters[4].Value = t.sturemarks;
parameters[5].Value = t.potstuid;
string sql = @"UPDATE tb_potential SET stuname=@stuname,stupho =@stupho,
stuparentpho= @stuparentpho,stuadress =@stuadress,sturemarks = @sturemarks
WHERE potstuid = @potstuid";
return _sqlhelper.ExecuteNonQurey(sql, CommandType.Text, parameters);
}
/// <summary>
/// 删除潜在学生信息
/// </summary>
/// <param name="t"></param>
/// <returns></returns>
public bool DeleteItem(string strSelected)
{
strSelected = strSelected.Trim(new char[] { ',' });//重要细节,慢慢研究
string sql = @"DELETE FROM [TSMS].[dbo].[tb_potential]
WHERE [potstuid] in (" + strSelected + ")";
return _sqlhelper.ExecuteNonQurey(sql, CommandType.Text);
}
public List<tb_potential> GetListModel()
{
throw new NotImplementedException();
}
public tb_potential GetModel(int id)
{
throw new NotImplementedException();
}
/// <summary>
/// 分页按钮
/// </summary>
/// <param name="condition"></param>
/// <param name="pageCount"></param>
/// <returns></returns>
public DataTable GetAllVacation(Condition condition, out int pageCount)
{
SqlParameter[] parameters =
{
new SqlParameter("@pageSize",SqlDbType.Int),
new SqlParameter("@pageIndex",SqlDbType.Int),
new SqlParameter("@tableName",SqlDbType.VarChar,50),
new SqlParameter("@priKey",SqlDbType.VarChar,20),
new SqlParameter("@condition",SqlDbType.VarChar,2000),
new SqlParameter("@sort",SqlDbType.VarChar,4),
new SqlParameter("@pageCount",SqlDbType.Int )
};
parameters[0].Value = condition.PageSize;
parameters[1].Value = condition.PageIndex;
parameters[2].Value = condition.TableName;
parameters[3].Value = condition.Prikye;
parameters[4].Value = condition.Condtion;
parameters[5].Value = condition.Pagesort;
parameters[6].Direction = ParameterDirection.Output;
string sql = @"exec proc_CommonSinglePage @pageSize,@pageIndex,@tableName,@priKey,@condition,@sort,@pagecount out";
DataTable db = _sqlhelper.GetDataTable(sql, CommandType.Text, parameters);
pageCount = (int)parameters[6].Value;
return db;
}
public bool DeleteItem(tb_potential t)
{
throw new NotImplementedException();
}
}
}
Bll层
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TSMS.DAL;
using TSMS.Model;
using System.Data;
namespace TSMS.BLL
{
public class Bllpotential
{
private Dalpotential dalpot = new Dalpotential();
/// <summary>
/// 新增一个潜在学生
/// </summary>
/// <param name="t"></param>
/// <returns></returns>
public bool InsertItem(tb_potential t)
{
return dalpot.InsertItem(t);
}
/// <summary>
/// 更新潜在学生信息
/// </summary>
/// <param name="t"></param>
/// <returns></returns>
public bool UpdateItem(tb_potential t)
{
return dalpot.UpdateItem(t);
}
/// <summary>
/// 删除潜在学生信息
/// </summary>
/// <param name="t"></param>
/// <returns></returns>
public bool DeleteItem(string strSelected)
{
return dalpot.DeleteItem(strSelected);
}
public DataTable GetAllVacation(Condition condition, out int pageCount)
{
return dalpot.GetAllVacation(condition, out pageCount);
}
}
}