2014年3月29日 星期六

AJAX 強制更新

在Web的應用中,很多人都會使用AJAX來做非同步的資料傳輸,但常常會遇到一個問題,就是我一開始抓取的值,在對資料做變更後,再回到同一頁,資料是沒有變動的,如果關閉瀏覽器,在開啟一次同一頁面,顯示的值就會是最新的值。

原來AJAX會將讀取過的資料CACHE起來,如果每次都要更新的話,請加上下面這一行程式碼。

Context.Response.Cache.SetCacheability(HttpCacheability.NoCache);

2014年1月27日 星期一

【指令】讓代理程式在Server上跑

tell amgr run "資料庫路徑" '代理程式名稱'

資料庫路徑:用雙引號包起來。

代理程式名稱:不能用雙引號,如果有(),也不能加上去。

2014年1月26日 星期日

MySql的Foreign Key

當關聯父資料表的主鍵紀錄行被刪除或修改時,子資料表中紀錄行的處理方式:
CASCADE - 會將有所關聯的紀錄行也會進行刪除或修改。
SET NULL - 會將有所關聯的紀錄行設定成 NULL。
NO ACTION - 有存在的關聯紀錄行時,會禁止父資料表的刪除或修改動作。
RESTRICT - 與 NO ACTION 相同。


參考網站:http://jax-work-archive.blogspot.tw/2007/10/innodb-mysql-foreign-key.html

2014年1月17日 星期五

使用Font類繪製文本(DrawString())

參考連結至:

http://blog.csdn.net/wwwiii520/article/details/2072010

利用Font的類別來定義文的的大小、樣式。

代碼如下:

public partial class Stringformat : Form
    {
        public Stringformat()
        {
            InitializeComponent();

            SetStyle(ControlStyles.Opaque, true);
            Point p = new Point(0, 0);
            Size s = new Size(500, 300);
            //Bounds = new Rectangle(0, 0, 500, 300);
            Bounds = new Rectangle(p, s);//窗體大小及相對於父客體的位置(0,0)
        }
        protected override void OnPaint(PaintEventArgs e)//重定義基類OnPaint()方法
        {
            Graphics g = e.Graphics;
            int y = 0;
            g.FillRectangle(Brushes.White, ClientRectangle);//繪制窗體背景色
            Rectangle rect = new Rectangle(0, y, 400, Font.Height);
            //g.FillRectangle(Brushes.Blue, rect);//墳兗一個矩形
            g.DrawRectangle(Pens.Blue, rect);//繪製一個矩形
            g.DrawString("This text is left justified.", Font, Brushes.Black, rect);
            y += Font.Height + 20;
            //Font.Dispose();//沒有創建對象,無須釋放資源

            Font afont = new Font("Arial", 16, FontStyle.Bold | FontStyle.Italic);
            rect = new Rectangle(0, y, 400, afont.Height);
            g.DrawRectangle(Pens.Blue, rect);
            StringFormat sf = new StringFormat();
            sf.Alignment = StringAlignment.Far;
            g.DrawString("This text is right justified.", afont, Brushes.Blue, rect,sf);
            y += afont.Height + 20;
            afont.Dispose();//創建了對象,須釋放資源

            afont = new Font("Courier Ncw", 12, FontStyle.Underline|FontStyle.Bold);
            rect = new Rectangle(0, y, 400, afont.Height);
            g.DrawRectangle(Pens.Blue, rect);
            sf = new StringFormat();
            sf.Alignment = StringAlignment.Center;
            g.DrawString("This text is centered, and unederlined.", afont, Brushes.Blue, rect, sf);
            y += afont.Height + 20;
            afont.Dispose();

            afont = new Font("Times New Roman", 12);
            rect = new Rectangle(0, y, 400, afont.Height * 3);
            g.DrawRectangle(Pens.Blue, rect);
            string longString = "This text is much longer, and drawn ";
            longString += "into a rectangle that is higher than ";
            longString += "one line,so that it will wrap. It is ";
            longString += "very easy to wrap text using GDI+.";
            g.DrawString(longString, afont, Brushes.Black, rect);
            afont.Dispose();
        }
    }