using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace DAL
{
    public class cars
    {
        public bool insercar(model.car mc)
        {
            string sql = "insert into T_Car values (@c_carID,@c_cartype,@c_driver,@c_stau)";
            List<SqlParameter> lists = new List<SqlParameter>();
            lists.Add(new SqlParameter("@c_carID", mc.c_carID));
            lists.Add(new SqlParameter("@c_cartype", mc.c_cartype));
            lists.Add(new SqlParameter("@c_driver", mc.c_driver));
            lists.Add(new SqlParameter("@c_stau", mc.c_stau));
            return DBUtility.SQLHelper.Execute(sql, lists);
        }
        public bool delete(string c_carID)
        {
            string sql = "delete from T_Car where c_carID=@c_carID";
            List<SqlParameter> lists = new List<SqlParameter>();
            lists.Add(new SqlParameter("@c_carID", c_carID));
            return DBUtility.SQLHelper.Execute(sql, lists);
        }
        public DataSet select(string strWhere)
        {
            string sql = "select * from T_Car";
            if (strWhere != "")
            {
                sql += " where " + strWhere;
            }
            return DBUtility.SQLHelper.query(sql);
        }
        public bool update(model.car mc, string oldcarid)
        {
            string sql = "update T_Car set c_carID=@c_carID,c_cartype=@c_cartype,c_driver=@c_driver,c_stau=@c_stau where c_carID=@oldcarid";
            List<SqlParameter> lists = new List<SqlParameter>();
            lists.Add(new SqlParameter("@c_carID", mc.c_carID));
            lists.Add(new SqlParameter("@c_cartype", mc.c_cartype));
            lists.Add(new SqlParameter("@c_driver", mc.c_driver));
            lists.Add(new SqlParameter("@c_stau", mc.c_stau));
            lists.Add(new SqlParameter("@oldcarid", oldcarid));
            return DBUtility.SQLHelper.Execute(sql, lists);
        }
    }
}
