home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / airline_re204714292007.psc / EmpDetails.frm < prev    next >
Text File  |  2003-04-11  |  22KB  |  825 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  3. Begin VB.Form frmEmpDetails 
  4.    Caption         =   "Form1"
  5.    ClientHeight    =   9090
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   11100
  9.    ClipControls    =   0   'False
  10.    BeginProperty Font 
  11.       Name            =   "Arial"
  12.       Size            =   9.75
  13.       Charset         =   0
  14.       Weight          =   400
  15.       Underline       =   0   'False
  16.       Italic          =   0   'False
  17.       Strikethrough   =   0   'False
  18.    EndProperty
  19.    LinkTopic       =   "Form1"
  20.    MDIChild        =   -1  'True
  21.    ScaleHeight     =   9090
  22.    ScaleWidth      =   11100
  23.    WindowState     =   2  'Maximized
  24.    Begin VB.ComboBox Combo1 
  25.       Height          =   360
  26.       Left            =   5520
  27.       TabIndex        =   32
  28.       Top             =   8640
  29.       Width           =   2295
  30.    End
  31.    Begin VB.TextBox txtEmail 
  32.       Height          =   375
  33.       Left            =   7800
  34.       TabIndex        =   5
  35.       Tag             =   "SANJEEV"
  36.       Top             =   3000
  37.       Width           =   2775
  38.    End
  39.    Begin VB.TextBox txtPhone 
  40.       Height          =   375
  41.       Left            =   7800
  42.       TabIndex        =   4
  43.       Tag             =   "SANJEEV"
  44.       Top             =   2280
  45.       Width           =   2775
  46.    End
  47.    Begin VB.ComboBox cmdDesignation 
  48.       Height          =   360
  49.       ItemData        =   "EmpDetails.frx":0000
  50.       Left            =   2520
  51.       List            =   "EmpDetails.frx":0002
  52.       Style           =   2  'Dropdown List
  53.       TabIndex        =   7
  54.       Top             =   5280
  55.       Width           =   2655
  56.    End
  57.    Begin VB.ComboBox cmdDepartment 
  58.       Height          =   360
  59.       ItemData        =   "EmpDetails.frx":0004
  60.       Left            =   2520
  61.       List            =   "EmpDetails.frx":0006
  62.       Style           =   2  'Dropdown List
  63.       TabIndex        =   6
  64.       Top             =   4560
  65.       Width           =   2655
  66.    End
  67.    Begin MSComDlg.CommonDialog CD1 
  68.       Left            =   480
  69.       Top             =   360
  70.       _ExtentX        =   847
  71.       _ExtentY        =   847
  72.       _Version        =   393216
  73.    End
  74.    Begin VB.CommandButton cmdEdit 
  75.       Caption         =   "Edit"
  76.       Height          =   375
  77.       Left            =   5640
  78.       TabIndex        =   27
  79.       Top             =   8040
  80.       Width           =   1455
  81.    End
  82.    Begin VB.CommandButton cmdSave 
  83.       Caption         =   "Save"
  84.       Default         =   -1  'True
  85.       Height          =   375
  86.       Left            =   4080
  87.       TabIndex        =   26
  88.       Top             =   8040
  89.       Width           =   1455
  90.    End
  91.    Begin VB.CommandButton cmdCancel 
  92.       Caption         =   "Cancel"
  93.       Height          =   375
  94.       Left            =   2400
  95.       TabIndex        =   25
  96.       Top             =   8040
  97.       Width           =   1455
  98.    End
  99.    Begin VB.CommandButton cmdNew 
  100.       Caption         =   "New"
  101.       Height          =   375
  102.       Left            =   840
  103.       TabIndex        =   24
  104.       Top             =   8040
  105.       Width           =   1455
  106.    End
  107.    Begin VB.TextBox txtLname 
  108.       Height          =   375
  109.       Left            =   2520
  110.       TabIndex        =   0
  111.       Tag             =   "SANJEEV"
  112.       Top             =   1560
  113.       Width           =   2295
  114.    End
  115.    Begin VB.CommandButton Command4 
  116.       Caption         =   "Browse"
  117.       Height          =   375
  118.       Left            =   5520
  119.       TabIndex        =   11
  120.       Top             =   7320
  121.       Width           =   855
  122.    End
  123.    Begin VB.PictureBox pcEmpPicture 
  124.       DataField       =   "Picture"
  125.       DataSource      =   "Adodc1"
  126.       Height          =   2415
  127.       Left            =   5520
  128.       ScaleHeight     =   2355
  129.       ScaleWidth      =   2115
  130.       TabIndex        =   22
  131.       Top             =   4440
  132.       Width           =   2175
  133.    End
  134.    Begin VB.TextBox txtPFD 
  135.       Height          =   375
  136.       Left            =   2520
  137.       TabIndex        =   10
  138.       Top             =   7440
  139.       Visible         =   0   'False
  140.       Width           =   2655
  141.    End
  142.    Begin VB.TextBox txtBase 
  143.       Height          =   375
  144.       Left            =   2520
  145.       TabIndex        =   9
  146.       Top             =   6720
  147.       Width           =   2655
  148.    End
  149.    Begin VB.TextBox txtPFN 
  150.       Height          =   375
  151.       Left            =   2520
  152.       TabIndex        =   8
  153.       Top             =   6000
  154.       Width           =   2655
  155.    End
  156.    Begin VB.TextBox txtDOJ 
  157.       Height          =   375
  158.       Left            =   2520
  159.       TabIndex        =   3
  160.       Top             =   3840
  161.       Width           =   2655
  162.    End
  163.    Begin VB.TextBox txtAddress 
  164.       Height          =   1095
  165.       Left            =   2520
  166.       MultiLine       =   -1  'True
  167.       ScrollBars      =   2  'Vertical
  168.       TabIndex        =   2
  169.       Top             =   2280
  170.       Width           =   3975
  171.    End
  172.    Begin VB.TextBox txtFname 
  173.       Height          =   375
  174.       Left            =   6600
  175.       TabIndex        =   1
  176.       Tag             =   "SANJEEV"
  177.       Top             =   1560
  178.       Width           =   2295
  179.    End
  180.    Begin VB.Label Label2 
  181.       Caption         =   "DD / MM / YYYY"
  182.       Height          =   255
  183.       Left            =   2520
  184.       TabIndex        =   31
  185.       Top             =   3600
  186.       Width           =   2175
  187.    End
  188.    Begin VB.Label lblEmail 
  189.       AutoSize        =   -1  'True
  190.       Caption         =   "Email"
  191.       Height          =   240
  192.       Left            =   7080
  193.       TabIndex        =   30
  194.       Top             =   3000
  195.       Width           =   495
  196.    End
  197.    Begin VB.Label lblPhone 
  198.       AutoSize        =   -1  'True
  199.       Caption         =   "Phone"
  200.       Height          =   240
  201.       Left            =   6960
  202.       TabIndex        =   29
  203.       Top             =   2280
  204.       Width           =   555
  205.    End
  206.    Begin VB.Label txtEmpPicturePath 
  207.       AutoSize        =   -1  'True
  208.       BackColor       =   &H00FFFFFF&
  209.       Height          =   240
  210.       Left            =   5520
  211.       TabIndex        =   28
  212.       Top             =   6960
  213.       Width           =   60
  214.    End
  215.    Begin VB.Line Line5 
  216.       BorderColor     =   &H80000001&
  217.       BorderWidth     =   5
  218.       X1              =   7920
  219.       X2              =   7920
  220.       Y1              =   8520
  221.       Y2              =   7920
  222.    End
  223.    Begin VB.Line Line4 
  224.       BorderColor     =   &H80000001&
  225.       BorderWidth     =   5
  226.       X1              =   0
  227.       X2              =   7920
  228.       Y1              =   8520
  229.       Y2              =   8520
  230.    End
  231.    Begin VB.Line Line3 
  232.       BorderColor     =   &H80000001&
  233.       BorderWidth     =   5
  234.       X1              =   0
  235.       X2              =   0
  236.       Y1              =   8520
  237.       Y2              =   7920
  238.    End
  239.    Begin VB.Line Line2 
  240.       BorderColor     =   &H80000001&
  241.       BorderWidth     =   5
  242.       X1              =   3960
  243.       X2              =   3960
  244.       Y1              =   8520
  245.       Y2              =   7920
  246.    End
  247.    Begin VB.Line Line1 
  248.       BorderColor     =   &H80000001&
  249.       BorderWidth     =   5
  250.       X1              =   0
  251.       X2              =   7920
  252.       Y1              =   7920
  253.       Y2              =   7920
  254.    End
  255.    Begin VB.Label lblPicture 
  256.       Caption         =   "Employee's Photograph"
  257.       Height          =   255
  258.       Left            =   5520
  259.       TabIndex        =   23
  260.       Top             =   3960
  261.       Width           =   2175
  262.    End
  263.    Begin VB.Label lblPFD 
  264.       AutoSize        =   -1  'True
  265.       Caption         =   "Provident Fund Dedn"
  266.       Height          =   240
  267.       Left            =   480
  268.       TabIndex        =   21
  269.       Top             =   7560
  270.       Visible         =   0   'False
  271.       Width           =   1800
  272.    End
  273.    Begin VB.Label lblBase 
  274.       AutoSize        =   -1  'True
  275.       Caption         =   "Basic Pay"
  276.       Height          =   240
  277.       Left            =   480
  278.       TabIndex        =   20
  279.       Top             =   6840
  280.       Width           =   900
  281.    End
  282.    Begin VB.Label lblPFN 
  283.       AutoSize        =   -1  'True
  284.       Caption         =   "Provident Fund No"
  285.       Height          =   240
  286.       Left            =   480
  287.       TabIndex        =   19
  288.       Top             =   6000
  289.       Width           =   1590
  290.    End
  291.    Begin VB.Label lblDesig 
  292.       AutoSize        =   -1  'True
  293.       BackStyle       =   0  'Transparent
  294.       Caption         =   "Designation"
  295.       Height          =   240
  296.       Left            =   480
  297.       TabIndex        =   18
  298.       Top             =   5280
  299.       Width           =   1020
  300.    End
  301.    Begin VB.Label lblDept 
  302.       AutoSize        =   -1  'True
  303.       BackStyle       =   0  'Transparent
  304.       Caption         =   "Department"
  305.       Height          =   240
  306.       Left            =   480
  307.       TabIndex        =   17
  308.       Top             =   4560
  309.       Width           =   1005
  310.    End
  311.    Begin VB.Label lblDOJ 
  312.       AutoSize        =   -1  'True
  313.       BackStyle       =   0  'Transparent
  314.       Caption         =   "Date of Joining"
  315.       Height          =   240
  316.       Left            =   480
  317.       TabIndex        =   16
  318.       Top             =   3840
  319.       Width           =   1275
  320.    End
  321.    Begin VB.Label lblAddress 
  322.       AutoSize        =   -1  'True
  323.       BackStyle       =   0  'Transparent
  324.       Caption         =   "Address"
  325.       Height          =   240
  326.       Left            =   480
  327.       TabIndex        =   15
  328.       Top             =   2280
  329.       Width           =   720
  330.    End
  331.    Begin VB.Label lblFirstName 
  332.       AutoSize        =   -1  'True
  333.       BackStyle       =   0  'Transparent
  334.       Caption         =   "First Name"
  335.       Height          =   240
  336.       Left            =   5400
  337.       TabIndex        =   14
  338.       Top             =   1560
  339.       Width           =   960
  340.    End
  341.    Begin VB.Label lblLastName 
  342.       AutoSize        =   -1  'True
  343.       BackStyle       =   0  'Transparent
  344.       Caption         =   "Last Name"
  345.       Height          =   240
  346.       Left            =   480
  347.       TabIndex        =   13
  348.       Top             =   1560
  349.       Width           =   945
  350.    End
  351.    Begin VB.Label Label1 
  352.       BackStyle       =   0  'Transparent
  353.       Caption         =   "Employee Details"
  354.       BeginProperty Font 
  355.          Name            =   "Arial"
  356.          Size            =   18
  357.          Charset         =   0
  358.          Weight          =   700
  359.          Underline       =   0   'False
  360.          Italic          =   0   'False
  361.          Strikethrough   =   0   'False
  362.       EndProperty
  363.       ForeColor       =   &H000000FF&
  364.       Height          =   495
  365.       Left            =   3720
  366.       TabIndex        =   12
  367.       Top             =   360
  368.       Width           =   3015
  369.    End
  370. End
  371. Attribute VB_Name = "frmEmpDetails"
  372. Attribute VB_GlobalNameSpace = False
  373. Attribute VB_Creatable = False
  374. Attribute VB_PredeclaredId = True
  375. Attribute VB_Exposed = False
  376. Option Explicit
  377. Public empNoDialog As String
  378.  
  379. Dim control As Variant
  380. Dim errorFlag As Boolean
  381. Public flag As String
  382. Dim newEmp As String
  383. Dim empName As String
  384.  
  385. Private Sub cmdCancel_Click()
  386. On Error GoTo ERRR
  387. rs.CancelUpdate
  388. rs.Close
  389. prcDisabled
  390. flag = ""
  391. Exit Sub
  392. ERRR:
  393. 'rs.Close
  394. prcDisabled
  395. flag = ""
  396. Exit Sub
  397. End Sub
  398.  
  399. Private Sub cmdEdit_Click()
  400. flag = "e"
  401. cmdEdit.Visible = False
  402. prcEnabled
  403. Combo1.Visible = True
  404. Combo1.Top = cmdEdit.Top
  405.  
  406. End Sub
  407.  
  408. Private Sub cmdNew_Click()
  409. On Error GoTo err
  410. prcNewEmp
  411. prcEnabled
  412. rs.Open "Select * from empmaster", con, adOpenDynamic, adLockOptimistic
  413. rs.AddNew
  414. flag = "n"
  415. Exit Sub
  416. err:
  417. MsgBox "eRROR"
  418. End Sub
  419.  
  420. Private Sub cmdSave_Click()
  421. prcValidate
  422. If errorFlag = True Then
  423.     flag = ""
  424.     prcSave
  425.     rs.Update
  426.     rs.Close
  427.         MsgBox "Employee Id for " & txtFname.Text & " " & txtLname.Text & " is " & newEmp
  428.  
  429.     prcDisabled
  430.     
  431. End If
  432. End Sub
  433.  
  434. Private Sub Combo1_Click()
  435. Combo1.Clear
  436. rs.Open "SELECT * FROM EMPMASTER", con, adOpenDynamic, adLockOptimistic
  437. Do While Not rs.EOF
  438. Combo1.AddItem rs("EMPNO")
  439. rs.MoveNext
  440. Loop
  441. rs.Close
  442.  
  443. rs.Open "SELECT * FROM EMPMASTER WHERE EMPNO ='" & Trim(Combo1.Text) & "'", con, adOpenDynamic, adLockOptimistic
  444. newEmp = Combo1.Text
  445. cmdEdit.Visible = True
  446. Combo1.Visible = False
  447. prcOpenRecord
  448. End Sub
  449.  
  450. Private Sub Command4_Click()
  451. CD1.DialogTitle = "Open the Employee's Picture"
  452. CD1.InitDir = "C:\"
  453. CD1.Filter = "All File(*.*)|*.*|JPEG Files(*.jpg)|*.jpg|BMP Files(*.bmp)|*.bmp"
  454. CD1.ShowOpen
  455. txtEmpPicturePath.Caption = CD1.FileName
  456. pcEmpPicture.Picture = LoadPicture(txtEmpPicturePath.Caption)
  457. pcEmpPicture.Visible = True
  458. End Sub
  459. Private Sub Form_Load()
  460. prcDisableMenu
  461. prcConnection
  462. errorFlag = True
  463. cmdDepartment.AddItem " "
  464. cmdDesignation.AddItem " "
  465. rs.Open "Select * from dept", con, adOpenDynamic, adLockOptimistic
  466. Do While Not rs.EOF
  467. cmdDepartment.AddItem rs(0)
  468. rs.MoveNext
  469. Loop
  470. rs.Close
  471.  
  472. rs.Open "Select * from desig", con, adOpenDynamic, adLockOptimistic
  473. Do While Not rs.EOF
  474. cmdDesignation.AddItem rs(0)
  475. rs.MoveNext
  476. Loop
  477. rs.Close
  478. rs.Open "SELECT * FROM EMPMASTER", con, adOpenDynamic, adLockOptimistic
  479. Do While Not rs.EOF
  480. Combo1.AddItem rs("EMPNO")
  481. rs.MoveNext
  482. Loop
  483. rs.Close
  484. prcDisabled
  485. Combo1.Visible = False
  486. End Sub
  487. Private Sub Form_Unload(Cancel As Integer)
  488. If Len(Trim(flag)) > 0 Then
  489.     MsgBox "you can't exit at this time"
  490.     Cancel = 1
  491.     Exit Sub
  492. End If
  493.  
  494. prcEnabledMenu
  495. End Sub
  496. Public Sub prcDisabled()
  497. For Each control In frmEmpDetails
  498.     If TypeOf control Is TextBox Or TypeOf control Is ComboBox Or TypeOf control Is CommandButton Then
  499.         control.Enabled = False
  500.     End If
  501. Next
  502. cmdNew.Enabled = True
  503. cmdEdit.Enabled = True
  504. Combo1.Visible = False
  505. cmdEdit.Visible = True
  506. prcClear
  507. End Sub
  508.  
  509. Public Sub prcEnabled()
  510. For Each control In frmEmpDetails
  511.     If TypeOf control Is TextBox Or TypeOf control Is ComboBox Or TypeOf control Is CommandButton Then
  512.         control.Enabled = True
  513.     End If
  514. Next
  515. cmdNew.Enabled = False
  516. cmdEdit.Enabled = False
  517. txtLname.SetFocus
  518. End Sub
  519.  
  520.  
  521. Public Sub prcValidate()
  522. Dim i, a As Integer
  523. Dim ch As String
  524. Dim chAT As Boolean
  525. Dim chDOT As Boolean
  526. Dim poAT As Integer
  527. Dim poDOT As Integer
  528. If Len(Trim(txtLname.Text)) = 0 Then
  529.     MsgBox "Please enter Last name of employee"
  530.     errorFlag = False
  531.     lblLastName.ForeColor = vbRed
  532.     txtLname.SetFocus
  533.     Exit Sub
  534. ElseIf IsNumeric(txtLname.Text) Then
  535.     MsgBox "Invalid entry in last name"
  536.     errorFlag = False
  537.     lblLastName.ForeColor = vbRed
  538.     txtLname.SetFocus
  539.     Exit Sub
  540. Else
  541.     errorFlag = True
  542.     lblLastName.ForeColor = vbBlack
  543. End If
  544.  
  545. If Len(Trim(txtFname.Text)) = 0 Then
  546.     MsgBox "Please enter first name of employee"
  547.     errorFlag = False
  548.     lblFirstName.ForeColor = vbRed
  549.     txtFname.SetFocus
  550.     Exit Sub
  551. ElseIf IsNumeric(txtFname.Text) Then
  552.     MsgBox "Invalid entry in first name"
  553.     errorFlag = False
  554.     lblFirstName.ForeColor = vbRed
  555.     txtFname.SetFocus
  556.     Exit Sub
  557. Else
  558.     errorFlag = True
  559.     lblFirstName.ForeColor = vbBlack
  560.  
  561. End If
  562.  
  563. If Len(Trim(txtAddress.Text)) = 0 Then
  564.     MsgBox "Please enter address of employee"
  565.     errorFlag = False
  566.     lblAddress.ForeColor = vbRed
  567.     txtAddress.SetFocus
  568.     Exit Sub
  569. Else
  570.     errorFlag = True
  571.     lblAddress.ForeColor = vbBlack
  572. End If
  573.  
  574. If Len(Trim(txtDOJ.Text)) = 0 Then
  575.     MsgBox "Please enter Date of Joining of employee"
  576.     errorFlag = False
  577.     lblDOJ.ForeColor = vbRed
  578.     txtDOJ.SetFocus
  579.     Exit Sub
  580. ElseIf Not IsDate(txtDOJ.Text) Then
  581.     MsgBox "Invalid entry in Date of Joining"
  582.     errorFlag = False
  583.     lblDOJ.ForeColor = vbRed
  584.     txtDOJ.SetFocus
  585.     Exit Sub
  586. Else
  587.     errorFlag = True
  588.     lblDOJ.ForeColor = vbBlack
  589. End If
  590.  
  591. If Len(Trim(txtPhone.Text)) = 0 Then
  592.     MsgBox "Please enter Phone number of employee"
  593.     errorFlag = False
  594.     lblPhone.ForeColor = vbRed
  595.     txtPhone.SetFocus
  596.     Exit Sub
  597.  
  598. Else
  599.     errorFlag = True
  600.     lblPhone.ForeColor = vbBlack
  601. End If
  602.  
  603. For i = 1 To Len(Trim(txtEmail.Text))
  604. ch = Mid(Trim(txtEmail.Text), i, Len(Trim(txtEmail.Text)) - (Len(Trim(txtEmail.Text)) - 1))
  605. If ch = "@" Then
  606.     If chAT = True Then
  607.         MsgBox "Wrong Email ID"
  608.         errorFlag = False
  609.         txtEmail.SetFocus
  610.         lblEmail.ForeColor = vbRed
  611.     
  612.         Exit Sub
  613.     Else
  614.         errorFlag = True
  615.         lblEmail.ForeColor = vbBlack
  616.     End If
  617.     
  618.     chAT = True
  619.     poAT = i
  620. ElseIf ch = "." Then
  621.     chDOT = True
  622.     poDOT = i
  623. End If
  624.  
  625. Next i
  626. If chAT = False Then
  627.     MsgBox "Wrong Email ID missing:" & vbNewLine & "'@'"
  628.     
  629.     errorFlag = False
  630.     txtEmail.SetFocus
  631.     lblEmail.ForeColor = vbRed
  632.     Exit Sub
  633. Else
  634.     errorFlag = True
  635.     lblEmail.ForeColor = vbBlack
  636. End If
  637.  
  638. If chDOT = False Then
  639.     MsgBox "Wrong Email ID missing:" & vbNewLine & "'.'"
  640.     
  641.     errorFlag = False
  642.     txtEmail.SetFocus
  643.     lblEmail.ForeColor = vbRed
  644.     Exit Sub
  645. Else
  646.     errorFlag = True
  647.     lblEmail.ForeColor = vbBlack
  648. End If
  649.  
  650. If poAT > poDOT Then
  651.     MsgBox "Wrong Email ID"
  652.     errorFlag = False
  653.     txtEmail.SetFocus
  654.     lblEmail.ForeColor = vbRed
  655.     Exit Sub
  656. Else
  657.     errorFlag = True
  658.     lblEmail.ForeColor = vbBlack
  659. End If
  660.  
  661. If Len(Trim(cmdDepartment.Text)) = 0 Then
  662.     MsgBox "Select appropriate value for Department"
  663.     errorFlag = False
  664.     cmdDepartment.SetFocus
  665.     lblDept.ForeColor = vbRed
  666.     Exit Sub
  667. Else
  668.     errorFlag = True
  669.     lblDept.ForeColor = vbBlack
  670. End If
  671. If Len(Trim(cmdDesignation.Text)) = 0 Then
  672.     MsgBox "Select appropriate value for Designation"
  673.     errorFlag = False
  674.     cmdDesignation.SetFocus
  675.     lblDesig.ForeColor = vbRed
  676.     Exit Sub
  677. Else
  678.     errorFlag = True
  679.     lblDesig.ForeColor = vbBlack
  680. End If
  681.  
  682. If Len(Trim(txtPFN.Text)) = 0 Then
  683.     MsgBox "Please enter Provident Fund number of employee"
  684.     errorFlag = False
  685.     lblPFN.ForeColor = vbRed
  686.     txtPFN.SetFocus
  687.     Exit Sub
  688.  
  689. Else
  690.     errorFlag = True
  691.     lblPFN.ForeColor = vbBlack
  692. End If
  693.  
  694. If Len(Trim(txtBase.Text)) = 0 Then
  695.     MsgBox "Please enter Basic of employee"
  696.     errorFlag = False
  697.     lblBase.ForeColor = vbRed
  698.     txtBase.SetFocus
  699.     Exit Sub
  700.  
  701. Else
  702.     errorFlag = True
  703.     lblBase.ForeColor = vbBlack
  704. End If
  705.  
  706. If Len(Trim(txtPFD.Text)) = 0 Then
  707.     txtPFD.Text = "0"
  708.     errorFlag = False
  709.     lblPFD.ForeColor = vbRed
  710.     'txtPFD.SetFocus
  711.     Exit Sub
  712.  
  713. Else
  714.     errorFlag = True
  715.     lblPFD.ForeColor = vbBlack
  716. End If
  717. If Len(Trim(txtEmpPicturePath.Caption)) = 0 Then
  718.     If vbNo = MsgBox("Are you sure you don't want to add picture of the employee", vbYesNo, "Confirm Picture Select") Then
  719.         MsgBox "Click on the browse to select the picture"
  720.         errorFlag = False
  721.         Command4.SetFocus
  722.         lblPicture.ForeColor = vbRed
  723.     Else
  724.         errorFlag = True
  725.         lblPicture.ForeColor = vbBlack
  726.     End If
  727. End If
  728. End Sub
  729.  
  730. Private Sub txtDOJ_LostFocus()
  731. txtDOJ.Text = Format(txtDOJ.Text, "DD/MMM/YYYY")
  732.  
  733. End Sub
  734.  
  735. Public Sub prcSave()
  736. On Error GoTo err
  737.  
  738. rs("EmpNo") = newEmp
  739. rs("First_Name") = Trim(txtFname.Text)
  740. rs("Last_name") = Trim(txtLname.Text)
  741. rs("address") = Trim(txtAddress.Text)
  742. rs("doj") = Trim(txtDOJ.Text)
  743. rs("dept") = Trim(cmdDepartment.Text)
  744. rs("desig") = Trim(cmdDesignation.Text)
  745. rs("pfno") = Trim(txtPFN.Text)
  746. rs("basic") = Trim(txtBase.Text)
  747. rs("pfdedn") = 0
  748. rs("picture_path") = Trim(txtEmpPicturePath.Caption)
  749. rs("phone") = Trim(txtPhone.Text)
  750. rs("email") = Trim(txtEmail.Text)
  751. Exit Sub
  752. err:
  753. MsgBox err.Description
  754. End Sub
  755.  
  756.  
  757. Public Sub prcNewEmp()
  758. Dim C As Integer
  759. Dim empNo As String
  760.  
  761. newEmp = ""
  762. C = 0
  763. rs.Open "Select * from empmaster", con, adOpenDynamic, adLockOptimistic
  764. Do While Not rs.EOF
  765. C = C + 1
  766. rs.MoveNext
  767. Loop
  768. rs.Close
  769.  
  770. If C = 0 Then
  771. newEmp = "E001"
  772. Exit Sub
  773. End If
  774. rs.Open "Select * from empmaster", con, adOpenDynamic, adLockOptimistic
  775. rs.MoveLast
  776. empNo = rs("empno")
  777. empNo = Mid(empNo, 2, 4)
  778. newEmp = empNo + 1
  779. If newEmp >= 1 And newEmp <= 9 Then
  780. newEmp = "E00" + newEmp
  781. ElseIf newEmp >= 10 And newEmp <= 99 Then
  782. newEmp = "E0" + newEmp
  783. ElseIf newEmp >= 100 And newEmp <= 999 Then
  784. newEmp = "E" + newEmp
  785. End If
  786. rs.Close
  787. End Sub
  788.  
  789. Public Sub prcClear()
  790. For Each control In frmEmpDetails
  791.     If TypeOf control Is TextBox Then
  792.         control.Text = ""
  793.     End If
  794.     
  795. Next
  796.  
  797. cmdDepartment.ListIndex = 0
  798. cmdDesignation.ListIndex = 0
  799. Combo1.Text = ""
  800.  
  801. txtEmpPicturePath.Caption = ""
  802. pcEmpPicture.Visible = False
  803.  
  804. End Sub
  805.  
  806. Public Sub prcOpenRecord()
  807. txtFname.Text = rs("First_Name")
  808. txtLname.Text = rs("Last_name")
  809. txtAddress.Text = rs("address")
  810. txtDOJ.Text = rs("doj")
  811. cmdDepartment.Text = rs("dept")
  812. cmdDesignation.Text = rs("desig")
  813. txtPFN.Text = rs("pfno")
  814. txtBase.Text = rs("basic")
  815. txtPFD.Text = rs("pfdedn")
  816. txtEmpPicturePath.Caption = rs("picture_path") & " "
  817. If Len(Trim(txtEmpPicturePath.Caption)) > 0 Then
  818.     pcEmpPicture.Picture = LoadPicture(Trim(txtEmpPicturePath.Caption))
  819.     pcEmpPicture.Visible = True
  820. End If
  821. txtPhone.Text = rs("phone")
  822. txtEmail.Text = rs("email")
  823.  
  824. End Sub
  825.