2008年11月4日星期二

javascript 打印print 窗口


var invoiceWindow=window.open('','','width=1,height=1,location=NO,locationbar=NO,menubar=YES,screenX=100,screenY=100');
invoiceWindow.document.write("hallo, this is new window");
invoiceWindow.document.close(); // --> Sehr wichtig
invoiceWindow.print();
invoiceWindow.close();

2008年9月23日星期二

Prototype JS Event.observe



Event.observe(window, 'load', function()
{
Event.observe( 'searchBt', 'click', function(e)
{
ajaxListReceiver('{$clientId}');
getWinnerCount(0);
Event.stop(e);
});
});




var phrase = "This is SPAARRTTAAAA!";

$('somelink').observe('click', sayIt.bindAsEventListener(this, phrase));

function sayIt(event, phrase) {
console.log(phrase);
}

phrase = "Red sauce on PAASTAAAA!";





var obj = { name: 'A nice demo' };

function handler(e) {
var tag = Event.element(e).tagName.toLowerCase();
var data = $A(arguments);
data.shift();
alert(this.name + '\nClick on a ' + tag + '\nOther args: ' + data.join(', '));
}

Event.observe(document.body, 'click', handler.bindAsEventListener(obj, 1, 2, 3));
// Now any click on the page displays obj.name, the lower-cased tag name
// of the clicked element, and "1, 2, 3".




/*
* add click event
*
*/

// Attaching events
for (var i = items.length; i--; ) {
Event.observe(items[i], 'click', e_onclick, false);
}
// Detaching events
for (var i = items.length; i--; ) {
Event.stopObserving(items[i], 'click', e_onclick, false);
}



/*
* add click event with "return false"
*
*/
in html file:

Event.observe(window, 'load', function() {
Event.observe('button2', 'click', onchecktime);
});

if js file:

var onchecktime = function(event){
var element = Event.element(event);

alert(Event.pointerX(event));
Event.stop(event); // avoid page reloading
};

2008年9月22日星期一

Prototype JS Event.observe

