后台三层Dal层调用存储过程

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using System.Data.SqlClient;
using Newtonsoft.Json;
using System.Data;
using System.Configuration;
namespace Dal
{
public class UserInfoDal
{
/// <summary>
/// 添加数据
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int Add(UserInfoModel model)
{
string str = "un_Add";
SqlParameter paras = new SqlParameter("@XQ", model.XiaoQuID);
SqlParameter paras1 = new SqlParameter("@DongHao", model.DongHao);
SqlParameter paras2 = new SqlParameter("@CengHao", model.CengHao);
SqlParameter paras3 = new SqlParameter("@FangHao", model.FangHao);
SqlParameter paras4 = new SqlParameter("@FangHaoMiabJi", model.FangYuanMianJi);
SqlParameter paras5 = new SqlParameter("@JiZuMianJi", model.JiZuMianJi);
SqlParameter paras6 = new SqlParameter("@HuXing", model.HuXingID);
SqlParameter paras7 = new SqlParameter("@JianZhu", model.JID);
SqlParameter paras8 = new SqlParameter("@ZuoLuo", model.ZuoLuo);
SqlParameter paras9 = new SqlParameter("@WeiZhi", model.WeiZhi);
SqlParameter paras10 = new SqlParameter("@XingZhi ", model.XingZhiID);
SqlParameter paras11 = new SqlParameter("@ZhuangTai", model.ZhuangTaiID);

SqlParameter[] marter = new SqlParameter[] { paras, paras1, paras2, paras3, paras4, paras5, paras6, paras7, paras8, paras9, paras10, paras11 };

return DBHelper.ExecuteNonQuery(str, marter);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public int Delete(int id)
{
string str = "up_Delete";
SqlParameter paraSid = new SqlParameter("@id", id);
SqlParameter[] paras = new SqlParameter[] { paraSid };
return DBHelper.ExecuteNonQuery(str, paras);
}
/// <summary>
/// 批量删除
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
public int DeleteIds(string ids)
{
string str = "up_DelPi";
SqlParameter paraSid = new SqlParameter("@ids", ids);
SqlParameter[] paras = new SqlParameter[] { paraSid };
int i = DBHelper.ExecuteNonQuery(str, paras);
return i;
}



/// <summary>
/// 分页
/// </summary>
/// <param name="json"></param>
/// <returns></returns>
public PageOut DataBind(string json)
{
PagePut pageput = JsonConvert.DeserializeObject<PagePut>(json);
SqlParameter[] paras = {
new SqlParameter("@tableName",pageput.tableName),
new SqlParameter("@indexCol",pageput.indexCol),
new SqlParameter("@pageSize",pageput.pageSize),
new SqlParameter("@pageIndex",pageput.pageIndex),
new SqlParameter ("@orderCol",pageput.orderCol),
new SqlParameter("@where",pageput.where),
new SqlParameter("@columns",pageput.columns),

};
DataSet ds = DBHelper.GetDataSet("up_selMainInfo", paras);
DataTable dt = ds.Tables[0]; //获取数据信息
int size = pageput.pageSize; //每页条数
int count = Convert.ToInt32(ds.Tables[1].Rows[0][0]); // 获取总条数
int sumpage = count / size + (count % size > 0 ? 1 : 0); //总页数判断

PageOut pageout = new PageOut();
pageout.tCount = count;
pageout.tPage = sumpage;
pageout.tDt = dt;

return pageout;
}
/// <summary>
/// 小区下拉列表
/// </summary>
/// <returns></returns>
public DataTable XiaoQu()
{
string str = "un_XiaoQu";
DataTable dt = DBHelper.GetDataTable(str);
return dt;
}
/// <summary>
/// 栋号下拉列表
/// </summary>
/// <returns></returns>
public DataTable DongHao()
{
string str = "un_DongHao";
DataTable dt = DBHelper.GetDataTable(str);
return dt;
}
/// <summary>
/// 户型
/// </summary>
/// <returns></returns>
public DataTable HuXing()
{
string str = "select * from HuXing";
DataTable dt = DBHelper.GetDataTable(str);
return dt;
}
/// <summary>
/// 建筑结构下拉
/// </summary>
/// <returns></returns>
public DataTable JianZhu()
{
string str = "select * from JianZhu";
DataTable dt = DBHelper.GetDataTable(str);
return dt;
}
/// <summary>
/// 性质表下拉
/// </summary>
/// <returns></returns>
public DataTable XingZhi()
{
string str = "select * from XingZhi";
DataTable dt = DBHelper.GetDataTable(str);
return dt;
}
/// <summary>
/// 状态下拉
/// </summary>
/// <returns></returns>
public DataTable ZhuangTai()
{
string str = "select * from ZhuangTai";
DataTable dt = DBHelper.GetDataTable(str);
return dt;
}
}
}

posted @ 2018-08-23 09:04  相安  阅读(433)  评论(0编辑  收藏  举报