2015年7月22日 星期三

ASP.NET-如何使用CalendarExtender選擇年月

功能需求:日期區間以年月來選 。
參考來源:連結
執行畫面:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="TestOnlyChangeMonthAndSetDefaultDay.aspx.vb"
    Inherits="SoluTest_CalendarUserControl.TestOnlyChangeMonthAndSetDefaultDay" %>


<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        var cal1;
        var cal2;
        function pageLoad() {
            cal1 = $find("calendar1");
            cal2 = $find("calendar2");
            modifyCalDelegates(cal1);
            modifyCalDelegates(cal2);
        }
        function modifyCalDelegates(cal) {
            //we need to modify the original delegate of the month cell.
            cal._cell$delegates = {
                mouseover: Function.createDelegate(cal, cal._cell_onmouseover),
                mouseout: Function.createDelegate(cal, cal._cell_onmouseout),


                click: Function.createDelegate(cal, function(e) {
                    /// <summary>
                    /// Handles the click event of a cell
                    /// </summary>
                    /// <param name="e" type="Sys.UI.DomEvent">The arguments for the event</param>


                    e.stopPropagation();
                    e.preventDefault();


                    if (!cal._enabled) return;


                    var target = e.target;
                    var visibleDate = cal._getEffectiveVisibleDate();
                    Sys.UI.DomElement.removeCssClass(target.parentNode, "ajax__calendar_hover");
                    switch (target.mode) {
                        case "prev":
                        case "next":
                            cal._switchMonth(target.date);
                            break;
                        case "title":
                            switch (cal._mode) {
                                case "days": cal._switchMode("months"); break;
                                case "months": cal._switchMode("years"); break;
                            }
                            break;
                        case "month":
                            //if the mode is month, then stop switching to day mode.
                            if (target.month == visibleDate.getMonth()) {
                                //this._switchMode("days");
                            } else {
                                cal._visibleDate = target.date;
                                //this._switchMode("days");
                            }
                            cal.set_selectedDate(target.date);
                            cal._switchMonth(target.date);
                            cal._blur.post(true);
                            cal.raiseDateSelectionChanged();
                            break;
                        case "year":
                            if (target.date.getFullYear() == visibleDate.getFullYear()) {
                                cal._switchMode("months");
                            } else {
                                cal._visibleDate = target.date;
                                cal._switchMode("months");
                            }
                            break;


                        //                case "day":
                        //                    this.set_selectedDate(target.date);
                        //                    this._switchMonth(target.date);
                        //                    this._blur.post(true);
                        //                    this.raiseDateSelectionChanged();
                        //                    break;
                        case "today":
                            cal.set_selectedDate(target.date);
                            cal._switchMonth(target.date);
                            cal._blur.post(true);
                            cal.raiseDateSelectionChanged();
                            break;
                    }


                })
            }


        }


        function onCalendarShown(sender, args) {
            //set the default mode to month
            sender._switchMode("months", true);
            changeCellHandlers(cal1);
        }




        function changeCellHandlers(cal) {


            if (cal._monthsBody) {


                //remove the old handler of each month body.
                for (var i = 0; i < cal._monthsBody.rows.length; i++) {
                    var row = cal._monthsBody.rows[i];
                    for (var j = 0; j < row.cells.length; j++) {
                        $common.removeHandlers(row.cells[j].firstChild, cal._cell$delegates);
                    }
                }
                //add the new handler of each month body.
                for (var i = 0; i < cal._monthsBody.rows.length; i++) {
                    var row = cal._monthsBody.rows[i];
                    for (var j = 0; j < row.cells.length; j++) {
                        $addHandlers(row.cells[j].firstChild, cal._cell$delegates);
                    }
                }


            }
        }


        function onCalendarHidden(sender, args) {


            if (sender.get_selectedDate()) {
                if (cal1.get_selectedDate() && cal2.get_selectedDate() && cal1.get_selectedDate() > cal2.get_selectedDate()) {
                    alert('The "From" Date should smaller than the "To" Date, please reselect!');
                    sender.show();
                    return;
                }
                //get the final date
                var finalDate = new Date(sender.get_selectedDate());
                var selectedMonth = finalDate.getMonth();
                finalDate.setDate(1);
                if (sender == cal2) {
                    // set the calender2's default date as the last day
                    finalDate.setMonth(selectedMonth + 1);
                    finalDate = new Date(finalDate - 1);
                }
                //set the date to the TextBox
                sender.get_element().value = finalDate.format(sender._format);
            }
        }


    </script>


</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        From :
        <asp:TextBox ID="TextBox1" runat="server" AutoCompleteType="Disabled"></asp:TextBox>
        <cc1:CalendarExtender ID="CalendarExtender1" BehaviorID="calendar1" runat="server"
            Enabled="True" Format="yyyy/MM/dd" TargetControlID="TextBox1" OnClientShown="onCalendarShown"
            OnClientHidden="onCalendarHidden">
        </cc1:CalendarExtender>
        To :
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        <cc1:CalendarExtender ID="CalendarExtender2" BehaviorID="calendar2" runat="server"
            Enabled="True" Format="yyyy/MM/dd" TargetControlID="TextBox2" OnClientShown="onCalendarShown"
            OnClientHidden="onCalendarHidden">
        </cc1:CalendarExtender>
    </div>
    </form>
</body>
</html>

2015年4月14日 星期二

鼎捷-易飛-查詢開窗程式碼

查詢窗口的左下方有序號,依此序號至用戶自定義開窗尋找就可以找的到了。
 


2015年3月17日 星期二

ubuntu下架mrbs

主系統安裝:


  • 透過visual box安裝ubuntu12,試著安裝14發現自己電腦跑不太動,就改安裝12。

需求軟體安裝:


  • 需要phpmyadmin、mysql、apache2
  • 啟動終端機『ctrl+alt+t』
  • $sudo apt-get install lamp-server^
  • $sudo apt-get install php5-gd
  • $sudo apt-get install phpmyadmin

測試:

  • 基本上只要安裝了apache2之後,在ubuntu的瀏灠器網址上打『http://localhost』都會出現『It works』,那代表已經安裝成功了。
  • 接著要測試phpmyadmin有沒有成功可以執行了,就是打上『http://localhost/phpmyadmin』,正常來說大家都會說一次成功,但是我失敗了....

  • 後來找到答案『連結

  • 重新啟動apache2,教學在此『連結
  • Start Apache 2 Server /啟動apache
    # /etc/init.d/apache2 start
    or
    $ sudo /etc/init.d/apache2 start

    Restart Apache 2 Server /重啟apache
    # /etc/init.d/apache2 restart
    or
    $ sudo /etc/init.d/apache2 restart

     Stop Apache 2 Server /停止apache
    # /etc/init.d/apache2 stop
    or
    $ sudo /etc/init.d/apache2 stop
  • 重啟之後再測一下,就連到phpmyadmin了。

  • 到這邊,整個基本的服務算是起來了,如果有需要拿同樣的架構來做不同事的話,可以先把這個vhd檔複製起來放一邊,方便回頭再拿來使用。

安裝mrbs,參考『連結』:

  • 下載mrbs:
    • wget http://jaist.dl.sourceforge.net/project/mrbs/mrbs/MRBS%201.4.11/mrbs-1.4.11.tar.gz
  • 解壓縮:
    • tar zxvf mrbs-1.4.11.tar.gz
  • 複製資料夾到apache執行資料夾
    • cd mrbs-1.4.11 --到資料夾
    • 先進入資料夾修正檔案
    • 家目錄\mrbs-1.4.11\www\config.inc.php
    • 修正:$timezone = "Asian/Taipei";
    • 修正:mysql的參數,你自己懂。
    • cp -r web /var/www/mrbs --複製web這資料夾過去
  • 在mysql內建立一個資料庫『mrbs』
  • 選擇資料庫『mrbs』,將mrbs-1.4.11\table.my.sql匯入執行產生系統資料表
  • 接著開啟瀏灠器『http://localhost/mrsb』就成功登入了。感動!!!!

變更設定(20150322新增):

  • 開啟systemdefualt.inc.pho,這邊可以設定『admin名稱』與『admin的email』、『company name』
  • 當然還有logo可以設定,不過就是看個人需求了。




以上。連結部份皆是本人參考作業的資料來源,只是各取所需以及將所查的資料統一。
感謝網路上的前輩留下資料,讓我可以成功弄起來個系統,也省掉一筆錢!!!
當然公司不會感謝我,哈哈。
再進階的部份還有連結AD的操作,可以參考這篇『連結
小弟先求有,再求好,等有再成功設定的時候再回頭更新文章。