顯示具有 Code Charge Studio 標籤的文章。 顯示所有文章
顯示具有 Code Charge Studio 標籤的文章。 顯示所有文章

2021年11月28日 星期日

避免按鈕被按了兩次!

<input type="submit" id="Contenttrns_cpButton_Update" class="btn btn-lg btn-primary btn-block" alt="{res:CCS_Update}" value="{res:CCS_Update}" name="{Button_Name}"
onclick="javascript:{this.disabled=true;document.getElementById('Contenttrns_cpButton_Cancel').disabled=true;document.trns_cp.submit();}">

在按鈕裡面多增加 

onclick="javascript:{
this.disabled=true;
document.getElementById('<cancel按鈕的ID>').disabled=true;
document.form_name.submit();
}"

Cancel按鈕是否也要失效?

2021年11月23日 星期二

CodeCharge 的 Update Panel 如果裡面有用 JS Confirm 對話框會無效

CodeCharge 的 Update Panel 如果裡面有用 <a href="" onclick="return confirm('{res:are_you_sure}');">

對話框,按了 取消,她還是會被執行!

紀錄一下

2021年11月21日 星期日

2021年11月19日 星期五

CodeCharge 搭配 CloudFlare經常沒用多久就自動被登出?!

 經過研究發現是 CodeChargeStudio 的 Common.php中有這一行:

if (session_id() == "") { session_start(); }

if (CCGetUserAddr() != $_SERVER["REMOTE_ADDR"]) { CCLogoutUser(); }

也就是 CCS 會檢查 REMOTE_ADDR,如果不一樣就會被強制登出!

解決這個問題,就必須拿掉這一行檢查。




//Initialize Common Variables @0-8AF2F782
$PHPVersion = explode(".",  phpversion());
if (($PHPVersion[0] < 4) || ($PHPVersion[0] == 4  && $PHPVersion[1] < 1)) {
    echo "Sorry. This program requires PHP 4.1 and above to run. You may upgrade your php at <a href='http://www.php.net/downloads.php'>http://www.php.net/downloads.php</a>";
    exit;
}
if (session_id() == "") { session_start(); }
if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
  $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
}
// if (CCGetUserAddr() != $_SERVER["REMOTE_ADDR"]) { CCLogoutUser(); }

2021年10月24日 星期日

CodeCharge Studio 的 子網頁裡面的 Panel 的參照

一個子網頁(被 include 的子網頁),它裡面的 Panel ,要被參照,例如 visible

應該這樣用:

global $page;

$page->control->Visible = false;

$page->panel->Visible = false;


不可以這樣:

global $panel;

$panel->Visible = true;


這個問題,我經常弄錯,紀錄在這裡,提醒自己。


但是,如果是子網頁page -> 子網頁subpage -> Panel 

就不能再這樣用了!

function subpage_BeforeShow(& $sender)

global $subpage;

$subpage->control->Visible = false;

$subpage->panel->Visible = false;



比較困擾的應該是因為 Panel 是透明的,無法直接用 global $Panel1;這種方式

此時,只能使用 $Component 這個變數了!

例如:

function navside_BeforeShow(& $sender)

{

    $navside_BeforeShow = true;

    $Component = & $sender;

    $Container = & CCGetParentContainer($sender);

    global $navside; //Compatibility

//End navside_BeforeShow


//Custom Code @17-2A29BDB7

// -------------------------

    // Write your own code here.

    

           $db = new clsDBconn_mysql();

$SQL = "SELECT is_fund_opened(".

             $db->ToSQL($_SESSION["UserID"], ccsInteger) .

             ") as v_opened;";

$sql_log = "CALL system_log(".$db->ToSQL($SQL, ccsText).")";

$db->query($sql_log);

$db->query($SQL);

$result = $db->next_record();

if ($db->f("v_opened")==0) {

    $Component->Panel1->Visible = True;

    $Component->Panel2->Visible = False;

} else {

    $Component->Panel1->Visible = False;

    $Component->Panel2->Visible = True;

}


    

    $db->close();

    

    

// -------------------------

//End Custom Code


//Close navside_BeforeShow @1-E75A1C39

    return $navside_BeforeShow;

}


這一段 CCS 自己的說明,要好好看看:

Referencing Objects

