Supplier addition in POS Management System

Source: Internet
Author: User

<% @ Page Language = "Java" Import = "Java. util. *" pageencoding = "UTF-8" %>

<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en">
<HTML>
<Head>

<Title> my JSP 'loginservlet. jsp 'starting page </title>
<Style type = "text/CSS">
Table {
Color: blue;
Font-weight: bold;
Text-align: center;
Border-color: # c1dcf9;
}
</Style>

</Head>

<Body>
<Form action = "<% = request. getcontextpath () %>/mfredit1.do" method = "Post">
<Table border = "1">
<Tr>
<TD> vendor code </TD>
<TD colspan = "3"> <input type = "text" name = "CNO">
<Input type = "hidden" name = "method" value = "add"/>
</TD>
</Tr>
<Tr>
<TD> vendor name </TD>
<TD> <input type = "text" name = "cname"> </TD>
<TD> agent </TD>
<TD> <input type = "text" name = "dname"> </TD>
</Tr>

<Tr>
<TD> vendor address </TD>
<TD> <input type = "text" name = "caddress"/> </TD>
<TD> agency address </TD>
<TD> <input type = "text" name = "daddress"/> </TD>
</Tr>
<Tr>
<TD> manufacturer's zip code </TD>
<TD> <input type = "text" name = "cemail"/> </TD>
<TD> agent zip code </TD>
<TD> <input type = "text" name = "dnumber"/> </TD>
</Tr>
<Tr>
<TD> manufacturer's contact number </TD>
<TD> <input type = "text" name = "cphone"/> </TD>
<TD> contact number of the agent </TD>
<TD> <input type = "text" name = "dphone"/> </TD>
</Tr>
<Tr>
<TD> vendor contact </TD>
<TD> <input type = "text" name = "cpeople"/> </TD>
<TD> agent contact </TD>
<TD> <input type = "text" name = "dpeople"/> </TD>
</Tr>
<Tr>
<TD> available products </TD>
<TD colspan = "3"> <textarea Cols = "70" rows = "5" name = "product"> </textarea> </TD>
</Tr>
<Tr>
<TD> after-sales service provider </TD>
<TD> <input type = "text" name = "shouhou"/> </TD>
<TD> service provider zip code </TD>
<TD> <input type = "text" name = "fnumber"/> </TD>
</Tr>
<Tr>
<TD> service provider address </TD>
<TD> <input type = "text" name = "faddress"/> </TD>
<TD> after-sales service hotline </TD>
<TD> <input type = "text" name = "shphone"/> </TD>
</Tr>
<Tr>
<TD> remarks </TD>
<TD colspan = "3"> <textarea Cols = "70" rows = "5" name = "beizhu"> </textarea> </TD>
</Tr>
<Tr>
<TD rowspan = "2"> <input type = "Submit" value = "save"/> </TD>
<TD rowspan = "2"> <input type = "Submit" value = "close"/> </TD>
</Tr>
</Table>

</Form>
</Body>
</Html>

 

Package servlet;

Import java. Io. ioexception;
Import java. SQL. connection;
Import java. SQL. drivermanager;
Import java. SQL. preparedstatement;
Import java. SQL. resultset;
Import java. SQL. sqlexception;
Import java. util. arraylist;
Import java. util. List;

Import javax. servlet. requestdispatcher;
Import javax. servlet. servletexception;
Import javax. servlet. http. httpservlet;
Import javax. servlet. http. httpservletrequest;
Import javax. servlet. http. httpservletresponse;

Import entity. cusinfo;

@ Suppresswarnings ("serial ")
Public class editservlet1 extends httpservlet {
Private final string url = "JDBC: oracle: thin: @ 127.0.0.1: 1521: orcl ";
Private final string user = "gsuser ";
Private final string Pwd = "160127 ";
 
@ Override
Protected void doget (httpservletrequest req, httpservletresponse resp)
Throws servletexception, ioexception {

Dopost (req, resp );
}

@ Override
Protected void dopost (httpservletrequest req, httpservletresponse resp)
Throws servletexception, ioexception {
Req. setcharacterencoding ("UTF-8 ");
String CNO = Req. getparameter ("CNO ");
String cname = Req. getparameter ("cname ");
String caddress = Req. getparameter ("caddress ");
String cemail = Req. getparameter ("cemail ");
String cphone = Req. getparameter ("cphone ");
String cpeople = Req. getparameter ("cpeople ");
Int I = savemfredit (CNO, cname, caddress, cemail, cphone, cpeople );
If (I> 0 ){
// Added successfully
Resp. sendredirect (req. getcontextpath () + "/success. jsp ");
} Else {
Resp. sendredirect ("http://www.sohu.com ");
}
}

Private int savemfredit (string CNO, string cname, string caddress, string cemail, string cphone, string cpeople ){
String insert = "insert into mfredit (CNO, cname, caddress, cemail, cphone, cpeople) values (?,?,?,?,?,?) ";
Int I = 0;
// Load the driver
Try {
Class. forname ("oracle. JDBC. Driver. oracledriver ");
} Catch (classnotfoundexception e ){
E. printstacktrace ();
}
Connection conn = NULL;
Preparedstatement pstmt = NULL;
Try {
Conn = drivermanager. getconnection (URL, user, PWD );
Pstmt = conn. preparestatement (insert );
// Set parameters
Pstmt. setstring (1, CNO );
Pstmt. setstring (2, cname );
Pstmt. setstring (3, caddress );
Pstmt. setstring (4, cemail );
Pstmt. setstring (5, cphone );
Pstmt. setstring (6, cpeople );
// Execute
I = pstmt.exe cuteupdate ();
} Catch (sqlexception e ){
E. printstacktrace ();
} Finally {
Try {
If (pstmt! = NULL ){
Pstmt. Close ();
}
If (Conn! = NULL ){
Conn. Close ();
}
} Catch (sqlexception e ){
E. printstacktrace ();
}
}
Return I;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.