Changeset 17


Ignore:
Timestamp:
Nov 15, 2012, 2:56:05 PM (12 years ago)
Author:
chronos
Message:
  • Opraveno: Editace časových údajů.
  • Opraveno: Generování ovládacích prvků v okně editace.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormEdit.pas

    r16 r17  
    139139  W := 130;
    140140  H := 24;
     141  for I := PanelControls.ControlCount - 1 downto 0 do
     142    PanelControls.Controls[I].Free;
    141143  for I := 0 to View.Items.Count - 1 do
    142144  with TFormItem(View.Items[I]) do begin
     
    232234      NewControl := TDateEdit.Create(Self);
    233235      NewControl.Parent := PanelControls;
    234       TDateEdit(NewControl).Date := SQLToDateTime(Values.Values[Name]);
     236      TDateEdit(NewControl).Date := SQLToDate(Values.Values[Name]);
    235237      NewControl.SetBounds(Rect.Left * W, Rect.Top * H,
    236238       (Rect.Right - Rect.Left) * W - TEditButton(NewControl).Button.Width, (Rect.Bottom - Rect.Top) * H);
     
    269271  with TFormItem(View.Items[I]) do begin
    270272    case ControlType of
    271       ctSpinEdit, ctDate, ctTime, ctDateTime, ctReference: Values.Add(Name, '0');
     273      ctCheckBox, ctSpinEdit, ctReference: Values.Add(Name, '0');
     274      ctDateTime: Values.Add(Name, '0000-00-00 00:00:00');
     275      ctDate: Values.Add(Name, '0000-00-00');
     276      ctTime: Values.Add(Name, '00:00:00');
    272277      else Values.Add(Name, '');
    273278    end;
  • trunk/Languages/Dochazka.cs.po

    r16 r17  
    1313#: tdatamoduleattendance.areadfromterminal.caption
    1414msgid "Read from terminal"
    15 msgstr ""
     15msgstr "Číst z terminálu"
    1616
    1717#: tdatamoduleattendance.areadfromterminal.hint
    1818msgid "Read new data from terminal"
    19 msgstr ""
     19msgstr "Číst nová data z terminálu"
    2020
    2121#: tform1.actionexit.caption
     
    257257#: uformedit.sitemnotfound
    258258msgid "Item not found"
    259 msgstr ""
     259msgstr "PoloÅŸka nenalezena"
    260260
    261261#: uformlist.sadditem
    262262msgid "Add item"
    263 msgstr ""
     263msgstr "Přidat poloÅŸku"
    264264
    265265#: uformlist.sdoyouwanttodeleteitem
     
    571571msgid "Year"
    572572msgstr "Rok"
    573 
  • trunk/Modules/Attendance/UModuleAttendance.pas

    r16 r17  
    183183  with ViewFormPassage do begin
    184184    with Items do begin
    185       AddItem(STime, 'Time', ctDate, True, Bounds(1, 0, 1, 1));
     185      AddItem(STime, 'Time', ctDateTime, True, Bounds(1, 0, 1, 1));
    186186      with AddItem(SUser, 'User', ctReference, True, Bounds(3, 0, 1, 1)) do
    187187        ReferencedTable := 'User';
  • trunk/Packages/CoolWeb/Persistence/USqlDatabase.pas

    r16 r17  
    9191  function SQLToDateTime(Value: string): TDateTime;
    9292  function SQLToTime(Value: string): TDateTime;
     93  function SQLToDate(Value: string): TDateTime;
    9394  function DateTimeToSQL(Value: TDateTime): string;
    9495  function TimeToSQL(Value: TDateTime): string;
     
    173174end;
    174175
     176function SQLToDate(Value: string): TDateTime;
     177var
     178  DateParts: TListString;
     179  Date: TDateTime;
     180begin
     181  try
     182    DateParts := TListString.Create;
     183    DateParts.Explode(Value, '-', StrToStr);
     184    if TryEncodeDate(StrToInt(DateParts[0]), StrToInt(DateParts[1]),
     185      StrToInt(DateParts[2]), Date) then
     186        Result := Date else Result := 0;
     187  finally
     188    DateParts.Free;
     189  end;
     190end;
     191
    175192function DateTimeToSQL(Value: TDateTime): string;
    176193begin
    177   Result := FormatDateTime('yyyy-mm-dd hh.nn.ss', Value);
     194  Result := FormatDateTime('yyyy-mm-dd hh:nn:ss', Value);
    178195end;
    179196
    180197function TimeToSQL(Value: TDateTime): string;
    181198begin
    182   Result := FormatDateTime('hh.nn.ss', Value);
     199  Result := FormatDateTime('hh:nn:ss', Value);
    183200end;
    184201
     
    191208var
    192209  TimeParts: TListString;
     210  Time: TDateTime;
    193211begin
    194212  try
    195213    TimeParts := TListString.Create;
    196214    TimeParts.Explode(Value, ':', StrToStr);
    197     Result := Result + EncodeTime(StrToInt(TimeParts[0]), StrToInt(TimeParts[1]),
    198       StrToInt(TimeParts[2]), 0);
     215    if TryEncodeTime(StrToInt(TimeParts[0]), StrToInt(TimeParts[1]),
     216      StrToInt(TimeParts[2]), 0, time) then
     217        Result := Time else Result := 0;
    199218  finally
    200219    TimeParts.Free;
Note: See TracChangeset for help on using the changeset viewer.