瀏覽次數: 627316

  • 錯誤訊息:的KeyField[Srvtools.KeyItem]欄位不存在?
    如果有Left join的欄位,請將Left Join的欄位放在sql語句的後半部分,比如:
    select Orders.*, CompanyName from Orders left join Customers on ......
    不要寫成:select CompanyName, Orders.* from Orders left join Customers on ......




  • 使用InfoTransaction元件,希望符合條件再執行過帳
    InfoTransaction元件有BeforeTrans事件,可以通過e.Cancel=true來取消。



  • InfoTransaction的BeforeTrans事件裡,該如何取得Client輸入的資料?
    在BeforeTrans事件中可以通過UpdateComp.CurrentRow來讀到當前的Row, 如下:
    private void infoTransaction1_BeforeTrans(object sender, InfoTransactionBeforeTransEventArgs e)
    {
    int i = Convert.ToInt16(ucMaster.CurrentRow["Quantity"]); // 取得 ucMaster所對應的Quantity欄位值
    ….
    }




  • server如何使用StoredProcedure?
    只要使用InfoCommand元件即可呼叫StoredProcedure,將InfoCommand的CommandType設定為StoredProcedure,並以CommandText來設定StoredProcedure的名稱,然後利用InfoParameters建立StoredProcedure所要傳遞的參數即可,網站下載區中有專門的參考文件,如下:
    http://www.infolight.com.tw/download/file/InfoCommand%E4%BD%BF%E7%94%A8%E5%AD%98%E5%84%B2%E9%81%8E%E7%A8%8B.doc




  • 如何在Server端使用StoredProcedure查詢?錯誤訊息:找不到預存程式 'SP_GET_USERSTOLIST?
    在InfoCommand的CommandText只能填入你的預存程式名稱,而不是整個sql語句,如:
    CommandText=SP_GET_USERSTOLIST
    CommandType=StoredProcedure
    InfoParameters建立一InfoParameters,ParameterName=UserID
    ServiceManager要註冊一function專門呼叫此InfoCommand回傳object,就可以調用成功了
    更多詳情,請參考
    http://www.infolight.com.tw/download/file/InfoCommand%E4%BD%BF%E7%94%A8%E5%AD%98%E5%84%B2%E9%81%8E%E7%A8%8B.doc




  • 如何在server上抓取當前login的User.
    直接寫使用object[] user_id = this.GetClientInfo(ClientInfoType.LoginUser);
    This是指DataModule這個Clasee,在Server端都是以DataModule這個Class為範圍的。




  • 寫了一個ServerMethod後始終在return傳回後,發生錯誤?
    在Server Method Return值時,其陣列的第一個參數一定必須傳回0, (如 ret[0] 必須是0),這是EEP系統用的返回參數,0代表正常執行,1代表有錯誤發生,因此,如果你傳為不是0的值,系統都會認為發生了錯誤,但從第二個參數開始,你可以自由使用。



  • 何時該使用 Server Method,使用 server method 有什麼好處?
    ServerMethod提供的是一種架構,非常自由,比如可以傳遞任意參數,可以返回任意結果,可以完成很多功能。因為在N-Tier架構中,不管是Windows Client還是IIS Server都不應該可以直接連線到Database Server才對(基於安全與流量管制理由),因此Client端要處理大量的資料或用程式自由存取資料庫,就必須藉由Server Method來處理,因此Server Method就好像Web Service一樣,提供所需的資料或商業邏輯的處理服務等等。至於什麼時候需使用Server Method,一般像大量資料的統計或者月結(年結)等都比較適合,這樣可以避免大量資料在server與client之間的傳輸。還有一些不需要client編輯操作的功能都可以放在server端用serverMethod來包裝處理。總之,Server Method用來處理與資料庫有關的商業邏輯,將U/I分離,因此Server Method也是一種SOA的架構之一。



  • Async call back後show另一form會當掉
    源碼如下:
    public void p_rod052_back(object[] oret1)
    {
    string repn = "rod052";
    cr070v.Form1 temp = new cr070v.Form1();
    temp.repn = repn;
    temp.MdiParent = this.MdiParent;
    temp.WindowState = FormWindowState.Maximized;
    temp.Show();
    }
    異步呼叫與Form的show是有沖突.
    以上述例子來看,解決方法:
    1. 在public void p_rod052_back(object[] oret1)上面加一行程式:
    public delegate void ShowForm();//定義一個委託
    2. 原public void p_rod052_back(object[] oret1)改為:
    {
    ShowForm call = delegate()
    {
    string repn = "rod052";
    cr070v.Form1 temp = new cr070v.Form1();
    temp.repn = repn;
    temp.MdiParent = this.MdiParent;
    temp.WindowState = FormWindowState.Maximized;
    temp.Show();
    }
    this.Invoke(call);
    }




  • 如何取得並顯示當前登入人數?
    在Server上ServerConfig.UserLoginCount就是當前的登錄人數,可以通過ServerMethod來返回這個值.如:
    Client端
    object[] ret = CliUtils.CallMethod("S001", "GetUserCount", null);
    Label1.Text = ret[1].ToString();
    Server端
    public object[] GetUserCount(object[] param)
    {
    return new object[]{0, ServerConfig.UserLoginCount};
    }