Form_NewDataBase.frm
上传用户:zhpu1995
上传日期:2013-09-06
资源大小:61151k
文件大小:10k
源码类别:

企业管理

开发平台:

Visual Basic

  1. VERSION 5.00
  2. Begin VB.Form Frm_Newdatabase 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "新建套帐"
  5.    ClientHeight    =   3330
  6.    ClientLeft      =   240
  7.    ClientTop       =   2670
  8.    ClientWidth     =   5085
  9.    HelpContextID   =   1012
  10.    Icon            =   "Form_NewDataBase.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    LockControls    =   -1  'True
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   3330
  16.    ScaleWidth      =   5085
  17.    Begin VB.CommandButton Command2 
  18.       Caption         =   "1"
  19.       BeginProperty Font 
  20.          Name            =   "Wingdings"
  21.          Size            =   9
  22.          Charset         =   2
  23.          Weight          =   400
  24.          Underline       =   0   'False
  25.          Italic          =   0   'False
  26.          Strikethrough   =   0   'False
  27.       EndProperty
  28.       Height          =   285
  29.       Left            =   4590
  30.       TabIndex        =   19
  31.       Top             =   1170
  32.       Width           =   315
  33.    End
  34.    Begin VB.TextBox Text1 
  35.       Height          =   270
  36.       Index           =   3
  37.       Left            =   1410
  38.       Locked          =   -1  'True
  39.       TabIndex        =   6
  40.       Top             =   1170
  41.       Width           =   3225
  42.    End
  43.    Begin VB.Frame Frame1 
  44.       Caption         =   "数据库信息"
  45.       Height          =   1725
  46.       Left            =   150
  47.       TabIndex        =   9
  48.       Top             =   1470
  49.       Width           =   4755
  50.       Begin VB.TextBox Text2 
  51.          Height          =   285
  52.          Index           =   0
  53.          Left            =   1380
  54.          TabIndex        =   13
  55.          Top             =   330
  56.          Width           =   2505
  57.       End
  58.       Begin VB.TextBox Text2 
  59.          Height          =   285
  60.          IMEMode         =   3  'DISABLE
  61.          Index           =   1
  62.          Left            =   1380
  63.          PasswordChar    =   "*"
  64.          TabIndex        =   12
  65.          Top             =   630
  66.          Width           =   2505
  67.       End
  68.       Begin VB.TextBox Text2 
  69.          Height          =   285
  70.          Index           =   2
  71.          Left            =   1380
  72.          TabIndex        =   11
  73.          Top             =   930
  74.          Width           =   2505
  75.       End
  76.       Begin VB.ComboBox Combo1 
  77.          Height          =   300
  78.          ItemData        =   "Form_NewDataBase.frx":038A
  79.          Left            =   1380
  80.          List            =   "Form_NewDataBase.frx":0391
  81.          Style           =   2  'Dropdown List
  82.          TabIndex        =   10
  83.          Top             =   1230
  84.          Width           =   2505
  85.       End
  86.       Begin VB.Label Label2 
  87.          AutoSize        =   -1  'True
  88.          Caption         =   "用户名:"
  89.          Height          =   180
  90.          Index           =   0
  91.          Left            =   360
  92.          TabIndex        =   17
  93.          Top             =   330
  94.          Width           =   630
  95.       End
  96.       Begin VB.Label Label2 
  97.          AutoSize        =   -1  'True
  98.          Caption         =   "口令:"
  99.          Height          =   180
  100.          Index           =   1
  101.          Left            =   360
  102.          TabIndex        =   16
  103.          Top             =   660
  104.          Width           =   450
  105.       End
  106.       Begin VB.Label Label2 
  107.          AutoSize        =   -1  'True
  108.          Caption         =   "数据服务器:"
  109.          Height          =   180
  110.          Index           =   2
  111.          Left            =   360
  112.          TabIndex        =   15
  113.          Top             =   960
  114.          Width           =   990
  115.       End
  116.       Begin VB.Label Label2 
  117.          AutoSize        =   -1  'True
  118.          Caption         =   "数据库类型:"
  119.          Height          =   180
  120.          Index           =   3
  121.          Left            =   360
  122.          TabIndex        =   14
  123.          Top             =   1290
  124.          Width           =   990
  125.       End
  126.    End
  127.    Begin VB.CommandButton Command1 
  128.       Caption         =   "取消&C"
  129.       Height          =   315
  130.       Index           =   1
  131.       Left            =   3720
  132.       TabIndex        =   8
  133.       Top             =   600
  134.       Width           =   1125
  135.    End
  136.    Begin VB.CommandButton Command1 
  137.       Caption         =   "确定&D"
  138.       Height          =   315
  139.       Index           =   0
  140.       Left            =   3720
  141.       TabIndex        =   7
  142.       Top             =   150
  143.       Width           =   1125
  144.    End
  145.    Begin VB.TextBox Text1 
  146.       Enabled         =   0   'False
  147.       Height          =   270
  148.       Index           =   2
  149.       Left            =   1410
  150.       TabIndex        =   5
  151.       Top             =   810
  152.       Width           =   2085
  153.    End
  154.    Begin VB.TextBox Text1 
  155.       Height          =   270
  156.       Index           =   1
  157.       Left            =   1410
  158.       TabIndex        =   4
  159.       Top             =   480
  160.       Width           =   2085
  161.    End
  162.    Begin VB.TextBox Text1 
  163.       Height          =   270
  164.       Index           =   0
  165.       Left            =   1410
  166.       TabIndex        =   3
  167.       Top             =   150
  168.       Width           =   2085
  169.    End
  170.    Begin VB.Label Label1 
  171.       AutoSize        =   -1  'True
  172.       Caption         =   "库文件路径:"
  173.       Height          =   180
  174.       Index           =   3
  175.       Left            =   240
  176.       TabIndex        =   18
  177.       Top             =   1170
  178.       Width           =   990
  179.    End
  180.    Begin VB.Label Label1 
  181.       Caption         =   "数据库名:"
  182.       Height          =   225
  183.       Index           =   2
  184.       Left            =   270
  185.       TabIndex        =   2
  186.       Top             =   840
  187.       Width           =   945
  188.    End
  189.    Begin VB.Label Label1 
  190.       Caption         =   "套帐名:"
  191.       Height          =   225
  192.       Index           =   1
  193.       Left            =   270
  194.       TabIndex        =   1
  195.       Top             =   510
  196.       Width           =   945
  197.    End
  198.    Begin VB.Label Label1 
  199.       Caption         =   "套帐编号:"
  200.       Height          =   225
  201.       Index           =   0
  202.       Left            =   270
  203.       TabIndex        =   0
  204.       Top             =   180
  205.       Width           =   945
  206.    End
  207. End
  208. Attribute VB_Name = "Frm_Newdatabase"
  209. Attribute VB_GlobalNameSpace = False
  210. Attribute VB_Creatable = False
  211. Attribute VB_PredeclaredId = True
  212. Attribute VB_Exposed = False
  213. Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
  214.     If KeyCode = 13 Then
  215.         SendKeys "{Tab}", True
  216.     End If
  217. End Sub
  218. Private Sub Command1_Click(Index As Integer)
  219.     If Index = 1 Then
  220.         Unload Me
  221.         Exit Sub
  222.     End If
  223.     
  224.     If Trim(Text1(0).Text) = "" Then MsgBox "套帐编码不能为空! ", 16: Text1(0).SetFocus: Exit Sub
  225.     If Trim(Text1(1).Text) = "" Then MsgBox "套帐名称不能为空! ", 16: Text1(1).SetFocus: Exit Sub
  226.     If Trim(Text1(2).Text) = "" Then MsgBox "数据库名不能为空! ", 16: Text1(2).SetFocus: Exit Sub
  227.     If IsNumeric(Text1(2).Text) Then MsgBox "数据库名不能为数值! ", 16: Text1(2).SetFocus: Exit Sub
  228.     If Trim(Text2(0).Text) = "" Then MsgBox "数据库用户不能为空! ", 16: Text2(0).SetFocus: Exit Sub
  229.     If Trim(Text2(2).Text) = "" Then MsgBox "数据服务器不能为空! ", 16: Text2(2).SetFocus: Exit Sub
  230.     '--------------------------
  231.     Dim Data_Error As Integer
  232.     Dim Data_ErrorName As String
  233.     'On Error GoTo Exit_error
  234.     Class.StatusBar "正在检测数据库信息...", False
  235.     If Conn_System1.State = 1 Then Conn_System1.Close
  236.     Conn_System1.Open "Provider=SQLOLEDB.1;Persist Security Info=False;Data Source=" & Trim(Text2(2).Text) & "; Initial Catalog=master;", Trim(Text2(0).Text), Trim(Text2(1).Text)
  237.     Class.StatusBar "", True
  238.     Me.MousePointer = 12
  239.     Class.StatusBar "正在创建套帐...", False
  240.     If Cw_DataEnvi.Connection2.State = 1 Then Cw_DataEnvi.Connection2.Close
  241.     Cw_DataEnvi.Connection2.Open "Provider=SQLOLEDB.1;Persist Security Info=False;Data Source=" & Trim(Text2(2).Text) & "; Initial Catalog=master;", Trim(Text2(0).Text), Trim(Text2(1).Text)
  242.     '-----------------
  243.     Cw_DataEnvi.dbo_HD_AddDatabase Trim(Text1(2).Text), Trim(Text1(3).Text) _
  244.                   , "Erp5Data", "Erp5Data", App.Path, Trim(Text1(1).Text), Trim(Text1(0).Text) _
  245.                   , Trim(Text2(2).Text), Trim(Combo1.Text), Data_Error, Data_ErrorName
  246.                   
  247.     Err.Clear
  248.     Class.StatusBar "", True
  249.     Me.MousePointer = 0
  250.     If Conn_System1.State = 1 Then Conn_System1.Close: Set Conn_System1 = Nothing
  251.     If Cw_DataEnvi.Connection2.State = 1 Then Cw_DataEnvi.Connection2.Close
  252.     Conn_System.Execute "update master.dbo.HDSystem_DataBases  set CountingRoomName='安信软件',CoName='常熟安信软件服务有限公司',YNuse='1',qsqj=1 where  DataBasesName='" & Text1(2).Text & "'"
  253.     If Data_Error = 1 Then
  254.         Form_main.Form_Load
  255.         MsgBox Data_ErrorName, 48
  256.         Unload Me
  257.       Else
  258.         Text1(2).Text = "AX" & Year(Date) & Month(Date) & Day(Date) & Hour(Time) & Minute(Time) & Second(Time)
  259.         MsgBox Data_ErrorName, 16
  260.     End If
  261.     Exit Sub
  262.     
  263.     '-----------------
  264. EXIT_ERROR:
  265.     Class.StatusBar "", True
  266.     Me.MousePointer = 0
  267.     Select Case Err.Number
  268.     Case -2147467259
  269.           MsgBox "数据服务器错误!", 16
  270.     Case -2147217843
  271.          MsgBox "用户名或口令错误!", 16
  272.     Case Else
  273.          MsgBox Err.Description & "(" & Err.Number & ")", 16
  274.     End Select
  275. End Sub
  276. Private Sub Command2_Click()
  277.     Frm_Path.Show 1
  278.     If PathStr <> "" Then Text1(3).Text = PathStr
  279. End Sub
  280. Private Sub Form_Load()
  281.     Dim str As String
  282.     Combo1.ListIndex = 0
  283.     Call TextFile
  284.     Text1(2).Text = "AX" & Year(Date) & Month(Date) & Day(Date) & Hour(Time) & Minute(Time) & Second(Time)
  285.     Text1(3).Text = App.Path
  286. End Sub
  287. Private Sub Text1_Change(Index As Integer)
  288.     If Index = 3 Then
  289.        If Len(Trim(Text1(3).Text)) = 3 Then Text1(3).Text = Mid(Trim(Text1(3)), 1, 2)
  290.     End If
  291. End Sub
  292. Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
  293.     If KeyCode = 13 Then
  294.     SendKeys "{Tab}", True
  295.     End If
  296. End Sub
  297. Private Sub Text2_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
  298.     If KeyCode = 13 Then
  299.         SendKeys "{Tab}", True
  300.     End If
  301. End Sub
  302. Private Sub TextFile()
  303.     Text2(2).Text = ReadOneString("Option", "SqlServer", "localhost")
  304.     Text2(0) = ReadOneString("Option", "UserID", "")
  305. End Sub