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

📄 discard.java

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

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

import devicecomm.DBOper;
import devicecomm.StringOper;

// 设备台帐类,完成对数据库中设备信息的添加、修改、删除等操作
public class Discard {
	private int DiscardId;		// 报废编号
    private String DevId;		// 设备编号
	private int DisCount;		// 报废数量
	private long Total;			// 报废总金额
	private String Dept;        // 申请报废部门
	private String Reason;		// 报废原因
	private int Flag;			// 状态标记(0 申请,1 提交,2 审批通过,3 审批不通过,4 报废)
	private String Poster;		// 提交人用户名
	private String PostTime;	// 提交时间
	private String ChkPerson;	// 审核人用户名
	private String ChkDate;		// 审核时间
    private String ChkResult;	// 审核结果

	StringOper so = new StringOper();

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

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

        String sql = "Select PostTime,Discardid,DevId,Dept,";
		sql=sql+" ChkDate,ChkResult,Flag,Total,DisCount,Poster";
		sql=sql+",ChkPerson,reason from dev_Discard where DiscardId="+DiscardId;

        try
        {
            rs = o_DBOper.getResultSet(sql);
            if(rs.next())
            {
                setDiscardId(rs.getInt("DiscardId"));
				setDevId(so.ReplaceNull(rs.getString("DevId")));
				setChkDate(so.ReplaceNull(rs.getString("ChkDate")));
				setChkResult(so.ReplaceNull(rs.getString("ChkResult")));
				setPostTime(so.ReplaceNull(rs.getString("PostTime")));
				setReason(so.ReplaceNull(rs.getString("reason")));
				setDept(so.ReplaceNull(rs.getString("Dept")));
 				setFlag(rs.getInt("Flag"));
				setTotal(rs.getLong("Total"));
				setDisCount(rs.getInt("DisCount"));
				setPoster(so.ReplaceNull(rs.getString("Poster")));
				setChkPerson(so.ReplaceNull(rs.getString("ChkPerson")));
               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 getMoreDiscard() throws Exception
    {
        Vector v_Discard = new Vector();
        int conditionNo = 0;

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

        String sql = "select  PostTime,DiscardId,DevId,Dept,";
		sql=sql+"  ChkDate,ChkResult,Flag,Total,DisCount,Poster";
		sql=sql+",ChkPerson,reason from dev_Discard ";
        String condition = " where ";
        try
        {
            if(DiscardId != 0)
            {
                condition += "DiscardId="+DiscardId;
                conditionNo++;
            }
			if(DevId != null)
            {
				if(conditionNo > 0)
                {
                    condition += " and";
                }
                condition += " DevId='"+DevId+"'";
                conditionNo++;
            }
            if(PostTime != null)
            {
                if(conditionNo > 0)
                {
                    condition += " and";
                }
                condition += " PostTime='"+PostTime+"'";
                conditionNo++;
            }
			if(Flag != 0)
            {
                if(conditionNo > 0)
                {
                    condition += " and";
                }
                condition += " Flag="+Flag;
                conditionNo++;
            }
			if(Poster != null)
            {
                if(conditionNo > 0)
                {
                    condition += " and";
                }
                condition += " Poster='"+Poster+"'";
                conditionNo++;
            }
			if(ChkPerson != null)
            {
                if(conditionNo > 0)
                {
                    condition += " and";
                }
                condition += " ChkPerson='"+ChkPerson+"'";
                conditionNo++;
            }
            if(conditionNo > 0)
            {
                sql += condition;
            }
            sql += " order by DiscardId desc,DevId desc";

            rs = o_DBOper.getResultSet(sql);
	//System.out.println(sql);
			while(rs.next())
            {
                Discard o_Discard2 = new Discard();
				o_Discard2.setDiscardId(rs.getInt("DiscardId"));
				o_Discard2.setDevId(so.ReplaceNull(rs.getString("DevId")));
				o_Discard2.setChkDate(so.ReplaceNull(rs.getString("ChkDate")));
				o_Discard2.setChkResult(so.ReplaceNull(rs.getString("ChkResult")));
				o_Discard2.setPostTime(so.ReplaceNull(rs.getString("PostTime")));
				o_Discard2.setReason(so.ReplaceNull(rs.getString("Reason")));
				o_Discard2.setDept(so.ReplaceNull(rs.getString("Dept")));
 				o_Discard2.setFlag(rs.getInt("Flag"));
				o_Discard2.setTotal(rs.getLong("Total"));
				o_Discard2.setDisCount(rs.getInt("DisCount"));
				o_Discard2.setPoster(so.ReplaceNull(rs.getString("Poster")));
				o_Discard2.setChkPerson(so.ReplaceNull(rs.getString("ChkPerson")));
                v_Discard.add(o_Discard2);
            }
        }
        catch(Exception e)
        {
            throw new Exception(e.getMessage());
        }
	    finally
	    {
            try {o_DBOper.close();} catch (Exception e) { System.out.print(e.toString());}
	    }
        return v_Discard;
    }

//删除记录
	public void DeleteDiscard(int Discardid) throws Exception
    {
        DBOper o_DBOper = new DBOper();
		//ResultSet rs = null;

        String sql_dlt = "delete from dev_Discard where DiscardId =" + Discardid;
        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 CreateDiscard() throws Exception
    {
        DBOper o_DBOper = new DBOper();
       // ResultSet rs = null;

        String sql = "insert into dev_Discard(DevId,Flag,Total,DisCount, Dept, PostTime,Poster,";
		sql = sql + "ChkResult,ChkDate,ChkPerson,reason) " ;
		sql = sql + "values('"+DevId+"',0,"+Total+","+DisCount+",'" + Dept+"',getdate(),'";
		sql = sql + Poster+"','"+ChkResult+"',getdate(),'"+ChkPerson+"','"+Reason+"')";
       // System.out.println("INSERT 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 UpdateDiscard() throws Exception
    {
        DBOper o_DBOper = new DBOper();
       // ResultSet rs = null;

        String sql = "update dev_Discard set DevId='"+DevId+"',DisCount="+DisCount+",";
		sql = sql + "reason='"+Reason+"', Dept='" + Dept + "',Total="+Total+" where DiscardId="+DiscardId;
        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 UpdateStatus(int Flag,String sNew) throws Exception
    {
		String sql="";
		DBOper o_DBOper = new DBOper();
      //  ResultSet rs = null;
		
		if(Flag==1)	//提交
			sql = "update dev_Discard set Flag=1,ChkPerson='"+sNew+"' where DiscardId="+ DiscardId;
		else if(Flag==2||Flag==3)//审批
			sql = "update dev_Discard set Flag="+Flag+",ChkResult='"+sNew+"',ChkDate=getdate() where DiscardId="+ DiscardId;
		else if(Flag==4)//报废
			sql = "update dev_Discard set Flag=4 where DiscardId="+ DiscardId;
//	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 UpdateCheckRlt() throws Exception
    {
        DBOper o_DBOper = new DBOper();
       // ResultSet rs = null;

        String sql = "update dev_Discard set Flag="+Flag+",ChkResult='"+ChkResult;
		sql = sql +"',ChkPerson='"+ChkPerson+"',ChkDate=getdate()";
		sql = sql + " where DiscardId=" + DiscardId;
        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 setDiscardId(int DiscardId){
        this.DiscardId = DiscardId;
    }
    public int getDiscardId(){
        return this.DiscardId;
    }
    public void setDevId(String DevId){
        this.DevId = DevId;
    }
    public String getDevId(){
        return this.DevId;
    }
	public void setDisCount(int DisCount){
        this.DisCount = DisCount;
    }
    public int getDisCount(){
        return this.DisCount;
    }
	public void setTotal(long Total){
        this.Total = Total;
    }
    public long getTotal(){
        return this.Total;
    }
	public void setDept(String Dept){
        this.Dept = Dept;
    }
    public String getDept(){
        return this.Dept;
    }

	public void setReason(String Reason){
        this.Reason = Reason;
    }
    public String getReason(){
        return this.Reason;
    }
	public void setFlag(int Flag){
        this.Flag = Flag;
    }
    public int getFlag(){
        return this.Flag;
    }
	public void setPostTime(String PostTime){
        this.PostTime = PostTime;
    }
    public String getPostTime(){
        return this.PostTime;
    }
	public void setPoster(String Poster){
        this.Poster = Poster;
    }
    public String getPoster(){
        return this.Poster;
    }
    public void setChkResult(String ChkResult){
        this.ChkResult = ChkResult;
    }
    public String getChkResult(){
        return this.ChkResult;
    }
	public void setChkDate(String ChkDate){
        this.ChkDate = ChkDate;
    }
    public String getChkDate(){
        return this.ChkDate;
    }	

	public void setChkPerson(String ChkPerson){
        this.ChkPerson = ChkPerson;
    }
    public String getChkPerson(){
        return this.ChkPerson;
    }
 }

⌨️ 快捷键说明

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