• 12-数据访问层


    using Entity;
    using System.Data.SqlClient;
    using System.Data;
    public class CarDAL
    {
    /// <summary>
    /// 添加房车信息
    /// </summary>
    /// <param name="car"></param>
    /// <returns></returns>
    public int CarAdd(Car car)
    {
    try
    {
    var parms = new[]
    {
    new SqlParameter("@ID",car.ID),
    new SqlParameter("@CarName",car.CarName),
    new SqlParameter("@CarPinPaiID",car.CarPinPaiID),
    new SqlParameter("@CarTypeID",car.CarTypeID),
    new SqlParameter("@CarTyoeID2",car.CarTyoeID2),
    new SqlParameter("@CarImg",car.CarImg),
    new SqlParameter("@CarRemark",car.CarRemark),
    new SqlParameter("@CarXingShi",car.CarXingShi),
    new SqlParameter("@CarQuDong",car.CarQuDong),
    new SqlParameter("@CarFaDongJi",car.CarFaDongJi),
    new SqlParameter("@CarZhouJu",car.CarZhouJu),
    new SqlParameter("@CarPaiLiang",car.CarPaiLiang),
    new SqlParameter("@CarZhiLiang",car.CarZhiLiang),
    new SqlParameter("@CarNiuJu",car.CarNiuJu),
    new SqlParameter("@CarZhengBei",car.CarZhengBei),
    new SqlParameter("@CarRanYou",car.CarRanYou),
    new SqlParameter("@CarYouXiang",car.CarYouXiang),
    new SqlParameter("@CarPriceID",car.CarPriceID),
    new SqlParameter("@CarXingTypeID",car.CarXingTypeID),
    new SqlParameter("@CarGroupID",car.CarGroupID),
    new SqlParameter("@CarZiXun",car.CarZiXun),
    new SqlParameter("@CarPaiFang",car.CarPaiFang),
    new SqlParameter("@CarPrice",car.CarPrice),
    new SqlParameter("@CarXingNum",car.CarXingNum),
    new SqlParameter("@CarTypeXing",car.CarTypeXing),
    new SqlParameter("@CarBaoYang",car.CarBaoYang),
    new SqlParameter("@CarGong",car.CarGong),
    new SqlParameter("@CarCreateTime",car.CarCreateTime),
    new SqlParameter("@CarBianSuXiang",car.CarBianSuXiang),
    new SqlParameter("@CarLongWidth",car.CarLongWidth),
    new SqlParameter("@CarZhanTing",car.CarZhanTing),
    new SqlParameter("@CarChangName",car.CarChangName),
    new SqlParameter("@CarChangAddress",car.CarChangAddress),
    new SqlParameter("@CarChangPhone",car.CarChangPhone),
    new SqlParameter("@CarChangRemark",car.CarChangRemark),
    new SqlParameter("@DataTable_Action_",car.DataTable_Action_)
    };
    var result = DBHelper.ExecuteNonQuery(CommandType.StoredProcedure, "Car_InsertUpdateDelete", parms);
    return result;
    }
    catch (Exception)
    {

    throw;
    }
    }
    /// <summary>
    /// 汽车品牌
    /// </summary>
    /// <returns></returns>
    public List<CarPinPai> GetCarPinPai()
    {
    return DBHelper.ExecuteObjects<CarPinPai>("select * from CarPinPai");
    }
    /// <summary>
    /// 汽车价格区间
    /// </summary>
    /// <returns></returns>
    public List<CarPrice> GetCarPrice()
    {
    return DBHelper.ExecuteObjects<CarPrice>("select * from CarPrice");
    }
    /// <summary>
    /// 汽车类型
    /// </summary>
    /// <returns></returns>
    public List<CarXingType> GetCarXingType()
    {
    return DBHelper.ExecuteObjects<CarXingType>("select * from CarXingType");
    }
    /// <summary>
    /// 汽车分组
    /// </summary>
    /// <returns></returns>
    public List<CarGroup> GetCarGroup()
    {
    return DBHelper.ExecuteObjects<CarGroup>("select * from CarGroup");
    }

    /// <summary>
    /// 图片添加
    /// </summary>
    /// <param name="carImg"></param>
    /// <returns></returns>
    public int AddImg(CarImg carImg)
    {
    string sql = string.Format("insert into CarImg values('{0}','{1}','{2}','{3}')", carImg.ImgTitle, carImg.ImgUlr, carImg.ImgTypeID, carImg.ImgTime);
    var result = DBHelper.ExecuteNonQuery(sql);
    return result;
    }
    /// <summary>
    /// 汽车分组
    /// </summary>
    /// <returns></returns>
    public List<CarImgType> GetCarImgType()
    {
    return DBHelper.ExecuteObjects<CarImgType>("select * from CarImgType");
    }
    /// <summary>
    /// 图片显示
    /// </summary>
    /// <returns></returns>
    public List<CarImg> GetImgList()
    {
    return DBHelper.ExecuteObjects<CarImg>("select a.*,b.CarImgTypeName AS CarImgTypeName from CarImg a join CarImgType b on a.ImgTypeID = b.ID ");
    }
    /// <summary>
    /// 删除
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    public int Delete(int id)
    {
    return DBHelper.ExecuteNonQuery(string.Format("DELETE dbo.CarImg WHERE ID ='{0}'", id));
    }
    /// <summary>
    /// 房车信息显示
    /// </summary>
    /// <returns></returns>
    public List<Car> GetCarList()
    {
    return DBHelper.ExecuteObjects<Car>("select * from Car");
    }
    }

  • 相关阅读:
    OCP-1Z0-053-V13.02-498题
    Oracle索引扫描算法
    dojo CsvStore简介
    Oracle预估的基数算法
    HTML多表头表格
    hql查询实例
    PGA突破pga_aggregate_target限制
    OCP-1Z0-053-V13.02-330题
    java 发送字节流图片,c++接收二进制流
    windows 7蓝屏解决办法
  • 原文地址:https://www.cnblogs.com/Wangyang11/p/10003344.html
Copyright © 2020-2023  润新知