The objects in the Web applications generated by CodeCharge Studio can be referenced in a variety of ways. In many cases, to work with a specific object within a program you will need to know its position within the program hierarchy. For example, an object that is placed directly on the page may need to be addressed differently compared to an object placed within a form (which is also an object).

ASP

Examples of working with objects Syntax
Form object placed on a page Page Events <form>.Visible = False
Form Events EventCaller.Visible = False
Control object placed within a form Page Events <form>.<control>.Value = "123"
Form Events EventCaller.<control>.Value = "123"
Control Events EventCaller.Value = "123"
Control object placed on a page Page Events <control>.Value = "ABC"
Control Events EventCaller.Value = "ABC"
Control object placed on an included page Main Page Events <page>.<control>.Visible = False
Includable Page Events EventCaller.<control>.Visible = False
Control Events EventCaller.Visible = False
Form object placed on an included page Main Page Events <page>.<form>.Visible = False
Includable Page Events EventCaller.<form>.Visible = False
Form Events EventCaller.Visible = False
Control object placed in a form within an  included page  Main Page Events <page>.<form>.<control>.Visible = False
Includable Page Events EventCaller.<form>.<control>.Visible = False
Form Events EventCaller.<control>.Visible = False
Control Events EventCaller.Visible = False

Note: Using EventCaller is recommended when planning to reuse the event code since it doesn't require referring to objects by name.

Perl

Examples of working with objects Syntax
Form object placed on a page $<form>->{Visible} = 0;
Control object placed within a form $<form>->{<control>}->SetValue("123");
Control object placed on a page $<control>->SetValue("ABC");
Control object placed on an included page $<page>->{<control>}->{Visible} = 0;
Form object placed on an included page $<page>->{<form>}->{Visible} = 0;
Control object placed in a form within an included page  $<page>->{<form>}->{<control>}->{Visible} = 0;
Assigning an object to a variable $<variable> = $<object>;

Java

Examples of working with objects Syntax
Form object placed on a page Page Events e.getPage().getComponent("<form>").setVisible(false);
Form Events e.getComponent().setVisible(false);
Control object placed within a form Page Events e.getPage().getComponent("<form>").getControl("<control>").setValue("123");
Form Events e.getComponent().getControl("<control>").setValue("123");
Control Events e.getControl().setValue("123");
Control object placed on a page Page Events e.getPage().getControl("<control>").setValue("ABC");
Control Events e.getControl().setValue("ABC");
Assigning an object to a variable <variable> = <object>;

Note: The syntax for accessing objects in an included page from events within the same included page is the same as specified above. The syntax for accessing objects in an included page from events within the including page is not supported. The syntax for accessing objects in the including page from events within the included page is also not supported.

C#

Examples of working with objects Syntax
Form object placed on a page Grid and Editable Grid Events <form>Repeater.Visible = false;
Record Events <form>Holder.Visible = false;
Directory and Path Events <form>.Visible = false;
Control object placed within a Record form <form><control>.Visible = false;
Control object placed within a Grid, Editable Grid, Directory and Path form Control's Before Show Event <form><control>.Visible = false;
Form's Before Show and Before Show Row Event Object reference should be retrieved from the FormControls collection.
See the ItemDataBound Event MSDN example.
Control object placed on a page <control>.Visible = false;
Assigning an object to a variable <variable> = <object>;

Note: The syntax for accessing objects in an included page from events within the same included page is the same as specified above. The syntax for accessing objects in an included page from events within the including page is not supported. The syntax for accessing objects in the including page from events within the included page is also not supported.

VB.Net

Examples of working with objects Syntax
Form object placed on a page Grid and Editable Grid Events <form>Repeater.Visible = False
Record Events <form>Holder.Visible = False
Directory and Path Events <form>.Visible = False
Control object placed within a Record form <form><control>.Visible = False
Control object placed within a Grid, Editable Grid, Directory and Path form Control's Before Show Event <form><control>.Visible = False
Form's Before Show and Before Show Row Event Object reference should be retrieved from the FormControls collection.
See the ItemDataBound Event MSDN example.
Control object placed on a page <control>.Visible = False
Assigning an object to a variable <variable> = <object>

Note: The syntax for accessing objects in an included page from events within the same included page is the same as specified above. The syntax for accessing objects in an included page from events within the including page is not supported. The syntax for accessing objects in the including page from events within the included page is also not supported.

ColdFusion

Examples of working with objects Syntax
Form variable placed on a page or within a form <CFSET blnReadAllowed<form>=false>
Control variable placed within a form or a page <CFSET fld<control> = "abc">

Note: The syntax for accessing objects in an included page from events within the same included page is the same as specified above.

PHP

When using PHP you can address objects in a generic way as $Component to refer to the component raising the event, and $Container to refer to the host form of $Component. This method of referring to objects is recommended to make the event code reusable since it doesn't require referring to objects by name. You can also refer to objects using global variables, for example use $MyGrid to refer to 'MyGrid' grid.

Examples of working with objects in a generic way Syntax
Form object placed on a page Page Events $Component->form->visible = false;
Form Events $Component->Visible = false;
Control object placed within a form Page Events $Component->form->control->SetValue($Component->form->PageNumber);
Form Events $Component->control->SetValue($Component->PageNumber);
Control Events $Component->SetValue($Container->PageNumber);
Control object placed on a page Page Events $Component->control->SetValue("ABC");
Control Events $Component->SetValue("ABC");
Control object placed on an included page Main Page Events $Component->page->control->Visible = false;
Includable Page  Events $Component->control->Visible = false;
Control Events $Component->Visible = false;
Form object placed on an included page Main Page Events $Component->page->form->Visible = false;
Includable Page  Events $Component->form->Visible = false;
Form Events $Component->Visible = false;
Control object placed in a form within an  included page  Main Page Events $Component->page->form->control->Visible = false;
Includable Page  Events $Component->form->control->Visible = false;
Form Events $Component->control->Visible = false;
Control Events $Component->Visible = false;


Examples of working with objects using global variables Syntax
Form object placed on a page $form->Visible = false;
Control object placed within a form $form->control->SetValue("123");
Control object placed on a page $control->SetValue("ABC");
Control object placed on an included page $page->control->Visible = false;
Form object placed on an included page $page->form->Visible = false;
Control object placed in a form within an  included page  $page->form->control->Visible = false;



2021年1月24日 星期日

CodeCharge 的 Validate Error 抓蟲經驗

 CCS欄位有自動檢查是否需要有值的功能,只要在"Required"設成"Yes",就可以了。

但是,奇怪,怎麼搞了半天,都沒有!

搞了好久。

只好去查原始碼~~~

Common.php

Classes.php

找到 clsControl 裡面的 Validate() method

使用 die("text -- $varibale"); 來查看變數內容,以抓蟲。

一個一個試,才發現問題出在 clsError->addError() 這裡!?

再查進去,原來是 

      $this->Errors->addError($CCSLocales->GetText('CCS_RequiredField', $this->Caption));

CCS_RequiredField 這一個tw-zh 沒有定義到!是空白的,出來的就是空白!
以至於加了Error ,還是沒有 Error

最後,把CCS_RequiredField語系檔定義進去,就跑出來了!

呼!!!鬆了一口氣!
終於找到原因了!

紀錄一下這個抓蟲經驗。

2021年1月5日 星期二

CodeCharge 的目錄功能

 CCS 有內建的目錄產生功能。

在製作電子購物網站時,會有產品目錄,分層進去,然後才顯示產品目錄頁,然後才是產品單頁。

在製作目錄時,CCS的內建目錄可以有兩層結構。

為了簡化產品目錄結構,產品項目幾百個以內,大概分三層就可以了。

第一層是"館別",第二層是主目錄、第三層是子目錄,然後是產品。

如果將目錄製作成為 共用的 子網頁,可以被嵌入的子網頁。

那就分別製作 N個館別,然後顯示主目錄以及子目錄,共三層。

第一層、第二層,都只有顯示,不能連結。

第三層才可以連結。

由於目錄是製作成 嵌入式子網頁,會在每個網頁都出現。如果 傳入的 Get 參數有 Categories_id,那麼CCS的目錄結構就跟著跑了。所以,只要將要連結出去的 GET 參數 改成 category_id,跟原本的 categories_id 不一樣,就不會引動目錄跟著跑了!而要顯示第三層產品目錄的網頁,其 GET 參數跟著改成 category_id 這樣就完成了!

2020年12月2日 星期三

CodeChargeStudio用來做 AJAX回應程式

 之前做了一個 AJAX動態去讀取伺服器程式 getname.php,要獲取姓名的程式。

結果程式呼叫 JavaScript 讀取 getname.php 之後,版面大變!

後來發現,原來是我是以CodeChargeStudio來製作getname.php,沒有把 html 模板清空、清乾淨,還留有CCS原本內定的一些 html模板的文字,這些<html><head>......</head><body>.....</body></html>整個一起都傳到網頁裡面去了!所以,CSS就大亂了!

我將 getname.php 在 CCS上留存的 html模板都清空,只剩下產生{name},就乾淨了!

犯了這個錯誤!紀錄一下。

2020年10月29日 星期四

CCS的權限設計很好用的

 CodeCharge的權限設計,分為三個等級:

1. 全站

2. 全頁(包含子頁)

3. 頁裡面的 Form Record/Grid 元件

--------------------------------------------------------

應用:不同會員等級,看見不同的選單MENU

設計整站會員等級。不同等級有不同的權限。
使用Group_level這個欄位,在Project Setting 裡面有這個選項。

選單頁中,採用可以被引入的 include page方式。

一般頁 + 選單子頁

選單子頁 再 + 子選單子頁

子選單子頁 再 分別設定會員等級權限

CCS就會依據會員等級權限,只顯示有權限的子頁



---------------------------------------------------------------

之前自己使用某頁來做測試,後來自己忘記了,竟然發現怎麼跑不出來了!經過好幾個小時的測試,還是跑不出來!最後,才發現,原來是自己更改了權限設計測試資料,才跑不出來。將權限設定拿掉就正常了!

這 CodeCharge的權限也太厲害了,搞到自己都暈了!

自覺這是一個糗事,紀錄一下,提醒自己,以後不要再發生!



2020年10月27日 星期二

談 CodeChargeStudio 的 upload 問題

原始的CCS文件:Description

File Upload 元件,使用來上傳到指定的 Web server.
使用 (<input type="file">) 讓使用者在他自己的電腦上瀏覽選擇檔案。
用戶選擇、且按了送出鍵,就上傳。
File Upload 元件會檢查 檔案大小限制 file size limit。
同時檢查允許的檔案格式副檔名。
成功上傳到 server (註一)以後,CCS就會給他一個檔名"yyyymmddHHnnss#.<originalName>",
'yyyymmddHHnnss' 是當時系統日期時間。
#加上序號,確保名稱唯一性。
File Upload 必須在 Record form 或 Editable Grid。


CCS的 upload control 必須在 Record/Grid 裡面使用。

使用 html 的 <input type="file"> 來做上傳。

會在 HTML 產生這段碼:

<!-- BEGIN FileUpload name -->
  <input type="hidden" name="{ControlName}" value="{State}">
  <!-- BEGIN Info --> {FileName} {FileSize} bytes <!-- END Info -->
  <!-- BEGIN Upload --><input type="file" name="{FileControl}"><!-- END Upload -->
  <!-- BEGIN DeleteControl --> Delete <input type="checkbox" name="{DeleteControl}" {DeleteChecked}><!-- END DeleteControl -->
<!-- END FileUpload name -->

File Input Control

File Upload 元件裡面主要的元素是 file input control. HTML 碼如下:

<input type= "file" name= "{ControlName}">

這個是讓用戶可以在他的電腦上瀏覽選取檔案。

檔案選擇以後,送出鍵,就會上傳到 server。(這一段:註一,由PHP處理)
在儲存到主機之前,CCS會檢查檔案大小以及格式,如果有錯,就會產生錯誤訊息,檔案不會儲存。

Note that the file input control appears when a new record is being inserted or there is no existing file associated with the record being viewed. If the record being viewed has an existing file, the File Upload component will display information about the file and hide the file input control. 


* 研究CCS的程式碼以後(包含:主程式.php、common.php、classes.php、還有 CCS所附的sample2) 發現,配合 upload 一定要配合一個 uploaded files 的  資料庫  table,例如:files,然後在該 upload control的 property裡面綁定的 table name、field等綁定,才能夠真正正確的執行整個CCS所提供的功能。如果沒有綁定table、field等,好像就是上傳到 Temporary Folder,無法再搬移到 File Folder裡。因為搬移這個動作,是設計在 Record form裡面的 insert()之後動作的!

這一點,我試了好久,沒有綁定table、一直試 File Folder,就是無用!只有在 Temporary Folder而已!只好去K CCS的程式碼、找 Sample2裡面的程式,才發現這樣!

