查询与加减

Posted xiaxinxin

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了查询与加减相关的知识,希望对你有一定的参考价值。

<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
<title>周考练习</title>
<script src="js/angular.min.js" type="text/javascript" charset="utf-8"></script>
<style type="text/css">
tr:nth-child(even) {
background: green;
}

tr:nth-child(odd) {
background: gold;
}
</style>
</head>

<body ng-app="myapp" ng-controller="myCtrl">
<h1>练习</h1>
<input type="text" placeholder="根据名称模糊查询" ng-model="name1" />
<table bgcolor="grey" border="1" cellpadding="0px" cellspacing="0px">
<tr>
<td ng-click="change1()">商品编号</td>
<td>商品名称</td>
<td>商品单价</td>
<td>商品数量</td>
<td ng-click="chang2()">商品小计</td>
<td>商品操作</td>
</tr>
<tr ng-repeat="a in goods|filter:name1|orderBy:type">
<td>{{a.gid}}</td>
<td>{{a.gname}}</td>
<td>{{a.gprice}}</td>
<td>
<input type="number" ng-model="a.gnum"/>

</td>
<td>{{a.gcount = a.gprice*a.gnum}}</td>

<td><input type="button" value="移除" ng-click="dele(a.gid)" /></td>
</tr>

</table>
<div>商品总数{{count()}}</div>
<div>商品总价:{{allPrice()}}</div>
<script type="text/javascript">
var app = angular.module("myapp", []);
app.controller("myCtrl", function($scope, $http) {
$http.get("goods.json").then(function(rq) {
$scope.goods = rq.data;
});
$scope.change1 = function() {
$scope.type = "gid";
}
$scope.chang2 = function() {
$scope.type = "-gcount";
}
$scope.add_sub = function(gid) {
console.log(in1 + "----")
var num1 = in1.values * 1;
for(var i = 0; i < $scope.goods.length; i++) {
var g = $scope.goods[i];
if(g.gid == gid) {
g.gnum = num1;
console.log(num1 + "--数量--")
console.log(g.gprice + "--数量--")
g.gcount = num1 * g.gprice * 1;
console.log(g.gcount + "----")
}
}
}

$scope.dele = function(gid) {
for (var i = 0; i < $scope.goods.length; i++) {

var p= $scope.goods[i].gid;
if (p==gid) {
if ($scope.goods[i].gnum<1) {


confirm("确定删除");
$scope.goods.splice(i,1);
break}
}
}
}
$scope.count = function() {
var c = 0;
for(var i = 0; i < $scope.goods.length; i++) {
var num = $scope.goods[i].gnum * 1;
c = c + num;
}
return c;
}
$scope.allPrice = function() {
var s = 0;
var len = $scope.goods.length;
for(var i = 0; i < len; i++) {
var count = $scope.goods[i].gcount * 1;
s = s + count;
}
return s;
}
$scope.deleAll = function() {
$scope.goods = [];
}
})
</script>

</body>

</html>



































































































以上是关于查询与加减的主要内容,如果未能解决你的问题,请参考以下文章

sql查询中日期加减的问题

sql多表查询详解用户表角色表权限表权限加减表,根据用户id查询所有权限,连接查询

poj3468区间加减查找——树状数组区间修改查询

使用 Impala 查询加盐的 Hbase 行键

java按照时间查询,获取近1月时间信息。时间如何加减?简单易懂,谢谢了。

3.1.4MySQL__数据库分组,拼接查询,日期函数,日期加减,间隔,数值四舍五入,排序,分组,having筛选,分组TopN,流程控制函数,