attendance_add_c.java~4~

来自「很好的Java绘图程序源代码」· JAVA~4~ 代码 · 共 87 行

JAVA~4~
87
字号
package project;

import javax.swing.JFrame;
import java.sql.*;
import javax.swing.JOptionPane;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class Attendance_add_C {
  int id ;
  String month = null;
  int zc, cd, zt, kg;
  String sql;
  ResultSet rst;
  public Attendance_add_C() {
  }

  public int confirm(Attendance_add_Model obj){
    DataBase db = new DataBase();
    id=obj.getId();
    month=obj.getCurrmonth();
    zc=obj.getZc();
    cd=obj.getCd();
    zt=obj.getZt();
    kg=obj.getKg();
    sql = "insert into attendance_table values("+ id +",'" + month + "'," + zc + "," + cd + "," + zt + "," + kg + ")";
    int n = db.executeUpdate(sql);
    db.close();
    return n;

  }

  public int edit_1(Attendance_add_Model obj){
    int n=1;
     DataBase db1 = new DataBase();
     id=obj.getId();
     month=obj.getCurrmonth();
     sql ="select * from attendance_table where id="+id+" and currmonth='"+month+"'";
     rst=db1.executeQuery(sql);
    try {
      if (rst.next()) {
        obj.setZc(rst.getInt(3));
        obj.setZt(rst.getInt(4));
        obj.setCd(rst.getInt(5));
        obj.setKg(rst.getInt(6));
      }
      else{
      n=0;
      }
    }
    catch (SQLException ex) {
    }
    db1.close();
    return n;
  }

  public int edit_2(Attendance_add_Model obj){
   DataBase db2 = new DataBase();
   id=obj.getId();
   month=obj.getCurrmonth();
   zc=obj.getZc();
   cd=obj.getCd();
   zt=obj.getZt();
   kg=obj.getKg();
   sql = "update attendance_table set zc="+zc+",cd="+cd+",zt="+zt+",kg="+kg+" where id="
       +id+" and currmonth='"+month+"' ";
  int m= db2.executeUpdate(sql);
  db2.close();
  return m;
  }





 }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?