Home » U++ Library support » U++ SQL » date not showing in sqlarray
Re: date not showing in sqlarray [message #52303 is a reply to message #52300] |
Mon, 02 September 2019 18:06   |
|
Hi all-
I noticed I left out some conversion magic. Here is my attempt at getting the dates to appear in the sqlarray control. They still do not show up! I am out foraging for tips. Please chime in. THNX ROBOLOKI
#include "fearmonger.h"
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct DateIntConvertCls : Convert {
virtual Value Format(const Value& q) const;
virtual Value Scan(const Value& text) const;
virtual int Filter(int chr) const;
};
Value DateIntConvertCls::Format(const Value& q) const
{
return IsNull(q) ? String() : ::Format(Date(1970, 1, 1) + (int)q);
}
Value DateIntConvertCls::Scan(const Value& text) const
{
String txt = text;
if(IsNull(txt))
return Null;
Date d;
if(StrToDate(d, txt))
return d - Date(1970, 1, 1);
return ErrorValue("Invalid date!");
}
int DateIntConvertCls::Filter(int chr) const
{
return CharFilterDate(chr);
}
Convert& DateIntConvert()
{
return Single<DateIntConvertCls>();
}
struct WinDlg : public WithWin10Layout<TopWindow> {
Button button;
SqlCtrls ctrls;
EditInt myid;
EditDate mydate;
EditString myloc;
typedef WinDlg CLASSNAME;
void exec4() {
SqlBool where;
SqlBool where2;
WinDlg dlg;
// SQL * Select(dlg.ctrls).From(SCHEDULE).Where(ID == 3);
disturbed.Query();
}
WinDlg() {
CtrlLayout(*this, "computer");
Title("My application with menu").Sizeable();
Add(button.LeftPos(10, 100).TopPos(10, 30));
disturbed.SetTable(SCHEDULE);
disturbed.AddKey(ID);
disturbed.AddColumn(ID,"ID").Edit(myid);
disturbed.AddColumn(LOCATION,"loc").Edit(myloc);
disturbed.AddColumn(START_DATE, "START_DATE").SetConvert(DateIntConvert());
disturbed.Appending().Inserting().Removing();
button <<= THISBACK(exec4);
}
};
void Cyborg::SqArray(){
WinDlg dlg;
dlg.Run();
// menu.Set(THISBACK(WinDlg());
}
-
Attachment: no-dates.PNG
(Size: 4.57KB, Downloaded 427 times)
|
|
|
Goto Forum:
Current Time: Thu Sep 04 06:56:39 CEST 2025
Total time taken to generate the page: 0.05693 seconds
|