Friday, November 13, 2009

CPD User Names Module 12 November

Dim cpd
Dim frmCPDMain
Dim panel
Dim frmUserAddEdit
Dim tabControl
Dim tabPage
Dim textBox
Dim groupBox
Dim ultraGrid
Dim file
Dim i


Sub Test1

'TestedApps.CPD2.Run()
Call Aliases.Explorer.wndShell_TrayWnd.ReBarWindow32.MSTaskSwWClass.ToolbarWindow32.CheckItem("Inter-Agency Child Protection Database - [User Names and passwords]", True, False)
Set cpd = Aliases.CPD
Set frmCPDMain = cpd.frmCPDMain
Call frmCPDMain.StripMainMenu.Click("Tools|User Names and passwords")
aqUtils.Delay(1000)
Set panel = frmCPDMain.MdiClient.frmUserMaster.panel2
Set frmUserAddEdit = cpd.frmUserAddEdit
Set tabControl = frmUserAddEdit.tabControl1


set file=DDt.ExcelDriver("D:\book1.xls","Sheet1")
j=1
while Not(file.EOF())

Call panel.toolStripProtocol.ClickItem("New")
Call tabControl.ClickTab("User")
Set tabPage = tabControl.tpUser
Set textBox = tabPage.txtUserName
Call textBox.Click(41, 6)


textBox.wText = file.Value("User")
Call textBox.Keys("[Tab]")
Set textBox = tabPage.txtPassword
textBox.wText = file.Value("Password")
Call textBox.Keys("[Tab]")
tabPage.txtConfirmPassword.wText = file.Value("Password")
Set groupBox = tabPage.grpBx

Select Case j
Case 1
tabControl.tpUser.chkIsAdmin.wState = cbChecked

case 2
groupBox.chkAddEditData.wState = cbChecked
groupBox.chkDeleteData.wState = cbChecked
groupBox.chkDropDown.wState = cbChecked
groupBox.chkCustReports.wState = cbChecked
groupBox.chkExImData.wState = cbChecked
groupBox.chkImportSystemConfig.wState = cbChecked
groupBox.chkDbBackup.wState = cbChecked
frmUserAddEdit.btnSave.ClickButton

case 3
groupBox.chkAddEditData.wState = cbChecked
case 4
groupBox.chkDeleteData.wState = cbChecked
case 5
groupBox.chkDropDown.wState = cbChecked
case 6
groupBox.chkCustReports.wState = cbChecked
case 7
groupBox.chkExImData.wState = cbChecked
case 8
groupBox.chkImportSystemConfig.wState = cbChecked
case 9
groupBox.chkDbBackup.wState = cbChecked

case Else
MsgBox("Some Error occured with j")
exit Sub

end Select

frmUserAddEdit.btnSave.ClickButton
j=j+1
file.Next


Wend
MsgBox(CStr(j))

set file=DDt.ExcelDriver("D:\book1.xls","Sheet1")

while Not(file.EOF)
j=1


Call frmCPDMain.StripMainMenu.Click("Logout")

Set frmLogin = cpd.frmLogin
Set textBox = frmLogin.txtUserName
Call textBox.Click(74, 10)
textBox.wText = file.Value("User")
Call textBox.Keys("[Tab]")
Set textBox = frmLogin.txtPassword
textBox.wText = file.Value("Password")
Call textBox.Keys("[Tab]")
Call frmLogin.btnOK.Keys("[Enter]")
Set frmChangePassword = cpd.frmChangePassword
Set tabControl = frmChangePassword.tabControl1

' -------------------Code to change password when user logs in for first time------------------------------
Call tabControl.Keys("[Tab]")
Call tabControl.ClickTab("User")
Set tabPage = tabControl.tpUser
Call tabPage.txtUserName.Keys("[Tab]")
Set textBox = tabPage.txtOldPassword
textBox.wText = file.Value("Password")
Call textBox.Keys("[Tab]")
Set textBox = tabPage.txtNewPassword
textBox.wText = file.Value("Password")
Call textBox.Keys("[Tab]")
Set textBox = tabPage.txtConfirmPassword
textBox.wText = file.Value("Password")
Call textBox.Keys("[Tab]")
Call frmChangePassword.btnSave.Keys("[Enter]")
Call cpd.dlgInterAgencyChildProtectionDatabase.btnOK.Keys("[Enter]")

MsgBox("Stop Script")

Wend

End Sub

Set cpd = Aliases.CPD
Set frmCPDMain = cpd.frmCPDMain
set frmperson = frmCPDMain.MdiClient.frmPerson
Set ultraGrid = Aliases.CPD.frmCPDMain.MdiClient.frmPerson.ctrlChildView.ugChild


Sub Test2
Aliases.CPD.win
' Dim cpd
' Dim frmCPDMain
' 'TestedApps.CPD2.Run()
' Set cpd = Aliases.CPD
' Set frmCPDMain = cpd.frmCPDMain

'Call frmCPDMain.StripMainMenu.Click("Tools")


