📄 form16.java
字号:
//Form16.java
import com.ms.wfc.app.*;
import com.ms.wfc.core.*;
import com.ms.wfc.ui.*;
import com.ms.wfc.data.*;
import com.ms.wfc.data.ui.*;
public class Form16 extends Form
{
public void btnAdd_Click(Object sender, Event evt)
{
try
{
dataSource1.getRecordset().cancelUpdate();
dataSource1.getRecordset().addNew();
m_bAddNew = true;
btnDelete.setText ("&返回" );
btnAdd.setEnabled( false );
btnRefresh.setEnabled( false );
}
catch (Exception e)
{
handleADOException(e);
}
}
public void btnDelete_Click(Object sender, Event evt)
{
try
{
if( m_bAddNew )
{
dataSource1.getRecordset().cancelUpdate();
m_bAddNew = false;
btnDelete.setText ("&删除" );
btnRefresh.setEnabled( true );
btnAdd.setEnabled( true );
}
else
{
dataSource1.getRecordset().delete(AdoEnums.Affect.CURRENT);
if( !dataSource1.getRecordset().getEOF() )
{
dataSource1.getRecordset().moveNext();
if( dataSource1.getRecordset().getEOF() )
dataSource1.getRecordset().movePrevious();
}
}
}
catch (Exception e)
{
handleADOException(e);
dataSource1.getRecordset().cancelBatch();
}
}
public void btnRefresh_Click(Object sender, Event evt)
{
try
{
btnRefresh.setEnabled( false );
dataSource1.getRecordset().cancelBatch();
Object bm = dataSource1.getRecordset().getBookmark();
dataSource1.requery();
if( bm != null )
dataSource1.getRecordset().setBookmark( bm );
}
catch (Exception e)
{
handleADOException(e);
}
btnRefresh.setEnabled( true );
}
public void btnUpdate_Click(Object sender, Event evt)
{
try
{
this.setCursor( Cursor.WAIT );
dataBinder1.commitChanges();
dataSource1.getRecordset().update();
if( m_bAddNew )
{
dataSource1.requery();
dataSource1.getRecordset().moveLast();
}
}
catch (Exception e)
{
handleADOException(e);
if( m_bAddNew )
{
this.setCursor( Cursor.DEFAULT );
return;
}
else
dataSource1.getRecordset().cancelUpdate();
}
this.setCursor( Cursor.DEFAULT );
m_bAddNew = false;
btnDelete.setText ("&删除" );
btnRefresh.setEnabled( true );
btnAdd.setEnabled( true );
}
public void btnClose_Click(Object sender, Event evt)
{
this.dispose();
}
boolean m_bAddNew;
public void dispose()
{
super.dispose();
components.dispose();
}
public Form16()
{
// Required for Visual J++ Form Designer support
initForm();
this.show();
this.update();
//TODO: Add any constructor code after initForm call
}
public void formClose(Event e)
{
Application.exit();
}
void handleADOException(Exception e)
{
e.printStackTrace();
MessageBox.show( e.toString(), "Form16" );
}
/**
* NOTE: The following code is required by the Visual J++ form
* designer. It can be modified using the form editor. Do not
* modify it using the code editor.
*/
Container components = new Container();
DataSource dataSource1 = new DataSource(components);
DataBinder dataBinder1 = new DataBinder(components);
Label label中文期刊名 = new Label();
Edit edit中文期刊名 = new Edit();
Label label国内发行 = new Label();
Edit edit国内发行 = new Edit();
Label label中文期刊馆藏编号 = new Label();
Edit edit中文期刊馆藏编号 = new Edit();
Label label中文期刊国内统一刊号 = new Label();
Edit edit中文期刊国内统一刊号 = new Edit();
Label label中文期刊年号 = new Label();
Edit edit中文期刊年号 = new Edit();
Label label中文期刊期号 = new Label();
Edit edit中文期刊期号 = new Edit();
Label label中文期刊邮发代号 = new Label();
Edit edit中文期刊邮发代号 = new Edit();
Label label主办单位 = new Label();
Edit edit主办单位 = new Edit();
Button btnAdd = new Button();
Button btnDelete = new Button();
Button btnRefresh = new Button();
Button btnUpdate = new Button();
Button btnClose = new Button();
Panel panel1 = new Panel();
DataNavigator dataNavigator = new DataNavigator();
private void initForm()
{
this.setBackColor(new Color(0, 192, 192));
this.setForeColor(new Color(0, 0, 128));
this.setLocation(new Point(7, 7));
this.setText("中文期刊管理");
this.setAutoScaleBaseSize(new Point(6, 12));
this.setAutoScroll(true);
this.setClientSize(new Point(420, 330));
this.setStartPosition(FormStartPosition.CENTER_SCREEN);
dataSource1.setConnectionString("PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source=C:\\My Documents\\db3.mdb");
dataSource1.setCommandText("select 中文期刊名, 国内发行, 中文期刊馆藏编号, 中文期刊国内统一刊号, 中文期刊年号, 中文期刊期号, 中文期刊邮发代号, 主办单位 from 中文期刊数据库 ORDER by 中文期刊馆藏编号");
dataSource1.setSort(null);
dataSource1.setStayInSync(true);
dataSource1.setUserId(null);
dataSource1.setPassword(null);
label中文期刊名.setBackColor(Color.CONTROL);
label中文期刊名.setLocation(new Point(10, 20));
label中文期刊名.setSize(new Point(100, 20));
label中文期刊名.setTabIndex(0);
label中文期刊名.setTabStop(false);
label中文期刊名.setText("中文期刊名");
edit中文期刊名.setAnchor(ControlAnchor.TOPLEFTRIGHT);
edit中文期刊名.setLocation(new Point(120, 20));
edit中文期刊名.setSize(new Point(280, 20));
edit中文期刊名.setTabIndex(1);
edit中文期刊名.setText("中文期刊名");
edit中文期刊名.setMaxLength(50);
edit中文期刊名.setMultiline(true);
label国内发行.setBackColor(Color.CONTROL);
label国内发行.setLocation(new Point(10, 50));
label国内发行.setSize(new Point(100, 20));
label国内发行.setTabIndex(2);
label国内发行.setTabStop(false);
label国内发行.setText("国内发行");
edit国内发行.setAnchor(ControlAnchor.TOPLEFTRIGHT);
edit国内发行.setLocation(new Point(120, 50));
edit国内发行.setSize(new Point(280, 20));
edit国内发行.setTabIndex(3);
edit国内发行.setText("国内发行");
edit国内发行.setMaxLength(50);
edit国内发行.setMultiline(true);
label中文期刊馆藏编号.setBackColor(Color.CONTROL);
label中文期刊馆藏编号.setLocation(new Point(10, 80));
label中文期刊馆藏编号.setSize(new Point(100, 20));
label中文期刊馆藏编号.setTabIndex(4);
label中文期刊馆藏编号.setTabStop(false);
label中文期刊馆藏编号.setText("中文期刊馆藏编号");
edit中文期刊馆藏编号.setAnchor(ControlAnchor.TOPLEFTRIGHT);
edit中文期刊馆藏编号.setLocation(new Point(120, 80));
edit中文期刊馆藏编号.setSize(new Point(280, 20));
edit中文期刊馆藏编号.setTabIndex(5);
edit中文期刊馆藏编号.setText("中文期刊馆藏编号");
edit中文期刊馆藏编号.setMultiline(true);
label中文期刊国内统一刊号.setBackColor(Color.CONTROL);
label中文期刊国内统一刊号.setLocation(new Point(10, 110));
label中文期刊国内统一刊号.setSize(new Point(100, 20));
label中文期刊国内统一刊号.setTabIndex(6);
label中文期刊国内统一刊号.setTabStop(false);
label中文期刊国内统一刊号.setText("中文期刊国内统一刊号");
edit中文期刊国内统一刊号.setAnchor(ControlAnchor.TOPLEFTRIGHT);
edit中文期刊国内统一刊号.setLocation(new Point(120, 110));
edit中文期刊国内统一刊号.setSize(new Point(280, 20));
edit中文期刊国内统一刊号.setTabIndex(7);
edit中文期刊国内统一刊号.setText("中文期刊国内统一刊号");
edit中文期刊国内统一刊号.setMaxLength(50);
edit中文期刊国内统一刊号.setMultiline(true);
label中文期刊年号.setBackColor(Color.CONTROL);
label中文期刊年号.setLocation(new Point(10, 140));
label中文期刊年号.setSize(new Point(100, 20));
label中文期刊年号.setTabIndex(8);
label中文期刊年号.setTabStop(false);
label中文期刊年号.setText("中文期刊年号");
edit中文期刊年号.setAnchor(ControlAnchor.TOPLEFTRIGHT);
edit中文期刊年号.setLocation(new Point(120, 140));
edit中文期刊年号.setSize(new Point(280, 20));
edit中文期刊年号.setTabIndex(9);
edit中文期刊年号.setText("中文期刊年号");
edit中文期刊年号.setMaxLength(50);
edit中文期刊年号.setMultiline(true);
label中文期刊期号.setBackColor(Color.CONTROL);
label中文期刊期号.setLocation(new Point(10, 170));
label中文期刊期号.setSize(new Point(100, 20));
label中文期刊期号.setTabIndex(10);
label中文期刊期号.setTabStop(false);
label中文期刊期号.setText("中文期刊期号");
edit中文期刊期号.setAnchor(ControlAnchor.TOPLEFTRIGHT);
edit中文期刊期号.setLocation(new Point(120, 170));
edit中文期刊期号.setSize(new Point(280, 20));
edit中文期刊期号.setTabIndex(11);
edit中文期刊期号.setText("中文期刊期号");
edit中文期刊期号.setMultiline(true);
label中文期刊邮发代号.setBackColor(Color.CONTROL);
label中文期刊邮发代号.setLocation(new Point(10, 200));
label中文期刊邮发代号.setSize(new Point(100, 20));
label中文期刊邮发代号.setTabIndex(12);
label中文期刊邮发代号.setTabStop(false);
label中文期刊邮发代号.setText("中文期刊邮发代号");
edit中文期刊邮发代号.setAnchor(ControlAnchor.TOPLEFTRIGHT);
edit中文期刊邮发代号.setLocation(new Point(120, 200));
edit中文期刊邮发代号.setSize(new Point(280, 20));
edit中文期刊邮发代号.setTabIndex(13);
edit中文期刊邮发代号.setText("中文期刊邮发代号");
edit中文期刊邮发代号.setMaxLength(50);
edit中文期刊邮发代号.setMultiline(true);
label主办单位.setBackColor(Color.CONTROL);
label主办单位.setLocation(new Point(10, 230));
label主办单位.setSize(new Point(100, 20));
label主办单位.setTabIndex(14);
label主办单位.setTabStop(false);
label主办单位.setText("主办单位");
edit主办单位.setAnchor(ControlAnchor.TOPLEFTRIGHT);
edit主办单位.setLocation(new Point(120, 230));
edit主办单位.setSize(new Point(280, 20));
edit主办单位.setTabIndex(15);
edit主办单位.setText("主办单位");
edit主办单位.setMaxLength(50);
edit主办单位.setMultiline(true);
dataBinder1.setDataSource(dataSource1);
dataBinder1.setDataMember("");
dataBinder1.setBindings(new DataBinding[] {
new DataBinding(edit中文期刊名, "Text", "中文期刊名", null),
new DataBinding(edit国内发行, "Text", "国内发行", null),
new DataBinding(edit中文期刊馆藏编号, "Text", "中文期刊馆藏编号", null),
new DataBinding(edit中文期刊国内统一刊号, "Text", "中文期刊国内统一刊号", null),
new DataBinding(edit中文期刊年号, "Text", "中文期刊年号", null),
new DataBinding(edit中文期刊期号, "Text", "中文期刊期号", null),
new DataBinding(edit中文期刊邮发代号, "Text", "中文期刊邮发代号", null),
new DataBinding(edit主办单位, "Text", "主办单位", null)});
/* @designTimeOnly dataBinder1.setLocation(new Point(96, 0)); */
btnAdd.setLocation(new Point(12, 8));
btnAdd.setSize(new Point(70, 30));
btnAdd.setTabIndex(0);
btnAdd.setText("&添加");
btnAdd.addOnClick(new EventHandler(this.btnAdd_Click));
btnDelete.setLocation(new Point(94, 8));
btnDelete.setSize(new Point(70, 30));
btnDelete.setTabIndex(1);
btnDelete.setText("&删除");
btnDelete.addOnClick(new EventHandler(this.btnDelete_Click));
btnRefresh.setLocation(new Point(176, 8));
btnRefresh.setSize(new Point(70, 30));
btnRefresh.setTabIndex(2);
btnRefresh.setText("刷新纪录");
btnRefresh.addOnClick(new EventHandler(this.btnRefresh_Click));
btnUpdate.setLocation(new Point(258, 8));
btnUpdate.setSize(new Point(70, 30));
btnUpdate.setTabIndex(3);
btnUpdate.setText("更新");
btnUpdate.addOnClick(new EventHandler(this.btnUpdate_Click));
btnClose.setLocation(new Point(340, 8));
btnClose.setSize(new Point(70, 30));
btnClose.setTabIndex(4);
btnClose.setText("&关闭");
btnClose.addOnClick(new EventHandler(this.btnClose_Click));
panel1.setDock(ControlDock.BOTTOM);
panel1.setLocation(new Point(0, 260));
panel1.setSize(new Point(420, 50));
panel1.setTabIndex(16);
panel1.setText("");
dataNavigator.setDock(ControlDock.BOTTOM);
dataNavigator.setLocation(new Point(0, 310));
dataNavigator.setSize(new Point(420, 20));
dataNavigator.setTabIndex(17);
dataNavigator.setTabStop(false);
dataNavigator.setText("");
dataNavigator.setDataMember("");
dataNavigator.setDataSource(dataSource1);
this.setNewControls(new Control[] {
dataNavigator,
panel1,
label中文期刊名,
edit中文期刊名,
label国内发行,
edit国内发行,
label中文期刊馆藏编号,
edit中文期刊馆藏编号,
label中文期刊国内统一刊号,
edit中文期刊国内统一刊号,
label中文期刊年号,
edit中文期刊年号,
label中文期刊期号,
edit中文期刊期号,
label中文期刊邮发代号,
edit中文期刊邮发代号,
label主办单位,
edit主办单位});
panel1.setNewControls(new Control[] {
btnAdd,
btnDelete,
btnRefresh,
btnUpdate,
btnClose});
dataSource1.begin();
dataBinder1.begin();
}
//NOTE: End of form designer support code.
/**
* The main entry point for the application.
*
* @param args Array of parameters passed to the application
* via the command line.
*/
public static void main(String args[])
{
Application.run( new Form16() );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -