📄 sorts.java
字号:
package mypkg;
import java.util.*;
import java.sql.*;
import java.text.*;
public class sorts extends Execute_DB
{
//定义成员变量
private long SortID;
private String SortName;
private int Tag;
private String strSql;
//初始化成员变量值
public sorts()
{
this.SortID=0;
this.SortName="";
this.Tag=0;
this.strSql="";
}
//向goods数据表中添加一条新记录
public boolean add_sort()
{
this.strSql="insert into sorts ";
this.strSql=this.strSql + "(";
this.strSql=this.strSql + "SortName,";
this.strSql=this.strSql + "Tag";
this.strSql=this.strSql + ") ";
this.strSql=this.strSql + "values(";
this.strSql=this.strSql + "'" + this.SortName + "',";
this.strSql=this.strSql + "'" + this.Tag + "'";
this.strSql=this.strSql + ")";
boolean isAdd = super.exeSql(this.strSql);
return isAdd;
}
//修改成员变量SortID对应的图书类别信息
public boolean modify_sort()
{
this.strSql="update sorts set ";
this.strSql=this.strSql + "SortName=" + "'" + this.SortName + "',";
this.strSql=this.strSql + "Tag=" + this.Tag;
this.strSql=this.strSql + " where SortID=" + this.SortID;
boolean isUpdate = super.exeSql(this.strSql);
return isUpdate;
}
//判断图书类别名称是否存在
public boolean is_exist()
{
this.strSql="select * from sorts ";
this.strSql=this.strSql + " where SortName='" + this.SortName + "'";
try
{
ResultSet rs = super.exeSqlQuery(this.strSql);
if (rs.next())
{
return true;
}
else
{
return false;
}
}
catch(Exception ex)
{
return false;
}
}
//删除类DeleteSortID中对应的图书类别信息
public boolean delete_sort(String DeleteSortID)
{
this.strSql="delete from sorts where SortID in (";
this.strSql=this.strSql + DeleteSortID + ")";
boolean isDelete = super.exeSql(this.strSql);
return isDelete;
}
//获取类成员变量SortID对应的图书类别信息
public boolean init()
{
this.strSql="select * from sorts where SortID=";
this.strSql=this.strSql + this.SortID;
try
{
ResultSet rs = super.exeSqlQuery(this.strSql);
if (rs.next())
{
SortID=rs.getLong("SortID");
SortName=rs.getString("SortName");
Tag=rs.getInt("Tag");
return true;
}
else
{
return false;
}
}
catch(Exception ex)
{
return false;
}
}
//获取所有图书类别信息,返回一个ResultSet类型对象
public ResultSet show_sorts()
{
this.strSql="select * from sorts";
ResultSet rs = null;
try
{
rs = super.exeSqlQuery(this.strSql);
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
return rs;
}
//设置类成员变量SortID的值
public void setSortID(long SortID)
{
this.SortID = SortID;
}
//获取类成员变量SortID的值
public long getSortID()
{
return this.SortID;
}
//设置类成员变量SortName的值
public void setSortName(String SortName)
{
this.SortName = SortName;
}
//获取类成员变量SortName的值
public String getSortName()
{
return this.SortName;
}
//设置类成员变量Tag的值
public void setTag(int Tag)
{
this.Tag = Tag;
}
//获取类成员变量Tag的值
public int getTag()
{
return this.Tag;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -