📄 add_customer.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<%
String c_name=request.getParameter("c_name");
c_name=new String(c_name.getBytes("ISO8859-1"),"gb2312");
String c_id=request.getParameter("c_id");
c_id=new String(c_id.getBytes("ISO8859-1"),"gb2312");
String card_id=request.getParameter("card_id");
if( (card_id != null)&&(card_id.length()!= 0 ) )
{
card_id = new String(card_id.getBytes("ISO8859-1"),"gb2312");
}
String adress=request.getParameter("adress");
if( (adress != null)&&(adress.length()!= 0 ) )
{
adress = new String(adress.getBytes("ISO8859-1"),"gb2312");
}
String sex=request.getParameter("sex");
if( (sex.equals("male")) )
{
sex="男";
}
else
sex="女";
String birthday=request.getParameter("birthday");
if( (birthday != null)&&(birthday.length()!= 0 ) )
{
birthday = new String(birthday.getBytes("ISO8859-1"),"gb2312");
}
String phone=request.getParameter("phone");
if( (phone != null)&&(phone.length()!= 0 ) )
{
phone = new String(phone.getBytes("ISO8859-1"),"gb2312");
}
String mobile_phone=request.getParameter("mobile_phone");
if( (mobile_phone != null)&&(mobile_phone.length()!= 0 ) )
{
mobile_phone = new String(mobile_phone.getBytes("ISO8859-1"),"gb2312");
}
String fax=request.getParameter("fax");
if( (fax != null)&&(fax.length()!= 0 ) )
{
fax= new String(fax.getBytes("ISO8859-1"),"gb2312");
}
String email=request.getParameter("email");
if( (email != null)&&(email.length()!= 0 ) )
{
email = new String(email.getBytes("ISO8859-1"),"gb2312");
}
String remark=request.getParameter("remark");
if( (remark != null)&&(remark.length()!= 0 ) )
{
remark = new String(remark.getBytes("ISO8859-1"),"gb2312");
}
%>
<%
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=dengfen";
String user="sa";
String password="123";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql_check="select * from customer where c_id='"+c_id+"'";
ResultSet rs1=stmt.executeQuery(sql_check);
if(rs1.next())
{
response.sendRedirect("main.jsp?add_check=yes&&check=false");
}
else
{
String sql_insert="insert into customer values('"+c_id+"','"+c_name+"','"+sex+"','"+card_id+"','"+adress+"','"+birthday+"','"+phone+"','"+mobile_phone+"','"+fax+"','"+email+"','"+remark+"')";
Statement stmt1=conn.createStatement();
stmt1.executeUpdate(sql_insert);
rs1.close();
stmt.close();
stmt1.close();
conn.close();
response.sendRedirect("main.jsp?check=true");
}
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -