0byt3m1n1
Path:
C:
/
BACKUPS
/
Biometric Backup
/
KELTRON
/
COSEC V14R4.1
/
Setup
/
API Samples
/
VB 6.0
/
[
Home
]
File: ctlUserAddEdit.ctl
VERSION 5.00 Begin VB.UserControl ctlUserAddEdit ClientHeight = 10200 ClientLeft = 0 ClientTop = 0 ClientWidth = 7155 ScaleHeight = 10200 ScaleWidth = 7155 Begin VB.CommandButton cmdfind Caption = "&Find" Height = 375 Left = 4500 TabIndex = 3 Top = 60 Width = 1215 End Begin VB.CommandButton cmdReset Caption = "&Reset" Height = 375 Left = 5880 TabIndex = 44 Top = 9720 Width = 1155 End Begin VB.CommandButton cmdSave Caption = "&Save" Height = 375 Left = 4560 TabIndex = 43 Top = 9720 Width = 1155 End Begin VB.CheckBox chkActive Height = 195 Left = 1920 TabIndex = 10 Top = 1980 Width = 195 End Begin VB.ComboBox cmbgrade Height = 315 Left = 1920 Style = 2 'Dropdown List TabIndex = 42 Top = 9180 Width = 5115 End Begin VB.ComboBox cmbcategory Height = 315 Left = 1920 Style = 2 'Dropdown List TabIndex = 40 Top = 8730 Width = 5115 End Begin VB.ComboBox cmbsection Height = 315 Left = 1920 Style = 2 'Dropdown List TabIndex = 38 Top = 8280 Width = 5115 End Begin VB.ComboBox cmbdesignation Height = 315 Left = 1920 Style = 2 'Dropdown List TabIndex = 36 Top = 7815 Width = 5115 End Begin VB.ComboBox cmbdepartment Height = 315 Left = 1920 Style = 2 'Dropdown List TabIndex = 34 Top = 7365 Width = 5115 End Begin VB.ComboBox cmbbranch Height = 315 Left = 1920 Style = 2 'Dropdown List TabIndex = 32 Top = 6915 Width = 5115 End Begin VB.ComboBox cmborganization Height = 315 ItemData = "ctlUserAddEdit.ctx":0000 Left = 1920 List = "ctlUserAddEdit.ctx":000A Style = 2 'Dropdown List TabIndex = 30 Top = 6465 Width = 5115 End Begin VB.TextBox txtaccessvaliditydate Height = 315 Left = 1920 TabIndex = 28 Top = 6015 Width = 2475 End Begin VB.TextBox txtcard2 Height = 315 Left = 1920 TabIndex = 26 Top = 5550 Width = 2475 End Begin VB.TextBox txtcard1 Height = 315 Left = 1920 TabIndex = 24 Top = 5100 Width = 2475 End Begin VB.TextBox txtpin Height = 315 Left = 1920 TabIndex = 22 Top = 4650 Width = 2475 End Begin VB.TextBox txtofficialemail Height = 315 Left = 1920 TabIndex = 20 Top = 4200 Width = 2475 End Begin VB.TextBox txtofficialcell Height = 315 Left = 1920 TabIndex = 18 Top = 3750 Width = 2475 End Begin VB.TextBox txtofficialextension Height = 315 Left = 1920 TabIndex = 16 Top = 3285 Width = 2475 End Begin VB.TextBox txtofficialphone Height = 315 Left = 1920 TabIndex = 14 Top = 2835 Width = 2475 End Begin VB.TextBox txtdateofbirth Height = 315 Left = 1920 TabIndex = 12 Top = 2385 Width = 2475 End Begin VB.TextBox txtshortname Height = 315 Left = 1920 TabIndex = 8 Top = 1485 Width = 2475 End Begin VB.TextBox txtname Height = 315 Left = 1920 TabIndex = 6 Top = 1020 Width = 2475 End Begin VB.TextBox txtreferencecode Height = 315 Left = 1920 TabIndex = 4 Top = 570 Width = 2475 End Begin VB.TextBox txtid Height = 315 Left = 1920 TabIndex = 1 Top = 120 Width = 2475 End Begin VB.Label Label1 Caption = "DDMMYYYY (e.g. 15062011)" ForeColor = &H000000C0& Height = 255 Index = 22 Left = 4500 TabIndex = 46 Top = 6060 Width = 2475 End Begin VB.Label Label1 Caption = "DDMMYYYY (e.g. 28101984)" ForeColor = &H000000C0& Height = 255 Index = 21 Left = 4500 TabIndex = 45 Top = 2400 Width = 2415 End Begin VB.Label Label1 Caption = "grade:" Height = 255 Index = 20 Left = 120 TabIndex = 41 Top = 9210 Width = 1635 End Begin VB.Label Label1 Caption = "category:" Height = 255 Index = 19 Left = 120 TabIndex = 39 Top = 8760 Width = 1635 End Begin VB.Label Label1 Caption = "section:" Height = 255 Index = 18 Left = 120 TabIndex = 37 Top = 8310 Width = 1635 End Begin VB.Label Label1 Caption = "designation:" Height = 255 Index = 17 Left = 120 TabIndex = 35 Top = 7845 Width = 1635 End Begin VB.Label Label1 Caption = "department:" Height = 255 Index = 16 Left = 120 TabIndex = 33 Top = 7395 Width = 1635 End Begin VB.Label Label1 Caption = "branch:" Height = 255 Index = 15 Left = 120 TabIndex = 31 Top = 6945 Width = 1635 End Begin VB.Label Label1 Caption = "organization:" Height = 255 Index = 14 Left = 120 TabIndex = 29 Top = 6495 Width = 1635 End Begin VB.Label Label1 Caption = "access-validity-date:" Height = 255 Index = 13 Left = 120 TabIndex = 27 Top = 6045 Width = 1635 End Begin VB.Label Label1 Caption = "card-2:" Height = 255 Index = 12 Left = 120 TabIndex = 25 Top = 5580 Width = 1635 End Begin VB.Label Label1 Caption = "card-1:" Height = 255 Index = 11 Left = 120 TabIndex = 23 Top = 5130 Width = 1635 End Begin VB.Label Label1 Caption = "pin:" Height = 255 Index = 10 Left = 120 TabIndex = 21 Top = 4680 Width = 1635 End Begin VB.Label Label1 Caption = "official-email:" Height = 255 Index = 9 Left = 120 TabIndex = 19 Top = 4230 Width = 1635 End Begin VB.Label Label1 Caption = "official-cell:" Height = 255 Index = 8 Left = 120 TabIndex = 17 Top = 3780 Width = 1635 End Begin VB.Label Label1 Caption = "official-extension:" Height = 255 Index = 7 Left = 120 TabIndex = 15 Top = 3315 Width = 1635 End Begin VB.Label Label1 Caption = "official-phone:" Height = 255 Index = 6 Left = 120 TabIndex = 13 Top = 2865 Width = 1635 End Begin VB.Label Label1 Caption = "date-of-birth:" Height = 255 Index = 5 Left = 120 TabIndex = 11 Top = 2415 Width = 1635 End Begin VB.Label Label1 Caption = "active:" Height = 255 Index = 4 Left = 120 TabIndex = 9 Top = 1950 Width = 1635 End Begin VB.Label Label1 Caption = "short-name:" Height = 255 Index = 3 Left = 120 TabIndex = 7 Top = 1500 Width = 1635 End Begin VB.Label Label1 Caption = "name:" Height = 255 Index = 2 Left = 120 TabIndex = 5 Top = 1050 Width = 1635 End Begin VB.Label Label1 Caption = "reference-code:" Height = 255 Index = 1 Left = 120 TabIndex = 2 Top = 600 Width = 1635 End Begin VB.Label Label1 Caption = "id:" Height = 255 Index = 0 Left = 120 TabIndex = 0 Top = 150 Width = 1635 End End Attribute VB_Name = "ctlUserAddEdit" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Private Sub cmdfind_Click() Dim err As String Dim objUserParams As UserAPIParameters Form1.ShowMessage "Requesting...", True Set objUserParams = Form1.apiHelperObj.GetUser(txtid.Text, err) If (Not objUserParams Is Nothing) Then txtid.Text = objUserParams.id txtreferencecode.Text = objUserParams.reference_code txtname.Text = objUserParams.username txtshortname.Text = objUserParams.short_name If (CInt(objUserParams.active) = 1) Then chkActive.Value = 1 Else chkActive.Value = 0 End If txtdateofbirth.Text = objUserParams.date_of_birth txtofficialphone.Text = objUserParams.official_phone txtofficialextension.Text = objUserParams.official_extension txtofficialcell.Text = objUserParams.official_cell txtofficialemail.Text = objUserParams.official_email txtpin.Text = objUserParams.pin txtcard1.Text = objUserParams.card_1 txtcard2.Text = objUserParams.card_2 txtaccessvaliditydate.Text = objUserParams.access_validity_date cmborganization.ListIndex = GetListIndex(cmborganization, objUserParams.organization) cmbbranch.ListIndex = GetListIndex(cmbbranch, objUserParams.branch) cmbdepartment.ListIndex = GetListIndex(cmbdepartment, objUserParams.department) cmbdesignation.ListIndex = GetListIndex(cmbdesignation, objUserParams.designation) cmbsection.ListIndex = GetListIndex(cmbsection, objUserParams.section) cmbcategory.ListIndex = GetListIndex(cmbcategory, objUserParams.category) cmbgrade.ListIndex = GetListIndex(cmbgrade, objUserParams.grade) Form1.ShowMessage "Request Completed", True Else Form1.ShowMessage err, False Call cmdReset_Click End If End Sub Private Function GetListIndex(CmbBox As ComboBox, itemValue As String) As Integer Dim i As Integer For i = 0 To CmbBox.ListCount - 1 If (CmbBox.ItemData(i) = itemValue) Then GetListIndex = i Exit Function End If Next End Function Private Sub cmdReset_Click() txtid.Text = "" txtreferencecode.Text = "" txtname.Text = "" txtshortname.Text = "" chkActive.Value = 0 txtdateofbirth.Text = "" txtofficialphone.Text = "" txtofficialextension.Text = "" txtofficialcell.Text = "" txtofficialemail.Text = "" txtpin.Text = "" txtcard1.Text = "" txtcard2.Text = "" txtaccessvaliditydate.Text = "" cmborganization.ListIndex = 0 cmbbranch.ListIndex = 0 cmbdepartment.ListIndex = 0 cmbdesignation.ListIndex = 0 cmbsection.ListIndex = 0 cmbcategory.ListIndex = 0 cmbgrade.ListIndex = 0 End Sub Private Sub cmdSave_Click() Form1.ClearMessage Dim objUserAPIParams As New UserAPIParameters objUserAPIParams.id = Trim(txtid.Text) objUserAPIParams.reference_code = Trim(txtreferencecode.Text) objUserAPIParams.username = Trim(txtname.Text) objUserAPIParams.short_name = Trim(txtshortname.Text) If (chkActive.Value = 1) Then objUserAPIParams.active = "1" Else objUserAPIParams.active = "0" End If objUserAPIParams.date_of_birth = Trim(txtdateofbirth.Text) objUserAPIParams.official_phone = Trim(txtofficialphone.Text) objUserAPIParams.official_extension = Trim(txtofficialextension.Text) objUserAPIParams.official_cell = Trim(txtofficialcell.Text) objUserAPIParams.official_email = Trim(txtofficialemail.Text) objUserAPIParams.pin = Trim(txtpin.Text) objUserAPIParams.card_1 = Trim(txtcard1.Text) objUserAPIParams.card_2 = Trim(txtcard2.Text) objUserAPIParams.access_validity_date = Trim(txtaccessvaliditydate.Text) objUserAPIParams.organization = cmborganization.ItemData(cmborganization.ListIndex) objUserAPIParams.branch = cmbbranch.ItemData(cmbbranch.ListIndex) objUserAPIParams.department = cmbdepartment.ItemData(cmbdepartment.ListIndex) objUserAPIParams.designation = cmbdesignation.ItemData(cmbdesignation.ListIndex) objUserAPIParams.section = cmbsection.ItemData(cmbsection.ListIndex) objUserAPIParams.category = cmbcategory.ItemData(cmbcategory.ListIndex) objUserAPIParams.grade = cmbgrade.ItemData(cmbgrade.ListIndex) Dim objResponseData As APIResponse Set objResponseData = Form1.apiHelperObj.SaveUser(objUserAPIParams) Form1.ShowMessage objResponseData.SuccessFailMessage, objResponseData.IsSuccess End Sub Private Sub UserControl_Initialize() Width = 7155 Height = 10200 End Sub Private Sub UserControl_Resize() Width = 7155 Height = 10200 End Sub Public Sub Load() Call CheckResponse(cmborganization, Form1.apiHelperObj.GetOrganization(xml)) Call CheckResponse(cmbbranch, Form1.apiHelperObj.GetBranch(xml)) Call CheckResponse(cmbdepartment, Form1.apiHelperObj.GetDepartment(xml)) Call CheckResponse(cmbdesignation, Form1.apiHelperObj.GetDesignation(xml)) Call CheckResponse(cmbsection, Form1.apiHelperObj.GetSection(xml)) Call CheckResponse(cmbcategory, Form1.apiHelperObj.GetCategory(xml)) Call CheckResponse(cmbgrade, Form1.apiHelperObj.GetGrade(xml)) Label1(14).Caption = Form1.apiHelperObj.strORG + ":" Label1(15).Caption = Form1.apiHelperObj.strBRC + ":" Label1(16).Caption = Form1.apiHelperObj.strDPT + ":" Label1(17).Caption = Form1.apiHelperObj.strDSG + ":" Label1(18).Caption = Form1.apiHelperObj.strSEC + ":" Label1(19).Caption = Form1.apiHelperObj.strCTG + ":" Label1(20).Caption = Form1.apiHelperObj.strGRD + ":" End Sub Private Sub CheckResponse(ByRef CmbBox As ComboBox, ByRef APIResponse As APIResponse) If (Not APIResponse Is Nothing) Then If (Trim(APIResponse.Data) <> "") Then 'If (apiResponse.Format = xml) Then Dim rs As ADODB.Recordset Set rs = Form1.apiHelperObj.RecordSetFromXMLString(APIResponse.Data) CmbBox.Clear While rs.EOF = False CmbBox.AddItem rs("name") CmbBox.ItemData(CmbBox.ListCount - 1) = rs("id") rs.MoveNext Wend rs.Close Set rs = Nothing If (CmbBox.ListCount > 0) Then CmbBox.ListIndex = 0 End If 'End If End If If (APIResponse.IsSuccess) Then If (Trim(APIResponse.SuccessFailMessage) = "") Then Form1.ShowMessage "Request completed", True Else Form1.ShowMessage APIResponse.SuccessFailMessage, True End If Else Form1.ShowMessage APIResponse.SuccessFailMessage, False End If End If End Sub