/// <summary>
/// /显示分页
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public PagesOut<Stu> GetDataList(ProcPrams model)
{
SqlParameter[] pam =
{
new SqlParameter("@TableName",model.TableName),
new SqlParameter("@indexCol",model.IndexCol),
new SqlParameter("@PageSize",model.PageSize),
new SqlParameter("@PageIndex",model.PageIndex),
new SqlParameter("@OrderCol",model.OrderCol),
new SqlParameter("@Where",model.Where),
new SqlParameter("@Columns",model.Columns),
};
DataSet ds = DbHelperSQL.ExecuteDataset(DbHelperSQL.ConnB2c, CommandType.StoredProcedure, "p_paging", pam);
var list = JsonConvert.DeserializeObject<List<Stu>>(JsonConvert.SerializeObject(ds.Tables[0]));
PagesOut<Stu> lis = new PagesOut<Stu>();
lis.list = list;
lis.SumCount = Convert.ToInt32(ds.Tables[1].Rows[0][0]);
return lis;
}
/// <summary>
/// 添加
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int InsertData(Stu model)
{
SqlParameter[] pam =
{
new SqlParameter("@Name",model.Name),
new SqlParameter("@Age",model.Age),
new SqlParameter("@Sex",model.Sex),
new SqlParameter("@StatId",model.StatId),
};
int i = DbHelperSQL.ExecuteNonQuery(DbHelperSQL.ConnB2c, CommandType.StoredProcedure, "p_Add", pam);
return i;
}
/// <summary>
/// 删除
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public int DeleteData(int id)
{
SqlParameter[] pam =
{
new SqlParameter("@ID",id)
};
int i = DbHelperSQL.ExecuteNonQuery(DbHelperSQL.ConnB2c, CommandType.StoredProcedure, "p_Del", pam);
return i;
}
//根据id获取
public Stu GetId(int id)
{
string sql = "select * from Stu where ID=" + id;
DataTable dt = DbHelperSQL.ExecuteDataTable(DbHelperSQL.ConnB2c, CommandType.Text, sql, null);
List<Stu> list = JsonConvert.DeserializeObject<List<Stu>>(JsonConvert.SerializeObject(dt));
return list.FirstOrDefault();
}
/// <summary>
/// 修改
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdataData(Stu model)
{
SqlParameter[] pam =
{
new SqlParameter("@ID",model.ID),
new SqlParameter("@Name",model.Name),
new SqlParameter("@Age",model.Age),
new SqlParameter("@Sex",model.Sex),
new SqlParameter("@StatId",model.StatId),
};
int i = DbHelperSQL.ExecuteNonQuery(DbHelperSQL.ConnB2c, CommandType.StoredProcedure, "p_update", pam);
return i;
}