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

namespace DAL
{
    public class tel
    {
        public bool insert(Model.tel Dep)
        {
            string sql = "insert into T_Tel  values (@txname,@txmember,@txuser,@txintro)";
            List<SqlParameter> lists = new List<SqlParameter>();
            lists.Add(new SqlParameter("@txname", Dep.txname));
            lists.Add(new SqlParameter("@txmember", Dep.txmember));
            lists.Add(new SqlParameter("@txuser", Dep.txuser));
            lists.Add(new SqlParameter("@txintro", Dep.txintro));
            return DBUtility.SQLHelper.Execute(sql, lists);
        }
        public bool update(Model.tel Dep, string oldtxname)
        {
            string sql = "update T_Tel set txname=@txname,txmember=@txmember,txuser=@txuser,txintro=@txintro where txname=@oldtxname";
            List<SqlParameter> lists = new List<SqlParameter>();

            lists.Add(new SqlParameter("@txname", Dep.txname));
            lists.Add(new SqlParameter("@txmember", Dep.txmember));
            lists.Add(new SqlParameter("@txuser", Dep.txuser));
            lists.Add(new SqlParameter("@txintro", Dep.txintro));
            lists.Add(new SqlParameter("@oldtxname", oldtxname));
            return DBUtility.SQLHelper.Execute(sql, lists);
        }
        public bool delete(string txname)
        {
            string sql = "delete from T_Tel where txname=@txname";
            List<SqlParameter> lists = new List<SqlParameter>();
            lists.Add(new SqlParameter("@txname", txname));
            return DBUtility.SQLHelper.Execute(sql, lists);
        }



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