Product List: Organize products and prices for a small business

Post your working scripts, libraries and tools for AHK v1.1 and older
EntropicBlackhole
Posts: 40
Joined: 12 Jun 2021, 15:28

Product List: Organize products and prices for a small business

Post by EntropicBlackhole » 25 Oct 2021, 14:06

Organize your business with Product List, just insert in the name and price of the product, and it'll be listed

The + Button is to add a new product to the list
The - Button is to delete any product from the list
The Modify Button is to modify any item from the list
The Save Button will save the list of items to the Ini file
The AOT Checkbox will keep the window Always On Top
The Reload Button will Reload the script
The Search Edit is where you can type a product's name and it will appear on the list
The DropDown is where you can filter the searcher. Select Name and only products with matching names will appear, select Price and only products with matching prices will appear
Press F6 to show the GUI
Enjoy! (If you find any bugs tell me so I can fix them)

Code: Select all

#SingleInstance Force
#NoEnv
SetWorkingDir %A_ScriptDir%
SetBatchLines -1
SysGet, VSBW, 2 ; SM_CXVSCROLL
Rows := 30
MinW := 96 - VSBW
MaxW := 96
Col2W := Max
Fol := "C:\Users\" A_UserName "\AppData\Local\EPBHs Creations\Product List"
Ini := Fol "\Items.ini"
FileCreateDir, %Fol%
IniRead, CreateItems, %Ini%, Items
Gui, Add, ListView, xm ym w337 h170 +LV0x10000 -Multi, Name|Price
Gui, Font, s30
Gui, Add, Button, xm y+5 w50 h45 gAddShow, +
Gui, Add, Button, x+5 w50 h45 gDelete, -
Gui, Font
Gui, Add, Button, x+5 w50 h20 gModifyShow, &Modify
Gui, Add, Button, y+5 w50 h20 gSave, &Save
Gui, Add, CheckBox, x+5 yp-24 w45 h20 gAOT, AOT
Gui, Add, Button, y+4 w47 h20 gReload, &Reload
Gui, Add, Edit, x+5 yp-24 w120 HwndSearchEdit vSearcher gSearch, 
Gui, Add, DropDownList, y+1 w120 AltSubmit vFilter gSearch, Name||Price
Gui, +hwndMainGUI
Loop, Parse, CreateItems, `n
{
	ItemsCreated := StrSplit(A_LoopField, "=")
	LV_Add(, ItemsCreated[1], ItemsCreated[2])
}
LV_ModifyCol(1, 276)
Gui, Show, , Product List
CueBanner(SearchEdit)
GoSub, SubLV
ControlGet, BackupListItems, List, , SysListView321, ahk_id %MainGUI%
Gui, New, , Add
Gui, Add:+ToolWindow
Gui, Add:Add, Text, , Name
Gui, Add:Add, Edit, w90 h20 vNameAdd
Gui, Add:Add, Edit, w50 h20 vPriceAdd
Gui, Add:Add, UpDown, , 1
Gui, Add:Add, Text, x+5 yp+3 w35, Price
Gui, Add:Add, Button, xm w90 gAdd, Add
return

AddShow:
GuiControl, Add:Text, Button1, Add
GuiControl, Add:+gAdd, Button1
GuiControl, Add:Text, Edit1
GuiControl, Add:Text, Edit2
Gui, Add:Show, , Add
return

Add:
Gui, Add:Submit
Gui, 1:Default
LV_Add(, NameAdd, PriceAdd)
GoSub, Save
return

Delete:
if CheckItemSelected()
{
	MsgBox 0x4, Product List, Are you sure you want to delete this item?
	IfMsgBox Yes
		if CheckItem
		{
			LV_GetText(out, CheckItem)
			IniDelete, %Ini%, Items, %out%
			LV_Delete(CheckItem)
			GoSub, Save
		}
}
else
	MsgBox 0x30, Product List, Please Select A Row First
return

ModifyShow:
if CheckItemSelected()
{
	GuiControl, Add:Text, Button1, Modify
	GuiControl, Add:+gModify, Button1
	LV_GetText(NameGet, CheckItem)
	LV_GetText(PriceGet, CheckItem, 2)
	GuiControl, Add:Text, Edit1, %NameGet%
	GuiControl, Add:Text, Edit2, %PriceGet%
	Gui, Add:Show, , Modify
}
else
	MsgBox 0x30, Product List, Please Select A Row First
return

Modify:
Gui, Add:Submit
Gui, 1:Default
LV_Modify(CheckItem, , NameAdd, PriceAdd)
IniDelete, %Ini%, Items, %NameGet%
BackupListItems := StrReplace(BackupListItems, NameGet, NameAdd)
BackupListItems := StrReplace(BackupListItems, PriceGet, PriceAdd)
GoSub, Save
return

Save:
ControlGet, ListOfItems, List, , SysListView321, ahk_id %MainGUI%
Loop, Parse, ListOfItems, `n
{
	StringSplit, Items, A_LoopField, %A_Tab%
	IniWrite, %Items2%, %Ini%, Items, %Items1%
}
return

