import java.sql.*; //数据库
import java.io.*; //IO
import java.text.SimpleDateFormat; //时间
class mainmenu
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public void mainmenu() throws IOException
{
System.out.println(" ***********************");
System.out.println(" | 1 - 供应商信息管理 |");
System.out.println(" | 2 - 商品信息管理 |");
System.out.println(" | 3 - 销售管理 |");
System.out.println(" | 4 - 订单管理 |");
System.out.println(" | 5 - 补 货 |");
System.out.println(" | 6 - 查看操作日志 |");
System.out.println(" | 其他 - 退出 |");
System.out.println(" ***********************");
System.out.print("请输入选项:");
String s=br.readLine();
while(true)
{
switch(Integer.parseInt(s))
{
case 1:Supplier obj_1=new Supplier();obj_1.suppliermenu();
case 2:Commodities obj_2=new Commodities();obj_2.commoditiesmenu();
case 3:Sales obj_3=new Sales();obj_3.Sales();
System.out.println("按回车继续");
s=br.readLine();
mainmenu m1=new mainmenu(); m1.mainmenu();
case 4:Orders obj_4=new Orders();obj_4.ordermenu();
case 5:add obj_5=new add();obj_5.add();
System.out.println("按回车继续");
s=br.readLine();
mainmenu m2=new mainmenu(); m2.mainmenu();
case 6:Daily obj_6=new Daily();obj_6.daily();
System.out.println("按回车继续");
s=br.readLine();
mainmenu m3=new mainmenu(); m3.mainmenu();
default:break;
}
break;
}
}
}
class Commodities
{
Connection con;
Statement stat;
PreparedStatement prestat;
ResultSet res;
int ires=0;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public void commoditiesmenu() throws IOException
{
System.out.println(" ***********************");
System.out.println(" | 1 - 查看所有商品信息 |");
System.out.println(" | 2 - 查看特定商品信息 |");
System.out.println(" | 3 - 修改商品信息 |");
System.out.println(" | 4 - 删除商品 |");
System.out.println(" | 5 - 增加商品 |");
System.out.println(" | 6 - 返回上级菜单 |");
System.out.println(" ***********************");
System.out.print("请输入选项:");
String s=br.readLine();
while(true)
{
switch(Integer.parseInt(s))
{
case 1: Commodities obj1=new Commodities();obj1.Query_commodities();
System.out.println("按回车继续");
s=br.readLine();
obj1.commoditiesmenu();
case 2: Commodities obj2=new Commodities();obj2.T_Query_commodities();
System.out.println("按回车继续");
s=br.readLine();
obj2.commoditiesmenu();
case 3: Commodities obj3=new Commodities();obj3.update_commodities();
case 4: Commodities obj4=new Commodities();obj4.delete_commodities();
System.out.println("按回车继续");
s=br.readLine();
obj4.commoditiesmenu();
case 5: Commodities obj5=new Commodities();obj5.insert_commodities();
System.out.println("按回车继续");
s=br.readLine();
obj5.commoditiesmenu();
case 6:mainmenu m=new mainmenu(); m.mainmenu();break;
default :Commodities obj7=new Commodities();obj7.commoditiesmenu();
}
}
}
public void Query_commodities()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Domino","sa","123456");
stat=con.createStatement();
res=stat.executeQuery("select * from Commodities");
while(res.next())
{
System.out.println(res.getString(1)+" "+res.getString(2)+" "+res.getString(3)+" "+res.getString(4)+" "+res.getString(5)+" "+res.getString(6));
}
}
catch(Exception e) //如果运行中产生错误,则把错误信息保存在变量e中(以便显示给用户或做它用)。
{
System.out.println("查询出错: "+e);
}
if (con!=null)
con=null;
}
public void T_Query_commodities() throws IOException
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Domino","sa","123456");
prestat=con.prepareStatement("select * from Commodities where cCommoditiesId=?");
System.out.print("输入商品ID : ");
String CommoditiesId=br.readLine();
prestat.setString(1,CommoditiesId);
res=prestat.executeQuery();
if(res.next())
System.out.println(res.getString(1)+" "+res.getString(2)+" "+res.getString(3)+" "+res.getString(4)+" "+res.getString(5)+" "+res.getString(6));
else
{
System.out.println("没有找到.");
}
}
catch(Exception e) //如果运行中产生错误,则把错误信息保存在变量e中(以便显示给用户或做它用)。
{
System.out.println("查询出错: "+e);
}
if (con!=null)
con=null;
}
public void update_commodities() throws IOException
{
System.out.println(" ***********************");
System.out.println(" | 1 - 修改商品名称 |");
System.out.println(" | 2 - 修改商品价格 |");
System.out.println(" | 3 - 修改商品供应商 |");
System.out.println(" | 4 - 修改商品库存 |");
System.out.println(" | 5 - 修改商品阀值 |");
System.out.println(" | 6 - 返回 |");
System.out.println(" ***********************");
System.out.print("请输入选项:");
String s=br.readLine();
while(true)
{
switch(Integer.parseInt(s))
{
case 1: Commodities obj1=new Commodities();obj1.Query_commodities();
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Domino","sa","123456");
prestat=con.prepareStatement("update Commodities set vCommoditiesName=? where cCommoditiesId=?");
System.out.print("输入需要修改的的商品ID : ");
String CommoditiesId=br.readLine();
System.out.print("新名称 : ");
String C_NewName=br.readLine();
prestat.setString(2,CommoditiesId);
prestat.setString(1,C_NewName);
ires=prestat.executeUpdate();
if(ires!=0)
{
System.out.println("修改成功");
Daily obj=new Daily();obj.writedaily( "修改的商品ID :"+CommoditiesId,"修改的新名称 :"+C_NewName);
}
else
{
System.out.println("没有该商品");
}
}
catch(Exception e) //如果运行中产生错误,则把错误信息保存在变量e中(以便显示给用户或做它用)。
{
System.out.println("修改失败: "+e);
}
obj1.update_commodities();
case 2:Commodities obj2=new Commodities();obj2.Query_commodities();
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Domino","sa","123456");
prestat=con.prepareStatement("update Commodities set mPrice=? where cCommoditiesId=?");
System.out.print("输入需要修改的的商品ID : ");
String CommoditiesId=br.readLine();
System.out.print("新价格 : ");
String C_Price=br.readLine();
prestat.setString(2,CommoditiesId);
prestat.setFloat(1,Float.parseFloat(C_Price));
ires=prestat.executeUpdate();
if(ires!=0)
System.out.println("修改成功");
else
{
System.out.println("没有该商品");
}
}
catch(Exception e) //如果运行中产生错误,则把错误信息保存在变量e中(以便显示给用户或做它用)。
{
System.out.println("修改失败: "+e);
}
obj2.update_commodities();
case 3:Commodities obj3=new Commodities();obj3.Query_commodities();
try
评论0