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

namespace DAL
{
    public class dept
    {
        public bool insert(Model.dept Dep)
        {
            string sql = "insert into T_Bumen  values (@deptid,@deptname,@deptintro)";
            List<SqlParameter> lists = new List<SqlParameter>();
            lists.Add(new SqlParameter("@deptid", Dep.deptid));
            lists.Add(new SqlParameter("@deptname", Dep.deptname));
            lists.Add(new SqlParameter("@deptintro", Dep.deptintro));
            return DBUtility.SQLHelper.Execute(sql, lists);
        }
        public bool update(Model.dept Dep, string olddeptid)
        {
            string sql = "update T_Bumen set deptid=@deptid,deptname=@deptname,deptintro=@deptintro where deptid=@olddeptid";
            List<SqlParameter> lists = new List<SqlParameter>();

            lists.Add(new SqlParameter("@deptid", Dep.deptid));
            lists.Add(new SqlParameter("@deptname", Dep.deptname));
            lists.Add(new SqlParameter("@deptintro", Dep.deptintro));
            lists.Add(new SqlParameter("@olddeptid", olddeptid));
            return DBUtility.SQLHelper.Execute(sql, lists);
        }
        public bool delete(string deptid)
        {
            string sql = "delete from T_Bumen where deptid=@deptid";
            List<SqlParameter> lists = new List<SqlParameter>();
            lists.Add(new SqlParameter("@deptid", deptid));
            return DBUtility.SQLHelper.Execute(sql, lists);
        }



        public DataTable select(string strWhere)
        {
            string sql = "select * from T_Bumen";
            if (strWhere != "")
            {
                sql += " where " + strWhere;
            }
            return DBUtility.SQLHelper.GetDataTable(sql);
        }
    }
}
