DAL

SQLSERVER类库
CityDal.cs
public class CityDal : CityType
{
public int DeleteInfos(string id)
{
throw new NotImplementedException();
}

    public List<ProductMades> GetCityType()
    {

        return JsonConvert.DeserializeObject<List<ProductMades>>(JsonConvert.SerializeObject(DbHelperSQL.ExecuteDataTable(DbHelperSQL.ConnB2c, CommandType.StoredProcedure, "up_ShowProductMades", null)));
    }

    public ProductMades GetInfoById(ProductMades model)
    {
        throw new NotImplementedException();
    }

    public int InsertInfos(ProductMades model)
    {
        throw new NotImplementedException();
    }

    public int UpdateInfos(ProductMades model)
    {
        throw new NotImplementedException();
    }
}
ProInfosDal.cs
  public class ProInfosDal : IProductInfosDal//实现接口
{
    /// <summary>
    /// 显示信息,分页,搜索
    /// </summary>
    /// <param name="json"></param>
    /// <returns></returns>
    public DataModel ShowBinds(string json)
    {
        FenPage page = JsonConvert.DeserializeObject<FenPage>(json);//参数封装的一个类
        int size = page.pageSize;//定义每一页显示的数据
        SqlParameter[] par =
        {
            new SqlParameter("@tableName",page.tableName),//表名
            new SqlParameter("@indexCol",page.indexCol),//标识列名
            new SqlParameter("@pageSize",page.pageSize),//每页显示的数据
            new SqlParameter("@pageIndex",page.pageIndex),//当前页
            new SqlParameter("@orderCol",page.orderCol),//排序
            new SqlParameter("@where",page.where),//条件
            new SqlParameter("@columns",page.columns),//显示的列

        };
        DataSet ds = DbHelperSQL.ExecuteDataset(DbHelperSQL.ConnB2c, CommandType.StoredProcedure, "up_PageProductInfos", par);
        DataTable dt = ds.Tables[0];
        int count = Convert.ToInt32(ds.Tables[1].Rows[0][0]);//获取条数
        int sumpage = count / size + (count % size > 0 ? 1 : 0);//获取页数
        DataModel dm = new DataModel();//输入类
        dm.tCount = count;//总条数
        dm.tPage = sumpage;//总页数
        dm.proinfos = dt;//数据信息
        return dm;
    }

    /// <summary>
    /// 删除产品信息
    /// </summary>
    /// <param name="ids"></param>
    /// <returns></returns>
    public int DeleteInfos(string id)
    {
        SqlParameter[] par =
        {
            new SqlParameter("@proid",id)
        };
        return DbHelperSQL.ExecuteNonQuery(DbHelperSQL.ConnB2c, CommandType.StoredProcedure, "up_DeleteProductInfos", par);
    }

    public ProductInfos GetInfoById(ProductInfos model)
    {
        throw new NotImplementedException();
    }

    /// <summary>
    /// 添加产品信息
    /// </summary>
    /// <param name="model"></param>
    /// <returns></returns>
    public int InsertInfos(ProductInfos model)
    {
        SqlParameter[] par =
        {
            new SqlParameter("@proname",model.ProductName),
            new SqlParameter("@proprice",model.ProductPrice),
            new SqlParameter("@proimage",model.ProductImage),
            new SqlParameter("@pmdid",model.PId),
            new SqlParameter("@prodate",model.ProductDate)
        };
        return DbHelperSQL.ExecuteNonQuery(DbHelperSQL.ConnB2c,CommandType.StoredProcedure, "up_AddProductInfos",par);
    }

    /// <summary>
    /// 修改产品信息
    /// </summary>
    /// <param name="model"></param>
    /// <returns></returns>
    public int UpdateInfos(ProductInfos model)
    {
        SqlParameter[] par =
       {
             new SqlParameter("@pid",model.ID),
            new SqlParameter("@proname",model.ProductName),
            new SqlParameter("@proprice",model.ProductPrice),
            new SqlParameter("@proimage",model.ProductImage),
            new SqlParameter("@paid",model.PId),
            new SqlParameter("@prodate",model.ProductDate)
        };
        return DbHelperSQL.ExecuteNonQuery(DbHelperSQL.ConnB2c,CommandType.StoredProcedure, "up_UpdateProductInfos",par);
    }
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值