人才招聘网站系统毕业论文(2)

2019-03-03 10:05

系统分析与设计

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

using System.Data.SqlClient; using System.Configuration;

namespace DAL {

public class SQLHelper {

private SqlConnection conn = null; private SqlCommand cmd = null; private SqlDataReader sdr = null;

public SQLHelper() {

string connStr = ConfigurationManager.ConnectionStrings

[\].ConnectionString;

conn = new SqlConnection(connStr); }

private SqlConnection GetConn() {

if (conn.State == ConnectionState.Closed) {

conn.Open(); }

return conn; }

///

/// 执行不带参数的增删改SQL语句或存储过程 ///

/// /// ///

public int ExecuteNonQuery(string cmdText, CommandType ct) {

int res; try {

cmd = new SqlCommand(cmdText, GetConn());

6

系统分析与设计

cmd.CommandType = ct;

res = cmd.ExecuteNonQuery(); }

catch (Exception ex) {

throw ex; }

finally {

if (conn.State == ConnectionState.Open) {

conn.Close(); } }

return res; }

///

/// 执行带参数的SQL增删改语句或存储过程 ///

/// /// ///

public int ExecuteNonQuery(string sql, SqlParameter[] paras,

CommandType ct)

{

int res;

using (cmd = new SqlCommand(sql, GetConn())) {

cmd.CommandType = ct;

cmd.Parameters.AddRange(paras); res = cmd.ExecuteNonQuery(); }

return res; }

///

/// 该方法执行传入的SQL查询语句或存储过程 ///

///

/// ///

7

系统分析与设计

public DataTable ExecuteQuery(string cmdText,CommandType ct) {

DataTable dt = new DataTable();

cmd = new SqlCommand(cmdText, GetConn()); cmd.CommandType = ct; using (sdr = cmd.ExecuteReader

(CommandBehavior.CloseConnection))

{

dt.Load(sdr); }

return dt; }

///

/// 执行带参数的查询SQL语句或存储过程 ///

/// /// /// /// public DataTable ExecuteQuery(string cmdText, SqlParameter[]

paras, CommandType ct)

{

DataTable dt = new DataTable();

cmd = new SqlCommand(cmdText, GetConn()); cmd.CommandType = ct;

cmd.Parameters.AddRange(paras); using (sdr = cmd.ExecuteReader

(CommandBehavior.CloseConnection))

{

dt.Load(sdr); }

return dt; } }

} 2.2.2、 DAL层实现数据库对表(CategoryDAO、CommentDAO、CompanyManageDAO、ManageDAO、UserManageDAO)的基本操作 /*

*招聘信息类别表的操作类 * 王溢文 */

using System;

using System.Collections.Generic;

8

系统分析与设计

using System.Linq; using System.Text; using System.Data;

using System.Data.SqlClient; using Model;

namespace DAL {

///

/// 招聘信息类别表的操作类 ///

public class CategoryDAO {

private SQLHelper sqlhelper = null; public CategoryDAO() {

sqlhelper = new SQLHelper(); }

///

/// 取出当前所有行业分类 ///

///

public DataTable SelectAll() {

DataTable dt = new DataTable();

string sql = \;

dt = sqlhelper.ExecuteQuery(sql,CommandType.Text); return dt; }

///

/// 增加分类 ///

/// ///

public bool Insert(string caName) {

bool flag = false;

string sql = \into category(name) values(@caName)\;

SqlParameter[] paras = new SqlParameter[] {

new SqlParameter(\,caName) }; int res =

9

系统分析与设计

sqlhelper.ExecuteNonQuery(sql,paras,CommandType.Text); if (res > 0) {

flag = true; }

return flag; }

///

/// 删除分类(连同其下招聘信息及询问一起删除) ///

///

public bool Delete(string id) {

bool flag = false;

string sql = \; SqlParameter[] paras = new SqlParameter[] {

new SqlParameter(\,id) };

int res = sqlhelper.ExecuteNonQuery(sql, paras,

CommandType.Text);

if (res > 0) {

flag = true; }

return flag; }

///

/// 修改分类 ///

///

/// ///

public bool Update(Category ca) {

bool flag = false;

string sql = \category set [name]=@caName where id

= @id\;

SqlParameter[] paras = new SqlParameter[]{ new SqlParameter(\,ca.Id),

new SqlParameter(\,ca.Name) };

int res = sqlhelper.ExecuteNonQuery(sql, paras,

10


人才招聘网站系统毕业论文(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2015-2020年中国铬锆铜市场深度调查及市场现状报告

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: