หน้าเว็บ

วันศุกร์ที่ 5 สิงหาคม พ.ศ. 2554

Axapta X++ :: สำหรับให้ถามเพื่อยืนยัน

void clicked()
{
    DialogButton    result;
    ;
    result = Box::yesNo("คุณแน่ใจหรือไม่ ?",DialogButton::No);
    if(result == DialogButton::Yes) {
      // คำสั่งที่จะให้ทำเมื่อผู้ใช้ตอบยืนยัน
    }
    super();
}



หรือใช้คำสั่งแบบไม่ต้องประกาศตัวแปร


if(box::yesNo("Do you want something to happen?",
      dialogbutton::Yes) == dialogbutton::Yes)
   {        
           somethingHappens = this.callTosSomeReturnMethod();
    }

Axapta X++ :: DynamicHeight Replacement

code สำหรับใช้แทน property DynamicHeight ที่มีไว้สำหรับการแสดงผลหลายบรรทัด (เป็น bug ของ axapta) ใน Reports

void executeSection()
{
    ReportStringControl   ctrlBatchReserved   = this.ControlName('batchReserved');
// Control ต้อง set ให้ AutoDeclare ด้วย
    str                   tmpStr;
    int                   i;
    ;
 
    tmpStr = inventJournalTrans.batchReserved(); //มี \n คั่นสำหรับขึ้นบรรทัดใหม่
    while(true){ // วนลูปนับบรรทัด
        i++;
        if(strLine(tmpStr, i) == '') break;
    }
 
    ctrlBatchReserved.height(i,Units::Char); // กำหนดความสูงตามบรรทัดที่นับได้
}

Axapta X++ :: การใช้ตัวแปรใน SQL Statement ของ Axapta

การรับตัวแปรเพิ่มเข้าไปเป็นเงื่อนไขในส่วนของ SQL เช่น รับค่าจาก Dialog แล้วเอามาเติม Wildcard ก่อนที่จะ query
หากใช้ตัวแปรที่เป็น str ธรรมดาจะมี error message
"Container and unbound string (text) fields are not allowed here in a WHERE expression"


แก้ไขได้โดย กำหนดขนาดของ string ให้แน่นอน หรือประกาศเป็น extended datatype ไปเลย
เช่น

WrkCtrIdBase              tmpStr;
//  str 10                     tmpStr;
   ;
 
    tmpStr = strfmt("%1%2",wrkCtrIdBase,"-LA*");
    SELECT sum(Amount) FROM prodRouteTrans WHERE prodRouteTrans.CategoryId LIKE tmpStr;

Axapta X++ :: Get or Set Checkbox Value

ตัวอย่างการตรวจสอบและเซ็ตสถานะของ checkbox ใน Axapta

public void clicked()
{
    Qty     tmpQty1;
    Qty     tmpQty2;
    FormCheckboxControl formCheckboxControl;
    ;
 
    super(); // ต้องรัน super ก่อน ไม่งั้นค่าไม่เปลี่ยน
    formCheckboxControl = element.design().control(control::ProdParmHistoricalCost_EndJob); // รับค่าจาก design
//   box::info(strfmt("%1",formCheckboxControl.value()));
if(formCheckboxControl.value() == 1){ //ถ้า checked จะเป็น 1
    tmpQty1 = ProdTable::find(ProdParmHistoricalCost.ProdId).QtySched;
    tmpQty2 = ProdTableJour::reportedFinishedGood(ProdParmHistoricalCost.prodId);
 
    if(tmpQty1 != tmpQty2){
       if(box::yesNo(strfmt("¨Ó¹Ç¹·Õè reported (%1) < ¨Ó¹Ç¹·Õè ÊÑè§¼ÅÔµ (%2) \n              µéͧ¡ÒôÓà¹Ô¹¡ÒõèÍËÃ×ÍäÁè",tmpQty2,tmpQty1), DialogButton::Yes, "Â×¹Âѹ¡Ò÷ӧҹ") == DialogButton::Yes)
       {
          if(box::yesNo("¤Ø³µéͧ¡ÒÃÂ×¹ÂѹËÃ×ÍäÁè",DialogButton::Yes,"¡ÃسÒÂ×¹Âѹ")== DialogButton::Yes){
            formCheckboxControl.value(true); //สั่งให้ checked
          }else{
            formCheckboxControl.value(false); //สั่งให้  ไม่ checked
          }
       }else{
        formCheckboxControl.value(false);
       }
    }
}
}

Ubuntu เสียบ Lan ใหม่ไม่เจอ Eth0.. Eth1

Ubuntu เสียบ Lan ใหม่ไม่เจอ Eth0.. Eth1
แก้โดยใช้คำสั่งนี้

- You use command sudo nano /etc/udev/rules.d/70-persistent-net.rules

# This file was automatically generated by the /lib/udev/write_net_rules
# program run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single line.

# PCI device 0x8086:0x294c (e1000e)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1c:ff:ff:ff:ff", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

- Delete red color
- Save the file (ctrl-o to write the file, ctrl-x to exit the editor), then reboot.


ที่มา http://ubuntuforums.org/showthread.php?t=955990

วันอังคารที่ 2 สิงหาคม พ.ศ. 2554

PHP : Get Real IP Address

function getRealIpAddr()
{
    if (!empty($_SERVER['HTTP_CLIENT_IP']))   //check ip from share internet
    {
      $ip=$_SERVER['HTTP_CLIENT_IP'];
    }
    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))   //to check ip is pass from proxy
    {
      $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else
    {
      $ip=$_SERVER['REMOTE_ADDR'];
    }
    return $ip;
}
 
 

PHP BB ให้มีเมนู List ด้านข้าง

1.แก้ template ไฟล์ overall_header.html (ใน \styles\prosilver\template\)
1.1 ด้านล่างสุด เพิ่ม
<table id="mainbody"><tr><td id="left_sidebar" valign="top">
<!-- INCLUDE sidebar.html -->
</td><td id="right_column" valign="top">

1.2 ด้านบน ก่อนปิด </head>
<style>
<!--
table#mainbody{ width:100%; }
td#left_sidebar{width:200px;}
//-->
</style>

2.แก้ template ไฟล์ overall_footer.html (ใน \styles\prosilver\template\)
2.1 ด้านบนสุด เพิ่ม  
  </td>
   </tr>
</table>

3.เพิ่ม template ชื่อ sidebar.html (ใน \styles\prosilver\template\) ให้มีโครงสร้างตามนี้
   <div class="panel">
    <div class="inner">
    <span class="corners-top"><span></span></span>
    <h3>Online Services : ฝซร.</h3>
        <li><a href="/sci/mn1_start.php">แจ้งซ่อม Online</a><br />
        <li><a href="/sci/mn1_make_start.php">แจ้งสร้าง Online</a><br />
    <span class="corners-bottom"><span></span></span>
    </div>
</div>