AddNewBook.frm
上传用户:zhuahui520
上传日期:2007-05-21
资源大小:347k
文件大小:12k
源码类别:

其他智力游戏

开发平台:

Java

  1. VERSION 5.00
  2. Begin VB.Form AddNewBook 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "添加新图书"
  5.    ClientHeight    =   4905
  6.    ClientLeft      =   45
  7.    ClientTop       =   330
  8.    ClientWidth     =   6645
  9.    Icon            =   "AddNewBook.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   4905
  14.    ScaleWidth      =   6645
  15.    ShowInTaskbar   =   0   'False
  16.    StartUpPosition =   2  '屏幕中心
  17.    Begin VB.CommandButton cmdOkCancel 
  18.       Cancel          =   -1  'True
  19.       Caption         =   "取消(&C)"
  20.       BeginProperty Font 
  21.          Name            =   "楷体_GB2312"
  22.          Size            =   12
  23.          Charset         =   134
  24.          Weight          =   700
  25.          Underline       =   0   'False
  26.          Italic          =   0   'False
  27.          Strikethrough   =   0   'False
  28.       EndProperty
  29.       Height          =   495
  30.       Index           =   1
  31.       Left            =   3960
  32.       Style           =   1  'Graphical
  33.       TabIndex        =   14
  34.       ToolTipText     =   "关闭此对话框"
  35.       Top             =   4320
  36.       Width           =   1335
  37.    End
  38.    Begin VB.CommandButton cmdOkCancel 
  39.       Caption         =   "添加(&E)"
  40.       Default         =   -1  'True
  41.       BeginProperty Font 
  42.          Name            =   "楷体_GB2312"
  43.          Size            =   12
  44.          Charset         =   134
  45.          Weight          =   700
  46.          Underline       =   0   'False
  47.          Italic          =   0   'False
  48.          Strikethrough   =   0   'False
  49.       EndProperty
  50.       Height          =   495
  51.       Index           =   0
  52.       Left            =   1560
  53.       Style           =   1  'Graphical
  54.       TabIndex        =   13
  55.       ToolTipText     =   "将图书加入数据库"
  56.       Top             =   4320
  57.       Width           =   1335
  58.    End
  59.    Begin VB.Frame Frame1 
  60.       Caption         =   "新书基本信息"
  61.       Height          =   3975
  62.       Left            =   120
  63.       TabIndex        =   1
  64.       Top             =   120
  65.       Width           =   6375
  66.       Begin VB.Frame Frame2 
  67.          Height          =   855
  68.          Left            =   360
  69.          TabIndex        =   11
  70.          Top             =   3120
  71.          Width           =   5775
  72.          Begin VB.Label Label2 
  73.             AutoSize        =   -1  'True
  74.             Caption         =   "**  请将以上信息填写完整,以便日后查询"
  75.             ForeColor       =   &H00C000C0&
  76.             Height          =   180
  77.             Left            =   1080
  78.             TabIndex        =   12
  79.             Top             =   360
  80.             Width           =   3420
  81.          End
  82.       End
  83.       Begin VB.ComboBox Combo1 
  84.          BeginProperty Font 
  85.             Name            =   "宋体"
  86.             Size            =   10.5
  87.             Charset         =   134
  88.             Weight          =   400
  89.             Underline       =   0   'False
  90.             Italic          =   0   'False
  91.             Strikethrough   =   0   'False
  92.          EndProperty
  93.          ForeColor       =   &H00000000&
  94.          Height          =   330
  95.          ItemData        =   "AddNewBook.frx":0442
  96.          Left            =   4800
  97.          List            =   "AddNewBook.frx":0444
  98.          TabIndex        =   10
  99.          Text            =   "Combo1"
  100.          Top             =   1320
  101.          Width           =   1335
  102.       End
  103.       Begin VB.TextBox txtCost 
  104.          BeginProperty Font 
  105.             Name            =   "宋体"
  106.             Size            =   10.5
  107.             Charset         =   134
  108.             Weight          =   400
  109.             Underline       =   0   'False
  110.             Italic          =   0   'False
  111.             Strikethrough   =   0   'False
  112.          EndProperty
  113.          ForeColor       =   &H00000000&
  114.          Height          =   315
  115.          Left            =   4800
  116.          TabIndex        =   9
  117.          Text            =   "Text1"
  118.          Top             =   2280
  119.          Width           =   1335
  120.       End
  121.       Begin VB.TextBox txtBookChu 
  122.          BeginProperty Font 
  123.             Name            =   "宋体"
  124.             Size            =   10.5
  125.             Charset         =   134
  126.             Weight          =   400
  127.             Underline       =   0   'False
  128.             Italic          =   0   'False
  129.             Strikethrough   =   0   'False
  130.          EndProperty
  131.          ForeColor       =   &H00000000&
  132.          Height          =   315
  133.          Left            =   1200
  134.          TabIndex        =   8
  135.          Text            =   "Text1"
  136.          Top             =   2280
  137.          Width           =   2535
  138.       End
  139.       Begin VB.TextBox txtBookName 
  140.          BeginProperty Font 
  141.             Name            =   "宋体"
  142.             Size            =   10.5
  143.             Charset         =   134
  144.             Weight          =   400
  145.             Underline       =   0   'False
  146.             Italic          =   0   'False
  147.             Strikethrough   =   0   'False
  148.          EndProperty
  149.          ForeColor       =   &H00000000&
  150.          Height          =   315
  151.          Left            =   1200
  152.          TabIndex        =   7
  153.          Text            =   "Text1"
  154.          Top             =   1290
  155.          Width           =   2535
  156.       End
  157.       Begin VB.TextBox txtBookNum 
  158.          BeginProperty Font 
  159.             Name            =   "宋体"
  160.             Size            =   12
  161.             Charset         =   134
  162.             Weight          =   700
  163.             Underline       =   0   'False
  164.             Italic          =   0   'False
  165.             Strikethrough   =   0   'False
  166.          EndProperty
  167.          ForeColor       =   &H00FF0000&
  168.          Height          =   330
  169.          Left            =   1920
  170.          TabIndex        =   0
  171.          Top             =   600
  172.          Width           =   1815
  173.       End
  174.       Begin VB.Image Image1 
  175.          Height          =   480
  176.          Left            =   4800
  177.          Picture         =   "AddNewBook.frx":0446
  178.          Top             =   480
  179.          Width           =   480
  180.       End
  181.       Begin VB.Label Label1 
  182.          AutoSize        =   -1  'True
  183.          Caption         =   "出版社"
  184.          BeginProperty Font 
  185.             Name            =   "宋体"
  186.             Size            =   12
  187.             Charset         =   134
  188.             Weight          =   700
  189.             Underline       =   0   'False
  190.             Italic          =   0   'False
  191.             Strikethrough   =   0   'False
  192.          EndProperty
  193.          ForeColor       =   &H00FF0000&
  194.          Height          =   240
  195.          Index           =   4
  196.          Left            =   360
  197.          TabIndex        =   6
  198.          Top             =   2280
  199.          Width           =   780
  200.       End
  201.       Begin VB.Label Label1 
  202.          AutoSize        =   -1  'True
  203.          Caption         =   "类  别"
  204.          BeginProperty Font 
  205.             Name            =   "宋体"
  206.             Size            =   12
  207.             Charset         =   134
  208.             Weight          =   700
  209.             Underline       =   0   'False
  210.             Italic          =   0   'False
  211.             Strikethrough   =   0   'False
  212.          EndProperty
  213.          ForeColor       =   &H00FF0000&
  214.          Height          =   240
  215.          Index           =   3
  216.          Left            =   3960
  217.          TabIndex        =   5
  218.          Top             =   1320
  219.          Width           =   795
  220.       End
  221.       Begin VB.Label Label1 
  222.          AutoSize        =   -1  'True
  223.          Caption         =   "价  格"
  224.          BeginProperty Font 
  225.             Name            =   "宋体"
  226.             Size            =   12
  227.             Charset         =   134
  228.             Weight          =   700
  229.             Underline       =   0   'False
  230.             Italic          =   0   'False
  231.             Strikethrough   =   0   'False
  232.          EndProperty
  233.          ForeColor       =   &H00FF0000&
  234.          Height          =   240
  235.          Index           =   2
  236.          Left            =   3960
  237.          TabIndex        =   4
  238.          Top             =   2280
  239.          Width           =   795
  240.       End
  241.       Begin VB.Label Label1 
  242.          AutoSize        =   -1  'True
  243.          Caption         =   "书  名"
  244.          BeginProperty Font 
  245.             Name            =   "宋体"
  246.             Size            =   12
  247.             Charset         =   134
  248.             Weight          =   700
  249.             Underline       =   0   'False
  250.             Italic          =   0   'False
  251.             Strikethrough   =   0   'False
  252.          EndProperty
  253.          ForeColor       =   &H00FF0000&
  254.          Height          =   240
  255.          Index           =   1
  256.          Left            =   360
  257.          TabIndex        =   3
  258.          Top             =   1320
  259.          Width           =   795
  260.       End
  261.       Begin VB.Label Label1 
  262.          AutoSize        =   -1  'True
  263.          Caption         =   "输入图书编号"
  264.          BeginProperty Font 
  265.             Name            =   "宋体"
  266.             Size            =   12
  267.             Charset         =   134
  268.             Weight          =   700
  269.             Underline       =   0   'False
  270.             Italic          =   0   'False
  271.             Strikethrough   =   0   'False
  272.          EndProperty
  273.          ForeColor       =   &H000000C0&
  274.          Height          =   240
  275.          Index           =   0
  276.          Left            =   360
  277.          TabIndex        =   2
  278.          Top             =   600
  279.          Width           =   1545
  280.       End
  281.    End
  282. End
  283. Attribute VB_Name = "AddNewBook"
  284. Attribute VB_GlobalNameSpace = False
  285. Attribute VB_Creatable = False
  286. Attribute VB_PredeclaredId = True
  287. Attribute VB_Exposed = False
  288. Dim db As Database
  289. Dim rst As Recordset
  290. Dim db1 As Database
  291. Dim rst1 As Recordset
  292. Private Sub cmdOkCancel_Click(Index As Integer)
  293. Select Case Index
  294.     Case 0
  295.         If txtBookNum = "" Or txtBookName = "" Or Combo1.Text = "" _
  296.             Or txtCost = "" Or txtBookChu = "" Then
  297.                 MsgBox "请将所有信息填写完整!", 0 + 48, "提示"
  298.                 Exit Sub
  299.         End If
  300.         rst.Seek "=", Trim(txtBookNum.Text)
  301.         If rst.NoMatch = False Then
  302.             MsgBox "此编号已经存在,请填写其它编号!", 0 + 48, "提示"
  303.             'txtBookNum.SelText = txtBookNum.Text
  304.             txtBookNum.SetFocus
  305.             Exit Sub
  306.         End If
  307.         rst.AddNew
  308.         rst.Fields("图书编号") = Trim(txtBookNum.Text)
  309.         rst.Fields("书名") = txtBookName.Text
  310.         rst.Fields("类别") = Combo1.Text
  311.         rst.Fields("价格") = txtCost.Text
  312.         rst.Fields("出版社") = txtBookChu.Text
  313.         rst.Update
  314.         MsgBox "添加成功!按回车继续", 0 + 48, "成功"
  315.         txtBookNum.Text = ""
  316.         txtBookName = ""
  317.         txtCost = ""
  318.         Combo1.Text = ""
  319.         txtBookChu = ""
  320.         txtBookNum.SetFocus
  321.     Case 1
  322.         Unload Me
  323. End Select
  324. End Sub
  325. Private Sub Form_Load()
  326. Set db = Workspaces(0).OpenDatabase("DataBaseData.mdb", False)
  327. Set rst = db.OpenRecordset("Book", dbOpenTable)
  328. rst.Index = "图书编号"
  329. Set db1 = Workspaces(0).OpenDatabase("DataBaseData.mdb", False)
  330. Set rst1 = db1.OpenRecordset("Type", dbOpenTable)
  331. TypeAdd
  332. txtBookNum.Text = ""
  333. txtBookName = ""
  334. txtCost = ""
  335. Combo1.Text = ""
  336. txtBookChu = ""
  337. End Sub
  338. Private Sub Form_Unload(Cancel As Integer)
  339. rst.Close
  340. rst1.Close
  341. db1.Close
  342. db.Close
  343. End Sub
  344. Private Sub TypeAdd()
  345. rst1.MoveLast
  346. rst1.MoveFirst
  347. For i = 1 To rst1.RecordCount
  348.     Combo1.AddItem rst1.Fields("类别")
  349.     rst1.MoveNext
  350.     If rst1.EOF Then Exit Sub
  351. Next
  352. End Sub