* 接下來,我要解決中文檔名的問題。因為上傳中文檔名,在 php的 move_uploaded_file()這裡會有錯誤。我們無法去改 php,只有自己想辦法解決!

move_uploaded_file(),只能接受 big5檔案名稱,所以,在使用以前,必須將utf8的中文名稱轉換成 big5,才可以呼叫 move_uploaded_file()

修改: classes.php

line 1839:
while($file_exists) {
// $ActualFileName = date("YmdHis") . $index . "." . $FileName;
$ActualFileName = date("YmdHis") . $index . "." . iconv("utf-8", "big5", $FileName);
$file_exists = file_exists($this->FileFolder . $ActualFileName) || file_exists($this->TemporaryFolder . $ActualFileName);
$index++;
}
if( move_uploaded_file($_FILES[$FileControl]["tmp_name"], $this->TemporaryFolder . $ActualFileName)) {
...
(略)
...
}

主要是 將 $FileName 用 iconv("utf-8","big5",$FileName)轉換成 big5

然後,交由 move_uploaded_file()處理就可以

CCS 將上傳的檔案(記住:中文檔名為 big5碼的)存放到 設定的 TemporaryFolder 裡面。

然後、綁定的TABLE新增一筆紀錄,此時要將檔名由 big5轉回 utf-8,才能正確儲存。

試了整個晚上,終於試出來了!就是在 upload 綁定的 record form 的Event: fileForm_ds_BeforeExecuteInsert 裡面,直接去修改 INSERT 的 SQL ,整個改掉,改成:

$fileForm->DataSource->SQL = 
"INSERT INTO files  (file_name, file_date_uploaded, file_owner_id, file_status) VALUES( " .
CCToSQL( iconv("big5","utf-8",$fileForm->FileUpload1->GetValue()), ccsText) . ",".
 " NOW() " . "," .
CCToSQL( $fileForm->file_owner_id->GetValue(), ccsInteger) . "," .
CCToSQL( $fileForm->file_status->GetValue(), ccsInteger) . ")"; 

主要要點是:將 file_name,使用 iconv("big5", "utf-8", filename欄位) 改回 utf-8

這樣就完成了。

總結:

未來:1. Classes.php 要注意使用這個修改一行的版本。本來想要盡量不要動到CCS預設的 Classes.php檔案,但是試了幾天,都找不到方法可以不動。那就只好動它了!記得維持這個版本。萬一,這版本被CCS改回去了。就記得手動去改 1840 那一行。

2. upload control 所在的 網頁檔,記得要綁定一個 Record / Editable Grid,才可以使用 upload 元件,同時,是先定義好files  table,裡面的欄位 filename 等。然後,在該 record 的 BeforeExecuteInsert Event 去改掉 INSERT SQL ,將 中文檔名編碼格式由 big5 改回 utf-8,如上。(去 copy來改比較快啦!)

完成!


註一:php 原始上傳是先上傳到 php.ini 裡面定義的 tmp folder,然後紀錄在$_FILE["file"] 系統變數裡面

分別是:

$_FILES["file"]["name"] - the name of the uploaded file
$_FILES["file"]["type"] - the type of the uploaded file
$_FILES["file"]["size"] - the size in bytes of the uploaded file
$_FILES["file"]["tmp_name"] - the name of the temporary copy of the file stored on the server
$_FILES["file"]["error"] - the error code resulting from the file upload

然後:再呼叫 move_uploaded_file($_FILES["file"]["tmp_name"],  $_FILES["file"]["name"]);

2. CCS 的 upload control 可以設定 兩個 property: Temporary Folder、 File Folder。


註二:2020/10/28 中午,將以上昨晚在local 電腦(windows系統)測試都成功的東東,上傳到 Linux Server!結果發現:又錯了!問題就在於 Windows 的中文檔名,與 Linux 的中文檔名,編譯的 碼 不一樣!

結果,我試著將 昨天以前在 windows 上測試好幾天成功的東東都拿掉,還原回原本CCS上的原始碼狀態,竟然成功運作!哈哈哈!也就是說我這幾天都做白工了!

唉!耶沒有做白工啦!至少對CCS的內部設計,更清楚一些了。也興起我運用他來設計一套 Generator 的想法!

哈哈!功不唐捐啦!~~~


2020年10月19日 星期一

CodeCharge 的 field validation

在 Field 的 property 裡面有 Validation rule、以及 Validation Text 兩個