AOT:
WinSet, AlwaysOnTop, , ahk_id %MainGUI%
return

Reload:
Reload
return

Search:
Gui, Submit, NoHide
LV_Delete()
Loop, Parse, BackupListItems, `n
{
	StringSplit, Out, A_LoopField, %A_Tab%
	if Searcher
		if InStr(Out%Filter%, Searcher)
		{
			GoSub, Save
			LV_Add(, Out1, Out2)
		}
	if not Searcher
		LV_Add(, Out1, Out2)
}
return

SubLV:
Gui, 1:Default
If (LV_GetCount() > Rows) {
   If (Col2W <> MinW)
      LV_ModifyCol(2, Col2W := MinW)
} Else {
   If (Col2W <> MaxW)
      LV_ModifyCol(2, Col2W := MaxW)
}
LV_ModifyCol(2, 40)
return

F6::Gui, Show

CheckItemSelected() {
	global CheckItem
	TotalSelectedItems := % LV_GetCount("S")
	CheckItem := LV_GetNext()
	if (TotalSelectedItems >= 1)
		return true
	else
		return false
}
CueBanner(Hwnd, Text := "Search") {
	SendMessage 0x1501, 0, &Text,, ahk_id %Hwnd%
}
Attachments
ProductList.png
ProductList.png (11.82 KiB) Viewed 3405 times

carno
Posts: 265
Joined: 20 Jun 2014, 16:48

Re: Product List: Organize products and prices for a small business

Post by carno » 21 Nov 2021, 09:56

This is a great script that can be used for other purposes such as personal inventory management, etc. :D

madensuyu1
Posts: 4
Joined: 13 Oct 2021, 01:16

Re: Product List: Organize products and prices for a small business

Post by madensuyu1 » 16 Dec 2021, 00:42

nice and I want to be able to collect(+) all prices or only selected prices with button click

DominikStanton
Posts: 1
Joined: 16 Aug 2022, 18:52

Re: Product List: Organize products and prices for a small business

Post by DominikStanton » 20 Aug 2022, 09:09

Great script! You deserve all credits!

WaringsChoville
Posts: 2
Joined: 26 Aug 2022, 13:16

Re: Product List: Organize products and prices for a small business

Post by WaringsChoville » 26 Aug 2022, 13:17

Many thanks for sharing! It makes it much easier to keep track of inventory and pricing information for a small business.

User avatar
moefr01
Posts: 115
Joined: 25 Nov 2015, 09:01
Location: Germany

Re: Product List: Organize products and prices for a small business

Post by moefr01 » 30 Aug 2022, 01:20

@EntropicBlackhole ... thanks for sharing, great job!
Something I noticed:
When searching for records (name or price) with content of one or more 0 (zero), no find is displayed filtered. Other numeric contents work as expected.
Maybe you or the community has a solution for a corrected search routine.
:wave: moefr01

WaringsChoville
Posts: 2
Joined: 26 Aug 2022, 13:16

Re: Product List: Organize products and prices for a small business

Post by WaringsChoville » 30 Aug 2022, 11:26

WaringsChoville wrote:
26 Aug 2022, 13:17
Many thanks for sharing! It makes it much easier to keep track of inventory and pricing information for a small business.
This great script can be used for other purposes, such as personal inventory management.

Post Reply

Return to “Scripts and Functions (v1)”