未能显示下一个日期的数据

时间:2016-11-07 06:27:54

标签: jquery angularjs asp.net-mvc-5 webmethod

我正在创建一个网络应用,我想在其中显示多个日期的数据

如果我执行我的proc exec welcomepageproc 'admin','admin',''将会加载今天的所有数据

如果我执行我的proc exec welcomepageproc 'admin','admin','1'数据将在明天(即11月8日)显示,如果我执行我的proc,如exec welcomepageproc'admin','admin','2'那么数据将于11月9日出现

今天的数据显示正常,但无法显示明天的数据

下一个日期的数据将显示在下一个按钮点击

这是我的js文件,它显示了今天的数据并且工作正常

  $http.get("welcome", "welcomepage", {
    params:
    {
        log: 'admin',
        pm: 'admin',
        button:''
    }
})
.then(function (response)
{
    $scope.welcometable = response.data;
    console.log(response.data);
})

但是这个js文件无法向我显示数据

    $scope.nextbutton = function () {
        $scope.button = '1';
        $http.get("welcome", "welcomepage", {
            params:
            {
                log: 'admin',
                pm: 'admin',
                button: '1'
            }
        })
   .then(function (response) {
       $scope.welcometable = response.data;
       console.log(response.data);
   })

这是我的下一个按钮

<button type="button" class="btn btn-info" ng-model="nextbuttons" ng-click="nextbutton()">Next</button>

这是我控制器中的webmethod

public JsonResult welcome(string log, string pm, string button)
    {
        log = "admin";
        pm = "admin";
        button = "0";

        List<object> welcome = new List<object>();
        SqlCommand cmd = new SqlCommand("welcomepageproc");
        cmd.Connection = con;
        cmd.CommandType = CommandType.StoredProcedure;
        SqlParameter[] param =
        {
            new SqlParameter("@log",log),
            new SqlParameter("@pm",pm),
            new SqlParameter("@Button",button)
        };
        con.Open();
        cmd.Parameters.AddRange(param);
        SqlDataReader dr = cmd.ExecuteReader();
        while (dr.Read())
        {
            welcome.Add(new
            {
                date = dr["date"].ToString(),
                day = dr["day"].ToString(),
                Company = dr["Company"].ToString(),
                brandname = dr["Brand"].ToString(),
                zone = dr["zone"].ToString(),
                location = dr["location"].ToString(),
                area = dr["area"].ToString(),
                trainer = dr["trainer"].ToString(),
                starttime = dr["Start Time"].ToString(),
                endtime = dr["End Time"].ToString(),
                hrs = dr["hrs"].ToString(),
                program = dr["program"].ToString(),
                instructore = dr["instructore"].ToString()
            });
        }
        con.Close();
        var json = welcome;
        return Json(json, JsonRequestBehavior.AllowGet);
    }

如果我想在点击按钮上显示下一个日期,我需要做什么

(如果我点击下一个按钮两次,那么应该显示11月9日的数据,如果我点击3次,将显示10日的数据,这意味着每次下一次按钮点击时数据都会改变)

我的sql storedprocedure

    CREATE PROCEDURE welcomepageproc  
(    
@log varchar(50),    
@pm varchar(50),    
@Button int    
)    

AS    
BEGIN    
declare @from varchar(50)    
select @from=Convert(varchar(20),getdate(),105)    

 declare @var varchar(50)    
 select @var=@log  
if(@button=null)  
begin   
if(@var='Partner Manager')    

begin    
 select convert(varchar,sonvininsert.date,105) as Date,    
sonvininsert.day as [Day],companydetails.comname as Company,sonvininsert.brandname as Brand,    
sonvininsert.zone as Zone,sonvininsert.location as Location,sonvininsert.area as Area,    
sonvininsert.trainer as Trainer,sonvininsert.starttime as [Start Time],sonvininsert.endtime as[End Time],    
sonvininsert.hrs as Hrs,sonvininsert.program as Program,sonvininsert.instructore as Instructore      
from sonvininsert,companydetails     
where companydetails.pm=@pm and companydetails.id=sonvininsert.property     
and sonvininsert.date = Convert(varchar(20),getdate()+@Button,101)    
and sonvininsert.status='0'  order by date    
end    

else if(@var='Admin')    
begin    
select convert(varchar,sonvininsert.date,105) as Date,    
sonvininsert.day as [Day],companydetails.comname as[Company],sonvininsert.brandname as[Brand],    
sonvininsert.zone as Zone,sonvininsert.location as Location,sonvininsert.area as Area,    
sonvininsert.trainer as Trainer,sonvininsert.starttime as[Start Time],sonvininsert.endtime as [End Time],    
sonvininsert.hrs as Hrs,sonvininsert.program as Program,sonvininsert.instructore as Instructore      
from sonvininsert,companydetails    
 where sonvininsert.date =Convert(varchar(20),getdate()+@Button,101)    
 and companydetails.id=sonvininsert.property    
 and sonvininsert.status='0'  order by date    
end    
end  
else  
begin  
if(@var='Partner Manager')    

begin    
 select convert(varchar,sonvininsert.date,105) as Date,    
sonvininsert.day as [Day],companydetails.comname as Company,sonvininsert.brandname as Brand,    
sonvininsert.zone as Zone,sonvininsert.location as Location,sonvininsert.area as Area,    
sonvininsert.trainer as Trainer,sonvininsert.starttime as [Start Time],sonvininsert.endtime as[End Time],    
sonvininsert.hrs as Hrs,sonvininsert.program as Program,sonvininsert.instructore as Instructore      
from sonvininsert,companydetails     
where companydetails.pm=@pm and companydetails.id=sonvininsert.property     
and sonvininsert.date = Convert(varchar(20),getdate()+@Button,101)    
and sonvininsert.status='0'  order by date    
end    

else if(@var='Admin')    
begin    
select convert(varchar,sonvininsert.date,105) as Date,    
sonvininsert.day as [Day],companydetails.comname as[Company],sonvininsert.brandname as[Brand],    
sonvininsert.zone as Zone,sonvininsert.location as Location,sonvininsert.area as Area,    
sonvininsert.trainer as Trainer,sonvininsert.starttime as[Start Time],sonvininsert.endtime as [End Time],    
sonvininsert.hrs as Hrs,sonvininsert.program as Program,sonvininsert.instructore as Instructore      
from sonvininsert,companydetails    
 where sonvininsert.date =Convert(varchar(20),getdate()+@Button,101)    
 and companydetails.id=sonvininsert.property    
 and sonvininsert.status='0'  order by date    
end  
end  
END

0 个答案:

没有答案