Changeset 16
- Timestamp:
- Nov 15, 2012, 2:01:43 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Dochazka.lpi
r15 r16 72 72 </local> 73 73 </RunParams> 74 <RequiredPackages Count=" 7">74 <RequiredPackages Count="8"> 75 75 <Item1> 76 <PackageName Value="TEditExtensions"/> 77 <DefaultFilename Value="Packages/TEditExtensions/TEditExtensions.lpk" Prefer="True"/> 78 </Item1> 79 <Item2> 76 80 <PackageName Value="synapse"/> 77 81 <DefaultFilename Value="Packages/synapse/synapse.lpk" Prefer="True"/> 78 </Item 1>79 <Item 2>82 </Item2> 83 <Item3> 80 84 <PackageName Value="ModularSystem"/> 81 85 <DefaultFilename Value="Packages/ModularSystem/ModularSystem.lpk" Prefer="True"/> 82 </Item 2>83 <Item 3>86 </Item3> 87 <Item4> 84 88 <PackageName Value="TemplateGenerics"/> 85 89 <DefaultFilename Value="Packages/TemplateGenerics/TemplateGenerics.lpk" Prefer="True"/> 86 </Item 3>87 <Item 4>90 </Item4> 91 <Item5> 88 92 <PackageName Value="CoolTranslator"/> 89 93 <DefaultFilename Value="Packages/CoolTranslator/CoolTranslator.lpk" Prefer="True"/> 90 </Item 4>91 <Item 5>94 </Item5> 95 <Item6> 92 96 <PackageName Value="Common"/> 93 97 <DefaultFilename Value="Packages/Common/Common.lpk" Prefer="True"/> 94 </Item 5>95 <Item 6>98 </Item6> 99 <Item7> 96 100 <PackageName Value="CoolWeb"/> 97 101 <DefaultFilename Value="Packages/CoolWeb/CoolWeb.lpk" Prefer="True"/> 98 </Item 6>99 <Item 7>102 </Item7> 103 <Item8> 100 104 <PackageName Value="LCL"/> 101 </Item 7>105 </Item8> 102 106 </RequiredPackages> 103 107 <Units Count="14"> -
trunk/Dochazka.lpr
r15 r16 10 10 Forms, UFormMain, UCore, UAttendance, UPersistentForm, CoolWeb, Common, 11 11 CoolTranslator, UFormSetting, SysUtils, UFormList, UFormEdit, UDataView, 12 URegistredModules, TemplateGenerics, synapse, UFormConnection,13 UModuleAttendance, UDataModel12 URegistredModules, TemplateGenerics, synapse, TEditExtensions, 13 UFormConnection, UModuleAttendance, UDataModel 14 14 { you can add units after this }; 15 15 -
trunk/Forms/UFormEdit.lfm
r15 r16 38 38 end 39 39 object PanelControls: TPanel 40 Left = 041 Height = 2 9042 Top = 043 Width = 5 5340 Left = 8 41 Height = 282 42 Top = 8 43 Width = 537 44 44 Align = alTop 45 45 Anchors = [akTop, akLeft, akRight, akBottom] 46 BorderSpacing.Around = 8 46 47 BevelOuter = bvNone 47 48 TabOrder = 2 -
trunk/Forms/UFormEdit.pas
r15 r16 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 9 Buttons, ExtCtrls, Spin, ComCtrls, EditBtn, SpecializedList, 10 SpecializedDictionary, UDataView, USqlDatabase ;10 SpecializedDictionary, UDataView, USqlDatabase, UTimeEdit; 11 11 12 12 type … … 19 19 Visible: Boolean; 20 20 Rect: TRect; 21 Control: TControl; // Used by TFormEdit 21 22 ControlType: TControlType; 22 23 TitlePlacement: TAlign; … … 48 49 ButtonOk: TButton; 49 50 ButtonCancel: TButton; 50 CalcEdit1: TCalcEdit;51 51 PanelControls: TPanel; 52 52 procedure FormCreate(Sender: TObject); 53 53 procedure FormDestroy(Sender: TObject); 54 procedure SpeedButton1Click(Sender: TObject);55 54 private 56 55 FView: TDataViewForm; 57 56 procedure SetView(AValue: TDataViewForm); 58 { private declarations }57 procedure RebuildControls; 59 58 public 60 RuntimeControls: TListObject;61 59 Values: TDictionaryStringString; 62 60 ItemId: Integer; 63 61 property View: TDataViewForm read FView write SetView; 64 procedure UpdateData; 62 procedure ClearData; 63 procedure LoadFromDatabase; 64 procedure SaveToDatabase; 65 procedure LoadFromControls; 65 66 end; 66 67 … … 72 73 uses 73 74 UCore, UFormMain; 75 76 resourcestring 77 SItemNotFound = 'Item not found'; 74 78 75 79 { TDataViewForm } … … 108 112 begin 109 113 Values := TDictionaryStringString.Create; 110 RuntimeControls := TListObject.Create;111 114 end; 112 115 113 116 procedure TFormEdit.FormDestroy(Sender: TObject); 114 117 begin 115 Values.Free; 116 RuntimeControls.Free; 117 end; 118 119 procedure TFormEdit.SpeedButton1Click(Sender: TObject); 120 begin 121 118 FreeAndNil(Values); 122 119 end; 123 120 … … 126 123 if FView=AValue then Exit; 127 124 FView := AValue; 128 if Assigned(AValue) then UpdateData125 if Assigned(AValue) then ClearData 129 126 else begin 130 127 Values.Clear; 131 RuntimeControls.Clear; 132 end; 133 end; 134 135 procedure TFormEdit.UpdateData; 128 end; 129 end; 130 131 procedure TFormEdit.RebuildControls; 136 132 var 137 133 NewControl: TControl; 138 134 I: Integer; 139 135 TitleRect: TRect; 140 DbRows: TDbRows;141 136 W: Integer; 142 137 H: Integer; … … 144 139 W := 130; 145 140 H := 24; 146 try147 DbRows := TDbRows.Create;148 Core.Database.Query(DbRows, 'SELECT * FROM ' + View.Name + ' WHERE Id=' +149 IntToStr(ItemId));150 if DbRows.Count > 0 then Values.Assign(DbRows[0])151 else begin152 Values.Free;153 Exit;154 end;155 finally156 DbRows.Free;157 end;158 159 RuntimeControls.Clear;160 141 for I := 0 to View.Items.Count - 1 do 161 142 with TFormItem(View.Items[I]) do begin … … 200 181 (Rect.Right - Rect.Left) * W, (Rect.Bottom - Rect.Top) * H); 201 182 NewControl.Show; 183 Control := NewControl; 202 184 end else 203 185 if ControlType = ctEdit then begin … … 209 191 (Rect.Right - Rect.Left) * W, (Rect.Bottom - Rect.Top) * H); 210 192 NewControl.Show; 193 Control := NewControl; 211 194 end else 212 195 if ControlType = ctMemo then begin … … 217 200 (Rect.Right - Rect.Left) * W, (Rect.Bottom - Rect.Top) * H); 218 201 NewControl.Show; 202 Control := NewControl; 219 203 end else 220 204 if ControlType = ctCheckBox then begin 221 205 NewControl := TCheckBox.Create(Self); 222 206 NewControl.Parent := PanelControls; 223 TCheckBox(NewControl).Enabled := Values.Values[Name] = '1'; 224 NewControl.SetBounds(Rect.Left * W, Rect.Top * H, 225 (Rect.Right - Rect.Left) * W, (Rect.Bottom - Rect.Top) * H); 226 NewControl.Show; 207 TCheckBox(NewControl).Checked := Values.Values[Name] = '1'; 208 NewControl.SetBounds(Rect.Left * W, Rect.Top * H, 209 (Rect.Right - Rect.Left) * W, (Rect.Bottom - Rect.Top) * H); 210 NewControl.Show; 211 Control := NewControl; 227 212 end else 228 213 if ControlType = ctComboBox then begin … … 233 218 (Rect.Right - Rect.Left) * W, (Rect.Bottom - Rect.Top) * H); 234 219 NewControl.Show; 220 Control := NewControl; 235 221 end else 236 222 if ControlType = ctSpinEdit then begin … … 241 227 (Rect.Right - Rect.Left) * W, (Rect.Bottom - Rect.Top) * H); 242 228 NewControl.Show; 229 Control := NewControl; 243 230 end else 244 231 if ControlType = ctDate then begin … … 249 236 (Rect.Right - Rect.Left) * W - TEditButton(NewControl).Button.Width, (Rect.Bottom - Rect.Top) * H); 250 237 NewControl.Show; 238 Control := NewControl; 251 239 end else 252 240 if ControlType = ctTime then begin 253 NewControl := TEdit.Create(Self); 254 NewControl.Parent := PanelControls; 255 TEdit(NewControl).Text := TimeToStr(SQLToTime(Values.Values[Name])); 256 NewControl.SetBounds(Rect.Left * W, Rect.Top * H, 257 (Rect.Right - Rect.Left) * W, (Rect.Bottom - Rect.Top) * H); 258 NewControl.Show; 241 NewControl := TTimeEdit.Create(Self); 242 NewControl.Parent := PanelControls; 243 TTimeEdit(NewControl).Time := SQLToTime(Values.Values[Name]); 244 NewControl.SetBounds(Rect.Left * W, Rect.Top * H, 245 (Rect.Right - Rect.Left) * W, (Rect.Bottom - Rect.Top) * H); 246 NewControl.Show; 247 Control := NewControl; 259 248 end else 260 249 if ControlType = ctReference then begin … … 267 256 (Rect.Bottom - Rect.Top) * H); 268 257 NewControl.Show; 258 Control := NewControl; 259 end; 260 end; 261 end; 262 263 procedure TFormEdit.ClearData; 264 var 265 I: Integer; 266 begin 267 Values.Clear; 268 for I := 0 to View.Items.Count - 1 do 269 with TFormItem(View.Items[I]) do begin 270 case ControlType of 271 ctSpinEdit, ctDate, ctTime, ctDateTime, ctReference: Values.Add(Name, '0'); 272 else Values.Add(Name, ''); 273 end; 274 end; 275 RebuildControls; 276 end; 277 278 procedure TFormEdit.LoadFromDatabase; 279 var 280 DbRows: TDbRows; 281 Columns: string; 282 I: Integer; 283 begin 284 Columns := ''; 285 for I := 0 to View.Items.Count - 1 do 286 with TFormItem(View.Items[I]) do 287 if Visible then 288 Columns := Columns + ', ' + Name; 289 Delete(Columns, 1, 2); 290 try 291 DbRows := TDbRows.Create; 292 Core.Database.Query(DbRows, 'SELECT ' + Columns + ' FROM `' + View.Name + '` WHERE `Id`=' + 293 IntToStr(ItemId)); 294 if DbRows.Count > 0 then Values.Assign(DbRows[0]) 295 else raise Exception.Create(SItemNotFound); 296 finally 297 DbRows.Free; 298 end; 299 RebuildControls; 300 end; 301 302 procedure TFormEdit.SaveToDatabase; 303 var 304 DbRows: TDbRows; 305 begin 306 LoadFromControls; 307 try 308 DbRows := TDbRows.Create; 309 if ItemId < 1 then Core.Database.Insert(View.Name, Values) 310 else Core.Database.Update(View.Name, Values, '`Id`=' + IntToStr(ItemId)); 311 finally 312 DbRows.Free; 313 end; 314 end; 315 316 procedure TFormEdit.LoadFromControls; 317 var 318 I: Integer; 319 begin 320 for I := 0 to View.Items.Count - 1 do 321 with TFormItem(View.Items[I]) do begin 322 if ControlType = ctLabel then begin 323 Values.Values[Name] := TLabel(Control).Caption; 324 end else 325 if ControlType = ctEdit then begin 326 Values.Values[Name] := TEdit(Control).Text; 327 end else 328 if ControlType = ctMemo then begin 329 Values.Values[Name] := TMemo(Control).Lines.Text; 330 end else 331 if ControlType = ctCheckBox then begin 332 Values.Values[Name] := BoolToStr(TCheckBox(Control).Checked); 333 end else 334 if ControlType = ctComboBox then begin 335 Values.Values[Name] := TComboBox(Control).Text; 336 end else 337 if ControlType = ctSpinEdit then begin 338 Values.Values[Name] := IntToStr(TSpinEdit(Control).Value); 339 end else 340 if ControlType = ctDate then begin 341 Values.Values[Name] := DateToSQL(TDateEdit(Control).Date); 342 end else 343 if ControlType = ctTime then begin 344 Values.Values[Name] := TimeToSQL(TTimeEdit(Control).Time); 345 end else 346 if ControlType = ctReference then begin 347 Values.Values[Name] := TEditButton(Control).Text; 269 348 end; 270 349 end; -
trunk/Forms/UFormList.lfm
r14 r16 30 30 end 31 31 object ToolButton2: TToolButton 32 Left = 4 932 Left = 45 33 33 Top = 2 34 34 Action = ADelete 35 35 end 36 36 object ToolButton3: TToolButton 37 Left = 9737 Left = 89 38 38 Top = 2 39 39 Action = ADuplicate 40 40 end 41 41 object ToolButton4: TToolButton 42 Left = 14 942 Left = 141 43 43 Top = 2 44 44 Action = AModify 45 45 end 46 46 object ToolButton5: TToolButton 47 Left = 1 9747 Left = 185 48 48 Top = 2 49 49 Action = AReload 50 50 end 51 51 object ToolButton6: TToolButton 52 Left = 2 4552 Left = 229 53 53 Top = 2 54 54 Action = APrint 55 55 end 56 56 object ToolButton7: TToolButton 57 Left = 2 9357 Left = 273 58 58 Top = 2 59 59 Action = AExport … … 128 128 Hint = 'Reload data' 129 129 ImageIndex = 5 130 OnExecute = AReloadExecute 130 131 end 131 132 object APrint: TAction -
trunk/Forms/UFormList.pas
r9 r16 69 69 procedure ADuplicateExecute(Sender: TObject); 70 70 procedure AModifyExecute(Sender: TObject); 71 procedure AReloadExecute(Sender: TObject); 71 72 procedure FormCreate(Sender: TObject); 72 73 procedure FormDestroy(Sender: TObject); … … 99 100 SDoYouWantToDeleteItem = 'Do you want to really delete item?'; 100 101 SItemCount = 'Item count: %s'; 102 SModifyItem = 'Modify item'; 103 SAddItem = 'Add item'; 101 104 102 105 { TDataViewList } … … 149 152 Index: Integer; 150 153 begin 151 Index := FormMain.DataViewLists.IndexOf(View); 152 FormEdit := TFormEdit.Create(FormMain); 153 FormEdit.ItemId := Integer(ListView1.Selected.Data); 154 FormEdit.View := TDataViewForm(FormMain.DataViewForms[Index]); 155 Core.CoolTranslator1.TranslateComponentRecursive(FormEdit); 156 if FormEdit.ShowModal = mrOk then begin 157 end; 158 FormEdit.Free; 154 try 155 FormEdit := TFormEdit.Create(FormMain); 156 Index := FormMain.DataViewLists.IndexOf(View); 157 FormEdit.ItemId := Integer(ListView1.Selected.Data); 158 FormEdit.View := TDataViewForm(FormMain.DataViewForms[Index]); 159 FormEdit.LoadFromDatabase; 160 FormEdit.Caption := SModifyItem; 161 Core.CoolTranslator1.TranslateComponentRecursive(FormEdit); 162 if FormEdit.ShowModal = mrOk then begin 163 FormEdit.SaveToDatabase; 164 UpdateData; 165 end; 166 finally 167 FormEdit.Free; 168 end; 169 end; 170 171 procedure TFormList.AReloadExecute(Sender: TObject); 172 begin 173 UpdateData; 159 174 end; 160 175 161 176 procedure TFormList.AAddExecute(Sender: TObject); 162 begin 163 if FormEdit.ShowModal = mrOk then begin 177 var 178 Index: Integer; 179 begin 180 try 181 FormEdit := TFormEdit.Create(FormMain); 182 Index := FormMain.DataViewLists.IndexOf(View); 183 FormEdit.ItemId := 0; 184 FormEdit.View := TDataViewForm(FormMain.DataViewForms[Index]); 185 FormEdit.ClearData; 186 FormEdit.Caption := SAddItem; 187 Core.CoolTranslator1.TranslateComponentRecursive(FormEdit); 188 if FormEdit.ShowModal = mrOk then begin 189 FormEdit.SaveToDatabase; 190 UpdateData; 191 end; 192 finally 193 FormEdit.Free; 164 194 end; 165 195 end; … … 167 197 procedure TFormList.ADeleteExecute(Sender: TObject); 168 198 begin 169 if FormEdit.ShowModal = mrOk then begin 170 if MessageDlg(SItemDeletion, SDoYouWantToDeleteItem, mtConfirmation, 171 [mbYes, mbNo], 0) = mrYes then begin 172 Core.Database.Query(nil, 'DELETE FROM `' + View.Name + 173 '` WHERE `Id` = ' + IntToStr(Integer(ListView1.Selected.Data))); 174 end; 199 if MessageDlg(SItemDeletion, SDoYouWantToDeleteItem, mtConfirmation, 200 [mbYes, mbNo], 0) = mrYes then begin 201 Core.Database.Delete(View.Name, '`Id` = ' + IntToStr(Integer(ListView1.Selected.Data))); 202 UpdateData; 175 203 end; 176 204 end; … … 200 228 for I := 0 to View.Columns.Count - 1 do begin 201 229 Item.Data := Pointer(StrToInt(DbRows[Item.Index].Values['Id'])); 202 if I = 0 then Item.Caption := DbRows[Item.Index]. Items[0].Value230 if I = 0 then Item.Caption := DbRows[Item.Index].Values[TDbColumn(View.Columns[I]).Name] 203 231 else Item.SubItems.Add(DbRows[Item.Index].Values[TDbColumn(View.Columns[I]).Name]); 204 232 end; -
trunk/Languages/Dochazka.cs.po
r15 r16 146 146 147 147 #: tformlist.amodify.hint 148 msgctxt "tformlist.amodify.hint" 148 149 msgid "Modify item" 149 150 msgstr "Upravit poloÅŸku" … … 254 255 msgstr "NastavenÃ" 255 256 257 #: uformedit.sitemnotfound 258 msgid "Item not found" 259 msgstr "" 260 261 #: uformlist.sadditem 262 msgid "Add item" 263 msgstr "" 264 256 265 #: uformlist.sdoyouwanttodeleteitem 257 266 #| msgid "Do you want to delte item" … … 268 277 msgstr "Mazánà poloÅŸky" 269 278 279 #: uformlist.smodifyitem 280 msgctxt "uformlist.smodifyitem" 281 msgid "Modify item" 282 msgstr "Upravit poloÅŸku" 283 270 284 #: uformmain.saddress 271 285 msgctxt "uformmain.saddress" -
trunk/Languages/Dochazka.po
r15 r16 136 136 137 137 #: tformlist.amodify.hint 138 msgctxt "tformlist.amodify.hint" 138 139 msgid "Modify item" 139 140 msgstr "" … … 242 243 msgstr "" 243 244 245 #: uformedit.sitemnotfound 246 msgid "Item not found" 247 msgstr "" 248 249 #: uformlist.sadditem 250 msgid "Add item" 251 msgstr "" 252 244 253 #: uformlist.sdoyouwanttodeleteitem 245 254 msgid "Do you want to really delete item?" … … 255 264 msgstr "" 256 265 266 #: uformlist.smodifyitem 267 msgctxt "uformlist.smodifyitem" 268 msgid "Modify item" 269 msgstr "" 270 257 271 #: uformmain.saddress 258 272 msgctxt "uformmain.saddress" -
trunk/Modules/Attendance/UModuleAttendance.pas
r15 r16 183 183 with ViewFormPassage do begin 184 184 with Items do begin 185 AddItem(STime, 'Time', ctDate, True, Bounds( 0, 0, 1, 1));185 AddItem(STime, 'Time', ctDate, True, Bounds(1, 0, 1, 1)); 186 186 with AddItem(SUser, 'User', ctReference, True, Bounds(3, 0, 1, 1)) do 187 187 ReferencedTable := 'User'; 188 with AddItem(SOperation, 'Operation', ctReference, True, Bounds( 0, 1, 1, 1)) do188 with AddItem(SOperation, 'Operation', ctReference, True, Bounds(1, 1, 1, 1)) do 189 189 ReferencedTable := 'User'; 190 190 with AddItem(STerminal, 'Terminal', ctReference, True, Bounds(3, 1, 1, 1)) do -
trunk/Packages/CoolWeb/Persistence/USqlDatabase.pas
r15 r16 92 92 function SQLToTime(Value: string): TDateTime; 93 93 function DateTimeToSQL(Value: TDateTime): string; 94 function TimeToSQL(Value: TDateTime): string; 95 function DateToSQL(Value: TDateTime): string; 94 96 95 97 procedure Register; … … 176 178 end; 177 179 180 function TimeToSQL(Value: TDateTime): string; 181 begin 182 Result := FormatDateTime('hh.nn.ss', Value); 183 end; 184 185 function DateToSQL(Value: TDateTime): string; 186 begin 187 Result := FormatDateTime('yyyy-mm-dd', Value); 188 end; 189 178 190 function SQLToTime(Value: string): TDateTime; 179 191 var
Note:
See TracChangeset
for help on using the changeset viewer.