后台调用存储过程

 1 public JsonResult GetResult(string p_account_month_to)
 2 
 3 {
 4 
 5 SqlParameter[] param =
 6 
 7 {
 8 
 9 new SqlParameter("@p_org_info_id ", SqlDbType.Int),
10 
11 new SqlParameter("@p_customer_info_id ", SqlDbType.Int),
12 
13 new SqlParameter("@p_account_month_from", SqlDbType.VarChar, 6),
14 
15 new SqlParameter("@p_account_month_to", SqlDbType.VarChar, 6),
16 
17 new SqlParameter("@p_user_name", SqlDbType.VarChar, 50),
18 
19 new SqlParameter("@p_feedback", SqlDbType.VarChar, 500)
20 
21 };
22 
23 param[0].Value = base.org_info_id;
24 
25 param[1].Value = base.customer_info_id;
26 
27 param[2].Value = "";
28 
29 param[3].Value = p_account_month_to;
30 
31 param[4].Value = base.userName;
32 
33 param[5].Direction = ParameterDirection.Output;//返回的值
34 
35 using (EFContext context = new EFContext())
36 
37 {
38 
39 var results =
40 
41 context.Database.ExecuteSqlCommand(
42 
43 "fm_init_opening_balance @p_org_info_id,@p_customer_info_id ,@p_account_month_from,@p_account_month_to,@p_user_name,@p_feedback output",
44 
45 param[0], param[1], param[2], param[3], param[4], param[5]);
46 
47 context.Dispose();
48 
49 }
50 
51 var msg = param[5].Value;
52 
53 return Json(msg, JsonRequestBehavior.AllowGet);

 

posted @ 2016-12-13 10:19  华家宝贝冬冬  阅读(960)  评论(0编辑  收藏  举报