add
前台
<input id="Button1" type="button" value="button" onclick="add()" />
<input id="save" onclick="saveadd()" type="button" value="批量保存" />
<div>
<table>
<tr>
<td><input type="checkbox" checked='checked'/></td>
<td>编号</td>
<td>学号</td>
<td>名称</td>
<td>年龄</td>
</tr>
<tbody id="tname">
</tbody>
</table>
</div>
<script>
$(function () {
show();
})
function show() {
debugger;
$.ajax({
url: "/show/add",
type: "get",
dataType: "json",
success: function ( data) {
console.log(data);
alert(data);
debugger;
var str = '';
for (var i = 0; i < data.length; i++) {
str += " <tr>";
str += "<td><input type=\"checkbox\" checked='checked'/></td>";
str += "<td>" + data[i].id + "</td>";
str += "<td>" + data[i].xuehao + "</td>";
str += "<td>" + data[i].name + "</td>";
str += "<td>" + data[i].age + "</td>";
str += "<td> <input id='del' type=\"button\" class=\"btn btn-primary\" onclick=\"del(" + data[i].id + ")\" value=\"删除\" /></td>";
str += "</tr>";
}
$("#tname").append(str);
}
})
}
//添加
function add()
{
//var ss = Date.now();
var ss = Date.now();
debugger
var str = "";
str += " <tr class='ss'>";
str += "<td><input type=\"checkbox\" checked='checked'/></td>";
str += "<td><input id=\"Text2\" type=\"text\" /></td>";
str += "<td><input id=\"Text3\" type=\"text\" /></td>";
str += "<td><input id=\"Text4\" type=\"text\" /></td>";
str += "<td><input id='del' type=\"button\" class=\"btn btn-primary\" value=\"删除\" /></td>";
str += "</tr>";
$("#tname").append(str);
}
function saveadd()
{
var arry = [];
$(".ss").each(function () {
if ($(this).children().eq(0).children().first().prop("checked") == true)
{
var ss = $(this).children().eq(1).children().first().val();
var sss = $(this).children().eq(2).children().first().val();
var ssss = $(this).children().eq(3).children().first().val();
arry.push(JSON.stringify({ xuehao: ss, name: sss, age: ssss }));
}
})
$.ajax({
url: "/show/ad",
type: "post",
traditional: true,
contentType: "application/x-www-form-urlencoded; charset=utf-8",
dataType: "json",
data: { arry: arry },
success: function (data) {
if (data > 0) {
alert("添加成s功!");
show();
}
}
})
}
</script>
后台
//显示
public ActionResult add()
{
var data = new BLL.stuBLL().show();
var data2 = JsonConvert.SerializeObject(data);
return Content(data2);
}
//添加
[HttpPost]
public ActionResult ad(string[] arry)
{
var str = "insert into student values";//添加数据库拼接
stuModel mm = new stuModel();//类
var data = arry.ToList();
var ass = "";
for (int i = 0; i < data.Count; i++)//循环
{
ass = data[i];
var person1 = JsonConvert.DeserializeAnonymousType(ass, mm);//把json转换为mm类
str += "( '" + person1.xuehao + "','" + person1.name + "', '" + person1.age + "') ,";
}
int chu = str.LastIndexOf(',');
var sss = str.Substring(0, chu - 1);
int cg = new BLL.stuBLL().add(sss);
return Content(cg.ToString());
}
add的更多相关文章
- AutoMapper:Unmapped members were found. Review the types and members below. Add a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type
异常处理汇总-后端系列 http://www.cnblogs.com/dunitian/p/4523006.html 应用场景:ViewModel==>Mode映射的时候出错 AutoMappe ...
- EntityFramework Core 1.1 Add、Attach、Update、Remove方法如何高效使用详解
前言 我比较喜欢安静,大概和我喜欢研究和琢磨技术原因相关吧,刚好到了元旦节,这几天可以好好学习下EF Core,同时在项目当中用到EF Core,借此机会给予比较深入的理解,这里我们只讲解和EF 6. ...
- ASP.NET Core: You must add a reference to assembly mscorlib, version=4.0.0.0
ASP.NET Core 引用外部程序包的时候,有时会出现下面的错误: The type 'Object' is defined in an assembly that is not referenc ...
- [转]NopCommerce How to add a menu item into the administration area from a plugin
本文转自:http://docs.nopcommerce.com/display/nc/How+to+code+my+own+shipping+rate+computation+method Go t ...
- [deviceone开发]-动态添加组件add方法的示例
一.简介 这个示例详细介绍ALayout的add方法的使用(原理也适用于Linearlayout),以及add上去的新ui和已有的ui如何数据交换,初学者推荐.二.效果图 三.相关下载 https:/ ...
- [LeetCode] Add Two Numbers II 两个数字相加之二
You are given two linked lists representing two non-negative numbers. The most significant digit com ...
- [LeetCode] Add Strings 字符串相加
Given two non-negative numbers num1 and num2 represented as string, return the sum of num1 and num2. ...
- [LeetCode] Expression Add Operators 表达式增加操作符
Given a string that contains only digits 0-9 and a target value, return all possibilities to add ope ...
- [LeetCode] Add Digits 加数字
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. ...
- [LeetCode] Different Ways to Add Parentheses 添加括号的不同方式
Given a string of numbers and operators, return all possible results from computing all the differen ...
随机推荐
- SQL语句基本语法总结
SQL语句基本语法 表的创建.修改.删除: 表中数据的增加.修改.删除.查看: SQL的 语法.数据类型.约束.删除表中数据(2种方法).语句查询的执行顺序: 查询 单列.多列.全部 子查询 单行子查 ...
- CTF大赛学习第一天!!!(学习中)
- topcoder srm 640 div1
problem1 link 首先使用两个端点颜色不同的边进行连通.答案是$n-1-m$.其中$m$是联通分量的个数. problem2 link 首先构造一个最小割的模型.左边的$n_{1}$个点与源 ...
- LintCode 1.A+B的问题
LintCode 1.A+B的问题 描述 给出两个整数 a 和 b , 求他们的和. 答案 public class Solution { /** * @param a: An integer * @ ...
- Go 参数传递是传值还是传引用
什么是传值(值传递)? 传值的意思是:函数传递的总是原来这个东西的一个副本.一个副拷贝.比如我们传递一个 int 类型的参数,传递 的其实这个参数的一个副本:传递一个指针类型的参数,其实传递的是这个指 ...
- scipy插值与拟合
原文链接:https://zhuanlan.zhihu.com/p/28149195 1.最小二乘拟合 实例1 import numpy as np import matplotlib.pyplot ...
- Matplotlib.pyplot 把画图保存为图片
在plt.show()之前执行plt.savefig()函数即可. 简单例子: import matplotlib.pyplot as plt x=[1,2,3,4,5] y=[10,5,15,10, ...
- Django 的命令及简单例子
第一步:下载mysql驱动 cmd进入创建好的django项目目录:然后使用下面的命令创建一个项目testdj. sudo /usr/lib/python3/dist-packages/djang ...
- Vue小项目二手书商城:(一)准备工作、组件和路由
本项目基于vue2.5.2,与低版本部分不同之处会在(五)参考资料中提出 完整程序:https://github.com/M-M-Monica/bukesi 实现内容: 资源准备(mock数据) 组件 ...
- 2019 To do List
做好测试不是靠编程,而是靠的是严禁的作风,慎密的逻辑思维,适合的测试流程. 内心有些迷茫的时候,迷茫的是作为测试既然要学那么多编程,为什么不直接去干开发呢?学了编程,用不上,到底有什么用呢? 看了这句 ...