2015年4月16日 星期四

[jqGrid]讓groupHeaders不重複載入

//從新載入時繼續使用這個GroupHeaders
    $("#list").jqGrid("destroyGroupHeader", false);

    //自訂合併表頭
    jQuery("#list").jqGrid('setGroupHeaders', {
        useColSpanStyle: true,
        groupHeaders: [
          { startColumnName: 'MaleQuantity', numberOfColumns: 2, titleText: '正式學籍之在學學生總人數' }
        ]
    });

2015年3月26日 星期四

[c#]無法存取關閉的檔案

剛剛在主機端發現上傳檔案時會出現
無法存取關閉的檔案
只要在Web.config  system.web中加入
<httpRuntime maxRequestLength="819200" requestLengthDiskThreshold="819200"/>
就可以了

2015年3月13日 星期五

[MVC]使用T-SQL查詢資料

如使用較複雜SQL時,可使用下列方式來處理

命名空間
using System.Data;
using System.Data.SqlClient;

using (xxxEntities db = new xxxEntities())
{
   string  result ="";
   SqlParameter[] p = new SqlParameter[1];
   p[0] = new SqlParameter("@Year", year);
  string sql =
                  @"
                        select count(*) Total from Table
                        where
                        ayear = @Year
                       ";
  result= db.Database.SqlQuery<int>(sql, p).FirstOrDefault();
}

 db.Database.SqlQuery<int> 此Sql統計筆數故使用int型態

捕捉實體資料模型edmx錯誤訊息



try{

}
catch (System.Data.Entity.Validation.DbEntityValidationException ex)
{
                result.Message = ex.Message;
 }

2015年2月25日 星期三

[SQL Server]stored procedure 發送Email

dbmail設定完成後可在stored procedure 下以下發送mail sql
exec msdb.dbo.sp_send_dbmail
@profile_name='test',   --設定檔名稱
@recipients='00@gmail.com', --收件者
@subject='test',  --主旨
@body='test001', --內文
@query='你的條件式',  --查詢條件
--@file_attachments='',  --夾帶檔
@attach_query_result_as_file=0,  -- 值為0:將@query顯示在信件內文 值為1將附加在附件內
@body_format=TEXT    --設定text格式or html格式

2015年1月14日 星期三

[RDLC] RDLC報表檔IIF使用方式

使用IIF 判斷DataSet傳回欄位值傳回True 就顯示 "是",反之顯示"否"

=First(IIF(Fields!IsAll.Value = "True","是","否"), "DataSet1")

2015年1月13日 星期二

[Jquery]尋找元素

<li onclick="SetRoomNumber('209', '雙人房', '');" class="list">
     <span class="fontSize14px fontweight fontColorBlue2">209</span>
     <div class="roomStatusTxt">
             <span class="fontColorBlack">空房</span>
              <span class="fontColorBrown">雙人房</span>
     </div>
</li>

尋找items 下li裡span class = "fontColorBlack"
$("#items").on("click", "li", function (e) {
    $(this).find("span.fontColorBlack").html() ;
});
結果:空房

Visual Studio JS intellisense 失效解決方式

  試了好久,發現到工具>選項>IntelliCode js項目設定啟用,重新開啟VS就正常了! 後來發現是TypeScript3.2版有問題停用,使用4.3版的TypeScript即可