标签:
获取接口的方法
public static T GetProvider<T>()
{
using (var kernal = new StandardKernel(new BusinessBinding()))
{
var provider = kernal.Get<T>();
return provider;
}
}
绑定接口
public override void Load()
{
Bind<ILPProvider>().To<LPProvider>();
}
接口IDAL写法
public interface ILPProvider
{
DataSet GetLPUser(string beginDate,string endDate,string clientID, string userID, string keywords, int status, int color, int index, int page, ref int tatal, string teamID, string seachUserID, int serchType,int sortName,int sortType, string searchClientID);
}
业务中写调用接口获取及接口方法,
var provider = Common.GetProvider<ILPProvider>();
DataSet data = provider.GetLPUser(beginDate,endDate,clientID, userID, keywords, (int)status, color, index, page, ref tatal, teamID, seachUserID, serchType, sortName, sortType, searchClientID);
数据接口DAL写法
public DataSet GetLPUser(string beginDate,string endDate,string clientID, string userID, string keywords, int status, int color, int index, int page, ref int total, string teamID, string seachUserID,
int serchType, int sortName, int sortType, string searchClientID)
{
using (SqlConnection conn = new SqlConnection(ConnectionString))
{
SqlCommand cmd = new SqlCommand("LP_GetLPList",conn);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
string SortName = "";
switch (sortName)
{
/**1.报备数
* 2.注册数
* 3.签约数
* 4.付费数
* 5.付费总额
* 6.加入时间
* 7.累计佣金
* **/
case 1:
SortName = "q.ReportNum";
break;
case 2:
SortName = "l.RegisterNum";
break;
case 3:
SortName = "l.SignNum";
break;
case 4:
SortName = "l.ExpenseNum";
break;
case 5:
SortName = "l.ExpenseAmount";
break;
case 6:
SortName = "l.AuditTime";
break;
case 7:
SortName = "l.HaveAmount";
break;
default:
SortName = "l.RegisterNum";
break;
}
cmd.Parameters.Add("@SortName", SqlDbType.VarChar, 50).Value = SortName;
cmd.Parameters.Add("@SortType", SqlDbType.Int).Value = sortType;
cmd.Parameters.Add("@FilterUserID", SqlDbType.VarChar, 64).Value = seachUserID;
cmd.Parameters.Add("@SerchType", SqlDbType.Int).Value = serchType;
cmd.Parameters.Add("@ClientID", SqlDbType.VarChar, 64).Value = clientID;
cmd.Parameters.Add("@UserID",SqlDbType.VarChar,64).Value=userID;
cmd.Parameters.Add("@KeyWords",SqlDbType.VarChar,100).Value=keywords;
cmd.Parameters.Add("@Status",SqlDbType.Int).Value=status;
cmd.Parameters.Add("@Color",SqlDbType.Int).Value=color;
cmd.Parameters.Add("@Index",SqlDbType.Int).Value=index;
cmd.Parameters.Add("@Page",SqlDbType.Int).Value=page;
cmd.Parameters.Add("@TeamID",SqlDbType.VarChar,64).Value=teamID;
cmd.Parameters.Add("@SearchClientID", SqlDbType.VarChar, 64).Value = searchClientID;
cmd.Parameters.Add("@BeginDate",SqlDbType.VarChar,32).Value = beginDate;
cmd.Parameters.Add("@EndDate", SqlDbType.VarChar, 32).Value = endDate;
cmd.Parameters.AddWithValue("@Total", total).Direction = ParameterDirection.InputOutput;
conn.Open();
DataSet data = new DataSet();
FillDataSet(data, cmd, "LP");
total = int.Parse(cmd.Parameters["@Total"].Value.ToString());
return data;
}
}
标签:
原文地址:http://www.cnblogs.com/ahlx/p/5226825.html