Call frmCPDMain.StripMainMenu.Click("Children")
Log.Message( export_import(True))
'Log.Message(delete_buttons(False))
Log.Message(is_admin())
Log.Message(restore_backup())
Log.Message(cust_dropdown())
Log.Message(cust_reports())
Log.Message(toolbar_new())
Log.Message(toolbar_edit())


'Log.Message("Export Import Menu bar" +CStr(exp_imp_menu()))







End Sub

'-------------------- Functions------------------------------------------------------

Function delete_buttons(flag)
flag2=""
' Checking toolbar delete

flag2=del_toolbar()
Log.Message("Toolbar Delete Button: "+CStr(flag2))
if flag <> flag2 Then
delete_buttons="........FAIL..........."
Exit Function
end if
'checking delete on right click
flag2=del_rightclk()
Log.Message("Right Click Delete Button: "+CStr(flag2))
if flag <> flag2 Then
delete_buttons=".........FAIL......."
Exit Function
end if
'checking delete on Registration Form
Call frmPerson.ctrlChildView.ugChild.ClickCellXY(1, 1, 55, 6)
Call cpd.frmChild_CaseData.pnlBase.flp.RegcustPanel.panel1.picBox.Click(31, 14)
flag2=del_regform()
Log.Message("Registration Form Delete Button: "+CStr(flag2))
if flag <> flag2 Then
delete_buttons=".......FAIL.........."
Exit Function
end if
cpd.frmPersonNew.Close
'checking Delete on Case Data Form
Call Aliases.CPD.frmChild_CaseData.pnlBase.flp.custPanel0.panel1.picBox.Click()
flag2=del_casedata_toolbar()
Log.Message("Case Data Form Delete Button: "+CStr(flag2))
if flag <> flag2 Then
delete_buttons=".........FAIL........."
Exit Function
end if
Aliases.CPD.frmCaseData.close()
delete_buttons="........PASS........"

end Function


Function export_import(flag)

flag2=""

'Checking Export import in Menu
Call frmCPDMain.StripMainMenu.Click("Tools")
flag2=exp_imp_menu()
Log.Message("Export Import Menu bar"+CStr(flag2))
if not flag = flag2 Then
MsgBox(CStr(flag)+CStr(flag2)+"Hi")
export_import="FAIL"
Exit Function
end if


'checking Export Import in Tool Bar
flag2=exp_toolbar()
Log.Message("Export In Tool bar"+CStr(flag2))
if flag <> flag2 Then
export_import="FAIL"
Exit Function
end if
flag2=imp_toolbar()
Log.Message("Import In Tool bar"+CStr(flag2))

if flag <> flag2 Then
export_import="FAIL"
Exit Function
end if
flag2=exptoexcel_toolbar()
Log.Message("Export to excel Toolbar"+CStr(flag2))
if flag<>flag2 Then
export_import="FAIL"
Exit Function
end if
flag2=trnsfr_toolbar()
Log.Message("Transfer in Toolbar"+CStr(flag2))
if flag <> flag2 Then
export_import="FAIL"
Exit Function
end if
flag2=refral_toolbar()
Log.Message("Referal in Toolbar"+CStr(flag2))
if flag <> flag2 Then
export_import="FAIL"
Exit Function
end if
'Checking Export Import in Tracing Request
flag2=export_tr()
Log.Message("Export in Toolbar Tracing Request "+CStr(flag2))
if flag <> flag2 Then
export_import="FAIL"
Exit Function
end if
flag2=import_tr()
Log.Message("Import in Toolbar Tracing Request "+CStr(flag2))
if flag <> flag2 Then
export_import="FAIL"
Exit Function
end if
flag2=exportoexcel_tr()
Log.Message("Export To Excel in Toolbar Tracing Request "+CStr(flag2))
if flag <> flag2 Then
export_import="FAIL"
Exit Function
end if

'checking Record Matching
flag2=exportoexcel_RM()
Log.Message("Export to Excel in Record Matching"+CStr(flag2))
if flag <> flag2 Then
export_import="FAIL"
Exit Function
end if

export_import="PASS"
end Function





Function exp_imp_menu()
'---- i is a global variable ----
i=1
MsgBox(cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(3).Text)

While ((cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(3).Text <> "Import") AND i<20)
'MsgBox(cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(3).Text)
'MsgBox(cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(4).Text)
i=i+1
Wend

if (cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(3).Text = "Import" And cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(4).Text = "Export") then
Call frmCPDMain.StripMainMenu.Click("Tools")
if (cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(3).Visible = True And cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(4).Visible = True) then
exp_imp_menu=True
Else
exp_imp_menu=False
end If
Else
exp_imp_menu=False
End if


end Function


Function exp_toolbar()

exp_toolbar=aqObject.CompareProperty(frmPerson.toolStripChild.wEnabled("Export"), cmpEqual, True, False)

end Function

Function imp_toolbar()
imp_toolbar =aqObject.CompareProperty(frmPerson.toolStripChild.wEnabled("Import"), cmpEqual, True, False)

End Function

Function exptoexcel_toolbar()
exptoexcel_toolbar=CompareProperty(frmPerson.toolStripChild.wEnabled("Export to Excel"), cmpEqual, True, False)
end Function

Function trnsfr_toolbar()
trnsfr_toolbar=aqObject.CompareProperty(frmPerson.toolStripChild.wEnabled("Transfer"), cmpEqual, True, False)
end Function

Function refral_toolbar()
refral_toolbar = aqObject.CompareProperty(frmPerson.toolStripChild.wEnabled("Referral"), cmpEqual, True, False)
end Function

Function export_cd_toolbar()

export_cd_toolbar=CompareProperty(CPD.frmCaseData.toolStripManageForm.wEnabled("Export"),cmpEqual,True, False)

end Function

Function import_cd_toolbar()

import_cd_toolbar=CompareProperty(CPD.frmCaseData.toolStripManageForm.wEnabled("Import"),cmpEqual,True, False)

end Function

Function open_cd_form()
Call frmCPDMain.StripMainMenu.Click("Children")
Call frmPerson.ctrlChildView.ugChild.ClickCellXY(1, 1, 55, 6)
Call Aliases.CPD.frmChild_CaseData.pnlBase.flp.custPanel0.panel1.picBox.Click()

end Function

Function close_cd_form()
Aliases.CPD.frmCaseData.close()
End Function

' To Check Export Button on Tracing request
Function export_tr()
Call frmCPDMain.StripMainMenu.Click("Tracing Request")
export_tr=aqObject.CompareProperty(frmPerson.toolStripChild.wEnabled("Export"), cmpEqual, True, False)
end Function

Function import_tr()
import_tr=aqObject.CompareProperty(frmPerson.toolStripChild.wEnabled("Import"), cmpEqual, True, False)
end Function

Function exportoexcel_tr()
exportoexcel_tr = aqObject.CompareProperty(frmPerson.toolStripChild.wEnabled("Export to Excel"), cmpEqual, True, False)
end Function


' To check button in Record Matching
function exportoexcel_RM()
Call frmCPDMain.StripMainMenu.Click("Record Matching")
exportoexcel_RM=aqObject.CompareProperty(frmPerson.toolStripChild.wEnabled("Export to Excel"), cmpEqual, True, False)
end Function



Function restore_backup()
' i=1
' While ((cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(3).Text <> "Backup") AND i<20)
' MsgBox(cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(3).Text)
' MsgBox(cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(4).Text)
' MsgBox(CStr(i))
' i=i+1
' Wend
'Call frmCPDMain.StripMainMenu.Click("Tools")


if (cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(0).Text = "Backup" And cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(1).Text = "Restore") then
Call frmCPDMain.StripMainMenu.Click("Tools")
if (cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(0).Visible = True And cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(1).Visible = True) then
restore_backup = True
Else
restore_backup = False
end if
Else
restore_backup = False
End if

end Function


Function cust_dropdown()

if cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(7).Text = "Customize Drop-down Values" then
cust_dropdown = True
Else
cust_dropdown = False
end if

end Function

Function cust_reports()
if cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(11).Text = "Customize Reports" then
cust_reports=True
Else
cust_reports= False
end If
end Function

Function is_admin ()

if (Trim((cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(8).Text) = "User Names and passwords" And Trim(cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(13).Text) = "Set Time Scale Targets")) then
is_admin = True
Else
is_admin= False

Log.Message(CStr(cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(8).Text))
Log.Message(CStr(cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(13).Text))

end If
end Function

' Checking Delete Button on Children - Tool Bar
Function del_toolbar()
del_toolbar=aqObject.CompareProperty(frmPerson.toolStripChild.wEnabled(2), cmpEqual, True, False)
End Function

' Checking Delete function on Registration Form
Function del_regform()
del_regform = CompareProperty(CPD.frmPersonNew.ugTab.ugTabPageChild.toolStripManageForm.wEnabled("Delete"), cmpEqual, True, False)
end Function

' Checking Delete button ON - Case data Tool bars :
Function del_casedata_toolbar()
del_casedata_toolbar = CompareProperty(CPD.frmCaseData.toolStripManageForm.wEnabled("Delete"),cmpEqual,True, False)
end Function

' Checking Delete Button on Right Click menu
Function del_rightclk()

Call frmCPDMain.StripMainMenu.Click("Children")
Call ultraGrid.ClickCellRXY(3, "Status", 28, 6)

if CPD.WinFormsObject("ContextMenuStrip", "", 1).Items.Item_2(1).text= "Delete" then
del_rightclk=True
Else
del_rightclk=False
end if
end Function



Function toolbar_new()
toolbar_new = aqObject.CompareProperty(frmPerson.toolStripChild.wEnabled(0), cmpEqual, True, False)

end Function

Function toolbar_edit()

toolbar_edit = aqObject.CompareProperty(frmPerson.toolStripChild.wEnabled(1), cmpEqual, True, False)

end Function

No comments:

Post a Comment

I welcome your comment, will respond and post it at the earliest:)