Esempio n. 1
0
 public void MainClassManager() {
   boolean flag = true;
   Class_ManageDao CM = new Class_ManageDaoImpl();
   do {
     System.out.println("\t1.增加大类");
     System.out.println("\t2.删除大类");
     System.out.println("\t3.返回上一级菜单");
     Scanner input = new Scanner(System.in);
     int choice = input.nextInt();
     switch (choice) {
       case 1:
         {
           System.out.println("请输入要添加的大类名称:");
           String mainClass = input.next();
           CM.Add(mainClass);
           break;
         }
       case 2:
         {
           System.out.println("请输入要删除的大类名称:");
           String name = input.next();
           CM.del(name);
           this.DelByName(name);
           break;
         }
       case 3:
         {
           flag = false;
           break;
         }
     }
   } while (flag == true);
 }
Esempio n. 2
0
 @Override
 public int Add() { // 增加资产
   Class_ManageDao cm = new Class_ManageDaoImpl();
   Scanner input = new Scanner(System.in);
   // 向资产表中添加数据
   System.out.println("请输入要增加的资产name");
   String name = input.next();
   System.out.println("请输入要增加的资产mainclass");
   String mainclass = input.next();
   System.out.println("请输入要增加的资产model");
   String model = input.next();
   System.out.println("请输入要增加的资产value");
   int value = input.nextInt();
   System.out.println("请输入要增加的资产date");
   String date = input.next();
   System.out.println("请输入要增加的资产status");
   int status = input.nextInt();
   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
   try {
     Date Occ_Date = sdf.parse(date);
   } catch (ParseException e) {
     e.printStackTrace();
   }
   String sql =
       "insert into Fixed_Assets (Assets_name,MainClass,Model,Value,Buy_date,Status) values (?,?,?,?,?,?)";
   Object[] param = {name, mainclass, model, value, date, status};
   int result = this.exceuteUpdate(sql, param);
   // 检查类表中是否有该大类,没有则添加
   // 有该大类时,函数返回true,否则返回false
   if (!cm.getByClassName(mainclass)) {
     cm.Add(mainclass);
   }
   return result;
 }