Advertisement
Guest User

Pascal

a guest
Nov 26th, 2020
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 94.54 KB | None | 0 0
  1. unit unit1_neo;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8. Classes, SysUtils, sqldb, Forms, Controls, Graphics, Dialogs, ComCtrls,
  9. StdCtrls, ExtCtrls, Menus, DBCtrls, ActnList, BCListBox, Windows,
  10. rxdbgrid, rxdbcomb, RxDBGridExportPdf, RxDBGridFooterTools,
  11. RxSortZeos, RxDBGridPrintGrid, RxLazReport, LCLType, db, DBGrids,
  12. Buttons, LR_Desgn, ZConnection, ATButtons;
  13.  
  14. // FXContainer
  15.  
  16. type
  17.  
  18. { TForm_Neo }
  19.  
  20. TForm_Neo = class(TForm)
  21. Action_AddCustomersColorOff: TAction;
  22. Action_AddCustomersColorOn: TAction;
  23. Action_AddItemsColorOff: TAction;
  24. Action_AddItemsColorOn: TAction;
  25. Action_CreateBOMColorOff: TAction;
  26. Action_CreateBOMColorOn: TAction;
  27. Action_ShowInventoryColorOff: TAction;
  28. Action_ShowInventoryColorOn: TAction;
  29. Action_TopPanelAddCustomersColorOff: TAction;
  30. Action_TopPanelAddCustomersColorOn: TAction;
  31. Action_TopPanelAddItemsColorOff: TAction;
  32. Action_TopPanelAddItemsColorOn: TAction;
  33. Action_TopPanelCreateBOMColorOff: TAction;
  34. Action_TopPanelCreateBOMColorOn: TAction;
  35. Action_ChildCreateBOMColorOff: TAction;
  36. Action_ChildCreateBOMColorOn: TAction;
  37. Action_ChildAddItemsColorOn: TAction;
  38. Action_ChildAddItemsColorOff: TAction;
  39. Action_ChildAddCustomersColorOn: TAction;
  40. Action_ChildAddCustomersColorOff: TAction;
  41. Action_HomeTreeColorOn: TAction;
  42. Action_HomeTreeColorOff: TAction;
  43. ActionList1: TActionList;
  44. ColorDialog1: TColorDialog;
  45. ComboBox_AddCustomersFilters: TComboBox;
  46. ComboBox_AddItemsFilters: TComboBox;
  47. ComboBox_BOMShowInventoryFilters: TComboBox;
  48. DBNavigator_AddCustomers: TDBNavigator;
  49. DBNavigator_AddItems: TDBNavigator;
  50. DBNavigator_BOMInventoryItems: TDBNavigator;
  51. Edit1: TEdit;
  52. Edit2: TEdit;
  53. Edit_AddCustomersSearch: TEdit;
  54. Edit_AddItemsSearch: TEdit;
  55. Edit_BOMShowInventorySearch: TEdit;
  56. //FXContainer1: TFXContainer;
  57. Label1: TLabel;
  58. Label2: TLabel;
  59. Label_AddCustomerAutoWildcard: TLabel;
  60. Label_AddItemsAutoWildcard: TLabel;
  61. Memo2: TMemo;
  62. MenuItem_ShowHintsOn: TMenuItem;
  63. MenuItem_ShowHints: TMenuItem;
  64. MenuItem_ShowHintsOff: TMenuItem;
  65. N3: TMenuItem;
  66. MenuItem_SetGridRowHeight: TMenuItem;
  67. N2: TMenuItem;
  68. MenuItem_CreateBOMGridColor: TMenuItem;
  69. MenuItem_ShowInventoryGridColor: TMenuItem;
  70. MenuItem_ShowInventoryGridColorOff: TMenuItem;
  71. MenuItem_ShowInventoryGridColorOn: TMenuItem;
  72. MenuItem_CreateBOMGridColorOff: TMenuItem;
  73. MenuItem_CreateBOMGridColorOn: TMenuItem;
  74. MenuItem_AddItemsGridColorOff: TMenuItem;
  75. MenuItem_AddItemsGridColorOn: TMenuItem;
  76. MenuItem_AddCustomersGridColorOff: TMenuItem;
  77. MenuItem_AddCustomersGridColorOn: TMenuItem;
  78. MenuItem_AddCustomersGridColor: TMenuItem;
  79. MenuItem_AddItemsGridColor: TMenuItem;
  80. Panel_BOMBottomInventory: TPanel;
  81. Timer1: TTimer;
  82. ToggleBox_ShowInventoryAutoWildcard: TToggleBox;
  83. TopPanelCreateBOM: TPanel;
  84. TopPanelAddItems: TPanel;
  85. ToggleBox_AddItemsAutoWildcard: TToggleBox;
  86. TopPanelAddCustomers: TPanel;
  87. RxDBGridExportPDF1: TRxDBGridExportPDF;
  88. RxDBGridFooterTools1: TRxDBGridFooterTools;
  89. RxDBGridPrint1: TRxDBGridPrint;
  90. ToggleBox_AddCustomersAutoWildcard: TToggleBox;
  91. MenuItem10: TMenuItem;
  92. MenuItem_TopPanelAddItemsColorOff: TMenuItem;
  93. MenuItem_TopPanelAddItemsColorOn: TMenuItem;
  94. MenuItem13: TMenuItem;
  95. MenuItem_TopPanelCreateBOMColorOff: TMenuItem;
  96. MenuItem_TopPanelCreateBOMColorOn: TMenuItem;
  97. MenuItem2: TMenuItem;
  98. MenuItem3: TMenuItem;
  99. MenuItem_TopPanelAddCustomerColorOff: TMenuItem;
  100. MenuItem_TopPanelAddCustomerColorOn: TMenuItem;
  101. MainMenu1: TMainMenu;
  102. Memo1: TMemo;
  103. MenuItem1: TMenuItem;
  104. MenuItem_AltGridColorOn: TMenuItem;
  105. MenuItem_ChildCreateBOMColorOn: TMenuItem;
  106. MenuItem_ChildAddItemsColorOff: TMenuItem;
  107. MenuItem_ChildAddItemsColorOn: TMenuItem;
  108. MenuItem_ChildAddCustomerColorOff: TMenuItem;
  109. MenuItem_ChildAddCustomerColorOn: TMenuItem;
  110. MenuItemHomeTreeColorOff: TMenuItem;
  111. MenuItemHomeTreeColorOn: TMenuItem;
  112. MenuItem4: TMenuItem;
  113. MenuItem5: TMenuItem;
  114. MenuItem7: TMenuItem;
  115. MenuItem8: TMenuItem;
  116. MenuItem_ChildCreateBOMColorOff: TMenuItem;
  117. MenuItemExit: TMenuItem;
  118. MenuItem_About: TMenuItem;
  119. MenuItem_AltGridColor: TMenuItem;
  120. MenuItem_Common: TMenuItem;
  121. MenuItem_File: TMenuItem;
  122. MenuItem_Help: TMenuItem;
  123. MenuItem_Inquiries: TMenuItem;
  124. MenuItem_Item: TMenuItem;
  125. MenuItem_Journals: TMenuItem;
  126. MenuItem_Options: TMenuItem;
  127. MenuItem_Periodic: TMenuItem;
  128. MenuItem_Reports: TMenuItem;
  129. MenuItem_Setups: TMenuItem;
  130. N1: TMenuItem;
  131. PageCon_Top: TPageControl;
  132. PageCon_Main: TPageControl;
  133. PageCon_Child: TPageControl;
  134. RxSortZeos1: TRxSortZeos;
  135. RxUnitComboBox: TRxDBComboBox;
  136. RxDBGrid_ShowInventory: TRxDBGrid;
  137. RxDBGrid_CreateBOM: TRxDBGrid;
  138. RxDBGrid_AddCustomers: TRxDBGrid;
  139. RxDBGrid_AddItems: TRxDBGrid;
  140. Splitter1: TSplitter;
  141. Splitter2: TSplitter;
  142. Splitter3: TSplitter;
  143. StatusBar1: TStatusBar;
  144. TS_TopAddItems: TTabSheet;
  145. TS_TopCreateBOM: TTabSheet;
  146. TS_TopAddCustomers: TTabSheet;
  147. TreeView_ChildCreateBOM: TTreeView;
  148. TS_ChildCreateBOM: TTabSheet;
  149. TreeView_ChildAddItems: TTreeView;
  150. TS_ChildAddItems: TTabSheet;
  151. TS_ChildAddCustomers: TTabSheet;
  152. TreeView_ChildAddCustomers: TTreeView;
  153. TS_CreateBOM: TTabSheet;
  154. TS_AddCustomers: TTabSheet;
  155. TS_AddItems: TTabSheet;
  156. HomeTree: TTreeView;
  157. procedure ComboBox_AddCustomersFiltersChange(Sender: TObject);
  158. procedure ComboBox_AddCustomersFiltersEnter(Sender: TObject);
  159. procedure ComboBox_AddCustomersFiltersExit(Sender: TObject);
  160. procedure ComboBox_AddItemsFiltersChange(Sender: TObject);
  161. procedure ComboBox_BOMShowInventoryFiltersChange(Sender: TObject);
  162. procedure DBNavigator_AddCustomersEnter(Sender: TObject);
  163. procedure DBNavigator_AddCustomersExit(Sender: TObject);
  164. procedure Edit_AddCustomersSearchEnter(Sender: TObject);
  165. procedure Edit_AddCustomersSearchExit(Sender: TObject);
  166. procedure Edit_AddCustomersSearchKeyUp(Sender: TObject; var Key: Word;
  167. Shift: TShiftState);
  168. procedure Edit_AddItemsSearchKeyUp(Sender: TObject; var Key: Word;
  169. Shift: TShiftState);
  170. procedure Edit_BOMShowInventorySearchKeyUp(Sender: TObject; var Key: Word;
  171. Shift: TShiftState);
  172. procedure FormActivate(Sender: TObject);
  173. procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
  174. procedure FormCreate(Sender: TObject);
  175. procedure HomeTreeChange(Sender: TObject; Node: TTreeNode);
  176. procedure HomeTreeEnter(Sender: TObject);
  177. procedure HomeTreeExit(Sender: TObject);
  178. procedure HomeTreeResize(Sender: TObject);
  179. procedure MenuItemExitClick(Sender: TObject);
  180. procedure CreateTables;
  181. procedure MenuItemHomeTreeColorOffClick(Sender: TObject);
  182. procedure MenuItemHomeTreeColorOnClick(Sender: TObject);
  183. procedure MenuItem_AboutClick(Sender: TObject);
  184. procedure MenuItem_AddCustomersGridColorOffClick(Sender: TObject);
  185. procedure MenuItem_AddCustomersGridColorOnClick(Sender: TObject);
  186. procedure MenuItem_AddItemsGridColorOffClick(Sender: TObject);
  187. procedure MenuItem_AddItemsGridColorOnClick(Sender: TObject);
  188. procedure MenuItem_ChildAddCustomerColorOffClick(Sender: TObject);
  189. procedure MenuItem_ChildAddCustomerColorOnClick(Sender: TObject);
  190. procedure MenuItem_ChildAddItemsColorOffClick(Sender: TObject);
  191. procedure MenuItem_ChildAddItemsColorOnClick(Sender: TObject);
  192. procedure MenuItem_ChildCreateBOMColorOffClick(Sender: TObject);
  193. procedure MenuItem_ChildCreateBOMColorOnClick(Sender: TObject);
  194. procedure MenuItem_CreateBOMGridColorOffClick(Sender: TObject);
  195. procedure MenuItem_CreateBOMGridColorOnClick(Sender: TObject);
  196. procedure MenuItem_SetGridRowHeightClick(Sender: TObject);
  197. procedure MenuItem_ShowHintsOffClick(Sender: TObject);
  198. procedure MenuItem_ShowHintsOnClick(Sender: TObject);
  199. procedure MenuItem_ShowInventoryGridColorOffClick(Sender: TObject);
  200. procedure MenuItem_ShowInventoryGridColorOnClick(Sender: TObject);
  201. procedure MenuItem_TopPanelAddCustomerColorOffClick(Sender: TObject);
  202. procedure MenuItem_TopPanelAddCustomerColorOnClick(Sender: TObject);
  203. procedure MenuItem_TopPanelAddItemsColorOffClick(Sender: TObject);
  204. procedure MenuItem_TopPanelAddItemsColorOnClick(Sender: TObject);
  205. procedure MenuItem_TopPanelCreateBOMColorOffClick(Sender: TObject);
  206. procedure MenuItem_TopPanelCreateBOMColorOnClick(Sender: TObject);
  207. procedure PageCon_ChildResize(Sender: TObject);
  208. procedure ReadGridAltColors;
  209. procedure RxDBGrid_AddCustomersColExit(Sender: TObject);
  210. procedure RxDBGrid_AddCustomersColumnSized(Sender: TObject);
  211. procedure RxDBGrid_AddCustomersEnter(Sender: TObject);
  212. procedure RxDBGrid_AddCustomersExit(Sender: TObject);
  213. procedure RxDBGrid_AddCustomersKeyDown(Sender: TObject; var Key: Word;
  214. Shift: TShiftState);
  215. procedure RxDBGrid_AddCustomersKeyUp(Sender: TObject; var Key: Word;
  216. Shift: TShiftState);
  217. procedure RxDBGrid_AddItemsColumnSized(Sender: TObject);
  218. procedure RxDBGrid_AddItemsKeyUp(Sender: TObject; var Key: Word;
  219. Shift: TShiftState);
  220. procedure RxDBGrid_AddItemsSelectEditor(Sender: TObject; Column: TColumn;
  221. var Editor: TWinControl);
  222. procedure RxDBGrid_CreateBOMColumnSized(Sender: TObject);
  223. procedure RxDBGrid_CreateBOMKeyUp(Sender: TObject; var Key: Word;
  224. Shift: TShiftState);
  225. procedure RxDBGrid_ShowInventoryColumnSized(Sender: TObject);
  226. procedure RxDBGrid_ShowInventoryDblClick(Sender: TObject);
  227. procedure RxDBGrid_ShowInventoryKeyDown(Sender: TObject; var Key: Word;
  228. Shift: TShiftState);
  229. procedure RxDBGrid_ShowInventoryKeyUp(Sender: TObject; var Key: Word;
  230. Shift: TShiftState);
  231. procedure RxUnitComboBoxKeyPress(Sender: TObject; var Key: char);
  232. procedure Timer1Timer(Sender: TObject);
  233. procedure ToggleBox_AddCustomersAutoWildcardClick(Sender: TObject);
  234. procedure ToggleBox_AddCustomersAutoWildcardEnter(Sender: TObject);
  235. procedure ToggleBox_AddCustomersAutoWildcardExit(Sender: TObject);
  236. procedure ToggleBox_AddItemsAutoWildcardClick(Sender: TObject);
  237. procedure ToggleBox_ShowInventoryAutoWildcardClick(Sender: TObject);
  238. procedure TreeView_ChildAddCustomersEnter(Sender: TObject);
  239. procedure TreeView_ChildAddCustomersExit(Sender: TObject);
  240. private
  241. procedure WriteGridColSizes;
  242. procedure ReadGridColSizes;
  243. procedure ReadSplitterINI;
  244. procedure SelectCustomers;
  245. procedure SelectItems;
  246. procedure SelectInventoryForBOM;
  247. procedure ReloadDBComboBox;
  248. procedure SetDBGridTitlesCustomers;
  249. procedure SetDBGridTitlesAddItems;
  250. procedure SetDBGridTitlesShowInventory;
  251. procedure VerifyCustPhoneNumbers;
  252. procedure VerifyCustEmails;
  253. procedure SetAddItemsGridFloats;
  254. procedure SetShowInventoryGridFloats;
  255. procedure ReadPanelColors;
  256. procedure ReadGridRowHeight;
  257. procedure ReadHints;
  258. procedure AddInventoryItemToBOM;
  259. procedure AddCustomer;
  260. procedure ShowCustomerNote;
  261. ////////////////////////////////////////////////////////////////////////////
  262. ////////////////////////////////////////////////////////////////////////////
  263. procedure ZQ_AddCustomersAfterDelete(DataSet: TDataSet);
  264. procedure ZQ_AddCustomersAfterPost(DataSet: TDataSet);
  265. procedure ZQ_AddCustomersBeforePost(DataSet: TDataSet);
  266. procedure ZQ_AddItemsAfterApplyUpdates(Sender: TObject);
  267. procedure ZQ_AddItemsAfterDelete(DataSet: TDataSet);
  268. procedure ZQ_AddItemsAfterPost(DataSet: TDataSet);
  269. procedure ZQ_AddItemsBeforePost(DataSet: TDataSet);
  270.  
  271. public
  272. intGridRowHeight: Integer;
  273.  
  274. //VARIABLES FOR ADDCUSTOMER
  275. //strFname, strLname, strCompany, strPhAddress, strPhCity, strPhState,
  276. //strPhZipCode, strBillAddress, strBillCity, strBillState, strBillZipCode,
  277. //strEmail1, strEmail2, strWorkNum, strCellNum, strNotes : String;
  278.  
  279. // CONTROL VARIABLE USED ON OTHER FORMS TO CONTROL THE MAIN FLOW ONCE IT
  280. // GETS BACK HERE.
  281. boolCancel: Boolean;
  282.  
  283. // CONTROL VARIABLE FOR F11 KEY. USED IN RxDBGrid_AddCustomersKeyUp
  284. TreeViewsHidden : Boolean;
  285.  
  286. end;
  287.  
  288. var
  289. Form_Neo: TForm_Neo;
  290.  
  291. implementation
  292.  
  293. uses
  294. IniFiles,
  295. unit_gridrowheight,
  296. unit_about,
  297. //unit_addcustomer,
  298. unit_viewcustomernote,
  299. dm;
  300.  
  301. {$R *.lfm}
  302.  
  303. { TForm_Neo }
  304.  
  305.  
  306. {----------------------------------------------------------------------------
  307. GET THE FORM SETUP TO SHOW ADDCUSTOMER. THIS MAY CHANGE DUE TO A POSSIBLE
  308. HOME PAGE, SOMETHING TINA MIGHT PREFER, SOMETHING SHE'S MORE ACCUSTOMED TO.
  309. --------------------------------------------------------------------------- }
  310. procedure TForm_Neo.FormCreate(Sender: TObject);
  311. begin
  312. Form_Neo.Caption := 'Neo';
  313.  
  314. RxDBGrid_ShowInventory.ReadOnly := True;
  315.  
  316. end;
  317.  
  318. {------------------------------------------------------------------------------
  319. CONNECT THE DATABASE COMPONENTS
  320. ------------------------------------------------------------------------------}
  321. procedure TForm_Neo.FormActivate(Sender: TObject);
  322. begin
  323. try
  324. with DM1.ZConn do
  325. begin
  326. Disconnect;
  327. HostName := 'localhost';
  328. Protocol := 'sqlite-3';
  329. Database := ExtractFilePath(Application.ExeName) + 'data.db';
  330. Properties.Add('foreign_keys=TRUE');
  331. Connected := True;
  332. end;
  333.  
  334. DM1.DS_AddCustomers.DataSet := DM1.ZQ_AddCustomers;
  335. DM1.DS_AddItems.DataSet := DM1.ZQ_AddItems;
  336. DM1.DS_CreateBOM.DataSet := DM1.ZQ_CreateBOM;
  337. DM1.DS_ReadInventory.DataSet := DM1.ZQ_ReadInventory;
  338. DM1.DS_UnitComboBox.DataSet := DM1.ZQ_UnitComboBox;
  339.  
  340. DM1.ZQ_AddCustomers.Connection := DM1.ZConn;
  341. DM1.ZQ_AddItems.Connection := DM1.ZConn;
  342. DM1.ZQ_CreateBOM.Connection := DM1.ZConn;
  343. DM1.ZQ_ReadInventory.Connection := DM1.ZConn;
  344. DM1.ZQ_UnitComboBox.Connection := DM1.ZConn;
  345.  
  346. RxDBGrid_AddCustomers.DataSource := DM1.DS_AddCustomers;
  347. RxDBGrid_AddItems.DataSource := DM1.DS_AddItems;
  348. RxDBGrid_CreateBOM.DataSource := DM1.DS_CreateBOM;
  349. RxDBGrid_ShowInventory.DataSource := DM1.DS_ReadInventory;
  350. RxUnitComboBox.DataSource := DM1.DS_AddItems;
  351.  
  352. DBNavigator_AddCustomers.DataSource := DM1.DS_AddCustomers;
  353. DBNavigator_AddItems.DataSource := DM1.DS_AddItems;
  354. DBNavigator_BOMInventoryItems.DataSource := DM1.DS_ReadInventory;
  355.  
  356. // SET HOW CALLS TO THE DATASET FROM THE DATAMODULE ARE CALLED
  357. DM1.ZQ_AddCustomers.AfterDelete := @ZQ_AddCustomersAfterDelete;
  358. DM1.ZQ_AddCustomers.AfterPost := @ZQ_AddCustomersAfterPost;
  359. DM1.ZQ_AddCustomers.BeforePost := @ZQ_AddCustomersBeforePost;
  360. DM1.ZQ_AddItems.AfterApplyUpdates := @ZQ_AddItemsAfterApplyUpdates;
  361. DM1.ZQ_AddItems.AfterDelete := @ZQ_AddItemsAfterDelete;
  362. DM1.ZQ_AddItems.AfterPost := @ZQ_AddItemsAfterPost;
  363. DM1.ZQ_AddItems.BeforePost := @ZQ_AddItemsBeforePost;
  364.  
  365. // CREATE THE TABLES, IF ANY ARE NEEDED
  366. CreateTables;
  367.  
  368. // GET THE COMBOBOX READY
  369. with RxUnitComboBox do
  370. begin
  371. DataField := 'inventory_unit';
  372. Visible:= False;
  373. end;
  374.  
  375. TreeViewsHidden := False;
  376.  
  377. // LOAD THE COMBOBOX
  378. ReloadDBComboBox;
  379.  
  380. // FILL THE CUSTOMER, ITEMS, INVENTORY GRIDS
  381. SelectCustomers;
  382. SelectItems;
  383. SelectInventoryForBOM;
  384.  
  385. // SET THE GRID WIDTHS ON ALL THE GRIDS
  386. ReadGridColSizes;
  387. ReadGridAltColors;
  388. ReadGridRowHeight;
  389.  
  390. // CHECK IF HINTS WILL BE DISPLAYED
  391. ReadHints;
  392.  
  393.  
  394.  
  395. // PUT THE HOMETREE AND CHILD PANELS BACK TO THE WAY THEY LEFT THEM, THEN
  396. // COLOR THE PANELS.
  397. ReadSplitterINI;
  398. ReadPanelColors;
  399.  
  400. // HERE WE SYNC THE THREE PAGECONTROLS, HIDE ALL TABS, AND
  401. // INCREASE THE DEFAULT ROW HEIGHT
  402. PageCon_Main.PageIndex := 0;
  403. PageCon_Child.PageIndex := 0;
  404. PageCon_Top.PageIndex := 0;
  405.  
  406. PageCon_Main.ShowTabs := False;
  407. PageCon_Child.ShowTabs := False;
  408. PageCon_Top.ShowTabs := False;
  409.  
  410. // PUT FOCUS ON THE CUSTOMER GRID
  411. RxDBGrid_AddCustomers.SetFocus;
  412. except
  413. On e: Exception do
  414. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  415. end;
  416. end;
  417.  
  418. procedure TForm_Neo.ComboBox_AddCustomersFiltersChange(Sender: TObject);
  419. begin
  420. Edit_AddCustomersSearch.SetFocus;
  421. end;
  422.  
  423. procedure TForm_Neo.ComboBox_AddCustomersFiltersEnter(Sender: TObject);
  424. begin
  425. StatusBar1.Panels[1].Text := 'Add Customers Search Items';
  426. end;
  427.  
  428. procedure TForm_Neo.ComboBox_AddCustomersFiltersExit(Sender: TObject);
  429. begin
  430. StatusBar1.Panels[1].Text := '';
  431. end;
  432.  
  433. procedure TForm_Neo.ComboBox_AddItemsFiltersChange(Sender: TObject);
  434. begin
  435. Edit_AddItemsSearch.SetFocus;
  436. end;
  437.  
  438. procedure TForm_Neo.ComboBox_BOMShowInventoryFiltersChange(Sender: TObject);
  439. begin
  440. Edit_BOMShowInventorySearch.SetFocus;
  441. end;
  442.  
  443. procedure TForm_Neo.DBNavigator_AddCustomersEnter(Sender: TObject);
  444. begin
  445. StatusBar1.Panels[1].Text := 'Add Customers DB Navigator';
  446. end;
  447.  
  448. procedure TForm_Neo.DBNavigator_AddCustomersExit(Sender: TObject);
  449. begin
  450. StatusBar1.Panels[1].Text := '';
  451. end;
  452.  
  453. procedure TForm_Neo.Edit_AddCustomersSearchEnter(Sender: TObject);
  454. begin
  455. StatusBar1.Panels[1].Text := 'Add Customers Search Box';
  456. end;
  457.  
  458. procedure TForm_Neo.Edit_AddCustomersSearchExit(Sender: TObject);
  459. begin
  460. StatusBar1.Panels[1].Text := '';
  461. end;
  462.  
  463. procedure TForm_Neo.Edit_AddCustomersSearchKeyUp(Sender: TObject;
  464. var Key: Word; Shift: TShiftState);
  465. var
  466. s: String;
  467. i: Integer;
  468. begin
  469. try
  470. if Edit_AddCustomersSearch.Text = '' then
  471. begin
  472. SelectCustomers;
  473. ReadGridColSizes;
  474. Edit_AddCustomersSearch.SetFocus;
  475. Exit;
  476. end;
  477.  
  478. s:= Edit_AddCustomersSearch.Text;
  479. i:= ComboBox_AddCustomersFilters.ItemIndex;
  480.  
  481. if ToggleBox_AddCustomersAutoWildcard.Checked then
  482. begin
  483. if i = 0 then
  484. begin
  485. DM1.ZQ_AddCustomers.Close;
  486. DM1.ZQ_AddCustomers.SQL.Text:= 'SELECT * FROM customers ' +
  487. 'WHERE cust_fname LIKE :fname';
  488. DM1.ZQ_AddCustomers.Params.ParamByName('fname').AsString:= '%'+Trim(s)+'%';
  489. DM1.ZQ_AddCustomers.Open;
  490. SetDBGridTitlesCustomers;
  491. ReadGridColSizes;
  492. end;
  493. if i = 1 then
  494. begin
  495. DM1.ZQ_AddCustomers.Close;
  496. DM1.ZQ_AddCustomers.SQL.Text:= 'SELECT * FROM customers ' +
  497. 'WHERE cust_lname LIKE :lname';
  498. DM1.ZQ_AddCustomers.Params.ParamByName('lname').AsString:= '%'+Trim(s)+'%';
  499. DM1.ZQ_AddCustomers.Open;
  500. SetDBGridTitlesCustomers;
  501. ReadGridColSizes;
  502. end;
  503. if i = 2 then
  504. begin
  505. DM1.ZQ_AddCustomers.Close;
  506. DM1.ZQ_AddCustomers.SQL.Text:= 'SELECT * FROM customers ' +
  507. 'WHERE cust_company LIKE :company';
  508. DM1.ZQ_AddCustomers.Params.ParamByName('company').AsString:= '%'+Trim(s)+'%';
  509. DM1.ZQ_AddCustomers.Open;
  510. SetDBGridTitlesCustomers;
  511. ReadGridColSizes;
  512. end;
  513. if i = 3 then
  514. begin
  515. DM1.ZQ_AddCustomers.Close;
  516. DM1.ZQ_AddCustomers.SQL.Text:= 'SELECT * FROM customers ' +
  517. 'WHERE cust_email1 LIKE :em1';
  518. DM1.ZQ_AddCustomers.Params.ParamByName('em1').AsString:= '%'+Trim(s)+'%';
  519. DM1.ZQ_AddCustomers.Open;
  520. SetDBGridTitlesCustomers;
  521. ReadGridColSizes;
  522. end;
  523. if i = 4 then
  524. begin
  525. DM1.ZQ_AddCustomers.Close;
  526. DM1.ZQ_AddCustomers.SQL.Text:= 'SELECT * FROM customers ' +
  527. 'WHERE cust_email2 LIKE :em2';
  528. DM1.ZQ_AddCustomers.Params.ParamByName('em2').AsString:= '%'+Trim(s)+'%';
  529. DM1.ZQ_AddCustomers.Open;
  530. SetDBGridTitlesCustomers;
  531. ReadGridColSizes;
  532. end;
  533. if i = 5 then
  534. begin
  535. DM1.ZQ_AddCustomers.Close;
  536. DM1.ZQ_AddCustomers.SQL.Text:= 'SELECT * FROM customers ' +
  537. 'WHERE cust_worknumber LIKE :wnum';
  538. DM1.ZQ_AddCustomers.Params.ParamByName('wnum').AsString:= '%'+Trim(s)+'%';
  539. DM1.ZQ_AddCustomers.Open;
  540. SetDBGridTitlesCustomers;
  541. ReadGridColSizes;
  542. end;
  543. if i = 6 then
  544. begin
  545. DM1.ZQ_AddCustomers.Close;
  546. DM1.ZQ_AddCustomers.SQL.Text:= 'SELECT * FROM customers ' +
  547. 'WHERE cust_cellnumber LIKE :cnum';
  548. DM1.ZQ_AddCustomers.Params.ParamByName('cnum').AsString:= '%'+Trim(s)+'%';
  549. DM1.ZQ_AddCustomers.Open;
  550. SetDBGridTitlesCustomers;
  551. ReadGridColSizes;
  552. end;
  553. Exit;
  554. end;
  555.  
  556. if i = 0 then
  557. begin
  558. DM1.ZQ_AddCustomers.Close;
  559. DM1.ZQ_AddCustomers.SQL.Text:= 'SELECT * FROM customers ' +
  560. 'WHERE cust_fname LIKE :fname';
  561. DM1.ZQ_AddCustomers.Params.ParamByName('fname').AsString:= Trim(s);
  562. DM1.ZQ_AddCustomers.Open;
  563. SetDBGridTitlesCustomers;
  564. ReadGridColSizes;
  565. end;
  566. if i = 1 then
  567. begin
  568. DM1.ZQ_AddCustomers.Close;
  569. DM1.ZQ_AddCustomers.SQL.Text:= 'SELECT * FROM customers ' +
  570. 'WHERE cust_lname LIKE :lname';
  571. DM1.ZQ_AddCustomers.Params.ParamByName('lname').AsString:= Trim(s);
  572. DM1.ZQ_AddCustomers.Open;
  573. SetDBGridTitlesCustomers;
  574. ReadGridColSizes;
  575. end;
  576. if i = 2 then
  577. begin
  578. DM1.ZQ_AddCustomers.Close;
  579. DM1.ZQ_AddCustomers.SQL.Text:= 'SELECT * FROM customers ' +
  580. 'WHERE cust_company LIKE :company';
  581. DM1.ZQ_AddCustomers.Params.ParamByName('company').AsString:= Trim(s);
  582. DM1.ZQ_AddCustomers.Open;
  583. SetDBGridTitlesCustomers;
  584. ReadGridColSizes;
  585. end;
  586. if i = 3 then
  587. begin
  588. DM1.ZQ_AddCustomers.Close;
  589. DM1.ZQ_AddCustomers.SQL.Text:= 'SELECT * FROM customers ' +
  590. 'WHERE cust_email1 LIKE :em1';
  591. DM1.ZQ_AddCustomers.Params.ParamByName('em1').AsString:= Trim(s);
  592. DM1.ZQ_AddCustomers.Open;
  593. SetDBGridTitlesCustomers;
  594. ReadGridColSizes;
  595. end;
  596. if i = 4 then
  597. begin
  598. DM1.ZQ_AddCustomers.Close;
  599. DM1.ZQ_AddCustomers.SQL.Text:= 'SELECT * FROM customers ' +
  600. 'WHERE cust_email2 LIKE :em2';
  601. DM1.ZQ_AddCustomers.Params.ParamByName('em2').AsString:= Trim(s);
  602. DM1.ZQ_AddCustomers.Open;
  603. SetDBGridTitlesCustomers;
  604. ReadGridColSizes;
  605. end;
  606. if i = 5 then
  607. begin
  608. DM1.ZQ_AddCustomers.Close;
  609. DM1.ZQ_AddCustomers.SQL.Text:= 'SELECT * FROM customers ' +
  610. 'WHERE cust_worknumber LIKE :wnum';
  611. DM1.ZQ_AddCustomers.Params.ParamByName('wnum').AsString:= Trim(s);
  612. DM1.ZQ_AddCustomers.Open;
  613. SetDBGridTitlesCustomers;
  614. ReadGridColSizes;
  615. end;
  616. if i = 6 then
  617. begin
  618. DM1.ZQ_AddCustomers.Close;
  619. DM1.ZQ_AddCustomers.SQL.Text:= 'SELECT * FROM customers ' +
  620. 'WHERE cust_cellnumber LIKE :cnum';
  621. DM1.ZQ_AddCustomers.Params.ParamByName('cnum').AsString:= Trim(s);
  622. DM1.ZQ_AddCustomers.Open;
  623. SetDBGridTitlesCustomers;
  624. ReadGridColSizes;
  625. end;
  626. except
  627. On e: Exception do
  628. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  629. end;
  630. end;
  631.  
  632. procedure TForm_Neo.Edit_AddItemsSearchKeyUp(Sender: TObject; var Key: Word;
  633. Shift: TShiftState);
  634. var
  635. s: String;
  636. i: Integer;
  637. begin
  638. try
  639. if Edit_AddItemsSearch.Text = '' then
  640. begin
  641. SelectItems;
  642. ReadGridColSizes;
  643. Edit_AddItemsSearch.SetFocus;
  644. Exit;
  645. end;
  646.  
  647. s:= Edit_AddItemsSearch.Text;
  648. i:= ComboBox_AddItemsFilters.ItemIndex;
  649.  
  650. if ToggleBox_AddItemsAutoWildcard.Checked then
  651. begin
  652. if i = 0 then
  653. begin
  654. DM1.ZQ_AddItems.Close;
  655. DM1.ZQ_AddItems.SQL.Text:= 'SELECT * FROM inventory ' +
  656. 'WHERE inventory_item_number LIKE :itemnum';
  657. DM1.ZQ_AddItems.Params.ParamByName('itemnum').AsString:= '%'+Trim(s)+'%';
  658. DM1.ZQ_AddItems.Open;
  659. SetDBGridTitlesAddItems;
  660. ReadGridColSizes;
  661. SetAddItemsGridFloats;
  662. end;
  663. if i = 1 then
  664. begin
  665. DM1.ZQ_AddItems.Close;
  666. DM1.ZQ_AddItems.SQL.Text:= 'SELECT * FROM inventory ' +
  667. 'WHERE inventory_description LIKE :desc';
  668. DM1.ZQ_AddItems.Params.ParamByName('desc').AsString:= '%'+Trim(s)+'%';
  669. DM1.ZQ_AddItems.Open;
  670. SetDBGridTitlesAddItems;
  671. ReadGridColSizes;
  672. SetAddItemsGridFloats;
  673. end;
  674. if i = 2 then
  675. begin
  676. DM1.ZQ_AddItems.Close;
  677. DM1.ZQ_AddItems.SQL.Text:= 'SELECT * FROM inventory ' +
  678. 'WHERE inventory_unit LIKE :unit';
  679. DM1.ZQ_AddItems.Params.ParamByName('unit').AsString:= '%'+Trim(s)+'%';
  680. DM1.ZQ_AddItems.Open;
  681. SetDBGridTitlesAddItems;
  682. ReadGridColSizes;
  683. SetAddItemsGridFloats;
  684. end;
  685. if i = 3 then
  686. begin
  687. DM1.ZQ_AddItems.Close;
  688. DM1.ZQ_AddItems.SQL.Text:= 'SELECT * FROM inventory ' +
  689. 'WHERE inventory_cost LIKE :cost';
  690. DM1.ZQ_AddItems.Params.ParamByName('cost').AsString:= '%'+Trim(s)+'%';
  691. DM1.ZQ_AddItems.Open;
  692. SetDBGridTitlesAddItems;
  693. ReadGridColSizes;
  694. SetAddItemsGridFloats;
  695. end;
  696. if i = 4 then
  697. begin
  698. DM1.ZQ_AddItems.Close;
  699. DM1.ZQ_AddItems.SQL.Text:= 'SELECT * FROM inventory ' +
  700. 'WHERE inventory_sell_price LIKE :sellPrice';
  701. DM1.ZQ_AddItems.Params.ParamByName('sellPrice').AsString:= '%'+Trim(s)+'%';
  702. DM1.ZQ_AddItems.Open;
  703. SetDBGridTitlesAddItems;
  704. ReadGridColSizes;
  705. SetAddItemsGridFloats;
  706. end;
  707. if i = 5 then
  708. begin
  709. DM1.ZQ_AddItems.Close;
  710. DM1.ZQ_AddItems.SQL.Text:= 'SELECT * FROM inventory ' +
  711. 'WHERE inventory_margin_contribution LIKE :mc';
  712. DM1.ZQ_AddItems.Params.ParamByName('mc').AsString:= '%'+Trim(s)+'%';
  713. DM1.ZQ_AddItems.Open;
  714. SetDBGridTitlesAddItems;
  715. ReadGridColSizes;
  716. SetAddItemsGridFloats;
  717. end;
  718. if i = 6 then
  719. begin
  720. DM1.ZQ_AddItems.Close;
  721. DM1.ZQ_AddItems.SQL.Text:= 'SELECT * FROM inventory ' +
  722. 'WHERE inventory_in_stock LIKE :inStock';
  723. DM1.ZQ_AddItems.Params.ParamByName('inStock').AsString:= '%'+Trim(s)+'%';
  724. DM1.ZQ_AddItems.Open;
  725. SetDBGridTitlesAddItems;
  726. ReadGridColSizes;
  727. SetAddItemsGridFloats;
  728. end;
  729. Exit;
  730. end;
  731.  
  732. if i = 0 then
  733. begin
  734. DM1.ZQ_AddItems.Close;
  735. DM1.ZQ_AddItems.SQL.Text:= 'SELECT * FROM inventory ' +
  736. 'WHERE inventory_item_number LIKE :itemnum';
  737. DM1.ZQ_AddItems.Params.ParamByName('itemnum').AsString:= Trim(s);
  738. DM1.ZQ_AddItems.Open;
  739. SetDBGridTitlesAddItems;
  740. ReadGridColSizes;
  741. SetAddItemsGridFloats;
  742. end;
  743. if i = 1 then
  744. begin
  745. DM1.ZQ_AddItems.Close;
  746. DM1.ZQ_AddItems.SQL.Text:= 'SELECT * FROM inventory ' +
  747. 'WHERE inventory_description LIKE :desc';
  748. DM1.ZQ_AddItems.Params.ParamByName('desc').AsString:= Trim(s);
  749. DM1.ZQ_AddItems.Open;
  750. SetDBGridTitlesAddItems;
  751. ReadGridColSizes;
  752. SetAddItemsGridFloats;
  753. end;
  754. if i = 2 then
  755. begin
  756. DM1.ZQ_AddItems.Close;
  757. DM1.ZQ_AddItems.SQL.Text:= 'SELECT * FROM inventory ' +
  758. 'WHERE inventory_unit LIKE :unit';
  759. DM1.ZQ_AddItems.Params.ParamByName('unit').AsString:= Trim(s);
  760. DM1.ZQ_AddItems.Open;
  761. SetDBGridTitlesAddItems;
  762. ReadGridColSizes;
  763. SetAddItemsGridFloats;
  764. end;
  765. if i = 3 then
  766. begin
  767. DM1.ZQ_AddItems.Close;
  768. DM1.ZQ_AddItems.SQL.Text:= 'SELECT * FROM inventory ' +
  769. 'WHERE inventory_cost LIKE :cost';
  770. DM1.ZQ_AddItems.Params.ParamByName('cost').AsString:= Trim(s);
  771. DM1.ZQ_AddItems.Open;
  772. SetDBGridTitlesAddItems;
  773. ReadGridColSizes;
  774. SetAddItemsGridFloats;
  775. end;
  776. if i = 4 then
  777. begin
  778. DM1.ZQ_AddItems.Close;
  779. DM1.ZQ_AddItems.SQL.Text:= 'SELECT * FROM inventory ' +
  780. 'WHERE inventory_sell_price LIKE :sellPrice';
  781. DM1.ZQ_AddItems.Params.ParamByName('sellPrice').AsString:= Trim(s);
  782. DM1.ZQ_AddItems.Open;
  783. SetDBGridTitlesAddItems;
  784. ReadGridColSizes;
  785. SetAddItemsGridFloats;
  786. end;
  787. if i = 5 then
  788. begin
  789. DM1.ZQ_AddItems.Close;
  790. DM1.ZQ_AddItems.SQL.Text:= 'SELECT * FROM inventory ' +
  791. 'WHERE inventory_margin_contribution LIKE :mc';
  792. DM1.ZQ_AddItems.Params.ParamByName('mc').AsString:= Trim(s);
  793. DM1.ZQ_AddItems.Open;
  794. SetDBGridTitlesAddItems;
  795. ReadGridColSizes;
  796. SetAddItemsGridFloats;
  797. end;
  798. if i = 6 then
  799. begin
  800. DM1.ZQ_AddItems.Close;
  801. DM1.ZQ_AddItems.SQL.Text:= 'SELECT * FROM inventory ' +
  802. 'WHERE inventory_in_stock LIKE :inStock';
  803. DM1.ZQ_AddItems.Params.ParamByName('inStock').AsString:= Trim(s);
  804. DM1.ZQ_AddItems.Open;
  805. SetDBGridTitlesAddItems;
  806. ReadGridColSizes;
  807. SetAddItemsGridFloats;
  808. end;
  809. except
  810. On e: Exception do
  811. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  812. end;
  813. end;
  814.  
  815. procedure TForm_Neo.Edit_BOMShowInventorySearchKeyUp(Sender: TObject;
  816. var Key: Word; Shift: TShiftState);
  817. var
  818. s: String;
  819. i: Integer;
  820. begin
  821. try
  822. if Edit_BOMShowInventorySearch.Text = '' then
  823. begin
  824. SelectInventoryForBOM;
  825. ReadGridColSizes;
  826. Edit_BOMShowInventorySearch.SetFocus;
  827. Exit;
  828. end;
  829.  
  830. s:= Edit_BOMShowInventorySearch.Text;
  831. i:= ComboBox_BOMShowInventoryFilters.ItemIndex;
  832.  
  833. if ToggleBox_ShowInventoryAutoWildcard.Checked then
  834. begin
  835. if i = 0 then
  836. begin
  837. DM1.ZQ_ReadInventory.Close;
  838. DM1.ZQ_ReadInventory.SQL.Text:= 'SELECT * FROM inventory ' +
  839. 'WHERE inventory_item_number LIKE :itemnum';
  840. DM1.ZQ_ReadInventory.Params.ParamByName('itemnum').AsString:= '%'+Trim(s)+'%';
  841. DM1.ZQ_ReadInventory.Open;
  842. SetDBGridTitlesShowInventory;
  843. ReadGridColSizes;
  844. SetShowInventoryGridFloats;
  845. end;
  846. if i = 1 then
  847. begin
  848. DM1.ZQ_ReadInventory.Close;
  849. DM1.ZQ_ReadInventory.SQL.Text:= 'SELECT * FROM inventory ' +
  850. 'WHERE inventory_description LIKE :desc';
  851. DM1.ZQ_ReadInventory.Params.ParamByName('desc').AsString:= '%'+Trim(s)+'%';
  852. DM1.ZQ_ReadInventory.Open;
  853. SetDBGridTitlesShowInventory;
  854. ReadGridColSizes;
  855. SetShowInventoryGridFloats;
  856. end;
  857. if i = 2 then
  858. begin
  859. DM1.ZQ_ReadInventory.Close;
  860. DM1.ZQ_ReadInventory.SQL.Text:= 'SELECT * FROM inventory ' +
  861. 'WHERE inventory_unit LIKE :unit';
  862. DM1.ZQ_ReadInventory.Params.ParamByName('unit').AsString:= '%'+Trim(s)+'%';
  863. DM1.ZQ_ReadInventory.Open;
  864. SetDBGridTitlesShowInventory;
  865. ReadGridColSizes;
  866. SetShowInventoryGridFloats;
  867. end;
  868. if i = 3 then
  869. begin
  870. DM1.ZQ_ReadInventory.Close;
  871. DM1.ZQ_ReadInventory.SQL.Text:= 'SELECT * FROM inventory ' +
  872. 'WHERE inventory_cost LIKE :cost';
  873. DM1.ZQ_ReadInventory.Params.ParamByName('cost').AsString:= '%'+Trim(s)+'%';
  874. DM1.ZQ_ReadInventory.Open;
  875. SetDBGridTitlesShowInventory;
  876. ReadGridColSizes;
  877. SetShowInventoryGridFloats;
  878. end;
  879. if i = 4 then
  880. begin
  881. DM1.ZQ_ReadInventory.Close;
  882. DM1.ZQ_ReadInventory.SQL.Text:= 'SELECT * FROM inventory ' +
  883. 'WHERE inventory_sell_price LIKE :sellPrice';
  884. DM1.ZQ_ReadInventory.Params.ParamByName('sellPrice').AsString:= '%'+Trim(s)+'%';
  885. DM1.ZQ_ReadInventory.Open;
  886. SetDBGridTitlesShowInventory;
  887. ReadGridColSizes;
  888. SetShowInventoryGridFloats;
  889. end;
  890. if i = 5 then
  891. begin
  892. DM1.ZQ_ReadInventory.Close;
  893. DM1.ZQ_ReadInventory.SQL.Text:= 'SELECT * FROM inventory ' +
  894. 'WHERE inventory_margin_contribution LIKE :mc';
  895. DM1.ZQ_ReadInventory.Params.ParamByName('mc').AsString:= '%'+Trim(s)+'%';
  896. DM1.ZQ_ReadInventory.Open;
  897. SetDBGridTitlesShowInventory;
  898. ReadGridColSizes;
  899. SetShowInventoryGridFloats;
  900. end;
  901. if i = 6 then
  902. begin
  903. DM1.ZQ_ReadInventory.Close;
  904. DM1.ZQ_ReadInventory.SQL.Text:= 'SELECT * FROM inventory ' +
  905. 'WHERE inventory_in_stock LIKE :inStock';
  906. DM1.ZQ_ReadInventory.Params.ParamByName('inStock').AsString:= '%'+Trim(s)+'%';
  907. DM1.ZQ_ReadInventory.Open;
  908. SetDBGridTitlesShowInventory;
  909. ReadGridColSizes;
  910. SetShowInventoryGridFloats;
  911. end;
  912. Exit;
  913. end;
  914.  
  915. if i = 0 then
  916. begin
  917. DM1.ZQ_ReadInventory.Close;
  918. DM1.ZQ_ReadInventory.SQL.Text:= 'SELECT * FROM inventory ' +
  919. 'WHERE inventory_item_number LIKE :itemnum';
  920. DM1.ZQ_ReadInventory.Params.ParamByName('itemnum').AsString:= Trim(s);
  921. DM1.ZQ_ReadInventory.Open;
  922. SetDBGridTitlesShowInventory;
  923. ReadGridColSizes;
  924. SetShowInventoryGridFloats;
  925. end;
  926. if i = 1 then
  927. begin
  928. DM1.ZQ_ReadInventory.Close;
  929. DM1.ZQ_ReadInventory.SQL.Text:= 'SELECT * FROM inventory ' +
  930. 'WHERE inventory_description LIKE :desc';
  931. DM1.ZQ_ReadInventory.Params.ParamByName('desc').AsString:= Trim(s);
  932. DM1.ZQ_ReadInventory.Open;
  933. SetDBGridTitlesShowInventory;
  934. ReadGridColSizes;
  935. SetShowInventoryGridFloats;
  936. end;
  937. if i = 2 then
  938. begin
  939. DM1.ZQ_ReadInventory.Close;
  940. DM1.ZQ_ReadInventory.SQL.Text:= 'SELECT * FROM inventory ' +
  941. 'WHERE inventory_unit LIKE :unit';
  942. DM1.ZQ_ReadInventory.Params.ParamByName('unit').AsString:= Trim(s);
  943. DM1.ZQ_ReadInventory.Open;
  944. SetDBGridTitlesShowInventory;
  945. ReadGridColSizes;
  946. SetShowInventoryGridFloats;
  947. end;
  948. if i = 3 then
  949. begin
  950. DM1.ZQ_ReadInventory.Close;
  951. DM1.ZQ_ReadInventory.SQL.Text:= 'SELECT * FROM inventory ' +
  952. 'WHERE inventory_cost LIKE :cost';
  953. DM1.ZQ_ReadInventory.Params.ParamByName('cost').AsString:= Trim(s);
  954. DM1.ZQ_ReadInventory.Open;
  955. SetDBGridTitlesShowInventory;
  956. ReadGridColSizes;
  957. SetShowInventoryGridFloats;
  958. end;
  959. if i = 4 then
  960. begin
  961. DM1.ZQ_ReadInventory.Close;
  962. DM1.ZQ_ReadInventory.SQL.Text:= 'SELECT * FROM inventory ' +
  963. 'WHERE inventory_sell_price LIKE :sellPrice';
  964. DM1.ZQ_ReadInventory.Params.ParamByName('sellPrice').AsString:= Trim(s);
  965. DM1.ZQ_ReadInventory.Open;
  966. SetDBGridTitlesShowInventory;
  967. ReadGridColSizes;
  968. SetShowInventoryGridFloats;
  969. end;
  970. if i = 5 then
  971. begin
  972. DM1.ZQ_ReadInventory.Close;
  973. DM1.ZQ_ReadInventory.SQL.Text:= 'SELECT * FROM inventory ' +
  974. 'WHERE inventory_margin_contribution LIKE :mc';
  975. DM1.ZQ_ReadInventory.Params.ParamByName('mc').AsString:= Trim(s);
  976. DM1.ZQ_ReadInventory.Open;
  977. SetDBGridTitlesShowInventory;
  978. ReadGridColSizes;
  979. SetShowInventoryGridFloats;
  980. end;
  981. if i = 6 then
  982. begin
  983. DM1.ZQ_ReadInventory.Close;
  984. DM1.ZQ_ReadInventory.SQL.Text:= 'SELECT * FROM inventory ' +
  985. 'WHERE inventory_in_stock LIKE :inStock';
  986. DM1.ZQ_ReadInventory.Params.ParamByName('inStock').AsString:= Trim(s);
  987. DM1.ZQ_ReadInventory.Open;
  988. SetDBGridTitlesShowInventory;
  989. ReadGridColSizes;
  990. SetShowInventoryGridFloats;
  991. end;
  992. except
  993. On e: Exception do
  994. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  995. end;
  996. end;
  997.  
  998. {------------------------------------------------------------------------------
  999. BECAUSE SPLITTERS ARE PART OF THE DESIGNED FORM, THEY WILL BE RESIZED TO THE
  1000. DESIGNED LAYOUT AT APP STARTUP, TRIGGERING ANY REZISE EVENTS THEY ARE TIED
  1001. TO. SO WE CAN'T USE A RESIZE EVENT TO CAPTURE THESE KIND OF FORM CHANGES.
  1002. WE MUST WRITE THEM HERE, THEN USE THESE VALUES AT FORM STARTUP SO THE FORM
  1003. WILL BE AS THE USER LEFT IT.
  1004. ------------------------------------------------------------------------------}
  1005. procedure TForm_Neo.FormClose(Sender: TObject; var CloseAction: TCloseAction);
  1006. var
  1007. ini: TCustomIniFile;
  1008. s : String;
  1009. z : Integer;
  1010. column : TColumn;
  1011. begin
  1012. try
  1013. if (HomeTree.Width = 1) and (PageCon_Child.Width = 1) then Exit;
  1014. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1015. try
  1016. ini.WriteInteger('TreeViewWidth', 'WidthHomeTree', HomeTree.Width);
  1017. ini.WriteInteger('TreeViewWidth', 'WidthChildPageCon', PageCon_Child.Width);
  1018. ini.WriteInteger('CreateBOMGrid', 'HeightCeateBOMGrid', RxDBGrid_CreateBOM.Height);
  1019. finally
  1020. ini.Free;
  1021. end;
  1022. except
  1023. On e: Exception do
  1024. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1025. end;
  1026. end;
  1027.  
  1028. {------------------------------------------------------------------------------
  1029. HOMETREECHANGE TAKES CARE OF KEEPING THE PAGECONTROLS IN SYNC.
  1030. ------------------------------------------------------------------------------}
  1031. procedure TForm_Neo.HomeTreeChange(Sender: TObject; Node: TTreeNode);
  1032. var
  1033. htNode,i : Integer;
  1034. begin
  1035. htNode := Node.SelectedIndex;
  1036. try
  1037. // THE FORMULA FOR i LOCATES OUR PLACEMENT OF THE SEARCH COMPONENTS PLACEMENT.
  1038. // THESE COMPONENTS WILL BE UPDATED WHEN THE USER NAVIGATES HOMETREE.
  1039. i := (Form_Neo.Width - PageCon_Child.Width)-
  1040. (ComboBox_AddCustomersFilters.Width + 32);
  1041.  
  1042. if htNode = 0 then
  1043. begin
  1044. PageCon_Main.PageIndex := 0;
  1045. PageCon_Child.PageIndex := 0;
  1046. PageCon_Top.PageIndex := 0;
  1047. ComboBox_AddCustomersFilters.left := i;
  1048. end
  1049. else if htNode = 1 then
  1050. begin
  1051. PageCon_Main.PageIndex := 1;
  1052. PageCon_Child.PageIndex := 1;
  1053. PageCon_Top.PageIndex := 1;
  1054. DBNavigator_AddItems.Left := HomeTree.Width+16;
  1055. ComboBox_AddItemsFilters.Left := i;
  1056. end
  1057. else if htNode = 2 then
  1058. begin
  1059. PageCon_Main.PageIndex := 2;
  1060. PageCon_Child.PageIndex := 2;
  1061. PageCon_Top.PageIndex := 2;
  1062. Edit1.Left := HomeTree.Width+58;
  1063. Edit2.Left := HomeTree.Width+58;
  1064. end;
  1065. except
  1066. On e: Exception do
  1067. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1068. end;
  1069. end;
  1070.  
  1071. procedure TForm_Neo.HomeTreeEnter(Sender: TObject);
  1072. begin
  1073. StatusBar1.Panels[1].Text := 'HomeTree';
  1074. end;
  1075.  
  1076. procedure TForm_Neo.HomeTreeExit(Sender: TObject);
  1077. begin
  1078. StatusBar1.Panels[1].Text := '';
  1079. end;
  1080.  
  1081. procedure TForm_Neo.HomeTreeResize(Sender: TObject);
  1082. begin
  1083. try
  1084. DBNavigator_AddCustomers.Left := HomeTree.Width + 16;
  1085. DBNavigator_AddItems.Left := DBNavigator_AddCustomers.Left;
  1086. Edit1.Left := HomeTree.Width+58;
  1087. Edit2.Left := HomeTree.Width+58;
  1088. except
  1089. On e: Exception do
  1090. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1091. end;
  1092. end;
  1093.  
  1094. procedure TForm_Neo.MenuItemExitClick(Sender: TObject);
  1095. begin
  1096. Close;
  1097. end;
  1098.  
  1099. {------------------------------------------------------------------------------
  1100. HERE WE WILL CREATE THE DATABASE TABLES
  1101. ------------------------------------------------------------------------------}
  1102. procedure TForm_Neo.CreateTables;
  1103. begin
  1104. try
  1105. with DM1.ZConn do
  1106. begin
  1107. ExecuteDirect(
  1108. 'CREATE TABLE IF NOT EXISTS customers(' +
  1109. 'cust_id INTEGER PRIMARY KEY AUTOINCREMENT, ' +
  1110. 'cust_fname VARCHAR(20), ' +
  1111. 'cust_lname VARCHAR(20), ' +
  1112. 'cust_company VARCHAR(30), ' +
  1113. 'cust_physical_address VARCHAR(30), ' +
  1114. 'cust_physical_city VARCHAR(15), ' +
  1115. 'cust_physical_state VARCHAR(15), ' +
  1116. 'cust_physical_zipcode VARCHAR(5), ' +
  1117. 'cust_billing_address VARCHAR(30), ' +
  1118. 'cust_billing_city VARCHAR(15), ' +
  1119. 'cust_billing_state VARCHAR(15), ' +
  1120. 'cust_billing_zipcode VARCHAR(5), ' +
  1121. 'cust_email1 VARCHAR(50), ' +
  1122. 'cust_email2 VARCHAR(50), ' +
  1123. 'cust_worknumber VARCHAR(12), ' +
  1124. 'cust_cellnumber VARCHAR(12), ' +
  1125. 'cust_notes TEXT)');
  1126.  
  1127. ExecuteDirect(
  1128. 'CREATE TABLE IF NOT EXISTS inventory(' +
  1129. 'inventory_id INTEGER PRIMARY KEY AUTOINCREMENT, ' +
  1130. 'inventory_item_number VARCHAR(50), ' +
  1131. 'inventory_description VARCHAR(80), ' +
  1132. 'inventory_unit VARCHAR(5), ' +
  1133. 'inventory_cost REAL, ' +
  1134. 'inventory_sell_price REAL, ' +
  1135. 'inventory_margin_contribution REAL, ' +
  1136. 'inventory_weight REAL, ' +
  1137. 'inventory_in_stock REAL)');
  1138.  
  1139. ExecuteDirect(
  1140. 'CREATE TABLE IF NOT EXISTS bom(' +
  1141. 'bom_id INTEGER PRIMARY KEY AUTOINCREMENT, ' +
  1142. 'bom_build_lines REAL, ' +
  1143. 'bom_item_number VARCHAR(50), ' +
  1144. 'bom_released VARCHAR(1), ' +
  1145. 'bom_description VARCHAR(80), ' +
  1146. 'bom_unit VARCHAR(5), ' +
  1147. 'bom_quantity INTEGER, ' +
  1148. 'bom_cost REAL, ' +
  1149. 'bom_sell_price REAL, ' +
  1150. 'bom_margin_contribution REAL, ' +
  1151. 'bom_weight REAL, ' +
  1152. 'bom_in_stock REAL)');
  1153. // CREATE A NEW TABLE TO KEEP TRACK OF ALL PRICE CHANGES WITH DATES OF CHANGE
  1154. end;
  1155. except
  1156. On e: Exception do
  1157. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1158. end;
  1159. end;
  1160.  
  1161. procedure TForm_Neo.MenuItemHomeTreeColorOffClick(Sender: TObject);
  1162. var
  1163. ini: TCustomIniFile;
  1164. begin
  1165. try
  1166. HomeTree.Color := clWhite;
  1167. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1168. try
  1169. ini.WriteInteger('HomeTreeColor', 'Color', HomeTree.Color);
  1170. finally
  1171. ini.Free;
  1172. MenuItemHomeTreeColorOff.Checked := True;
  1173. MenuItemHomeTreeColorOn.Checked := False;
  1174. end;
  1175. except
  1176. On e: Exception do
  1177. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1178. end;
  1179. end;
  1180.  
  1181. procedure TForm_Neo.MenuItemHomeTreeColorOnClick(Sender: TObject);
  1182. var
  1183. ini: TCustomIniFile;
  1184. begin
  1185. try
  1186. if ColorDialog1.Execute then
  1187. HomeTree.Color := ColorDialog1.Color;
  1188. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1189. try
  1190. ini.WriteInteger('HomeTreeColor', 'Color', HomeTree.Color);
  1191. finally
  1192. ini.Free;
  1193. MenuItemHomeTreeColorOff.Checked := False;
  1194. MenuItemHomeTreeColorOn.Checked := True;
  1195. end;
  1196. except
  1197. On e: Exception do
  1198. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1199. end;
  1200. end;
  1201.  
  1202. procedure TForm_Neo.MenuItem_AboutClick(Sender: TObject);
  1203. var
  1204. i : Integer;
  1205. begin
  1206. try
  1207. Form_About:= TForm_About.Create(Self);
  1208. try
  1209. Form_About.ShowModal;
  1210. finally
  1211. Form_About.Release;
  1212. Form_About:= Nil;
  1213. end;
  1214. except
  1215. On e: Exception do
  1216. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1217. end;
  1218. end;
  1219.  
  1220. procedure TForm_Neo.MenuItem_AddCustomersGridColorOffClick(Sender: TObject);
  1221. var
  1222. ini: TCustomIniFile;
  1223. begin
  1224. try
  1225. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1226. RxDBGrid_AddCustomers.AlternateColor := clWhite;
  1227. try
  1228. ini.WriteInteger('GridColors', 'AddCustomersAltColor', RxDBGrid_AddCustomers.AlternateColor);
  1229. finally
  1230. ini.Free;
  1231. MenuItem_AddCustomersGridColorOff.Checked := True;
  1232. MenuItem_AddCustomersGridColorOn.Checked := False;
  1233. end;
  1234. except
  1235. On e: Exception do
  1236. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1237. end;
  1238. end;
  1239.  
  1240. procedure TForm_Neo.MenuItem_AddCustomersGridColorOnClick(Sender: TObject);
  1241. var
  1242. ini: TCustomIniFile;
  1243. begin
  1244. try
  1245. if ColorDialog1.Execute then
  1246. RxDBGrid_AddCustomers.AlternateColor := ColorDialog1.Color;
  1247. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1248. try
  1249. ini.WriteInteger('GridColors', 'AddCustomersAltColor', RxDBGrid_AddCustomers.AlternateColor);
  1250. finally
  1251. ini.Free;
  1252. MenuItem_AddCustomersGridColorOff.Checked := False;
  1253. MenuItem_AddCustomersGridColorOn.Checked := True;
  1254. end;
  1255. except
  1256. On e: Exception do
  1257. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1258. end;
  1259. end;
  1260.  
  1261. procedure TForm_Neo.MenuItem_AddItemsGridColorOffClick(Sender: TObject);
  1262. var
  1263. ini: TCustomIniFile;
  1264. begin
  1265. try
  1266. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1267. RxDBGrid_AddItems.AlternateColor := clWhite;
  1268. try
  1269. ini.WriteInteger('GridColors', 'AddItemsAltColor', RxDBGrid_AddItems.AlternateColor);
  1270. finally
  1271. ini.Free;
  1272. MenuItem_AddItemsGridColorOff.Checked := True;
  1273. MenuItem_AddItemsGridColorOn.Checked := False;
  1274. end;
  1275. except
  1276. On e: Exception do
  1277. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1278. end;
  1279. end;
  1280.  
  1281. procedure TForm_Neo.MenuItem_AddItemsGridColorOnClick(Sender: TObject);
  1282. var
  1283. ini: TCustomIniFile;
  1284. begin
  1285. try
  1286. if ColorDialog1.Execute then
  1287. RxDBGrid_AddItems.AlternateColor := ColorDialog1.Color;
  1288. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1289. try
  1290. ini.WriteInteger('GridColors', 'AddItemsAltColor', RxDBGrid_AddItems.AlternateColor);
  1291. finally
  1292. ini.Free;
  1293. MenuItem_AddItemsGridColorOff.Checked := False;
  1294. MenuItem_AddItemsGridColorOn.Checked := True;
  1295. end;
  1296. except
  1297. On e: Exception do
  1298. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1299. end;
  1300. end;
  1301.  
  1302. procedure TForm_Neo.MenuItem_ChildAddCustomerColorOffClick(Sender: TObject);
  1303. var
  1304. ini: TCustomIniFile;
  1305. begin
  1306. try
  1307. TreeView_ChildAddCustomers.Color := clWhite;
  1308. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1309. try
  1310. ini.WriteInteger('TreeView_ChildAddCustomers', 'Color', TreeView_ChildAddCustomers.Color);
  1311. finally
  1312. ini.Free;
  1313. MenuItem_ChildAddCustomerColorOff.Checked := True;
  1314. MenuItem_ChildAddCustomerColorOn.Checked := False;
  1315. end;
  1316. except
  1317. On e: Exception do
  1318. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1319. end;
  1320. end;
  1321.  
  1322. procedure TForm_Neo.MenuItem_ChildAddCustomerColorOnClick(Sender: TObject);
  1323. var
  1324. ini: TCustomIniFile;
  1325. begin
  1326. try
  1327. if ColorDialog1.Execute then
  1328. TreeView_ChildAddCustomers.Color := ColorDialog1.Color;
  1329. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1330. try
  1331. ini.WriteInteger('TreeView_ChildAddCustomers', 'Color', TreeView_ChildAddCustomers.Color);
  1332. finally
  1333. ini.Free;
  1334. MenuItem_ChildAddCustomerColorOff.Checked := False;
  1335. MenuItem_ChildAddCustomerColorOn.Checked := True;
  1336. end;
  1337. except
  1338. On e: Exception do
  1339. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1340. end;
  1341. end;
  1342.  
  1343. procedure TForm_Neo.MenuItem_ChildAddItemsColorOffClick(Sender: TObject);
  1344. var
  1345. ini: TCustomIniFile;
  1346. begin
  1347. try
  1348. TreeView_ChildAddItems.Color := clWhite;
  1349. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1350. try
  1351. ini.WriteInteger('TreeView_ChildAddItems', 'Color', TreeView_ChildAddItems.Color);
  1352. finally
  1353. ini.Free;
  1354. MenuItem_ChildAddItemsColorOff.Checked := True;
  1355. MenuItem_ChildAddItemsColorOn.Checked := False;
  1356. end;
  1357. except
  1358. On e: Exception do
  1359. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1360. end;
  1361. end;
  1362.  
  1363. procedure TForm_Neo.MenuItem_ChildAddItemsColorOnClick(Sender: TObject);
  1364. var
  1365. ini: TCustomIniFile;
  1366. begin
  1367. try
  1368. if ColorDialog1.Execute then
  1369. TreeView_ChildAddItems.Color := ColorDialog1.Color;
  1370. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1371. try
  1372. ini.WriteInteger('TreeView_ChildAddItems', 'Color', TreeView_ChildAddItems.Color);
  1373. finally
  1374. ini.Free;
  1375. MenuItem_ChildAddItemsColorOff.Checked := False;
  1376. MenuItem_ChildAddItemsColorOn.Checked := True;
  1377. end;
  1378. except
  1379. On e: Exception do
  1380. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1381. end;
  1382. end;
  1383.  
  1384. procedure TForm_Neo.MenuItem_ChildCreateBOMColorOffClick(Sender: TObject);
  1385. var
  1386. ini: TCustomIniFile;
  1387. begin
  1388. try
  1389. TreeView_ChildCreateBOM.Color := clWhite;
  1390. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1391. try
  1392. ini.WriteInteger('TreeView_ChildCreateBOM', 'Color', TreeView_ChildCreateBOM.Color);
  1393. finally
  1394. ini.Free;
  1395. MenuItem_ChildCreateBOMColorOff.Checked := True;
  1396. MenuItem_ChildCreateBOMColorOn.Checked := False;
  1397. end;
  1398. except
  1399. On e: Exception do
  1400. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1401. end;
  1402. end;
  1403.  
  1404. procedure TForm_Neo.MenuItem_ChildCreateBOMColorOnClick(Sender: TObject);
  1405. var
  1406. ini: TCustomIniFile;
  1407. begin
  1408. try
  1409. if ColorDialog1.Execute then
  1410. TreeView_ChildCreateBOM.Color := ColorDialog1.Color;
  1411. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1412. try
  1413. ini.WriteInteger('TreeView_ChildCreateBOM', 'Color', TreeView_ChildCreateBOM.Color);
  1414. finally
  1415. ini.Free;
  1416. MenuItem_ChildCreateBOMColorOff.Checked := False;
  1417. MenuItem_ChildCreateBOMColorOn.Checked := True;
  1418. end;
  1419. except
  1420. On e: Exception do
  1421. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1422. end;
  1423. end;
  1424.  
  1425. procedure TForm_Neo.MenuItem_CreateBOMGridColorOffClick(Sender: TObject);
  1426. var
  1427. ini: TCustomIniFile;
  1428. begin
  1429. try
  1430. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1431. RxDBGrid_CreateBOM.AlternateColor := clWhite;
  1432. try
  1433. ini.WriteInteger('GridColors', 'CreateBOMAltColor', RxDBGrid_CreateBOM.AlternateColor);
  1434. finally
  1435. ini.Free;
  1436. MenuItem_CreateBOMGridColorOff.Checked := True;
  1437. MenuItem_CreateBOMGridColorOn.Checked := False;
  1438. end;
  1439. except
  1440. On e: Exception do
  1441. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1442. end;
  1443. end;
  1444.  
  1445. procedure TForm_Neo.MenuItem_CreateBOMGridColorOnClick(Sender: TObject);
  1446. var
  1447. ini: TCustomIniFile;
  1448. begin
  1449. try
  1450. if ColorDialog1.Execute then
  1451. RxDBGrid_CreateBOM.AlternateColor := ColorDialog1.Color;
  1452. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1453. try
  1454. ini.WriteInteger('GridColors', 'AddCustomersAltColor', RxDBGrid_CreateBOM.AlternateColor);
  1455. finally
  1456. ini.Free;
  1457. MenuItem_CreateBOMGridColorOff.Checked := True;
  1458. MenuItem_CreateBOMGridColorOn.Checked := False;
  1459. end;
  1460. except
  1461. On e: Exception do
  1462. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1463. end;
  1464. end;
  1465.  
  1466. procedure TForm_Neo.MenuItem_SetGridRowHeightClick(Sender: TObject);
  1467. begin
  1468. try
  1469. Form_GridRowHeight:= TForm_GridRowHeight.Create(Self);
  1470. try
  1471. Form_GridRowHeight.ShowModal;
  1472. finally
  1473. Form_GridRowHeight.Release;
  1474. Form_GridRowHeight:= Nil;
  1475.  
  1476. // IF ADDCUSTOMER FORM'S CANCEL BUTTON WAS CLICKED, WE WON'T HAVE A RECORD TO
  1477. // WRITE...SO WE EXIT
  1478. if boolCancel = True then Exit;
  1479.  
  1480. RxDBGrid_AddCustomers.DefaultRowHeight := intGridRowHeight;
  1481. RxDBGrid_AddItems.DefaultRowHeight := intGridRowHeight;
  1482. RxDBGrid_CreateBOM.DefaultRowHeight := intGridRowHeight;
  1483. RxDBGrid_ShowInventory.DefaultRowHeight := intGridRowHeight;
  1484. end;
  1485. except
  1486. On e: Exception do
  1487. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1488. end;
  1489. end;
  1490.  
  1491. procedure TForm_Neo.MenuItem_ShowHintsOffClick(Sender: TObject);
  1492. var
  1493. ini : TCustomIniFile;
  1494. begin
  1495. try
  1496. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1497. try
  1498. ini.WriteBool('ShowHints', 'On', False);
  1499. finally
  1500. ini.Free;
  1501. MenuItem_ShowHintsOn.Checked := False;
  1502. MenuItem_ShowHintsOff.Checked := True;
  1503. ToggleBox_AddCustomersAutoWildcard.ShowHint := False;
  1504. ToggleBox_AddItemsAutoWildcard.ShowHint := False;
  1505. Label_AddCustomerAutoWildcard.ShowHint := False;
  1506. Label_AddItemsAutoWildcard.ShowHint := False;
  1507. end;
  1508. except
  1509. On e: Exception do
  1510. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1511. end;
  1512. end;
  1513.  
  1514. procedure TForm_Neo.MenuItem_ShowHintsOnClick(Sender: TObject);
  1515. var
  1516. ini : TCustomIniFile;
  1517. begin
  1518. try
  1519. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1520. try
  1521. ini.WriteBool('ShowHints', 'On', True);
  1522. finally
  1523. ini.Free;
  1524. MenuItem_ShowHintsOn.Checked := True;
  1525. MenuItem_ShowHintsOff.Checked := False;
  1526. ToggleBox_AddCustomersAutoWildcard.ShowHint := True;
  1527. ToggleBox_AddItemsAutoWildcard.ShowHint := True;
  1528. Label_AddCustomerAutoWildcard.ShowHint := True;
  1529. Label_AddItemsAutoWildcard.ShowHint := True;
  1530. end;
  1531. except
  1532. On e: Exception do
  1533. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1534. end;
  1535. end;
  1536.  
  1537. procedure TForm_Neo.MenuItem_ShowInventoryGridColorOffClick(Sender: TObject);
  1538. var
  1539. ini: TCustomIniFile;
  1540. begin
  1541. try
  1542. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1543. RxDBGrid_ShowInventory.AlternateColor := clWhite;
  1544. try
  1545. ini.WriteInteger('GridColors', 'CreateBOMAltColor', RxDBGrid_CreateBOM.AlternateColor);
  1546. ini.WriteInteger('GridColors', 'ShowInventoryAltColor', RxDBGrid_ShowInventory.AlternateColor);
  1547. finally
  1548. ini.Free;
  1549. MenuItem_ShowInventoryGridColorOff.Checked := True;
  1550. MenuItem_ShowInventoryGridColorOn.Checked := False;
  1551. end;
  1552. except
  1553. On e: Exception do
  1554. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1555. end;
  1556. end;
  1557.  
  1558. procedure TForm_Neo.MenuItem_ShowInventoryGridColorOnClick(Sender: TObject);
  1559. var
  1560. ini: TCustomIniFile;
  1561. begin
  1562. try
  1563. if ColorDialog1.Execute then
  1564. RxDBGrid_ShowInventory.AlternateColor := ColorDialog1.Color;
  1565. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1566. try
  1567.  
  1568. ini.WriteInteger('GridColors', 'ShowInventoryAltColor', RxDBGrid_ShowInventory.AlternateColor);
  1569. finally
  1570. ini.Free;
  1571. MenuItem_ShowInventoryGridColorOff.Checked := True;
  1572. MenuItem_ShowInventoryGridColorOn.Checked := False;
  1573. end;
  1574. except
  1575. On e: Exception do
  1576. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1577. end;
  1578. end;
  1579.  
  1580. procedure TForm_Neo.MenuItem_TopPanelAddCustomerColorOffClick(Sender: TObject);
  1581. var
  1582. ini: TCustomIniFile;
  1583. begin
  1584. try
  1585. TopPanelAddCustomers.Color := clWhite;
  1586. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1587. try
  1588. ini.WriteInteger('TopPanels', 'AddCustomersColor', TopPanelAddCustomers.Color);
  1589. finally
  1590. ini.Free;
  1591. MenuItem_TopPanelAddCustomerColorOff.Checked := True;
  1592. MenuItem_TopPanelAddCustomerColorOn.Checked := False;
  1593. DBNavigator_AddCustomers.Color := TopPanelAddCustomers.Color;
  1594. end;
  1595. except
  1596. On e: Exception do
  1597. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1598. end;
  1599. end;
  1600.  
  1601. procedure TForm_Neo.MenuItem_TopPanelAddCustomerColorOnClick(Sender: TObject);
  1602. var
  1603. ini: TCustomIniFile;
  1604. begin
  1605. try
  1606. if ColorDialog1.Execute then
  1607. TopPanelAddCustomers.Color := ColorDialog1.Color;
  1608. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1609. try
  1610. ini.WriteInteger('TopPanels', 'AddCustomersColor', TopPanelAddCustomers.Color);
  1611. finally
  1612. ini.Free;
  1613. MenuItem_TopPanelAddCustomerColorOff.Checked := False;
  1614. MenuItem_TopPanelAddCustomerColorOn.Checked := True;
  1615. DBNavigator_AddCustomers.Color := TopPanelAddCustomers.Color;
  1616. end;
  1617. except
  1618. On e: Exception do
  1619. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1620. end;
  1621. end;
  1622.  
  1623. procedure TForm_Neo.MenuItem_TopPanelAddItemsColorOffClick(Sender: TObject);
  1624. var
  1625. ini: TCustomIniFile;
  1626. begin
  1627. try
  1628. TopPanelAddItems.Color := clWhite;
  1629. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1630. try
  1631. ini.WriteInteger('TopPanels', 'AddItemsColor', TopPanelAddItems.Color);
  1632. finally
  1633. ini.Free;
  1634. MenuItem_TopPanelAddItemsColorOff.Checked := True;
  1635. MenuItem_TopPanelAddItemsColorOn.Checked := False;
  1636. DBNavigator_AddItems.Color := TopPanelAddItems.Color
  1637. end;
  1638. except
  1639. On e: Exception do
  1640. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1641. end;
  1642. end;
  1643.  
  1644. procedure TForm_Neo.MenuItem_TopPanelAddItemsColorOnClick(Sender: TObject);
  1645. var
  1646. ini: TCustomIniFile;
  1647. begin
  1648. try
  1649. if ColorDialog1.Execute then
  1650. TopPanelAddItems.Color := ColorDialog1.Color;
  1651. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1652. try
  1653. ini.WriteInteger('TopPanels', 'AddItemsColor', TopPanelAddItems.Color);
  1654. finally
  1655. ini.Free;
  1656. MenuItem_TopPanelAddItemsColorOff.Checked := False;
  1657. MenuItem_TopPanelAddItemsColorOn.Checked := True;
  1658. DBNavigator_AddItems.Color := TopPanelAddItems.Color;
  1659. end;
  1660. except
  1661. On e: Exception do
  1662. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1663. end;
  1664. end;
  1665.  
  1666. procedure TForm_Neo.MenuItem_TopPanelCreateBOMColorOffClick(Sender: TObject);
  1667. var
  1668. ini: TCustomIniFile;
  1669. begin
  1670. try
  1671. TopPanelCreateBOM.Color := clWhite;
  1672. Panel_BOMBottomInventory.Color := clWhite;
  1673. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1674. try
  1675. ini.WriteInteger('TopPanels', 'CreateBOMColor', TopPanelCreateBOM.Color);
  1676. finally
  1677. ini.Free;
  1678. MenuItem_TopPanelCreateBOMColorOff.Checked := True;
  1679. MenuItem_TopPanelCreateBOMColorOn.Checked := False;
  1680. end;
  1681. except
  1682. On e: Exception do
  1683. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1684. end;
  1685. end;
  1686.  
  1687. procedure TForm_Neo.MenuItem_TopPanelCreateBOMColorOnClick(Sender: TObject);
  1688. var
  1689. ini: TCustomIniFile;
  1690. begin
  1691. try
  1692. if ColorDialog1.Execute then
  1693. TopPanelCreateBOM.Color := ColorDialog1.Color;
  1694. Panel_BOMBottomInventory.Color := TopPanelCreateBOM.Color;
  1695. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  1696. try
  1697. ini.WriteInteger('TopPanels', 'CreateBOMColor', TopPanelCreateBOM.Color);
  1698. finally
  1699. ini.Free;
  1700. MenuItem_TopPanelCreateBOMColorOff.Checked := False;
  1701. MenuItem_TopPanelCreateBOMColorOn.Checked := True;
  1702. end;
  1703. except
  1704. On e: Exception do
  1705. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1706. end;
  1707. end;
  1708.  
  1709. procedure TForm_Neo.PageCon_ChildResize(Sender: TObject);
  1710. var
  1711. i : Integer;
  1712. begin
  1713. try
  1714. i := (Form_Neo.Width - PageCon_Child.Width)-
  1715. (ComboBox_AddCustomersFilters.Width + 32);
  1716. ComboBox_AddCustomersFilters.Left := i;
  1717. ComboBox_AddItemsFilters.Left := i;
  1718. except
  1719. On e: Exception do
  1720. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1721. end;
  1722. end;
  1723.  
  1724. procedure TForm_Neo.RxDBGrid_AddCustomersColumnSized(Sender: TObject);
  1725. begin
  1726. WriteGridColSizes;
  1727. end;
  1728.  
  1729. procedure TForm_Neo.RxDBGrid_AddCustomersEnter(Sender: TObject);
  1730. begin
  1731. StatusBar1.Panels[1].Text := 'Add Customers Grid';
  1732. end;
  1733.  
  1734. procedure TForm_Neo.RxDBGrid_AddCustomersExit(Sender: TObject);
  1735. begin
  1736. StatusBar1.Panels[1].Text := '';
  1737. end;
  1738.  
  1739. procedure TForm_Neo.RxDBGrid_AddCustomersKeyDown(Sender: TObject;
  1740. var Key: Word; Shift: TShiftState);
  1741. const
  1742. GoodKeys = [
  1743. VK_0..VK_9,
  1744. VK_NUMPAD0..VK_NUMPAD9,
  1745. VK_Left,VK_Right,
  1746. VK_UP, VK_DOWN,
  1747. VK_BACK,VK_DELETE,
  1748. VK_END,VK_HOME,
  1749. VK_RETURN,VK_TAB
  1750. ];
  1751. begin
  1752. try
  1753. if RxDBGrid_AddCustomers.SelectedField = DM1.ZQ_AddCustomers.FieldByName('cust_worknumber') then
  1754. if not(Key in GoodKeys) then Key:= 0;
  1755. if RxDBGrid_AddCustomers.SelectedField = DM1.ZQ_AddCustomers.FieldByName('cust_cellnumber') then
  1756. if not(Key in GoodKeys) then Key:= 0;
  1757. except
  1758. On e: Exception do
  1759. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1760. end;
  1761. end;
  1762.  
  1763. procedure TForm_Neo.RxDBGrid_AddCustomersKeyUp(Sender: TObject; var Key: Word;
  1764. Shift: TShiftState);
  1765. var
  1766. i : Integer;
  1767. begin
  1768. i := (Form_Neo.Width - PageCon_Child.Width)-
  1769. (ComboBox_AddCustomersFilters.Width + 32);
  1770. try
  1771. if (Shift = [ssCtrl]) and (Key = VK_2) then
  1772. begin
  1773. PageCon_Main.PageIndex:= 1;
  1774. PageCon_Child.PageIndex:= 1;
  1775. PageCon_Top.PageIndex:= 1;
  1776. DBNavigator_AddItems.Left := HomeTree.Width+2;
  1777. ComboBox_AddItemsFilters.Left := i;
  1778. RxDBGrid_AddItems.SetFocus;
  1779. end;
  1780. if (Shift = [ssCtrl]) and (Key = VK_3) then
  1781. begin
  1782. PageCon_Main.PageIndex:= 2;
  1783. PageCon_Child.PageIndex:= 2;
  1784. PageCon_Top.PageIndex:= 2;
  1785. Edit1.Left := HomeTree.Width+58;
  1786. Edit2.Left := HomeTree.Width+58;
  1787. RxDBGrid_ShowInventory.SetFocus;
  1788. end;
  1789. if Key = VK_F11 then
  1790. if not TreeViewsHidden then
  1791. begin
  1792. HomeTree.Width := 1;
  1793. PageCon_Child.Width := 1;
  1794. TreeViewsHidden := True;
  1795. end
  1796. else
  1797. begin
  1798. ReadSplitterINI;
  1799. TreeViewsHidden := False;
  1800. end;
  1801.  
  1802. if (Shift = [ssCtrl]) and (Key = VK_E) then
  1803. ShowCustomerNote;
  1804. except
  1805. On e: Exception do
  1806. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1807. end;
  1808. end;
  1809.  
  1810. procedure TForm_Neo.RxDBGrid_AddItemsColumnSized(Sender: TObject);
  1811. begin
  1812. WriteGridColSizes;
  1813. end;
  1814.  
  1815. procedure TForm_Neo.RxDBGrid_AddItemsKeyUp(Sender: TObject; var Key: Word;
  1816. Shift: TShiftState);
  1817. begin
  1818. try
  1819. if (Shift = [ssCtrl]) and (Key = VK_1) then
  1820. begin
  1821. PageCon_Main.PageIndex:= 0;
  1822. PageCon_Child.PageIndex:= 0;
  1823. PageCon_Top.PageIndex:= 0;
  1824. RxDBGrid_AddCustomers.SetFocus;
  1825. end;
  1826. if (Shift = [ssCtrl]) and (Key = VK_3) then
  1827. begin
  1828. PageCon_Main.PageIndex:= 2;
  1829. PageCon_Child.PageIndex:= 2;
  1830. PageCon_Top.PageIndex:= 2;
  1831. RxDBGrid_ShowInventory.SetFocus;
  1832. end;
  1833. except
  1834. On e: Exception do
  1835. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1836. end;
  1837. end;
  1838.  
  1839. procedure TForm_Neo.RxDBGrid_AddItemsSelectEditor(Sender: TObject;
  1840. Column: TColumn; var Editor: TWinControl);
  1841. begin
  1842. try
  1843. if Column.Field = RxUnitComboBox.Field then
  1844. begin
  1845. Editor := RxUnitComboBox;
  1846. Editor.BoundsRect := RxDBGrid_AddItems.SelectedFieldRect;
  1847. end;
  1848. except
  1849. On e: Exception do
  1850. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1851. end;
  1852. end;
  1853.  
  1854. procedure TForm_Neo.RxDBGrid_CreateBOMColumnSized(Sender: TObject);
  1855. begin
  1856. WriteGridColSizes;
  1857. end;
  1858.  
  1859. procedure TForm_Neo.RxDBGrid_CreateBOMKeyUp(Sender: TObject; var Key: Word;
  1860. Shift: TShiftState);
  1861. begin
  1862. try
  1863. if (Shift = [ssCtrl]) and (Key = VK_1) then
  1864. begin
  1865. PageCon_Main.PageIndex:= 0;
  1866. PageCon_Child.PageIndex:= 0;
  1867. PageCon_Top.PageIndex:= 0;
  1868. RxDBGrid_AddCustomers.SetFocus;
  1869. end;
  1870. if (Shift = [ssCtrl]) and (Key = VK_2) then
  1871. begin
  1872. PageCon_Main.PageIndex:= 1;
  1873. PageCon_Child.PageIndex:= 1;
  1874. PageCon_Top.PageIndex:= 1;
  1875. DBNavigator_AddItems.Left := HomeTree.Width+2;
  1876. RxDBGrid_AddItems.SetFocus;
  1877. end;
  1878. except
  1879. On e: Exception do
  1880. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1881. end;
  1882. end;
  1883.  
  1884. procedure TForm_Neo.RxDBGrid_ShowInventoryColumnSized(Sender: TObject);
  1885. begin
  1886. WriteGridColSizes;
  1887. end;
  1888.  
  1889. procedure TForm_Neo.RxDBGrid_ShowInventoryDblClick(Sender: TObject);
  1890. begin
  1891. ShowMessage('Add to BOM');
  1892. end;
  1893.  
  1894. procedure TForm_Neo.RxDBGrid_ShowInventoryKeyDown(Sender: TObject;
  1895. var Key: Word; Shift: TShiftState);
  1896. begin
  1897. if key = VK_RETURN then ShowMessage('Return key');
  1898. end;
  1899.  
  1900. procedure TForm_Neo.RxDBGrid_ShowInventoryKeyUp(Sender: TObject; var Key: Word;
  1901. Shift: TShiftState);
  1902. begin
  1903. try
  1904. if (Shift = [ssCtrl]) and (Key = VK_R) then
  1905. begin
  1906. SelectInventoryForBOM;
  1907. ReadGridColSizes;
  1908. end;
  1909.  
  1910. if (Shift = [ssCtrl]) and (Key = VK_1) then
  1911. begin
  1912. PageCon_Main.PageIndex:= 0;
  1913. PageCon_Child.PageIndex:= 0;
  1914. PageCon_Top.PageIndex:= 0;
  1915. RxDBGrid_AddCustomers.SetFocus;
  1916. end;
  1917. if (Shift = [ssCtrl]) and (Key = VK_2) then
  1918. begin
  1919. PageCon_Main.PageIndex:= 1;
  1920. PageCon_Child.PageIndex:= 1;
  1921. PageCon_Top.PageIndex:= 1;
  1922. DBNavigator_AddItems.Left := HomeTree.Width+2;
  1923. RxDBGrid_AddItems.SetFocus;
  1924. end;
  1925. if Key = VK_RETURN then
  1926. AddInventoryItemToBOM;
  1927. except
  1928. On e: Exception do
  1929. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1930. end;
  1931. end;
  1932.  
  1933. procedure TForm_Neo.RxUnitComboBoxKeyPress(Sender: TObject; var Key: char);
  1934. begin
  1935. if (key = #9) or (key = #13) then
  1936. try
  1937. if RxDBGrid_AddItems.SelectedIndex + 1 < RxDBGrid_AddItems.Columns.Count then
  1938. RxDBGrid_AddItems.SelectedIndex := RxDBGrid_AddItems.SelectedIndex + 1;
  1939. except
  1940. On e: Exception do
  1941. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1942. end;
  1943. end;
  1944.  
  1945. procedure TForm_Neo.Timer1Timer(Sender: TObject);
  1946. begin
  1947. StatusBar1.Panels[2].Text := FormatDateTime('DDDD dd MMMM YYYY HH:MM:SS', Now) + ' ';
  1948. end;
  1949.  
  1950. procedure TForm_Neo.ToggleBox_AddCustomersAutoWildcardClick(Sender: TObject);
  1951. begin
  1952. try
  1953. if ToggleBox_AddCustomersAutoWildcard.Caption = 'On' then
  1954. begin
  1955. ToggleBox_AddCustomersAutoWildcard.Caption := 'Off';
  1956. ToggleBox_AddCustomersAutoWildcard.Checked := False;
  1957. end
  1958. else
  1959. begin
  1960. ToggleBox_AddCustomersAutoWildcard.Caption := 'On';
  1961. ToggleBox_AddCustomersAutoWildcard.Checked := True;
  1962. end;
  1963. Edit_AddCustomersSearch.SetFocus;
  1964. except
  1965. On e: Exception do
  1966. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1967. end;
  1968. end;
  1969.  
  1970. procedure TForm_Neo.ToggleBox_AddCustomersAutoWildcardEnter(Sender: TObject);
  1971. begin
  1972. StatusBar1.Panels[1].Text := 'AutoWildcard Toggle';
  1973. end;
  1974.  
  1975. procedure TForm_Neo.ToggleBox_AddCustomersAutoWildcardExit(Sender: TObject);
  1976. begin
  1977. StatusBar1.Panels[1].Text := '';
  1978. end;
  1979.  
  1980. procedure TForm_Neo.ToggleBox_AddItemsAutoWildcardClick(Sender: TObject);
  1981. begin
  1982. try
  1983. if ToggleBox_AddItemsAutoWildcard.Caption = 'On' then
  1984. begin
  1985. ToggleBox_AddItemsAutoWildcard.Caption := 'Off';
  1986. ToggleBox_AddItemsAutoWildcard.Checked := False;
  1987. end
  1988. else
  1989. begin
  1990. ToggleBox_AddItemsAutoWildcard.Caption := 'On';
  1991. ToggleBox_AddItemsAutoWildcard.Checked := True;
  1992. end;
  1993. Edit_AddItemsSearch.SetFocus;
  1994. except
  1995. On e: Exception do
  1996. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  1997. end;
  1998. end;
  1999.  
  2000. procedure TForm_Neo.ToggleBox_ShowInventoryAutoWildcardClick(Sender: TObject);
  2001. begin
  2002. try
  2003. if ToggleBox_ShowInventoryAutoWildcard.Caption = 'On' then
  2004. begin
  2005. ToggleBox_ShowInventoryAutoWildcard.Caption := 'Off';
  2006. ToggleBox_ShowInventoryAutoWildcard.Checked := False;
  2007. end
  2008. else
  2009. begin
  2010. ToggleBox_ShowInventoryAutoWildcard.Caption := 'On';
  2011. ToggleBox_ShowInventoryAutoWildcard.Checked := True;
  2012. end;
  2013. Edit_BOMShowInventorySearch.SetFocus;
  2014. except
  2015. On e: Exception do
  2016. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  2017. end;
  2018. end;
  2019.  
  2020. procedure TForm_Neo.TreeView_ChildAddCustomersEnter(Sender: TObject);
  2021. begin
  2022. StatusBar1.Panels[1].Text := 'Add Customers ChildTree';
  2023. end;
  2024.  
  2025. procedure TForm_Neo.TreeView_ChildAddCustomersExit(Sender: TObject);
  2026. begin
  2027. StatusBar1.Panels[1].Text := '';
  2028. end;
  2029.  
  2030. procedure TForm_Neo.ReadGridAltColors;
  2031. var
  2032. ini: TCustomIniFile;
  2033. C,D,E,F: TStrings;
  2034. defaultColor : Integer;
  2035. begin
  2036. try
  2037. defaultColor := clWhite;
  2038. ini := TMemIniFile.Create(ChangeFileExt(Application.ExeName, '.ini'));
  2039. try
  2040. C := TStringList.Create;
  2041. D := TStringList.Create;
  2042. E := TStringList.Create;
  2043. F := TStringList.Create;
  2044. try
  2045. ini.ReadSection('GridColors', C);
  2046. RxDBGrid_AddCustomers.AlternateColor := ini.ReadInteger('GridColors', 'AddCustomersAltColor', RxDBGrid_AddCustomers.AlternateColor);
  2047. if RxDBGrid_AddCustomers.AlternateColor = defaultColor then
  2048. begin
  2049. MenuItem_AddCustomersGridColorOff.Checked := True;
  2050. MenuItem_AddCustomersGridColorOn.Checked := False;
  2051. end
  2052. else
  2053. begin
  2054. MenuItem_AddCustomersGridColorOff.Checked := False;
  2055. MenuItem_AddCustomersGridColorOn.Checked := True;
  2056. end;
  2057.  
  2058. ini.ReadSection('GridColors', D);
  2059. RxDBGrid_AddItems.AlternateColor := ini.ReadInteger('GridColors', 'AddItemsAltColor', RxDBGrid_AddItems.AlternateColor);
  2060. if RxDBGrid_AddItems.AlternateColor = defaultColor then
  2061. begin
  2062. MenuItem_AddItemsGridColorOff.Checked := True;
  2063. MenuItem_AddItemsGridColorOn.Checked := False;
  2064. end
  2065. else
  2066. begin
  2067. MenuItem_AddItemsGridColorOff.Checked := False;
  2068. MenuItem_AddItemsGridColorOn.Checked := True;
  2069. end;
  2070.  
  2071. ini.ReadSection('GridColors', E);
  2072. RxDBGrid_CreateBOM.AlternateColor := ini.ReadInteger('GridColors', 'CreateBOMAltColor', RxDBGrid_CreateBOM.AlternateColor);
  2073. if RxDBGrid_CreateBOM.AlternateColor = defaultColor then
  2074. begin
  2075. MenuItem_CreateBOMGridColorOff.Checked := True;
  2076. MenuItem_CreateBOMGridColorOn.Checked := False;
  2077. end
  2078. else
  2079. begin
  2080. MenuItem_CreateBOMGridColorOff.Checked := False;
  2081. MenuItem_CreateBOMGridColorOn.Checked := True;
  2082. end;
  2083.  
  2084. ini.ReadSection('GridColors', F);
  2085. RxDBGrid_ShowInventory.AlternateColor := ini.ReadInteger('GridColors', 'ShowInventoryAltColor', RxDBGrid_ShowInventory.AlternateColor);
  2086. if RxDBGrid_ShowInventory.AlternateColor = defaultColor then
  2087. begin
  2088. MenuItem_ShowInventoryGridColorOff.Checked := True;
  2089. MenuItem_ShowInventoryGridColorOn.Checked := False;
  2090. end
  2091. else
  2092. begin
  2093. MenuItem_ShowInventoryGridColorOff.Checked := False;
  2094. MenuItem_ShowInventoryGridColorOn.Checked := True;
  2095. end;
  2096. finally
  2097. C.Free;
  2098. D.Free;
  2099. E.Free;
  2100. F.Free;
  2101. end;
  2102. finally
  2103. ini.Free;
  2104. end;
  2105. except
  2106. On e: Exception do
  2107. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  2108. end;
  2109. end;
  2110.  
  2111. // CHECK FOR VALID EMAIL ADDRESSES AS SOON AS THE USER LEAVES THE CELLS
  2112. procedure TForm_Neo.RxDBGrid_AddCustomersColExit(Sender: TObject);
  2113. var
  2114. a : String;
  2115. begin
  2116. try
  2117. if RxDBGrid_AddCustomers.SelectedField = DM1.ZQ_AddCustomers.FieldByName('cust_email1') then
  2118. begin
  2119. a:= DM1.ZQ_AddCustomers.FieldByName('cust_email1').AsString;
  2120. if a = '' then exit;
  2121. if (pos('@',a) = 0) or (pos('.',a) = 0) or (pos(',',a) <> 0) then
  2122. MessageDlg('Warning', a + ' does not appear to be a valid email address.', mtWarning,[mbOK],0);
  2123. end;
  2124. if RxDBGrid_AddCustomers.SelectedField = DM1.ZQ_AddCustomers.FieldByName('cust_email2') then
  2125. begin
  2126. a:= DM1.ZQ_AddCustomers.FieldByName('cust_email2').AsString;
  2127. if a = '' then exit;
  2128. if (pos('@',a) = 0) or (pos('.',a) = 0) or (pos(',',a) <> 0) then
  2129. MessageDlg('Warning', a + ' does not appear to be a valid email address.', mtWarning,[mbOK],0);
  2130. end;
  2131. except
  2132. On e: Exception do
  2133. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  2134. end;
  2135. end;
  2136.  
  2137. procedure TForm_Neo.WriteGridColSizes;
  2138. var
  2139. ini: TCustomIniFile;
  2140. i: Integer;
  2141. begin
  2142. try
  2143. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  2144. try
  2145. for i:=0 to RxDBGrid_AddCustomers.Columns.Count-1 do
  2146. ini.WriteInteger('ColWidthsAddCust', 'Col' + IntToStr(i), RxDBGrid_AddCustomers.Columns[i].Width);
  2147.  
  2148. for i:=0 to RxDBGrid_AddItems.Columns.Count-1 do
  2149. ini.WriteInteger('ColWidthsAddItems', 'Col' + IntToStr(i), RxDBGrid_AddItems.Columns[i].Width);
  2150.  
  2151. for i:=0 to RxDBGrid_ShowInventory.Columns.Count-1 do
  2152. ini.WriteInteger('ColWidthsShowInventory', 'Col' + IntToStr(i), RxDBGrid_ShowInventory.Columns[i].Width);
  2153.  
  2154. for i:=0 to RxDBGrid_CreateBOM.Columns.Count-1 do
  2155. ini.WriteInteger('ColWidthsRxDBGrid_CreateBOM', 'Col' + IntToStr(i), RxDBGrid_CreateBOM.Columns[i].Width);
  2156. finally
  2157. ini.Free;
  2158. end;
  2159. except
  2160. On e: Exception do
  2161. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  2162. end;
  2163. end;
  2164.  
  2165. procedure TForm_Neo.ReadGridColSizes;
  2166. var
  2167. ini: TCustomIniFile;
  2168. A,B,C: TStrings;
  2169. i: Integer;
  2170. begin
  2171. try
  2172. ini := TMemIniFile.Create(ChangeFileExt(Application.ExeName, '.ini'));
  2173. A := TStringList.Create;
  2174. B := TStringList.Create;
  2175. C := TStringList.Create;
  2176. try
  2177. ini.ReadSection('ColWidthsAddCust', A);
  2178. //if not DM1.DS_AddCustomers.DataSet.IsEmpty then
  2179. // begin
  2180. for i := 0 to A.Count-1 do
  2181. RxDBGrid_AddCustomers.Columns[i].Width := ini.ReadInteger('ColWidthsAddCust', A[i], RxDBGrid_AddCustomers.Columns[i].Width);
  2182. // end;
  2183.  
  2184. ini.ReadSection('ColWidthsAddItems', B);
  2185. //if not DM1.DS_AddItems.DataSet.IsEmpty then
  2186. // begin
  2187. for i := 0 to B.Count-1 do
  2188. RxDBGrid_AddItems.Columns[i].Width := ini.ReadInteger('ColWidthsAddItems', B[i], RxDBGrid_AddItems.Columns[i].Width);
  2189. //end;
  2190.  
  2191. ini.ReadSection('ColWidthsShowInventory', C);
  2192. //if not DM1.DS_ReadInventory.DataSet.IsEmpty then
  2193. // begin
  2194. for i := 0 to C.Count-1 do
  2195. RxDBGrid_ShowInventory.Columns[i].Width := ini.ReadInteger('ColWidthsShowInventory', C[i], RxDBGrid_ShowInventory.Columns[i].Width);
  2196. //end;
  2197. finally
  2198. ini.Free;
  2199. A.Free;
  2200. B.Free;
  2201. C.Free;
  2202. end;
  2203. except
  2204. On e: Exception do
  2205. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  2206. end;
  2207. end;
  2208.  
  2209. {------------------------------------------------------------------------------
  2210. WHEN THE PROGRAM FIRST LOADS, THIS PROCEDURE IS CALLED. IT SETS THE DISPLAY,
  2211. PUTTING THE SPLITTERS BACK WHERE THE USER LAST HAD THEM. AND AS SEEN BELOW,
  2212. IT WILL ALSO SETUP THE SEARCH COMPONENTS ON THE FIRST PAGE DISPLAYED: ADD
  2213. CUSTOMER PAGE.
  2214. ------------------------------------------------------------------------------}
  2215. procedure TForm_Neo.ReadSplitterINI;
  2216. var
  2217. ini: TCustomIniFile;
  2218. B,C,D: TStrings;
  2219. i : Integer;
  2220. loc : LongInt;
  2221. begin
  2222. ini := TMemIniFile.Create(ChangeFileExt(Application.ExeName, '.ini'));
  2223. try
  2224. B := TStringList.Create;
  2225. C := TStringList.Create;
  2226. D := TStringList.Create;
  2227. try
  2228. ini.ReadSection('CreateBOMGrid', B);
  2229. RxDBGrid_CreateBOM.Height:= ini.ReadInteger('CreateBOMGrid', 'HeightCeateBOMGrid', RxDBGrid_CreateBOM.Height);
  2230.  
  2231. ini.ReadSection('TreeViewWidth', C);
  2232. HomeTree.Width:= ini.ReadInteger('TreeViewWidth', 'WidthHomeTree', HomeTree.Width);
  2233.  
  2234. ini.ReadSection('TreeViewWidth', D);
  2235. PageCon_Child.Width:= ini.ReadInteger('TreeViewWidth', 'WidthChildPageCon', PageCon_Child.Width);
  2236. finally
  2237. ini.Free;
  2238. B.Free;
  2239. C.Free;
  2240. D.Free;
  2241. // HERE WE INITIALLY SET THE SAERCH BOXES/BUTTON FOR THE ADD CUSTOMER PAGE,
  2242. // SINCE IT'S THE FIRST PAGE TO BE SHOWN. AFTER THIS, EACH TIME THE USER
  2243. // CHANGES THE PAGE VIA HOMETREECHANGE, ALL SEARCH BOXES/BUTTONS WILL BE UPDATED
  2244. // AND BE PROPERLY DISPLAYED.
  2245. i := (Form_Neo.Width - PageCon_Child.Width)-(ComboBox_AddCustomersFilters.Width + 32);
  2246. ComboBox_AddCustomersFilters.Left := i;
  2247. end;
  2248. except
  2249. On e: Exception do
  2250. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  2251. end;
  2252. end;
  2253.  
  2254. procedure TForm_Neo.SelectCustomers;
  2255. begin
  2256. try
  2257. try
  2258. with DM1 do
  2259. begin
  2260. ZQ_AddCustomers.Close;
  2261. ZQ_AddCustomers.SQL.Text := 'SELECT * FROM customers';
  2262. ZQ_AddCustomers.Open;
  2263. end;
  2264. finally
  2265. SetDBGridTitlesCustomers;
  2266. RxDBGrid_AddCustomers.FixedCols := 0;
  2267. end;
  2268. except
  2269. On e: Exception do
  2270. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  2271. end;
  2272. end;
  2273.  
  2274. procedure TForm_Neo.SelectItems;
  2275. begin
  2276. try
  2277. try
  2278. with DM1 do
  2279. begin
  2280. ZQ_AddItems.Close;
  2281. ZQ_AddItems.SQL.Text := 'SELECT * FROM inventory';
  2282. ZQ_AddItems.Open;
  2283. end;
  2284. finally
  2285. SetDBGridTitlesAddItems;
  2286. SetAddItemsGridFloats;
  2287. end;
  2288. except
  2289. On e: Exception do
  2290. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  2291. end;
  2292. end;
  2293.  
  2294. procedure TForm_Neo.SelectInventoryForBOM;
  2295. begin
  2296. try
  2297. try
  2298. with DM1 do
  2299. begin
  2300. ZQ_ReadInventory.Close;
  2301. ZQ_ReadInventory.SQL.Text := 'SELECT * FROM inventory';
  2302. ZQ_ReadInventory.Open;
  2303. end;
  2304. finally
  2305. SetDBGridTitlesShowInventory;
  2306. SetShowInventoryGridFloats;
  2307. end;
  2308. except
  2309. On e: Exception do
  2310. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  2311. end;
  2312. end;
  2313.  
  2314. procedure TForm_Neo.ReloadDBComboBox;
  2315. begin
  2316. try
  2317. try
  2318. RxUnitComboBox.Clear;
  2319. DM1.ZQ_UnitComboBox.Close;
  2320. DM1.ZQ_UnitComboBox.SQL.Text := 'SELECT DISTINCT inventory_unit FROM inventory';
  2321. DM1.ZQ_UnitComboBox.Open;
  2322. DM1.ZQ_UnitComboBox.First;
  2323. while not DM1.ZQ_UnitComboBox.EOF do
  2324. begin
  2325. if DM1.ZQ_UnitComboBox.FieldByName('inventory_unit').AsString <> '' then
  2326. RxUnitComboBox.Items.Add(DM1.ZQ_UnitComboBox.FieldByName('inventory_unit').DisplayText);
  2327. DM1.ZQ_UnitComboBox.Next;
  2328. end;
  2329. finally
  2330. RxUnitComboBox.Sorted := True;
  2331. end;
  2332. except
  2333. On e: Exception do
  2334. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  2335. end;
  2336. end;
  2337.  
  2338. procedure TForm_Neo.SetDBGridTitlesCustomers;
  2339. begin
  2340. try
  2341. with RxDBGrid_AddCustomers do
  2342. begin
  2343. Columns[0].Visible:= False;
  2344. Columns[1].Title.Caption:= 'First Name';
  2345. Columns[2].Title.Caption:= 'Last Name';
  2346. Columns[3].Title.Caption:= 'Company';
  2347. Columns[4].Title.Caption:= 'Phys Address';
  2348. Columns[5].Title.Caption:= 'Phys City';
  2349. Columns[6].Title.Caption:= 'Phys Sate';
  2350. Columns[7].Title.Caption:= 'Phys Zip Code';
  2351. Columns[8].Title.Caption:= 'Billing Address';
  2352. Columns[9].Title.Caption:= 'Billing City';
  2353. Columns[10].Title.Caption:= 'Billing State';
  2354. Columns[11].Title.Caption:= 'Billing Zip Code';
  2355. Columns[12].Title.Caption:= 'E-mail 1';
  2356. Columns[13].Title.Caption:= 'E-mail 2';
  2357. Columns[14].Title.Caption:= 'Work Number';
  2358. Columns[15].Title.Caption:= 'Cell Number';
  2359. Columns[16].Title.Caption:= 'Notes';
  2360. end;
  2361. except
  2362. On e: Exception do
  2363. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  2364. end;
  2365. end;
  2366.  
  2367. procedure TForm_Neo.SetDBGridTitlesAddItems;
  2368. begin
  2369. try
  2370. with RxDBGrid_AddItems do
  2371. begin
  2372. Columns[0].Visible:= False;
  2373. Columns[1].Title.Caption:= 'Item #';
  2374. columns[2].Title.Caption:= 'Description';
  2375. columns[3].Title.Caption:= 'Unit';
  2376. columns[4].Title.Caption:= 'Cost';
  2377. columns[5].Title.Caption:= 'Sell Price';
  2378. columns[6].Title.Caption:= 'MC %';
  2379. columns[7].Title.Caption:= 'Weight';
  2380. columns[8].Title.Caption:= 'In Stock';
  2381. end;
  2382. except
  2383. On e: Exception do
  2384. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  2385. end;
  2386. end;
  2387.  
  2388. procedure TForm_Neo.SetDBGridTitlesShowInventory;
  2389. begin
  2390. try
  2391. with RxDBGrid_ShowInventory do
  2392. begin
  2393. Columns[0].Visible:= False;
  2394. Columns[1].Title.Caption:= 'Item #';
  2395. columns[2].Title.Caption:= 'Description';
  2396. columns[3].Title.Caption:= 'Unit';
  2397. columns[4].Title.Caption:= 'Cost';
  2398. columns[5].Title.Caption:= 'Sell Price';
  2399. columns[6].Title.Caption:= 'MC %';
  2400. columns[7].Title.Caption:= 'Weight';
  2401. columns[8].Title.Caption:= 'In Stock';
  2402. end;
  2403. except
  2404. On e: Exception do
  2405. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  2406. end;
  2407. end;
  2408.  
  2409. procedure TForm_Neo.ZQ_AddCustomersAfterDelete(DataSet: TDataSet);
  2410. begin
  2411. DM1.ZQ_AddCustomers.ApplyUpdates;
  2412. end;
  2413.  
  2414. procedure TForm_Neo.ZQ_AddCustomersAfterPost(DataSet: TDataSet);
  2415. begin
  2416. DM1.ZQ_AddCustomers.ApplyUpdates;
  2417. end;
  2418.  
  2419. procedure TForm_Neo.ZQ_AddCustomersBeforePost(DataSet: TDataSet);
  2420. var
  2421. s: String;
  2422. begin
  2423. try
  2424. s:= DM1.ZQ_AddCustomers.FieldByName('cust_fname').AsString;
  2425. DM1.ZQ_AddCustomers.FieldByName('cust_fname').AsString:= Trim(s);
  2426.  
  2427. s:= DM1.ZQ_AddCustomers.FieldByName('cust_lname').AsString;
  2428. DM1.ZQ_AddCustomers.FieldByName('cust_lname').AsString:= Trim(s);
  2429.  
  2430. s:= DM1.ZQ_AddCustomers.FieldByName('cust_company').AsString;
  2431. DM1.ZQ_AddCustomers.FieldByName('cust_company').AsString:= Trim(s);
  2432.  
  2433. s:= DM1.ZQ_AddCustomers.FieldByName('cust_email1').AsString;
  2434. DM1.ZQ_AddCustomers.FieldByName('cust_email1').AsString:= Trim(s);
  2435.  
  2436. s:= DM1.ZQ_AddCustomers.FieldByName('cust_email2').AsString;
  2437. DM1.ZQ_AddCustomers.FieldByName('cust_email2').AsString:= Trim(s);
  2438.  
  2439. s:= DM1.ZQ_AddCustomers.FieldByName('cust_worknumber').AsString;
  2440. DM1.ZQ_AddCustomers.FieldByName('cust_worknumber').AsString:= Trim(s);
  2441.  
  2442. s:= DM1.ZQ_AddCustomers.FieldByName('cust_cellnumber').AsString;
  2443. DM1.ZQ_AddCustomers.FieldByName('cust_cellnumber').AsString:= Trim(s);
  2444.  
  2445. VerifyCustPhoneNumbers;
  2446. //VerifyCustEmails;
  2447. except
  2448. On e: Exception do
  2449. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  2450. end;
  2451. end;
  2452.  
  2453. procedure TForm_Neo.ZQ_AddItemsAfterApplyUpdates(Sender: TObject);
  2454. begin
  2455. SetAddItemsGridFloats;
  2456. ReloadDBComboBox;
  2457. end;
  2458.  
  2459. procedure TForm_Neo.ZQ_AddItemsAfterDelete(DataSet: TDataSet);
  2460. begin
  2461. DM1.ZQ_AddItems.ApplyUpdates;
  2462. end;
  2463.  
  2464. procedure TForm_Neo.ZQ_AddItemsAfterPost(DataSet: TDataSet);
  2465. begin
  2466. DM1.ZQ_AddItems.ApplyUpdates;
  2467.  
  2468. SetAddItemsGridFloats;
  2469. SetDBGridTitlesAddItems;
  2470. ReloadDBComboBox;
  2471. ReadGridColSizes;
  2472. end;
  2473.  
  2474. procedure TForm_Neo.ZQ_AddItemsBeforePost(DataSet: TDataSet);
  2475. var
  2476. s: String;
  2477. a, b, c: Double;
  2478. begin
  2479. try
  2480. if (DM1.ZQ_AddItems.FieldByName('inventory_cost').AsString = '') or
  2481. (DM1.ZQ_AddItems.FieldByName('inventory_sell_price').AsString = '') then
  2482. Exit;
  2483. a := DM1.ZQ_AddItems.FieldByName('inventory_cost').AsFloat;
  2484. b := DM1.ZQ_AddItems.FieldByName('inventory_sell_price').AsFloat;
  2485. c := ((b - a) / a) * 100;
  2486.  
  2487. s:= DM1.ZQ_AddItems.FieldByName('inventory_item_number').AsString;
  2488. DM1.ZQ_AddItems.FieldByName('inventory_item_number').AsString:= Trim(s);
  2489.  
  2490. s:= DM1.ZQ_AddItems.FieldByName('inventory_description').AsString;
  2491. DM1.ZQ_AddItems.FieldByName('inventory_description').AsString:= Trim(s);
  2492.  
  2493. s:= DM1.ZQ_AddItems.FieldByName('inventory_unit').AsString;
  2494. DM1.ZQ_AddItems.FieldByName('inventory_unit').AsString:= Trim(s);
  2495.  
  2496. s:= DM1.ZQ_AddItems.FieldByName('inventory_cost').AsString;
  2497. DM1.ZQ_AddItems.FieldByName('inventory_cost').AsString:= Trim(s);
  2498.  
  2499. s:= DM1.ZQ_AddItems.FieldByName('inventory_sell_price').AsString;
  2500. DM1.ZQ_AddItems.FieldByName('inventory_sell_price').AsString:= Trim(s);
  2501.  
  2502. DM1.ZQ_AddItems.FieldByName('inventory_margin_contribution').AsFloat := c;
  2503.  
  2504. s:= DM1.ZQ_AddItems.FieldByName('inventory_weight').AsString;
  2505. DM1.ZQ_AddItems.FieldByName('inventory_weight').AsString:= Trim(s);
  2506.  
  2507. s:= DM1.ZQ_AddItems.FieldByName('inventory_in_stock').AsString;
  2508. DM1.ZQ_AddItems.FieldByName('inventory_in_stock').AsString:= Trim(s);
  2509. except
  2510. On e: Exception do
  2511. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  2512. end;
  2513. end;
  2514.  
  2515. procedure TForm_Neo.VerifyCustPhoneNumbers;
  2516. var
  2517. s, t, u, f: String;
  2518. begin
  2519. try
  2520. if DM1.ZQ_AddCustomers.FieldByName('cust_worknumber').AsString <> '' then
  2521. begin
  2522. f:= DM1.ZQ_AddCustomers.FieldByName('cust_worknumber').AsString;
  2523. if pos('-',f) = 0 then
  2524. begin
  2525. s:= Copy(f,1,3);
  2526. s:= s +'-';
  2527. t:= Copy(f,4,3);
  2528. t:= t + '-';
  2529. u:= s + t + Copy(f,7,4);
  2530. DM1.ZQ_AddCustomers.FieldByName('cust_worknumber').AsString := u;
  2531. end;
  2532. end;
  2533.  
  2534. if DM1.ZQ_AddCustomers.FieldByName('cust_cellnumber').AsString <> '' then
  2535. begin
  2536. f:= DM1.ZQ_AddCustomers.FieldByName('cust_cellnumber').AsString;
  2537. if pos('-',f) = 0 then
  2538. begin
  2539. s:= Copy(f,1,3);
  2540. s:= s +'-';
  2541. t:= Copy(f,4,3);
  2542. t:= t + '-';
  2543. u:= s + t + Copy(f,7,4);
  2544. DM1.ZQ_AddCustomers.FieldByName('cust_cellnumber').AsString := u;
  2545. end;
  2546. end;
  2547. except
  2548. On e: Exception do
  2549. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  2550. end;
  2551. end;
  2552.  
  2553. procedure TForm_Neo.VerifyCustEmails;
  2554. var
  2555. a: String;
  2556. begin
  2557. try
  2558. if DM1.ZQ_AddCustomers.FieldByName('cust_email1').AsString <> '' then
  2559. begin
  2560. a:= DM1.ZQ_AddCustomers.FieldByName('cust_email1').AsString;
  2561. if (pos('@',a) = 0) or (pos('.',a) = 0) then
  2562. MessageDlg('Error', 'Email 1 is not a valid email address.', mtError,[mbOK],0);
  2563. end;
  2564.  
  2565. if DM1.ZQ_AddCustomers.FieldByName('cust_email2').AsString <> '' then
  2566. begin
  2567. a:= DM1.ZQ_AddCustomers.FieldByName('cust_email2').AsString;
  2568. if (pos('@',a) = 0) or (pos('.',a) = 0) then
  2569. MessageDlg('Error', 'Email 2 is not a valid email address.', mtError,[mbOK],0);
  2570. end;
  2571. except
  2572. On e: Exception do
  2573. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  2574. end;
  2575. end;
  2576.  
  2577. procedure TForm_Neo.SetAddItemsGridFloats;
  2578. begin
  2579. try
  2580. TFloatField(DM1.ZQ_AddItems.FieldByName('inventory_cost')).DisplayFormat := '####0.00';
  2581. TFloatField(DM1.ZQ_AddItems.FieldByName('inventory_sell_price')).DisplayFormat := '####0.00';
  2582. TFloatField(DM1.ZQ_AddItems.FieldByName('inventory_margin_contribution')).DisplayFormat := '####0.00';
  2583. TFloatField(DM1.ZQ_AddItems.FieldByName('inventory_weight')).DisplayFormat := '####0.00';
  2584. TFloatField(DM1.ZQ_AddItems.FieldByName('inventory_in_stock')).DisplayFormat := '####0.00';
  2585. except
  2586. On e: Exception do
  2587. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  2588. end;
  2589. end;
  2590.  
  2591. procedure TForm_Neo.SetShowInventoryGridFloats;
  2592. begin
  2593. try
  2594. TFloatField(DM1.ZQ_ReadInventory.FieldByName('inventory_cost')).DisplayFormat := '####0.00';
  2595. TFloatField(DM1.ZQ_ReadInventory.FieldByName('inventory_sell_price')).DisplayFormat := '####0.00';
  2596. TFloatField(DM1.ZQ_ReadInventory.FieldByName('inventory_margin_contribution')).DisplayFormat := '####0.00';
  2597. TFloatField(DM1.ZQ_ReadInventory.FieldByName('inventory_weight')).DisplayFormat := '####0.00';
  2598. TFloatField(DM1.ZQ_ReadInventory.FieldByName('inventory_in_stock')).DisplayFormat := '####0.00';
  2599. except
  2600. On e: Exception do
  2601. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  2602. end;
  2603. end;
  2604.  
  2605. procedure TForm_Neo.ReadPanelColors;
  2606. var
  2607. ini: TCustomIniFile;
  2608. A,B,C,D,E,F,G: TStrings;
  2609. defaultColor : Integer;
  2610. begin
  2611. try
  2612. defaultColor := clWhite;
  2613. ini := TMemIniFile.Create(ChangeFileExt(Application.ExeName, '.ini'));
  2614. A := TStringList.Create;
  2615. B := TStringList.Create;
  2616. C := TStringList.Create;
  2617. D := TStringList.Create;
  2618. E := TStringList.Create;
  2619. F := TStringList.Create;
  2620. G := TStringList.Create;
  2621. try
  2622. ini.ReadSection('HomeTreeColor', A);
  2623. HomeTree.Color := ini.ReadInteger('HomeTreeColor', 'Color', HomeTree.Color);
  2624. if HomeTree.Color = defaultColor then
  2625. begin
  2626. MenuItemHomeTreeColorOff.Checked := True;
  2627. MenuItemHomeTreeColorOn.Checked := False;
  2628. end
  2629. else
  2630. begin
  2631. MenuItemHomeTreeColorOff.Checked := False;
  2632. MenuItemHomeTreeColorOn.Checked := True;
  2633. end;
  2634.  
  2635. ini.ReadSection('TreeView_ChildAddCustomers', B);
  2636. TreeView_ChildAddCustomers.Color := ini.ReadInteger('TreeView_ChildAddCustomers', 'Color', TreeView_ChildAddCustomers.Color);
  2637. if TreeView_ChildAddCustomers.Color = defaultColor then
  2638. begin
  2639. MenuItem_ChildAddCustomerColorOff.Checked := True;
  2640. MenuItem_ChildAddCustomerColorOn.Checked := False;
  2641. end
  2642. else
  2643. begin
  2644. MenuItem_ChildAddCustomerColorOff.Checked := False;
  2645. MenuItem_ChildAddCustomerColorOn.Checked := True;
  2646. end;
  2647.  
  2648. ini.ReadSection('TreeView_ChildAddItems', C);
  2649. TreeView_ChildAddItems.Color := ini.ReadInteger('TreeView_ChildAddItems', 'Color', TreeView_ChildAddItems.Color);
  2650. if TreeView_ChildAddCustomers.Color = defaultColor then
  2651. begin
  2652. MenuItem_ChildAddItemsColorOff.Checked := True;
  2653. MenuItem_ChildAddItemsColorOn.Checked := False;
  2654. end
  2655. else
  2656. begin
  2657. MenuItem_ChildAddItemsColorOff.Checked := False;
  2658. MenuItem_ChildAddItemsColorOn.Checked := True;
  2659. end;
  2660.  
  2661. ini.ReadSection('TreeView_ChildCreateBOM', D);
  2662. TreeView_ChildCreateBOM.Color := ini.ReadInteger('TreeView_ChildCreateBOM', 'Color', TreeView_ChildCreateBOM.Color);
  2663. if TreeView_ChildCreateBOM.Color = defaultColor then
  2664. begin
  2665. MenuItem_ChildCreateBOMColorOff.Checked := True;
  2666. MenuItem_ChildCreateBOMColorOn.Checked := False;
  2667. end
  2668. else
  2669. begin
  2670. MenuItem_ChildCreateBOMColorOff.Checked := False;
  2671. MenuItem_ChildCreateBOMColorOn.Checked := True;
  2672. end;
  2673.  
  2674. ini.ReadSection('TopPanels', E);
  2675. TopPanelAddCustomers.Color := ini.ReadInteger('TopPanels', 'AddCustomersColor', TopPanelAddCustomers.Color);
  2676. DBNavigator_AddCustomers.Color := TopPanelAddCustomers.Color;
  2677. if TopPanelAddCustomers.Color = defaultColor then
  2678. begin
  2679. MenuItem_TopPanelAddCustomerColorOff.Checked := True;
  2680. MenuItem_TopPanelAddCustomerColorOn.Checked := False;
  2681. end
  2682. else
  2683. begin
  2684. MenuItem_TopPanelAddCustomerColorOff.Checked := False;
  2685. MenuItem_TopPanelAddCustomerColorOn.Checked := True;
  2686. end;
  2687.  
  2688. ini.ReadSection('TopPanels', F);
  2689. TopPanelAddItems.Color := ini.ReadInteger('TopPanels', 'AddItemsColor', TopPanelAddItems.Color);
  2690. DBNavigator_AddItems.Color := TopPanelAddItems.Color;
  2691. if TopPanelAddItems.Color = defaultColor then
  2692. begin
  2693. MenuItem_TopPanelAddItemsColorOff.Checked := True;
  2694. MenuItem_TopPanelAddItemsColorOn.Checked := False;
  2695. end
  2696. else
  2697. begin
  2698. MenuItem_TopPanelAddItemsColorOff.Checked := False;
  2699. MenuItem_TopPanelAddItemsColorOn.Checked := True;
  2700. end;
  2701.  
  2702. ini.ReadSection('TopPanels', G);
  2703. TopPanelCreateBOM.Color := ini.ReadInteger('TopPanels', 'CreateBOMColor', TopPanelCreateBOM.Color);
  2704. Panel_BOMBottomInventory.Color := TopPanelCreateBOM.Color;
  2705. if TopPanelCreateBOM.Color = defaultColor then
  2706. begin
  2707. MenuItem_TopPanelCreateBOMColorOff.Checked := True;
  2708. MenuItem_TopPanelCreateBOMColorOn.Checked := False;
  2709. end
  2710. else
  2711. begin
  2712. MenuItem_TopPanelCreateBOMColorOff.Checked := False;
  2713. MenuItem_TopPanelCreateBOMColorOn.Checked := True;
  2714. end;
  2715. finally
  2716. ini.Free;
  2717. A.Free;
  2718. B.Free;
  2719. C.Free;
  2720. D.Free;
  2721. E.Free;
  2722. F.Free;
  2723. G.Free;
  2724. end;
  2725. except
  2726. On e: Exception do
  2727. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  2728. end;
  2729. end;
  2730.  
  2731. procedure TForm_Neo.ReadGridRowHeight;
  2732. var
  2733. ini: TCustomIniFile;
  2734. A: TStrings;
  2735. begin
  2736. try
  2737. ini := TMemIniFile.Create(ChangeFileExt(Application.ExeName, '.ini'));
  2738. try
  2739. A := TStringList.Create;
  2740. ini.ReadSection('GridRowHeight', A);
  2741. RxDBGrid_AddCustomers.DefaultRowHeight := ini.ReadInteger
  2742. ('GridRowHeight', 'Height',
  2743. RxDBGrid_AddCustomers.DefaultRowHeight);
  2744. RxDBGrid_AddItems.DefaultRowHeight := RxDBGrid_AddCustomers.DefaultRowHeight;
  2745. RxDBGrid_CreateBOM.DefaultRowHeight := RxDBGrid_AddCustomers.DefaultRowHeight;
  2746. RxDBGrid_ShowInventory.DefaultRowHeight := RxDBGrid_AddCustomers.DefaultRowHeight;
  2747. finally
  2748. A.Free;
  2749. ini.Free;
  2750. end;
  2751. except
  2752. On e: Exception do
  2753. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  2754. end;
  2755. end;
  2756.  
  2757. procedure TForm_Neo.ReadHints;
  2758. var
  2759. ini : TCustomIniFile;
  2760. A : TStrings;
  2761. checked : BOOL;
  2762. begin
  2763. try
  2764. ini := TMemIniFile.Create(ChangeFileext(Application.ExeName, '.ini'));
  2765. try
  2766. A := TStringList.Create;
  2767. ini.ReadSection('ShowHints', A);
  2768. checked := ini.ReadBool('ShowHints', 'On', checked);
  2769.  
  2770. if checked = True then
  2771. begin
  2772. MenuItem_ShowHintsOn.Checked := True;
  2773. MenuItem_ShowHintsOff.Checked := False;
  2774. ToggleBox_AddCustomersAutoWildcard.ShowHint := True;
  2775. ToggleBox_AddItemsAutoWildcard.ShowHint := True;
  2776. end;
  2777. if checked = False then
  2778. begin
  2779. MenuItem_ShowHintsOn.Checked := False;
  2780. MenuItem_ShowHintsOff.Checked := True;
  2781. ToggleBox_AddCustomersAutoWildcard.ShowHint := False;
  2782. ToggleBox_AddItemsAutoWildcard.ShowHint := False;
  2783. end;
  2784. finally
  2785. ini.Free;
  2786. A.Free;
  2787. end;
  2788. except
  2789. On e: Exception do
  2790. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  2791. end;
  2792. end;
  2793.  
  2794. procedure TForm_Neo.AddInventoryItemToBOM;
  2795. var
  2796. id : Integer;
  2797. begin
  2798. id:= DM1.ZQ_ReadInventory.Fields[0].AsInteger;
  2799. ShowMessage(IntToStr(id));
  2800. end;
  2801.  
  2802. procedure TForm_Neo.AddCustomer;
  2803. begin
  2804. //Form_AddCustomer.ShowModal;
  2805. end;
  2806.  
  2807. procedure TForm_Neo.ShowCustomerNote;
  2808. begin
  2809. try
  2810. Form_ViewCustomerNote:= TForm_ViewCustomerNote.Create(Self);
  2811. try
  2812. Form_ViewCustomerNote.ShowModal;
  2813. finally
  2814. Form_ViewCustomerNote.Release;
  2815. Form_ViewCustomerNote:= Nil;
  2816. end;
  2817. except
  2818. On e: Exception do
  2819. MessageDlg('Error' + e.Message, mtError,[mbOK],0);
  2820. end;
  2821. end;
  2822.  
  2823. end.
  2824.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement