⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mntain.java

📁 jsp+javabean+sqlserver开发的设备管理系统
💻 JAVA
字号:
package device;

import java.sql.ResultSet;
import java.util.Vector;

import devicecomm.DBOper;
import devicecomm.StringOper;


public class Mntain {
	private int MnId;		// 维护编号
    private String DevId;		// 设备编号
	private String MnName;		// 维护人员
	private String MnDate;		// 维护时间
	private String MnRecord;	// 维护记录

	StringOper so = new StringOper();

    public boolean getMntain()throws Exception
    {
       // int conditionNo = 0;

        DBOper o_DBOper = new DBOper();
        ResultSet rs = null;

		String sql = "select MnId,DevId,MnName,MnDate,MnRecord";
		sql+="  from dev_Mntain where MnId="+MnId;
//System.out.println(sql);
        try
        {
            rs = o_DBOper.getResultSet(sql);
            if(rs.next())
            {
                setMnId(rs.getInt("MnId"));
				setDevId(so.ReplaceNull(rs.getString("DevId")));
				setMnName(so.ReplaceNull(rs.getString("MnName")));
				setMnDate(so.ReplaceNull(rs.getString("MnDate")));
				setMnRecord(so.ReplaceNull(rs.getString("MnRecord")));
               return true;
            }
        }
        catch(Exception e)
        {
            throw new Exception(e.getMessage());
        }
	    finally
	    {
            try {o_DBOper.close();} catch (Exception e) { System.out.print(e.toString());}
	    }
        return false;
    }

	public Vector getMoreMntain() throws Exception
    {
        Vector v_mn = new Vector();
        int conditionNo = 0;

        DBOper o_DBOper = new DBOper();
        ResultSet rs = null;

        String sql = "select * from dev_Mntain";
        String condition = " where ";
        try
        {
            if(MnId != 0)
            {
                condition += "MnId="+MnId;
                conditionNo++;
            }

			if(DevId != null)
            {
				if(conditionNo > 0)
                {
                    condition += " and";
                }
                condition += "DevId='"+DevId+"'";
                conditionNo++;
            }
			if(MnName != null)
            {
                if(conditionNo > 0)
                {
                    condition += " and";
                }
                condition += " MnName='"+MnName+"'";
                conditionNo++;
            }
            if(conditionNo > 0)
            {
                sql += condition;
            }
            sql += " order by MnId desc";

            rs = o_DBOper.getResultSet(sql);
//	System.out.println(sql);
			while(rs.next())
            {
                Mntain o_mn = new Mntain();
				o_mn.setMnId(rs.getInt("MnId"));
				o_mn.setDevId(so.ReplaceNull(rs.getString("DevId")));
				o_mn.setMnName(so.ReplaceNull(rs.getString("MnName")));
				o_mn.setMnDate(so.ReplaceNull(rs.getString("MnDate")));
				o_mn.setMnRecord(so.ReplaceNull(rs.getString("MnRecord")));

                v_mn.add(o_mn);
            }
        }
        catch(Exception e)
        {
            throw new Exception(e.getMessage());
        }
	    finally
	    {
            try {o_DBOper.close();} catch (Exception e) { System.out.print(e.toString());}
	    }
        return v_mn;
    }

//删除维护记录
	public void DeleteMntain(String MnId) throws Exception
    {
        DBOper o_DBOper = new DBOper();
		//ResultSet rs = null;

        String sql_dlt = "delete from dev_Mntain where MnId =" + MnId;
        try
        {
//			System.out.println(sql_dlt);
            o_DBOper.DataUpdate(sql_dlt);
        }
        catch(Exception e)
        {
            throw new Exception(e.getMessage());
        }
	    finally
	    {
            try {o_DBOper.close();} catch (Exception e) { System.out.print(e.toString());}
	    }
    }
//插入维护记录
	public void CreateMntain() throws Exception
    {
        DBOper o_DBOper = new DBOper();
       // ResultSet rs = null;

        String sql = "insert into dev_Mntain(MnName,DevId,MnDate,MnRecord) ";
		sql =sql+"values('"+MnName+"','"+DevId+"','"+MnDate+"','"+MnRecord+"')";
        try
        {
            o_DBOper.DataUpdate(sql);
        }
        catch(Exception e)
        {
            throw new Exception(e.getMessage());
        }
	    finally
	    {
            try {o_DBOper.close();} catch (Exception e) { System.out.print(e.toString());}
	    }
    }
//update维护记录
	public void UpdateMntain() throws Exception
    {
        int MnId = getMnId();
        DBOper o_DBOper = new DBOper();
       // ResultSet rs = null;

        String sql = "update dev_Mntain set MnName='"+MnName+"',MnDate='"+MnDate+"',MnRecord='"+MnRecord+"',";
		sql+="DevId='"+DevId+"' where MnId="+MnId;
//	System.out.println("UPDATE SQL :"+sql);
        try
        {
            o_DBOper.DataUpdate(sql);
        }
        catch(Exception e)
        {
            throw new Exception(e.getMessage());
        }
	    finally
	    {
            try {o_DBOper.close();} catch (Exception e) { System.out.print(e.toString());}
	    }
    }

	public void setMnId(int MnId){
        this.MnId = MnId;
    }
    public int getMnId(){
        return this.MnId;
    }
    public void setDevId(String DevId){
        this.DevId = DevId;
    }
    public String getDevId(){
        return this.DevId;
    }
	public void setMnName(String MnName){
        this.MnName = MnName;
    }
    public String getMnName(){
        return this.MnName;
    }

	public void setMnDate(String MnDate){
        this.MnDate = MnDate;
    }
    public String getMnDate(){
        return this.MnDate;
    }
	public void setMnRecord(String MnRecord){
        this.MnRecord = MnRecord;
    }
    public String getMnRecord(){
        return this.MnRecord;
    }
 }

⌨️ 快捷键说明

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