📄 form22.java
字号:
//Form22.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 Form22 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 );
dataGrid.setDataSource( (Recordset)dataSource1.getRecordset().getField("ChildCMD").getObject());
}
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();
dataGrid.setDataSource( (Recordset)dataSource1.getRecordset().getField("ChildCMD").getObject());
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 Form22()
{
// Required for Visual J++ Form Designer support
initForm();
dataGrid.setDataSource( (Recordset)dataSource1.getRecordset().getField("ChildCMD").getObject());
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(), "Form22" );
}
/**
* 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();
CheckBox chk借书情况 = new CheckBox();
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();
DataGrid dataGrid = new DataGrid();
Column column1 = new Column();
Column column2 = new Column();
Column column3 = new Column();
Column column4 = new Column();
Column column5 = new Column();
Column column6 = new Column();
Column column7 = new Column();
Column column8 = new Column();
private void initForm()
{
this.setBackColor(new Color(0, 192, 192));
this.setForeColor(new Color(0, 0, 192));
this.setLocation(new Point(7, 7));
this.setText("中文期刊借还管理");
this.setAutoScaleBaseSize(new Point(6, 12));
this.setAutoScroll(true);
this.setClientSize(new Point(792, 573));
this.setStartPosition(FormStartPosition.CENTER_SCREEN);
dataSource1.setConnectionString("PROVIDER=MSDataShape;Data PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source=C:\\My Documents\\db3.mdb");
dataSource1.setCommandText("SHAPE {select 姓名, 读者借书证号, 国籍, 借书情况, 中文期刊馆藏编号 from 表2 ORDER by 读者借书证号} AS ParentCMD APPEND ({select 中文期刊名, 中文期刊馆藏编号, 中文期刊国内统一刊号, 中文期刊年号, 中文期刊期号, 中文期刊邮发代号, 主办单位, 国内发行 from 中文期刊数据库 ORDER by 中文期刊馆藏编号 } AS ChildCMD RELATE 中文期刊馆藏编号 TO 中文期刊馆藏编号) AS ChildCMD");
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(652, 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, 48));
edit读者借书证号.setSize(new Point(652, 20));
edit读者借书证号.setTabIndex(3);
edit读者借书证号.setText("读者借书证号");
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(652, 20));
edit国籍.setTabIndex(5);
edit国籍.setText("国籍");
edit国籍.setMaxLength(50);
edit国籍.setMultiline(true);
chk借书情况.setBackColor(Color.CONTROL);
chk借书情况.setLocation(new Point(10, 110));
chk借书情况.setSize(new Point(120, 20));
chk借书情况.setTabIndex(6);
chk借书情况.setText("借书情况");
chk借书情况.setTextAlign(LeftRightAlignment.LEFT);
chk借书情况.setChecked(true);
chk借书情况.setCheckState(CheckState.CHECKED);
label中文期刊馆藏编号.setBackColor(Color.CONTROL);
label中文期刊馆藏编号.setLocation(new Point(10, 140));
label中文期刊馆藏编号.setSize(new Point(100, 20));
label中文期刊馆藏编号.setTabIndex(7);
label中文期刊馆藏编号.setTabStop(false);
label中文期刊馆藏编号.setText("中文期刊馆藏编号");
edit中文期刊馆藏编号.setAnchor(ControlAnchor.TOPLEFTRIGHT);
edit中文期刊馆藏编号.setLocation(new Point(120, 140));
edit中文期刊馆藏编号.setSize(new Point(652, 20));
edit中文期刊馆藏编号.setTabIndex(8);
edit中文期刊馆藏编号.setText("中文期刊馆藏编号");
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(chk借书情况, "Checked", "借书情况", 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(256, 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, 503));
panel1.setSize(new Point(792, 50));
panel1.setTabIndex(10);
panel1.setText("");
dataNavigator.setDock(ControlDock.BOTTOM);
dataNavigator.setLocation(new Point(0, 553));
dataNavigator.setSize(new Point(792, 20));
dataNavigator.setTabIndex(11);
dataNavigator.setTabStop(false);
dataNavigator.setText("");
dataNavigator.setDataMember("");
dataNavigator.setDataSource(dataSource1);
column1.setWidth(190);
column1.setAlignment(ContentAlignment.MIDDLELEFT);
column1.setBoundFieldName("中文期刊名");
column1.setCaption("中文期刊名");
column1.setIndex(0);
column2.setWidth(104);
column2.setAlignment(ContentAlignment.MIDDLELEFT);
column2.setBoundFieldName("中文期刊馆藏编号");
column2.setCaption("中文期刊馆藏编号");
column2.setIndex(1);
column3.setWidth(128);
column3.setAlignment(ContentAlignment.MIDDLELEFT);
column3.setBoundFieldName("中文期刊国内统一刊号");
column3.setCaption("中文期刊国内统一刊号");
column3.setIndex(2);
column4.setWidth(80);
column4.setAlignment(ContentAlignment.MIDDLELEFT);
column4.setBoundFieldName("中文期刊年号");
column4.setCaption("中文期刊年号");
column4.setIndex(3);
column5.setWidth(80);
column5.setAlignment(ContentAlignment.MIDDLELEFT);
column5.setBoundFieldName("中文期刊期号");
column5.setCaption("中文期刊期号");
column5.setIndex(4);
column6.setWidth(104);
column6.setAlignment(ContentAlignment.MIDDLELEFT);
column6.setBoundFieldName("中文期刊邮发代号");
column6.setCaption("中文期刊邮发代号");
column6.setIndex(5);
column7.setWidth(200);
column7.setAlignment(ContentAlignment.MIDDLELEFT);
column7.setBoundFieldName("主办单位");
column7.setCaption("主办单位");
column7.setIndex(6);
column8.setWidth(200);
column8.setAlignment(ContentAlignment.MIDDLELEFT);
column8.setBoundFieldName("国内发行");
column8.setCaption("国内发行");
column8.setIndex(7);
dataGrid.setAnchor(ControlAnchor.TOPLEFTRIGHT);
dataGrid.setBackColor(Color.WINDOW);
dataGrid.setLocation(new Point(8, 192));
dataGrid.setSize(new Point(772, 250));
dataGrid.setTabIndex(9);
dataGrid.setText("");
dataGrid.setCaption("");
dataGrid.setColumns(new Column[] {
column1,
column2,
column3,
column4,
column5,
column6,
column7,
column8});
dataGrid.setHeaderFont(Font.DEFAULT_GUI);
dataGrid.setDynamicColumns(false);
dataGrid.setDataMember("");
this.setNewControls(new Control[] {
dataNavigator,
panel1,
label姓名,
edit姓名,
label读者借书证号,
edit读者借书证号,
label国籍,
edit国籍,
chk借书情况,
label中文期刊馆藏编号,
edit中文期刊馆藏编号,
dataGrid});
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 Form22() );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -