Jump to content

Salary - calculator hour/day/month


Zedna
 Share

Recommended Posts

Salary - calculator hour/day/month

You can enter any of the three values and other two are immediatelly calculated

Number of hours a day (8), days a month (20) is configurable in INI file:

salary.ini

[Config]
Hours=8
Days=20


Code:

#AutoIt3Wrapper_Icon=salary.ico
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_run_obfuscator=y
#Obfuscator_parameters=/SO /OM
#NoTrayIcon

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Global $ext = StringRight(@ScriptName, 4) ; .exe / .au3
Global $ini = StringReplace(@ScriptName,$ext,'.ini',1,1)

Global $ini_h = IniRead($ini, "Config", "Hours", "8")
If $ini_h == '' Then $ini_h = 8
Global $ini_d = IniRead($ini, "Config", "Days", "20")
If $ini_d == '' Then $ini_d = 20

#Region ### START Koda GUI section ### Form=salary.kxf
$Form1 = GUICreate("Salary", 385, 54)
$ed_hour = GUICtrlCreateInput("", 14, 10, 57, 21)
GUICtrlSetColor(-1, 0x800080)
$lbl_hour = GUICtrlCreateLabel("/hour", 75, 13, 27, 17)
$lbl_arrow1 = GUICtrlCreateLabel("==>", 105, 13, 25, 17, $SS_CENTER)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x800000)
$lbl_x_hour = GUICtrlCreateLabel("x" & $ini_h, 110, 32, 17, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
$ed_day = GUICtrlCreateInput("", 140, 10, 57, 21)
GUICtrlSetColor(-1, 0x800080)
GUICtrlSetBkColor(-1, 0xFFFFB9)
$lbl_day = GUICtrlCreateLabel("/day", 201, 13, 27, 17)
$lbl_arrow2 = GUICtrlCreateLabel("==>", 234, 13, 25, 17, $SS_CENTER)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x800000)
$lbl_x_day = GUICtrlCreateLabel("x" & $ini_d, 235, 32, 24, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
$ed_month = GUICtrlCreateInput("", 272, 10, 57, 21)
GUICtrlSetColor(-1, 0x800080)
GUICtrlSetBkColor(-1, 0xFFFF00)
$lbl_month = GUICtrlCreateLabel("/month", 333, 12, 37, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func WM_COMMAND($hWinHandle, $iMsg, $wParam, $lParam)
    If _WinAPI_HiWord($wParam) = $EN_CHANGE Then
        Switch _WinAPI_LoWord($wParam)
            Case $ed_hour
                $h = Num(GUICtrlRead($ed_hour))
                GUICtrlSetData($ed_day, P($h, Round($h * $ini_h, 0)))
                GUICtrlSetData($ed_month, P($h, Round($h * $ini_h * $ini_d, 0)))
            Case $ed_day
                $d = Num(GUICtrlRead($ed_day))
                GUICtrlSetData($ed_hour, P($d, Round($d / $ini_h, 0)))
                GUICtrlSetData($ed_month, P($d, Round($d * $ini_d, 0)))
            Case $ed_month
                $m = Num(GUICtrlRead($ed_month))
                GUICtrlSetData($ed_hour, P($m, Round($m / $ini_d / $ini_h, 0)))
                GUICtrlSetData($ed_day, P($m, Round($m / $ini_d, 0)))
        EndSwitch
    EndIf
EndFunc

Func Num($c)
    If $c == '' Then Return ''
    $c = StringReplace($c,',','.',1,1)
    If StringRight($c,1) == '.' Then $c = StringTrimRight($c,1)
    Return $c
EndFunc

Func P($c, $v) ; empty
    If $c == '' Then Return ''
    Return $v
EndFunc

Screenshot:

image.png.6c9b1688f8887027ea3fcd0c8f69a294.png

 

Link to comment
Share on other sites

Just note:

I have created very similar utility/calculator for myself for showing (downloaded green) actual currency exchange rate USD/Kc EUR/Kc (Czech crown) and bidirectional calculation between these currencies by this exchange rate.

Just screenshots:

image.png.3b5e58792625525f19d2bf59f092f144.png

image.png.68900a6db5acd69adfbb19b77bea5ae2.png

Edited by Zedna
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...