CODE:
/*
*you'd want this line of code to run once the form exists in the DOM; but putting *inline scripts in the document is pretty obtrusive, so instead we'll go for a simple *approach that waits till the page is fully loaded:
*/
Event.observe(window, 'load', function() {
Event.observe('percent', 'change', selectProPercent);
}

in main.js:
var selectProPercent = function()
{
......
}

2008年9月19日星期五

mysql_real_escape_string(PHP) SQL中的特殊字符查询

Problem:

TABLE COL => "cb_spielhalle" with context "RT-Betzingen (Carl-Zeiss-Str.)|*|RT-Betzingen (Eisenbahnstr.)|*|Mössingen|*|Tübingen|*|Li.-Unterhausen"

sql有效查询 带"Mössingen"的数据:
SELECT * FROM jos_comprofiler WHERE cb_handy != '' AND (cb_spielhalle LIKE '%Mössingen%' ) AND ( cb_infoserhaltenper = 'SMS und E-Mail' OR cb_infoserhaltenper = 'nur SMS' ) AND cb_anrede LIKE '%Frau%'

PHP有效查询 带"Mössingen"的数据:
SELECT * FROM jos_comprofiler WHERE cb_handy != '' AND (cb_spielhalle LIKE '%Mössingen%' ) AND ( cb_infoserhaltenper = 'SMS und E-Mail' OR cb_infoserhaltenper = 'nur SMS' ) AND cb_anrede LIKE '%Frau%'

其中 AND (cb_spielhalle LIKE '%Mössingen%' ) 使用了mysql_real_escape_string();
$q .= $dataDbtablecol2." LIKE '%".mysql_real_escape_string($spielhalle)."%' OR ";

2008年4月11日星期五

_variant_t 到 CString 转换

数据类型转换函数

CString CZjyDlg::VariantToString(VARIANT var)
{
CString strValue;
_variant_t var_t;
_bstr_t bstr_t;
time_t cur_time;
CTime time_value;
COleCurrency var_currency;
switch(var.vt)
{
case VT_EMPTY:
case VT_NULL:strValue=_T("");break;
case VT_UI1:strValue.Format("%d",var.bVal);break;
case VT_I2:strValue.Format("%d",var.iVal);break;
case VT_I4:strValue.Format("%d",var.lVal);break;
case VT_R4:strValue.Format("%f",var.fltVal);break;
case VT_R8:strValue.Format("%f",var.dblVal);break;
case VT_CY:
var_currency=var;
strValue=var_currency.Format(0);
break;
case VT_BSTR:
var_t =var;
bstr_t=var_t;
strValue.Format("%s",(const char *)bstr_t);
break;
case VT_DATE:
cur_time=var.date;
time_value=cur_time;
strValue.Format("%A,%B,%d,%Y");
break;
case VT_BOOL:strValue.Format("%d",var.boolVal);break;
default:strValue=_T("");break;

}
return strValue;

}

2008年4月10日星期四

使用Adox取得MS Access 的table信息

1. import msadox.dll
#import "C:\Programme\Gemeinsame Dateien\System\ado\msadox.dll"

Problem:
Kompilierung läuft...
ADOBase.cpp
d:\project\dbinfo2\debug\msadox.tli(246) : error C2511: 'long __thiscall ADOX::Columns::Append(const class _variant_t &,enum ADOX::DataTypeEnum,long)' : Überladene Member-Funktion nicht in '' gefunden
d:\project\dbinfo2\debug\msadox.tli(346) : error C2556: 'enum ADOX::DataTypeEnum __thiscall ADOX::_Column::GetType(void)' : Überladene Funktion unterscheidet sich nur hinsichtlich des Rückgabetyps von 'enum DataTypeEnum __thiscall ADOX::_Column::Get
Type(void)'
d:\project\dbinfo2\debug\msadox.tlh(444) : Siehe Deklaration von 'GetType'
d:\project\dbinfo2\debug\msadox.tli(346) : error C2371: 'GetType' : Neudefinition; unterschiedliche Basistypen
d:\project\dbinfo2\debug\msadox.tlh(444) : Siehe Deklaration von 'GetType'
d:\project\dbinfo2\debug\msadox.tli(348) : error C2664: 'get_Type' : Konvertierung des Parameters 1 von 'enum ADOX::DataTypeEnum *' in 'enum DataTypeEnum *' nicht moeglich
Die Typen, auf die verwiesen wird, sind nicht verwandt; die Konvertierung erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C- oder Funktionsformat
d:\project\dbinfo2\debug\msadox.tli(353) : error C2511: 'void __thiscall ADOX::_Column::PutType(enum ADOX::DataTypeEnum)' : Überladene Member-Funktion nicht in '' gefunden
Fehler beim Ausführen von cl.exe.

ADOBase.obj - 5 Fehler, 0 Warnung(en)


问题原因:
与Dao冲突定义了同名的"DataTypeEnum" and "EOF"


解决方案:
#import "C:\Programme\Gemeinsame Dateien\System\ado\msadox.dll" rename("EOF", "adoXEOF") rename("DataTypeEnum","adoXDataTypeEnum")


2. use _CatalogPtr 取得Table Information
in ADOBase.h:
#import "C:\Programme\Gemeinsame Dateien\System\ado\msadox.dll" rename("EOF", "adoXEOF") rename("DataTypeEnum","adoXDataTypeEnum")
using namespace ADOX;
ADOX::_CatalogPtr m_pCatalog;
BOOL existTable(CString sTable);


in ADOBase.cpp:
BOOL ADOBase::existTable(CString sTable)
{

try
{
m_pCatalog.CreateInstance(__uuidof(Catalog));
m_pCatalog->PutActiveConnection(_variant_t((IDispatch *) m_pConnectionSpecial));

TablesPtr m_pTables = m_pCatalog->GetTables();

_Table* m_pTable = NULL;
//m_pTables = cat->Tables->Item[sTable];

if (m_pTables->get_Item(_variant_t(sTable), &m_pTable) == S_OK)
{
return true;

}
else
return false;

}
catch (_com_error &e)
{
m_nLastError=ADOLE_OPEN_FAILED;
HandleErrorAB(e, "existTable (DB", sTable);
PROTOCOL_ENTRY(0,0,"END (_com_error) ADOBase::existTable")
return false;

}
catch(...)
{
m_nLastError=ADOLE_OPEN_FAIL_UNHANDLED;
m_sLastError = "**** Unhandled exception! **** in Open";
HandleErrorAB();
PROTOCOL_ENTRY(0,0,"END (...error) ADOBase::existTable")
return false;

}


}