2016-12-06 11 views
1

私はデータを取り出すウェブアプリケーションを作成しています(従業員の経費)。テーブルの金額を計算します。

すべての金額を計算して金額を印刷したいと思います。

私はデータをフェッチするためにangularjsを使用しています。ここで

は私のテーブルです:

<tr> 
       <th colspan="2" style="border:1px solid black">Payment Id</th> 
       <th colspan="2" style="border:1px solid black">Date Of Issue</th> 
       <th colspan="2" style="border:1px solid black">Date Of Trainer</th> 
       <th colspan="1" style="border:1px solid black">Training Id</th> 
       <th colspan="2" style="border:1px solid black">Payment Mode</th> 
       <th colspan="2" style="border:1px solid black">Cheque/ UTR no</th> 
       <th style="border:1px solid black">Amount</th> 
      </tr> 
      <tr ng-repeat="i in getexpenseinfo"> 
       <td colspan="2" style="border:1px solid black">{{i.paymentid}}</td> 
       <td colspan="2" style="border:1px solid black">{{i.dateofissue}}</td> 
       <td colspan="2" style="border:1px solid black">{{i.dateoftransfer}}</td> 
       <td colspan="1" style="border:1px solid black">{{i.trainingid}}</td> 
       <td colspan="2" style="border:1px solid black">{{i.paymentmode}}</td> 
       <td colspan="2" style="border:1px solid black">{{i.chequeno}}</td> 
       <td style="border:1px solid black">{{i.amount}}</td> 
      </tr> 

{{i.amount}}がここ費に費やした金額をフェッチしている同じ

$http.get('/paymentrpt.asmx/expenseinforpt', { 
       params: { 
        datefrm: $scope.datefrm, 
        dateto: $scope.dateto, 
        empname: $scope.emp 
       } 
      }).then(function (response) { 

       $scope.getexpenseinfo = response.data.info; 
       $scope.pageload = false; 
      }); 

と私はデータをフェッチしています私のWebサービスのための私のコントローラです。

[WebMethod] 
     [ScriptMethod(UseHttpGet = true)] 
     public void expenseinforpt(string datefrm, string dateto, string empname) 
     { 
      List<object> expenseinfo = new List<object>(); 
      SqlCommand cmd = new SqlCommand("prolltexpense", con); 
      cmd.CommandType = CommandType.StoredProcedure; 
      cmd.Connection = con; 
      con.Open(); 
      SqlParameter[] param = { 
       new SqlParameter("@from",datefrm), 
       new SqlParameter("@to",dateto), 
       new SqlParameter("@trainer",empname) 
      }; 
      cmd.Parameters.AddRange(param); 
      SqlDataReader dr = cmd.ExecuteReader(); 
      while (dr.Read()) 
      { 
       expenseinfo.Add(new 
       { 
        trainingno = dr["trainingno"].ToString(), 
        expenseno=dr["expenseno"].ToString(), 
        expensehead=dr["expensehead"].ToString(), 
        amount=dr["amt"].ToString(), 
        remark=dr["remark"].ToString(), 
        claim=dr["gigeraccount1"].ToString() 
       }); 
      } 
      var json = js.Serialize(expenseinfo); 
      Context.Response.Write("{" + '"' + "info" + '"' + ":" + json + "}"); 
      con.Close(); 
     } 

これは私のストアドプロシージャです私は金額を取得しています:

CREATE PROCEDURE prolltexpense (@from varchar(50),@to varchar(50),@trainer varchar(50)) 

AS 
BEGIN 
select expense.trainingno,expense.expenseno,expense.expensehead,expense.amt,expense.remark,(case when expense.gigeraccount=1 then 'YES' when expense.gigeraccount=0 then 'NO' end) as gigeraccount1 from instructoreexpense left outer join sonvininsert on son 
vininsert.sonvinid=instructoreexpense.sonvinid left outer join finalinstructoreexpense on finalinstructoreexpense.sonvinid=instructoreexpense.sonvinid join expense on sonvininsert.trainingno=expense.trainingno where sonvininsert.date between convert(date 
time,@from,105) and convert(datetime,@to,105) and [email protected] order by sonvininsert.date 

END 

私はテーブルの量を計算する必要がありますか?

これは私のテーブルがどのように見えるかです:

Training Id Expense No. Expense Head Amount Remark Claim 
16100800002 16100800002001 Conveyance 20 Kurla to Mumbra Return by train NO 
16100800002 16100800002002 Conveyance 80 Mumbra stn. to School by auto Patrick, Kishan & me NO 
16100800002 16100800002003 Conveyance 45 School to Mumbra stn. by auto Patrick, Kisan & me NO 
16111800006 16111800006001 F&B 110 Dinner in train on 17th NO 
16111800006 16111800006002 Conveyance 18 Residence to Vile parle stn. by auto on 17th NO 
16111800006 16111800006003 Travelling 150 Hotel to Guru Nanak school by auto NO 
16111800006 16111800006004 Travelling 30 Guru nanak school to hotel by sharing auto and bus NO 
16111800006 16111800006006 Conveyance 18 Vile parle to residence by auto on 19th NO 
16111800006 16111800006005 F&B 287 Breakfast, Lunch & dinner NO 



(B) Payable 
0 

答えて

1

私は私ので、それはあなたにエラーを与えた場合、私に知らせてangularjsについて知っているが、uは、SQLサーバから簡単に

select sum (expense.amt) as totalamt 
from instructoreexpense left outer join sonvininsert on 
sonvininsert.sonvinid=instructoreexpense.sonvinid left outer join finalinstructoreexpense on 
finalinstructoreexpense.sonvinid=instructoreexpense.sonvinid join expense 
on sonvininsert.trainingno=expense.trainingno where sonvininsert.date 
between convert(datetime,@from,105) 
and convert(datetime,@to,105) and [email protected] 

を行うことができますいけませんあなたの与えられたコードを使用して、私は経費があなたのSQLでintまたはvarcharであるかわからない

関連する問題