舉例:Login 登入帳號,要求長度需要大於 8 位元,就在該欄位的 Validation rule 輸入:strlen($this->login->GetValue())>=8

Validation TEXT:{res:msg_login_length_must_be_greater_than_8}

然後在 多語系定義裡面,定義上面那段{res:msg_login_length_must_be_greater_than_8}就可以了!


Code Charge 的 Validation 可以在很多地方處理:

一、在欄位的屬性裡

1. 是否 Unique、是否 Required、 Input Validation格式(EMail、5-digit ZIP Codes)

2. 就如同本文上面所舉的例子

3. Error Control:將錯誤訊息顯示在一個 Label 裡面,該Label Control 可以隨自己控制,放在想要顯示的地方。

標準的 Error是顯示在畫面的 上面。

二、每個欄位、Control、Page都有 OnValid_Event

可在那個 Event 裡面寫程式檢查


2020年8月9日 星期日

CCS Example2 範例:設計A網頁上的客戶ID變更,AJAX去資料庫抓客戶名稱回來

 在CCS Example2 上的範例:


order.php 網頁上一個欄位: customer、是一個選單欄位

下拉式 Selection,變更(onchange())就去資料庫讀取 客戶姓名、地址等客戶資料。

設計如下:

1. 在 customer欄位裡面

 <select id="orders1order_customer_id" onchange="OpenCustomerInfo(this.value);" name="{order_customer_id_Name}">
<option value="" selected>Select Value</option>
{order_customer_id_Options}
</select>


2. 在head 裡面建立:

<script language="JavaScript" type="text/javascript">
function OpenCustomerInfo(cust_id) {
  var win = window.open("GetCustomerInfo.php?customer_id="+cust_id,"CustomerInfo","height=1,width=1,toolbar=no,scrollbars=no,menubar=no");
 win.focus();
}
</script>


3. 另外,用CCS寫一個 GetCustomerInfo.php 程式

<!DOCTYPE HTML>

<html>

<head>

<title>Please Wait...</title>

<script language="JavaScript" type="text/javascript">

function getCustomerInfo(){

<!-- BEGIN Record Customer -->

  window.opener.document.orders1.order_ship_address.value = "{customer_address}";

  window.opener.document.orders1.order_ship_city.value = "{customer_city}";

  window.opener.document.orders1.order_ship_state.value = "{customer_state}";

  window.opener.document.orders1.order_ship_zip.value = "{customer_zip}";


<!-- END Record Customer -->

window.opener.focus();

window.close();

}

</script>

</head>

<body onload="getCustomerInfo();">

Please Wait 

</body>

</html>

2020年5月19日 星期二

CodeCharge 的 註冊 密碼 加密 很奇怪

用他的 event, 加密,都不會成功?
用 Before_insert 沒有加密

乾脆直接在  properties 裡面的  Insert 裡面自訂 SQL 中的欄位加上 md5('{password1}')

這樣就好了!

2020年5月16日 星期六

CodeCharge 複製CCP檔到別的專案,自加程式不會Copy過去!

如題。

CCS實在是一個很好的工具。
我現在還在使用
可惜原設計者已經不再更新版本
有發現 Bug 反應也沒人接、沒人修改

可惜。

2019年4月6日 星期六

CodeCharge 的 Security Group 很好用

CodeCharge 的Security 都已經設計好了,拿來用就可以了。
還蠻好用的。

可以有

Site Level
Page Level
Form Level

三個Level ,分別有權限管控。

問題:不符合權限時,警告訊息要如何顯現呢?

2019年3月5日 星期二

CodeChargeStudio 不同的 Design 如何轉換

如果同一個 project,可是會需要用到兩個以上不同的Design,這時怎麼辦?

CCS 提供了兩個方法:

一、透過 querystring 設定 ?design=xxx

二、透過 session variable $_SESSION["design"] = "xxx";

只要在每個 page 的 before_show event 中,多寫下:

$_SESSION["design"] = "xxx";

這樣就可以了!

2018年10月13日 星期六

改變 radio 的選項

Form 裡面有 radio control
他的選項需要隨著程式邏輯而變異,如何改變?

例如:該 radio control 叫做: items
在該 control 的 "Before Build SELECT " Event 中增加:

$items->DataSource->Where = " items > 0";

這樣就可以了。

2018年9月23日 星期日

codecharge 設計筆記



