@@ -30,13 +30,17 @@ TMainForm = class(TForm)
3030 Edit5: TEdit;
3131 Label9: TLabel;
3232 Label10: TLabel;
33+ Button3: TButton;
34+ CheckBox1: TCheckBox;
3335 procedure FormCreate (Sender: TObject);
3436 procedure Button1Click (Sender: TObject);
3537 procedure FormDestroy (Sender: TObject);
3638 procedure Edit3Change (Sender: TObject);
3739 procedure ListView1SelectItem (Sender: TObject; Item: TListItem; Selected: Boolean);
3840 procedure Button2Click (Sender: TObject);
3941 procedure Label10Click (Sender: TObject);
42+ procedure FormClose (Sender: TObject; var Action: TCloseAction);
43+ procedure Button3Click (Sender: TObject);
4044 public
4145 Suppliers: TOpenConnectBusinessList;
4246 Configuration : TMemIniFile;
@@ -55,7 +59,12 @@ procedure TMainForm.FormCreate(Sender: TObject);
5559 Suppliers:= TOpenConnectBusinessList.Create;
5660 Configuration := TMemIniFile.Create(ExtractFilePath(ExtractFileDir(ExtractFileDir(Application.ExeName)))+' configuration.ini' );
5761 Editable := false;
58-
62+
63+ Left := 50 ;
64+ Top := 50 ;
65+ Width := Screen.DesktopWidth-100 ;
66+ Height := Screen.DesktopHeight-100 ;
67+
5968 with ListView1.Columns.Add do
6069 begin
6170 Caption := ' Service-Name' ;
@@ -117,11 +126,25 @@ procedure TMainForm.FormCreate(Sender: TObject);
117126 Alignment := taLeftJustify;
118127 Width := 50 ;
119128 end ;
129+ for var i : Integer := 0 to ListView1.Columns.Count-1 do
130+ ListView1.Columns[i].Width := Configuration.ReadInteger(ListView1.Name ,i.ToString,ListView1.Columns[i].Width);
131+ end ;
132+
133+ procedure TMainForm.FormClose (Sender: TObject; var Action: TCloseAction);
134+ begin
135+ for var i : Integer := 0 to ListView1.Columns.Count-1 do
136+ Configuration.WriteInteger(ListView1.Name ,i.ToString,ListView1.Columns[i].Width);
120137end ;
121138
122139procedure TMainForm.FormDestroy (Sender: TObject);
123140begin
124- if Assigned(Configuration) then begin Configuration.UpdateFile; Configuration.Free; Configuration := nil ; end ;
141+ if Assigned(Configuration) then
142+ begin
143+ if not CheckBox1.Checked then
144+ Configuration.UpdateFile;
145+ Configuration.Free;
146+ Configuration := nil ;
147+ end ;
125148 if Assigned( Suppliers) then begin ListView1.Clear; Suppliers.Free; Suppliers := nil ; end ;
126149end ;
127150
@@ -153,7 +176,7 @@ procedure TMainForm.Button1Click(Sender: TObject);
153176 SubItems.Add(Suppliers[i].Supplier[j].Zip);
154177 SubItems.Add(Suppliers[i].Supplier[j].City);
155178 SubItems.Add(Suppliers[i].Supplier[j].Country);
156- if Configuration.SectionExists(IntToStr(Suppliers[i].ID)+' -' +IntToStr(Suppliers[i].Supplier[j].ID)) then
179+ if Configuration.SectionExists(Suppliers[i].ServiceURL+ ' - ' + IntToStr(Suppliers[i].ID)+' -' +IntToStr(Suppliers[i].Supplier[j].ID)) then
157180 SubItems.Add(' vorhanden' )
158181 else
159182 SubItems.Add(' ' );
@@ -163,26 +186,35 @@ procedure TMainForm.Button1Click(Sender: TObject);
163186procedure TMainForm.Edit3Change (Sender: TObject);
164187var
165188 section : String;
189+ i : Integer;
166190begin
167191 if ListView1.Selected = nil then
168192 exit;
169193 if not Editable then
170194 exit;
171- section := ListView1.Selected.SubItems[0 ]+' -' +ListView1.Selected.SubItems[3 ];
172- if Trim(Edit1.Text).IsEmpty and Trim(Edit2.Text).IsEmpty and Trim(Edit3.Text).IsEmpty and
173- Trim(Edit4.Text).IsEmpty and Trim(Edit5.Text).IsEmpty then
174- begin
195+
196+ section := ListView1.Selected.SubItems[1 ]+' -' +ListView1.Selected.SubItems[0 ]+' -' +ListView1.Selected.SubItems[3 ];
197+
198+ if // Trim(Edit1.Text).IsEmpty and Trim(Edit2.Text).IsEmpty and
199+ Trim(Edit3.Text).IsEmpty and Trim(Edit4.Text).IsEmpty and Trim(Edit5.Text).IsEmpty then
200+ begin
175201 Configuration.EraseSection(section);
176- ListView1.Selected.SubItems[ListView1.Selected.SubItems.Count-1 ] := ' ' ;
177202 end else
178203 begin
179204 Configuration.WriteString(section,' idsconnectprocesses' ,Edit1.Text);
180205 Configuration.WriteString(section,' idsconnecturl' ,Edit2.Text);
181206 Configuration.WriteString(section,' customerno' ,Edit3.Text);
182207 Configuration.WriteString(section,' username' ,Edit4.Text);
183208 Configuration.WriteString(section,' password' ,Edit5.Text);
184- ListView1.Selected.SubItems[ListView1.Selected.SubItems.Count-1 ] := ' vorhanden' ;
185209 end ;
210+
211+ for i := 0 to ListView1.Items.Count-1 do
212+ if Configuration.SectionExists(ListView1.Items[i].SubItems[1 ]+' -' +ListView1.Items[i].SubItems[0 ]+' -' +ListView1.Items[i].SubItems[3 ]) then
213+ ListView1.Items[i].SubItems[ListView1.Selected.SubItems.Count-1 ] := ' vorhanden'
214+ else
215+ ListView1.Items[i].SubItems[ListView1.Selected.SubItems.Count-1 ] := ' ' ;
216+
217+
186218end ;
187219
188220procedure TMainForm.ListView1SelectItem (Sender: TObject; Item: TListItem; Selected: Boolean);
@@ -195,7 +227,7 @@ procedure TMainForm.ListView1SelectItem(Sender: TObject; Item: TListItem; Select
195227 exit;
196228 Editable := false;
197229 try
198- section := Item.SubItems[0 ]+' -' +Item.SubItems[3 ];
230+ section := Item.SubItems[1 ]+ ' - ' +Item.SubItems[ 0 ]+' -' +Item.SubItems[3 ];
199231 Edit1.Text := Configuration.ReadString(section,' idsconnectprocesses' ,' ' );
200232 Edit2.Text := Configuration.ReadString(section,' idsconnecturl' ,' ' );
201233 Edit3.Text := Configuration.ReadString(section,' customerno' ,' ' );
@@ -244,6 +276,11 @@ procedure TMainForm.Button2Click(Sender: TObject);
244276 end ;
245277end ;
246278
279+ procedure TMainForm.Button3Click (Sender: TObject);
280+ begin
281+ Close;
282+ end ;
283+
247284procedure TMainForm.Label10Click (Sender: TObject);
248285begin
249286 ShellExecute(0 ,' open' ,PChar(' https://github.com/LandrixSoftware/IDSConnect-for-Delphi' ),' ' ,' ' ,SW_SHOWNORMAL);
0 commit comments