using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace DAL
{
   public  class worker
    {
       model.worker mw = new model.worker();
        public bool inserus(model.worker mw)
        {
            string sql = "insert into T_YuangongXinxi values (@userid,@username,@usersex,@userbirthday,@userzhiwei,@userschool,@usertel)";
            List<SqlParameter> lists = new List<SqlParameter>();
            lists.Add(new SqlParameter("@userid", mw.userid));
            lists.Add(new SqlParameter("@username", mw.username));
            lists.Add(new SqlParameter("@usersex", mw.usersex));
            lists.Add(new SqlParameter("@userbirthday", mw.userbirthday));
            lists.Add(new SqlParameter("@userzhiwei", mw.userzhiwei));
            lists.Add(new SqlParameter("@userschool", mw.userschool));
            lists.Add(new SqlParameter("@usertel", mw.usertel));
            return DBUtility.SQLHelper.Execute(sql, lists);

        }
        public bool delete(string userid)
        {
            string sql = "delete from T_YuangongXinxi where userid=@userid";
            List<SqlParameter> lists = new List<SqlParameter>();
            lists.Add(new SqlParameter("@userid", userid));
            return DBUtility.SQLHelper.Execute(sql, lists);
        }
        public DataSet select(string strWhere)
        {
            string sql = "select * from T_YuangongXinxi";
            if (strWhere != "")
            {
                sql += " where " + strWhere;
            }
            return DBUtility.SQLHelper.query(sql);
        }
        public bool update(model.worker mw, string olduserid)
        {
            string sql = "update T_YuangongXinxi set userid=@userid,username=@username,usersex=@usersex,userbirthday=@userbirthday,userzhiwei=@userzhiwei,userschool=@userschool,usertel=@usertel where userid=@olduserid";
            List<SqlParameter> lists = new List<SqlParameter>();
            lists.Add(new SqlParameter("@userid", mw.userid));
            lists.Add(new SqlParameter("@username", mw.username));
            lists.Add(new SqlParameter("@usersex", mw.usersex));
            lists.Add(new SqlParameter("@userbirthday", mw.userbirthday));
            lists.Add(new SqlParameter("@userzhiwei", mw.userzhiwei));
            lists.Add(new SqlParameter("@userschool", mw.userschool));
            lists.Add(new SqlParameter("@usertel", mw.usertel));
            lists.Add(new SqlParameter("@olduserid",olduserid));
            return DBUtility.SQLHelper.Execute(sql, lists);
        }

     
    }
}
