方式:
http://www.pureexample.com/tw/jquery/cross-domain-ajax.html
可能的問題:
http://jsgears.com/thread-2369-1-1.html
http://blog.toright.com/posts/3205/%E5%AF%A6%E4%BD%9C-cross-origin-resource-sharing-cros-%E8%A7%A3%E6%B1%BA-ajax-%E7%99%BC%E9%80%81%E8%B7%A8%E7%B6%B2%E5%9F%9F%E5%AD%98%E5%8F%96-request.html
其他:
https://code.google.com/p/chromium/issues/detail?id=321241
2014年9月29日 星期一
2014年7月10日 星期四
{JavaScript} Close 畫面 並將父畫面Reload
Close 畫面 並將父畫面Reload
Script:
window.opener.location.reload();
window.close();
C# 編寫JavaScript 語法
//直接關閉視窗
public void Close()
{
Page p = (Page)System.Web.HttpContext.Current.Handler;
ClientScriptManager CSM = p.ClientScript;
String ScriptName = "close";
String ScriptMsg = "window.opener.location.reload();window.close();";
Type CsType = p.GetType();
if (!CSM.IsStartupScriptRegistered(CsType, ScriptName))
{
CSM.RegisterStartupScript(CsType, ScriptName, ScriptMsg, true);
}
}
參考資訊:
http://stackoverflow.com/questions/19027959/how-to-refresh-parent-page-after-closing-popup-window-in-javascript
Script:
window.opener.location.reload();
window.close();
C# 編寫JavaScript 語法
//直接關閉視窗
public void Close()
{
Page p = (Page)System.Web.HttpContext.Current.Handler;
ClientScriptManager CSM = p.ClientScript;
String ScriptName = "close";
String ScriptMsg = "window.opener.location.reload();window.close();";
Type CsType = p.GetType();
if (!CSM.IsStartupScriptRegistered(CsType, ScriptName))
{
CSM.RegisterStartupScript(CsType, ScriptName, ScriptMsg, true);
}
}
參考資訊:
http://stackoverflow.com/questions/19027959/how-to-refresh-parent-page-after-closing-popup-window-in-javascript
2014年4月21日 星期一
{LInq} Linq 方法。 最後新增日期:4/21
1.Except
譯:二陣列中,前有,後者沒有的
Ex:
var a=[1,2,3];
var b=[2,3];
a.Except(b); Result=1;
參考資訊:http://www.cnblogs.com/626498301/archive/2011/02/24/1963413.html
2.Zip
譯:二個相同長度陣列串連成一個;如不同長度,以最短長度為準
Ex:
var a=[1,2,3];
var b=[2,3,4];
a.Zip(b,(f,s)=>f+s); Result=[3,5,7]
參考資訊:http://msdn.microsoft.com/zh-tw/library/dd267698(v=vs.100).aspx
http://www.cnblogs.com/fox23/archive/2009/12/14/zip-operator-in-csharp4-vs-python3.html
譯:二陣列中,前有,後者沒有的
Ex:
var a=[1,2,3];
var b=[2,3];
a.Except(b); Result=1;
參考資訊:http://www.cnblogs.com/626498301/archive/2011/02/24/1963413.html
2.Zip
譯:二個相同長度陣列串連成一個;如不同長度,以最短長度為準
Ex:
var a=[1,2,3];
var b=[2,3,4];
a.Zip(b,(f,s)=>f+s); Result=[3,5,7]
參考資訊:http://msdn.microsoft.com/zh-tw/library/dd267698(v=vs.100).aspx
http://www.cnblogs.com/fox23/archive/2009/12/14/zip-operator-in-csharp4-vs-python3.html
{LInQ} 做Dictionary、Distinct ... 多屬性為Key 比對其Class覆寫方法
如需要將多個屬性做為Key供判斷,需要另外覆寫 Equals()與 GetHashCode() 才能達到判斷是否相同的結果....
public class InventoryWODetail
{
public int SOItemId { set; get; }
public string CPSPN { set; get; }
public string WONo { set; get; }
public int WOTotalQty { set; get; }
public int WOCloseQty { set; get; }
public int WOOpenQty { set; get; }
public string CPSSONo { set; get; }
public string CPSSOPlannedShipDate { set; get; }
public string WOPlannedClose { set; get; }
public override bool Equals(object obj)
{
if (!(obj is InventoryWODetail))
return false;
else
{
InventoryWODetail other = obj as InventoryWODetail;
return (other.SOItemId == this.SOItemId && other.CPSPN == this.CPSPN && other.WONo == this.WONo && other.WOTotalQty == this.WOTotalQty
&& other.WOCloseQty == this.WOCloseQty && other.WOOpenQty == this.WOOpenQty && other.CPSSONo == this.CPSSONo && other.CPSSOPlannedShipDate == this.CPSSOPlannedShipDate
&& other.WOPlannedClose == this.WOPlannedClose);
}
}
public override int GetHashCode()
{
return string.Format("{0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} ", this.SOItemId, this.CPSPN, this.WONo, this.WOTotalQty, this.WOCloseQty, this.WOOpenQty, this.CPSSONo, this.CPSSOPlannedShipDate, this.WOPlannedClose).GetHashCode();
}
}
參考資訊:http://www.cnblogs.com/626498301/archive/2011/02/24/1963413.html
public class InventoryWODetail
{
public int SOItemId { set; get; }
public string CPSPN { set; get; }
public string WONo { set; get; }
public int WOTotalQty { set; get; }
public int WOCloseQty { set; get; }
public int WOOpenQty { set; get; }
public string CPSSONo { set; get; }
public string CPSSOPlannedShipDate { set; get; }
public string WOPlannedClose { set; get; }
public override bool Equals(object obj)
{
if (!(obj is InventoryWODetail))
return false;
else
{
InventoryWODetail other = obj as InventoryWODetail;
return (other.SOItemId == this.SOItemId && other.CPSPN == this.CPSPN && other.WONo == this.WONo && other.WOTotalQty == this.WOTotalQty
&& other.WOCloseQty == this.WOCloseQty && other.WOOpenQty == this.WOOpenQty && other.CPSSONo == this.CPSSONo && other.CPSSOPlannedShipDate == this.CPSSOPlannedShipDate
&& other.WOPlannedClose == this.WOPlannedClose);
}
}
public override int GetHashCode()
{
return string.Format("{0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} ", this.SOItemId, this.CPSPN, this.WONo, this.WOTotalQty, this.WOCloseQty, this.WOOpenQty, this.CPSSONo, this.CPSSOPlannedShipDate, this.WOPlannedClose).GetHashCode();
}
}
參考資訊:http://www.cnblogs.com/626498301/archive/2011/02/24/1963413.html
2014年4月9日 星期三
{CSS} !important 用法
加上!important 有最高有優先權
.ui-state-disabled { cursor: default !important; }
.ui-state-disabled { cursor: }
同時在page 的Css 相同命名下,有!important則有較高的被用權利
參考資料:
http://note.tc.edu.tw/598.html
.ui-state-disabled { cursor: default !important; }
.ui-state-disabled { cursor: }
同時在page 的Css 相同命名下,有!important則有較高的被用權利
參考資料:
http://note.tc.edu.tw/598.html
{Javascript} 從檔案路徑取檔案名稱
var type=url.match(/[^\/.]+$/gi);
g 比對多次
i 忽略字元的大小寫
m 多行(^與$能比對行末字元)
參考資料:
http://carlos-studio.com/2013/09/12/%E6%AD%A3%E8%A6%8F%E9%81%8B%E7%AE%97%E5%BC%8Fregular-expression/
g 比對多次
i 忽略字元的大小寫
m 多行(^與$能比對行末字元)
參考資料:
http://carlos-studio.com/2013/09/12/%E6%AD%A3%E8%A6%8F%E9%81%8B%E7%AE%97%E5%BC%8Fregular-expression/
{JQuery} 圖片上傳前先預覽--連結
http://sundoctor.iteye.com/blog/1943278
http://www.blueshop.com.tw/board/FUM20041006152641OLG/BRD20100429165520ZQ2.html
http://www.cnblogs.com/sooj/archive/2013/04/25/3041862.html
http://support.microsoft.com/kb/294714/zh-tw
http://avnpc.com/pages/single-file-upload-component-by-jquery-file-upload
http://www.dotblogs.com.tw/cross/archive/2010/09/21/17840.aspx
Funcion 回傳 <img> Tag Html
http://www.blueshop.com.tw/board/FUM20041006152641OLG/BRD20100429165520ZQ2.html
http://www.cnblogs.com/sooj/archive/2013/04/25/3041862.html
http://support.microsoft.com/kb/294714/zh-tw
http://avnpc.com/pages/single-file-upload-component-by-jquery-file-upload
http://www.dotblogs.com.tw/cross/archive/2010/09/21/17840.aspx
Funcion 回傳 <img> Tag Html
imgdiv=$('<div id="imgDiv"> </div>')
imgScaling(fileuploadControl,imgdiv);
function imgScaling(slave, imgDiv) {
var maxsize = 4096;
var version = parseInt($.browser.version, 10);
var returnValue = '';
if (slave.value) {
if ($.browser.msie && version < 10) {
if (version == 6) {
var image = new Image();
image.onload = function () {
if ((image.fileSize / 1024) > maxsize) {
alert('圖片大小不能超過' + maxsize + 'K');
return false;
}
}
image.src = 'file:///' + slave.value;
imgDiv = createImg(imgDiv);
imgDiv.attr('src', image.src);
returnValue= imgDiv[0].outerHTML;
// imgDiv = autoScaling(imgDiv);
} else {
//IE8版本 用DXImageTransform.Microsoft.AlphaImageLoader 一直失敗
imgDiv.html('');
slave.select();
var img = document.selection.createRange().text;
var image = new Image();
image.onload = function () {
if ((image.fileSize / 1024) > maxsize) {
alert('圖片大小不能超過' + maxsize + 'K');
return false;
}
}
image.src = img;
try {
var v = String(slave.value || '');
var temp = v.match(/[^\/\\]+$/gi);
imgDiv.append(temp[0]);
returnValue=temp[0];
//imgDiv.css({ "-ms-filter": "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=image,src=" + img + ")" });
// imgDiv.get(0).filters.item("DXImageTransform.Microsoft.AlphaImageLoader").sizingMethod = "image";
// imgDiv.get(0).filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = img;
// var aa = imgDiv;
} catch (e) {
alert("無效的圖片文件!");
return false;
}
}
}
else {
try {
var file = null;
var size = 0;
if (slave.files && slave.files[0]) {
file = slave.files[0];
size = file.size;
} else if (slave.files && slave.files.item(0)) {
file = slave.files.item(0);
size = file.fileSize;
}
if ((size / 1024) > maxsize) {
alert('圖片大小不能超過' + maxsize + 'K');
return false;
}
imgDiv = createImg(imgDiv);
//Firefox 因安全性問題已無法直接通過input[file].value 獲取完整的文件路徑
try {
//Firefox7.0 以下
imgDiv.attr('src', file.getAsDataURL());
} catch (e) {
//Firefox8.0以上
imgDiv.attr('src', window.URL.createObjectURL(file));
}
imgDiv.css({ "vertical-align": "middle" });
returnValue=imgDiv[0].outerHTML;
} catch (e) {
//支持html5的瀏覽器,比如高版本的firefox、chrome、ie10
if (slave.files && slave.files[0]) {
if ((slave.files[0].size / 1024) > maxsize) {
alert('圖片大小不能超過' + maxsize + 'K');
return false;
}
var reader = new FileReader();
reader.onload = function (e) {
imgDiv.attr('src', e.target.result);
};
reader.readAsDataURL(slave.files[0]);
returnValue=imgDiv[0].outerHTML;
}
};
}
}
return returnValue;
}
function createImg(imgDiv) {
imgDiv.html('');
var img = $("<img />");
imgDiv.replaceWith(img);
imgDiv = img;
imgDiv.width(90);
imgDiv.height(110);
return imgDiv;
}
2014年3月26日 星期三
{C#} 預約系統 -時間判斷某一天預約時間區間是否衝突
下列判斷方式需為同一天的時間區間
參考資料:
http://bibby.be/2008/07/blog-post_10.html
//目前起始時間是否大於目前終止時間
if (!(start >= end))
{
var tempDate = start.ToShortDateString();
//目前的起始時間到終止期間有連續多天欲預約
//ex:2014/03/26 10:00~2014/03/27 10:00
if(start.ToShortDateString()!=end.ToShortDateString())
{
var tempStart = start;
// 一天一天的比對
while (tempStart <= end)
{
var tempSource = call funcion(tempStart.ToShortDateString());//資料庫已預約完成某一天的資料
if (tempSource.Count() > 0)
{
//時分秒是否衝突
var queryCount = tempSource.Any(s => s.StartDate < end && s.EndDate > tempStart);
if (queryCount && !result) { result = true; msg = "預約時段衝突"; break; }
//完全相同---為安全確保而多寫的
queryCount = tempSource.Any(s => s.StartDate == start && s.EndDate == tempStart);
if (queryCount && !result) { result = true; msg = "預約時段衝突"; break; }
}
tempStart = tempStart.AddDays(1);
}
}
//目前起始時間小於當下
else if (start < now)
{
result = true;//起始日小於現在
msg = "預約時間已過期, 請更改預約時間";
}
//目前結束時間小於當下
else if(end <now)
{
result = true;//結束時間小於當下
msg = "預約時間已過期, 請更改預約時間";
}
else
{
//目前的起始時間到終止期間有同一日時間區間預約
//ex:2014/03/26 10:00~2014/03/26 18:00
var source =call funcion();//資料庫已預約完成的全部資料
if (source.Count() > 0)
{
var queryCount = source.Any(s => s.StartDate < end && s.EndDate > start);
if (queryCount && !result) { result = true; msg = "預約時段衝突"; }
//完全相同
queryCount = source.Any(s => s.StartDate == start && s.EndDate == start);
if (queryCount && !result) { result = true; msg = "預約時段衝突"; }
}
}
}
else{
result = true;//起始大於終止
msg = "開始時間不可大於結束時間";
}
}
else
{
result = true;
msg = "預約資訊異常-起始日為空、終止日為空、無此設備";
}
參考資料:
http://bibby.be/2008/07/blog-post_10.html
{JQuery} BlockUI 網頁遮罩-鎖畫面
Post back:
參考資訊:
http://malsup.com/jquery/block/
http://blog.hellocode.info/2012/11/jquery-blockui.html
http://jerry459tw.pixnet.net/blog/post/33689453-~-%E7%84%A1%E6%B3%95-unblockui-%E7%9A%84%E6%99%82%E5%80%99%E8%A9%B2%E6%80%8E%E8%BE%A6-~
$(function(){
$("#FormId").submit(function () {
$.blockUI();
});
});
Ajax:
$.blockUI();
$('#MainDiv').AdminViewer();
//有時會失效
$.unblockUI();
//另一解法--但畫面會被鎖住,畫面上的下拉、文字方塊等控制項將無法被再度使用
$(".blockUI").fadeOut("slow");
參考資訊:
http://malsup.com/jquery/block/
http://blog.hellocode.info/2012/11/jquery-blockui.html
http://jerry459tw.pixnet.net/blog/post/33689453-~-%E7%84%A1%E6%B3%95-unblockui-%E7%9A%84%E6%99%82%E5%80%99%E8%A9%B2%E6%80%8E%E8%BE%A6-~
訂閱:
文章 (Atom)