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 就正常了!

2016年4月1日 星期五

CodeCharge Studio的 DateTime format

Code Charge 有他自己的 DateTime 格式,不同於 MySql 與 php,所以,從mySql 中讀出來的日期資料,如果用 php程式處理,需要使用 CCS 提供的函數:

CCFormatDate Function (PHP)

CCParseDate Function (PHP)

2016年1月23日 星期六

codecharge 設計一個grid 後面,不同的按鈕形狀

想要設計一個效果:在Grid 資料表裡面,每一筆記錄,因為資料狀泰不同,而有不同的按鈕。
按鈕是一個連結到另一個網頁,伴隨著一些連結參數。

原本使用Code Charge 的 Link Control,然後在該Grid 的 BeforeShowRow Event 中進行設定:
$grids->link1->SetValue("some thing");
結果發現,都失敗了!連結的文字,跟本都不理我。

後來,看了 CCS的 help 檔案,裡面有一個範例是這樣的:

<a href="{label1}?parameter={label2}">{label3}</a>

也就是根本就捨棄使用CCS內的 Link Control,而是使用html,裡面的一些設定,完全自己使用label來控制。這引發我很多想法。
Bootstarp 裡面,可以有很多現成的可以使用效果:
<a href=.....> 也可以使用 class="btn btn-primary",這樣一來,Link也有按鈕的效果。
class="btn btn-primary disabled" 就可以使該連結失效!
而這些值都可以在
BeforeShowRow Event 中依據需要而自由設定。
這樣就解決問題了!

2016年1月12日 星期二

CodeChargeStudio!!! button onclick bug!?

設計了一個 record form,裡面有 button ,
可是為什麼設計了一個 on-click event,卻抓不到該筆 records 的欄位?

奇怪?!




2015年12月21日 星期一

2015年12月19日 星期六

jQuery AJAX

jQuery AJAX Methods

AJAX is the art of exchanging data with a server, and update parts of a web page - without reloading the whole page.
The following table lists all the jQuery AJAX methods:
MethodDescription
$.ajax()Performs an async AJAX request
$.ajaxPrefilter()Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax()
$.ajaxSetup()Sets the default values for future AJAX requests
$.ajaxTransport()Creates an object that handles the actual transmission of Ajax data
$.get()Loads data from a server using an AJAX HTTP GET request
$.getJSON()Loads JSON-encoded data from a server using a HTTP GET request
$.getScript()Loads (and executes) a JavaScript from a server using an AJAX HTTP GET request
$.param()Creates a serialized representation of an array or object (can be used as URL query string for AJAX requests)
$.post()Loads data from a server using an AJAX HTTP POST request
ajaxComplete()Specifies a function to run when the AJAX request completes
ajaxError()Specifies a function to run when the AJAX request completes with an error
ajaxSend()Specifies a function to run before the AJAX request is sent
ajaxStart()Specifies a function to run when the first AJAX request begins
ajaxStop()Specifies a function to run when all AJAX requests have completed
ajaxSuccess()Specifies a function to run when an AJAX request completes successfully
load()Loads data from a server and puts the returned data into the selected element
serialize()Encodes a set of form elements as a string for submission
serializeArray()Encodes a set of form elements as an array of names and values

AJAX

AJAX 概念:

AJAX




Create an XMLHttpRequest Object



var xhttp;
if (window.XMLHttpRequest) {
    xhttp = new XMLHttpRequest();
    } else {
    // code for IE6, IE5    xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}


Send a Request To a Server






Server Response






The onreadystatechange Event








<!DOCTYPE html>
<html>
<body>

<h3>Start typing a name in the input field below:</h3>

<form action=""> 
First name: <input type="text" id="txt1" onkeyup="showHint(this.value)">
</form>

<p>Suggestions: <span id="txtHint"></span></p> 

<script>
function showHint(str) {
  var xhttp;
  if (str.length == 0) { 
    document.getElementById("txtHint").innerHTML = "";
    return;
  }
  xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (xhttp.readyState == 4 && xhttp.status == 200) {
      document.getElementById("txtHint").innerHTML = xhttp.responseText;
    }
  };
  xhttp.open("GET", "gethint.php?q="+str, true);
  xhttp.send();   
}
</script>

</body>
</html>



showCustomer

function showCustomer(str) {
  var xhttp; 
  if (str == "") {
    document.getElementById("txtHint").innerHTML = "";
    return;
  }
  xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (xhttp.readyState == 4 && xhttp.status == 200) {
    document.getElementById("txtHint").innerHTML = xhttp.responseText;
    }
  };
  xhttp.open("GET""getcustomer.asp?q="+str, true);
  xhttp.send();
}




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

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