Codecharge 的 event
Before_Update
Before_Build_Update
Before_Execute_Update
做了一個隱藏的 text 連結到資料庫,然後在上面三個 update event 將之改變
然後,測試執行 update 後,是否更新到資料庫中
結果:只有 Before Update 有真的更新
其餘兩個,都還是原來的舊值,亦即沒有更新!
好奇怪喔!


Before Update Event
This event occurs at the onset of the operations performed to update a database record.
Possible applications:
  • Checking update rights
  • Preventing a row from updating
  • Setting custom query parameters 

Before Build Update Event
This event occurs before the creation of the query that will be used to update database content.
Possible applications:
  • Setting custom query parameters or changing existing ones

Before Execute Update Event
This event occurs after the query has been composed and immediately before a row update query is executed.
Possible applications:
  • Altering query parameters
  • Opening a transaction
  • Performing transaction operations



經過查詢 codecharge 的產生程式碼,他是 先處理 Before Update
然後進入 Update 程序了
在Update 的程序中,再進入 Before Build Update/Before Execute Update 裡
所以,如果在 Before Build Update/Before Execute Update裡面嘗試要去改變 連結資料欄位的值時已經來不及了。







=================
2018/09/22
================
留意:codecharge的 Object 階層關係。
Page -> Panel -> Form -> Control
查看 help 裡面的範例。
不是每個都可以 SetValue/GetValue
有些是只有 Visibl=True 之類的!

=======================
可以重複使用的內容,可以善用 includeable page 子頁的方式製作。






2016年6月11日 星期六

CodeCharge: cannot connect to database

CodeChargeStudio : DataBase Error: Cannot connect to database MySQL
Databse Halted.

Database error: cannot connect to Database
MySQL Error
Session halted.

上兩周原本是Win7 的電腦被自動更新為 Win 10,原本擔心一些舊的AP不知道是否可以正常運作,例如CodeCharge等,結果試試,似乎還好。

前天,將原本舊的一個專案,原本運作都正常,就做了一些更新後,就上傳了。結果,產生了上述的錯誤!

搞了一整天,查不出原因。

後來,逐一比對 db_mysql.php 這檔案才發現,我不知道為什麼 db_mysql.php 是舊的,應該是 php 5.5以後,一些舊的 指令已經不能用了,mysql_pconnect() 必須改成:mysqli_connect() 等等。

手動的ftp方式,將新的 db_mysql.php 更新到伺服器上,就正常了!

註記在這裡。

註:
不是:是新的改成 mysqli_connect() 就不行了!
舊的可以!
將 舊的 db_mysql.php 改回去,蓋掉新的 db_mysql.php 就正常了!

2015年12月7日 星期一

快速訂單設計記錄

這篇是寄給我自己看的,讀者看不懂就算了!

在資料庫中讀取相同的介紹會員,且還沒有完成的快速訂單中,找出最近的一筆,亦即是 id 最大的那筆,然後,設定一個 Session 給他。

在 STEP1 Page 中的 PageBeforeInitialize 中,寫:
$db = new clsDBmysql_conn(); 
$SQL = "SELECT max(qf_id) as maxid FROM quick_form WHERE refer_mem_extid='" .$_SESSION["mem_id"]."' AND finished='0';";
$db->query($SQL);
$Result = $db->next_record(); 
if ($Result) {$_SESSION["qf_id"] = $db->f("maxid");} else {$_SESSION["qf_id"] = 0;}

然後,在 Page 的 Record 中,DataSource 中,要設定該 Table ,Where 設定為:qf_id=$_SESSION["qf_id"];

這樣就可以搞定。

STEP 2, STEP 3....之後的步驟網頁,也都是一樣的設定,這樣就可以確保處裡的都是相同的一筆資料了!

上一步、下一步,都可以指稱到相同的一筆。縱使是 user 直接在 url 輸入 step2網址,也可以指到我們希望的那一筆資料。(相同會員最後未完成的那一筆記錄)。

注意:當最後一個步驟完成時,記得必需將 Finished 欄位設為"1",且將 Session 清空!表示已經完成,不會被重複處理!


如何判斷現在FORM是在 insert mode? 還是 update mode?

只要用  if (empty({primary_key})) 就可以知道是否為新增模式了。 如果 {promary_key} 是空白的,那麼就是在新增模式;反之,就是更新模式。 以上。