TITLE-TEXT

SHORT DESCRIPTION HERE , ...
title

TITLE-TEXT

SHORT DESCRIPTION HERE , ...
title
ewefr

test

張貼者: Tony

public static string getCASEDPFSEL(string IPROFILE_ID)
{
IDataReader FSEL = selCASEDPFSEL(IPROFILE_ID);
string lsFieldStr = string.Empty;
while (FSEL.Read())
{
lsFieldStr = lsFieldStr + Convert.ToString(FSEL["COLNAME_TX"]) + ",";
}
FSEL.Close();

return lsFieldStr;
}

SyntaxHighlighter使用方法

張貼者: Tony

先找到<b:skin>標籤,在此標籤前加入以下代碼。

<!-- SyntaxHighlighter  3.0.83-->
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/>
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shAutoloader.js' type='text/javascript'/>

再找到</body>標籤,在標籤前加入以下代碼。

<!-- SyntaxHighlighter  3.0.83-->
<script type='text/javascript'>
SyntaxHighlighter.autoloader(
  'applescript            http://alexgorbatchev.com/pub/sh/current/scripts/shBrushAppleScript.js',
  'actionscript3 as3      http://alexgorbatchev.com/pub/sh/current/scripts/shBrushAS3.js',
  'bash shell             http://alexgorbatchev.com/pub/sh/current/scripts/shBrushBash.js',
  'coldfusion cf          http://alexgorbatchev.com/pub/sh/current/scripts/shBrushColdFusion.js',
  'cpp c                  http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js',
  'c# c-sharp csharp      http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js',
  'css                    http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js',
  'delphi pascal          http://alexgorbatchev.com/pub/sh/current/scripts/shBrushDelphi.js',
  'diff patch pas         http://alexgorbatchev.com/pub/sh/current/scripts/shBrushDiff.js',
  'erl erlang             http://alexgorbatchev.com/pub/sh/current/scripts/shBrushErlang.js',
  'groovy                 http://alexgorbatchev.com/pub/sh/current/scripts/shBrushGroovy.js',
  'java                   http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js',
  'jfx javafx             http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJavaFX.js',
  'js jscript javascript  http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js',
  'perl pl                http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js',
  'php                    http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js',
  'text plain             http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPlain.js',
  'py python              http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js',
  'ruby rails ror rb      http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js',
  'sass scss              http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSass.js',
  'scala                  http://alexgorbatchev.com/pub/sh/current/scripts/shBrushScala.js',
  'sql                    http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js',
  'vb vbnet               http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js',
  'xml xhtml xslt html    http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js'
);
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all()
</script>




<pre class="brush: 語言名稱" title="標題名稱">
    程式碼打在這裡
</pre>


C#-Array.Exists(arrays,match) match泛行的寫法

張貼者: Tony

方法一

string name = "Jack6";

        protected void Page_Load(object sender, EventArgs e)
        {
           
            string[] names = new string[] {"Jack","Jucy","Michael","Antony" };

            bool IsExist = Array.Exists(names, match);

            Response.Write(IsExist.ToString());
        }

        public  bool match(string nameArray) {
            return nameArray == name;
        }

方法二
string name = "Jack6";

        protected void Page_Load(object sender, EventArgs e)
        {
           
            string[] names = new string[] {"Jack","Jucy","Michael","Antony" };

            bool IsExist = Array.Exists(names,
                                                                 (string value)=>
                                                                  {
                                                                        return value == name;
                                                                   }
                                                       );

            Response.Write(IsExist.ToString());
        }

方法三
string name = "Jack6";

        protected void Page_Load(object sender, EventArgs e)
        {
           
            string[] names = new string[] {"Jack","Jucy","Michael","Antony" };

            bool IsExist = Array.Exists(names, x=>x.Equals(name));
            Response.Write(IsExist.ToString());
        }

C#-Guid格式

張貼者: Tony

var guid = Guid.NewGuid();

// 10244798-9a34-4245-b1ef-9143f9b1e68a
Console.WriteLine(guid.ToString("D"));

// 102447989a344245b1ef9143f9b1e68a
Console.WriteLine(guid.ToString("N"));

// {10244798-9a34-4245-b1ef-9143f9b1e68a}
Console.WriteLine(guid.ToString("B"));

// (10244798-9a34-4245-b1ef-9143f9b1e68a)
Console.WriteLine(guid.ToString("P"));

C#-字串操作

張貼者: Tony

字串陣列宣告

string[] array = new string[] { "A""B""C""D""E" }; 
string[] array = "A""B""C""D""E" }; 

字串轉字串陣列、字串陣列轉字串

string[] d = "1,2,3".Split(',');
string f = String.Join(",", d);

字串陣列轉List
List<string> listStr = new List<string>(array);

字串陣列委派
var days = Array.FindAll(array,match);

public static bool match(string str)
{
if (str == "A")
return true;
if (str == "B")
return true;

return false;
}  

List委派
var days = listStr.FindAll(match);

public static bool match(string str)
{
if (str == "A")
return true;
if (str == "B")
return true;

return false;
} 

C#-delegate調用範例

張貼者: Tony

委派調用1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleAP
{
    class MulticastTester
    {
         delegate void Greeting();


        public static void main()
        {

            Greeting SayHello = new Greeting(SayHelloGo);
            Greeting SayHi = new Greeting(SayHiGo);
            Greeting SayHelloAndHi = SayHello + SayHi;
            Greeting SayBye = new Greeting(SayByeGo);

            SayHi();
            SayHello();
            SayHelloAndHi();

            SayHelloAndHi += SayBye;
            SayHelloAndHi += SayHello;
            SayHelloAndHi += SayHello;
            SayHelloAndHi();
            Console.WriteLine("-----------------------------");
            SayHelloAndHi -= SayHello;
            SayHelloAndHi -= SayHello;
            SayHelloAndHi();


            Console.ReadKey();
        }


        public static void SayHelloGo() {
            Console.WriteLine("Hello!");
        }

        public static void SayHiGo() {
            Console.WriteLine("Hi!");
        }

        public static void SayByeGo() {
            Console.WriteLine("Bye!");
        }

    }
}

委派調用2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleAP
{
    class delegateTest
    {
        public delegate int mydelegate(int i,int j);

        public static void Main()
        {
            mydelegate AddGo = new mydelegate(Add);
            Console.WriteLine("9+1=");
            Console.WriteLine(AddGo(9,1).ToString());

            mydelegate SubGo = new mydelegate(Sub);
            Console.WriteLine("9-1=");
            Console.WriteLine(SubGo(9, 1).ToString());


            Console.ReadKey();
        }

        public static int Add(int i,int j){
            return i + j;
        }

        public static int Sub(int i, int j) {
            return i - j;
        }

    }
}

C#語法 Word轉Pdf、合併Word、下載MS檔案

張貼者: Tony

這個要先加入Microsoft.Office.Interop.Word參考
using Word = Microsoft.Office.Interop.Word;
using System.Reflection;//這個記得參考


Word轉Pdf
public static bool ConvertWordtoPdf(object WoldFilePath, object PdfFilePath)
{
// 在此处放置用户代码以初始化页面
object Missing = Type.Missing;
Word.Application WordApp = new Microsoft.Office.Interop.Word.Application();
//必须设置为不可见
WordApp.Visible = false;
try
{
//Document doc = new Document(WoldFilePath.ToString());
//doc.Save(PdfFilePath.ToString());
//创建以strTemp为模板的文档
//object oTemplate = Server.MapPath(strTemp);

Word.Document WordDoc = WordApp.Documents.Add(ref WoldFilePath, ref Missing, ref Missing, ref Missing);
WordDoc.Activate();

//对标签"Title"进行填充
//string strBM = "Title";
//object objBM = strBM;
//if (WordApp.ActiveDocument.Bookmarks.Exists(strBM) == true)
//{
// WordApp.ActiveDocument.Bookmarks.get_Item(ref objBM).Select();
// WordApp.Selection.TypeText("公文標題");
//}

object FileFormat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatPDF;
//保存为新文件
//object oNewFileName = Server.MapPath(newFileName);
WordDoc.SaveAs(ref PdfFilePath, FileFormat, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing,
ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing);
WordDoc.Close(ref Missing, ref Missing, ref Missing);
WordApp.Quit(ref Missing, ref Missing, ref Missing);
return true;
}

catch (Exception e)
{
MessageBox.Show(e.Message.ToString());
return false;

}
}

合併Word
public static bool MergeWord(string[] InFilePath,string OutFilePath)
{
try
{
object missing = Missing.Value;
object iLastWord = InFilePath.Last();//最後合併的word
object oOutputDoc = OutFilePath;//合併檔
object oPageBreak = Word.WdBreakType.wdSectionBreakContinuous;
//object oPageBreak = Word.WdBreakType.wdLineBreak;//接下行合併(LineBreak)
//object oPageBreak = Word.WdBreakType.wdPageBreak;//接下頁合併(PageBreak)

Word.Application wordApp = new Word.Application();

Word.Document origDoc = wordApp.Documents.Open(ref iLastWord, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
origDoc.Activate();

for (int i = 0; i < InFilePath.Count();i++)
{
if (i == (InFilePath.Count() - 1) || InFilePath.Count() == 0)
break;
wordApp.Selection.InsertFile(InFilePath[i], ref missing, ref missing, ref missing, ref missing);
wordApp.Selection.InsertBreak(ref oPageBreak);
}

wordApp.ActiveDocument.SaveAs(ref oOutputDoc, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
wordApp.ActiveDocument.Close(ref missing, ref missing, ref missing);
wordApp.Quit(ref missing, ref missing, ref missing); //加這行可以 Kill WINWORD.EXE process

return true;
}
catch
{
return false;
}
}

下載MS檔案
public static bool DownloadFile(string FilePath,string NewFileName, HttpResponse response)
{
try
{
FileInfo DownloadFile = new FileInfo(FilePath);
response.Clear();
response.ClearHeaders();
response.Buffer = false;
//Response.ContentType指定檔案類型
//可以為application/ms-excel || application/ms-word || application/ms-txt
//application/ms-html || 或其他瀏覽器可以支援的文件
response.ContentType = "application/octet-stream";//所有類型
//下面這行很重要, attachment 参数表示作為附件下載,可以改成 online線上開啟
//filename=FileFlow.xls 指定输出檔案名稱,注意其附檔名和指定檔案類型相符,
//可以為:.doc || .xls || .txt ||.htm
response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(NewFileName, System.Text.Encoding.UTF8));
response.AppendHeader("Content-Length", DownloadFile.Length.ToString());//取得檔案大小

response.WriteFile(DownloadFile.FullName);
response.Flush();
response.End();

return true;
}
catch
{
return false;
}
}

C# Dictionary用法

張貼者: Tony

 參考文章

Dictionary宣告
Dictionary<string, string> mydic = new Dictionary<string, string>();

.ContainsKey(TKey)用來判斷Key是否存在
mydic.ContainsKey(TKey)

取值的時候,使用foreach(KeyValuePair<string, string> pair in mydic)
foreach (KeyValuePair<string, string> pair in _ratedic)
{
TextBox1.Text = pair.Value.ToString(); //取Value
TextBox2.Text = pair.Key.ToString(); //取Key
}

物件導向相關文章

張貼者: Tony

CSharp語法 下載Word 合併Word Word轉Pdf

張貼者: Tony

using Word = Microsoft.Office.Interop.Word;//這個要先加入Microsoft.Office.Interop.Word參考 
using System.Reflection;//這個記得參考 

下載Word
/// <summary>
        /// 下載Word
        /// </summary>
        /// <param name="FilePath"></param>
        /// <param name="FileName"></param>
        /// <param name="response"></param>
        /// <returns></returns>
        public static bool DownloadWord(string FilePath, string FileName, HttpResponse response)
        {
            try
            {
                FileInfo DownloadFile = new FileInfo(FilePath + FileName);
                response.Clear();
                response.ClearHeaders();
                response.Buffer = false; 
                 //Response.ContentType指定檔案類型  
                 //可以為application/ms-excel || application/ms-word || application/ms-txt  
                 //application/ms-html || 或其他瀏覽器可以支援的文件 
                response.ContentType = "application/octet-stream";//所有類型 
                 //下面這行很重要, attachment 参数表示作為附件下載,可以改成 online線上開啟 
                 //filename=FileFlow.xls 指定输出檔案名稱,注意其附檔名和指定檔案類型相符, 
                 //可以為:.doc || .xls || .txt ||.htm 
                response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8));
                response.AppendHeader("Content-Length", DownloadFile.Length.ToString());//取得檔案大小 

                response.WriteFile(DownloadFile.FullName);
                response.Flush();
                //response.End();


                return true;
            }
            catch
            {
                return false;
            }

        }


合併多個Wold
/// <summary>
        /// 合併多個Wold
        /// </summary>
        /// <param name="InFilePath"></param>
        /// <param name="OutFilePath"></param>
        /// <returns></returns>
        public static bool MergeWord(string[] InFilePath,string OutFilePath)
        {
            try
            {
                object missing = Missing.Value; 
                object iLastWord = InFilePath.Last();//最後合併的word
                object oOutputDoc = OutFilePath;//合併檔 
                object oPageBreak = Word.WdBreakType.wdSectionBreakContinuous;
                //object oPageBreak = Word.WdBreakType.wdLineBreak;//接下行合併(LineBreak) 
                //object oPageBreak = Word.WdBreakType.wdPageBreak;//接下頁合併(PageBreak) 

                Word.Application wordApp = new Word.Application();

                Word.Document origDoc = wordApp.Documents.Open(ref iLastWord, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
                origDoc.Activate();
              
                for (int i = 0; i < InFilePath.Count();i++)
                {
                    if (i == (InFilePath.Count() - 1) || InFilePath.Count() == 0)
                        break;
                    wordApp.Selection.InsertFile(InFilePath[i], ref missing, ref missing, ref missing, ref missing);
                    wordApp.Selection.InsertBreak(ref oPageBreak);
                }

                wordApp.ActiveDocument.SaveAs(ref oOutputDoc, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); 
                wordApp.ActiveDocument.Close(ref missing, ref missing, ref missing); 
                wordApp.Quit(ref missing, ref missing, ref missing);    //加這行可以 Kill WINWORD.EXE process 

                return true;
            }
            catch
            {
                return false;
            }
        }


Word轉Pdf
/// <summary>
        /// Word轉Pdf
        /// </summary>
        /// <param name="WoldFilePath">Wold路徑</param>
        /// <param name="PdfFilePath">Pdf路徑</param>
        public static bool ConvertWordtoPdf(object WoldFilePath, object PdfFilePath)
        {

            // 在此处放置用户代码以初始化页面
            object Missing = Type.Missing;

            Word.Application WordApp = new Microsoft.Office.Interop.Word.Application();

            //必须设置为不可见
            WordApp.Visible = false;

            try
            {

                //创建以strTemp为模板的文档
                //object oTemplate = Server.MapPath(strTemp);
                Word.Document WordDoc = WordApp.Documents.Add(ref WoldFilePath, ref Missing, ref Missing, ref Missing);
                WordDoc.Activate();


                //对标签"Title"进行填充
                //string strBM = "Title";
                //object objBM = strBM;

                //if (WordApp.ActiveDocument.Bookmarks.Exists(strBM) == true)
                //{
                //    WordApp.ActiveDocument.Bookmarks.get_Item(ref objBM).Select();
                //    WordApp.Selection.TypeText("公文標題");
                //}

                object FileFormat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatPDF;

                //保存为新文件
                //object oNewFileName = Server.MapPath(newFileName);
                WordDoc.SaveAs(ref PdfFilePath, FileFormat, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing,
                ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing);
                WordDoc.Close(ref Missing, ref Missing, ref Missing);
                WordApp.Quit(ref Missing, ref Missing, ref Missing);

                return true;
            }
            catch
            {
                return false;
            }

        }
        #endregion

    }

ASP.NET 前端寫C#

張貼者: Tony

<dx:ASPxImage ID="ASPxImage1"
     ImageUrl='<%#Convert.ToInt32(Eval("ORDER_NM")) == 2 ?  "~/Manager/images/b1.gif" : "" %>'
     Visible='<%#Convert.ToInt32(Eval("ORDER_NM")) == 2 ?  true : false %>'
     runat="server">
</dx:ASPxImage>

在Windows 7「命令提示字元」使用「telnet」指令

張貼者: Tony

在預設的情況下,使用Windows 7 「命令提示字元」是不能無法下「telnet」指令的。
因此要先對Windows 7 做開啟「telnet」指令的動作,如下:
(1) 開啟「控制台」
(2) 在「程式集」項目下,點選「解除安裝程式」
(3) 點選左側「開啟或關閉Windows功能」
(4) 對「Telnet 用戶端」打勾

使用Gmail當作寄信主機

張貼者: Tony

using System.Net;

c#
---------------------------------------------------------------------------------------
string fromEmail = "service@gmail.com";
string fromName = "Manager";
MailAddress from = new MailAddress(fromEmail, fromName, Encoding.UTF8);
string toEmail = "tony1017888@gmail.com";
MailMessage mail = new MailMessage(from, new MailAddress(toEmail));
 string subject = "Test Subject";
 mail.Subject = subject;
 mail.SubjectEncoding = Encoding.UTF8;
 string body = "Test Body";
 mail.Body = body;
 mail.BodyEncoding = Encoding.UTF8;
 mail.IsBodyHtml = false;
 mail.Priority = MailPriority.High;
  // SMTP Setting
  SmtpClient client = new SmtpClient();
  client.Host = "smtp.gmail.com";
  client.Port = 587;
  client.Credentials = new NetworkCredential("username@gmail.com", "password");
  client.EnableSsl = true;
  // Send Mail
  client.Send(mail);
  // Sent Compeleted Eevet
   //client.SendCompleted += new SendCompletedEventHandler(client_SendCompleted);

CSS學習 樣式表

張貼者: Tony

ime-mode: disabled;   限定只能輸入英文
letter-spacing:1px;       字距




參考網址
常用基本CSS設定

Razor view-engine 用法

張貼者: Tony

Code First - Membership

張貼者: Tony

使用.NET內建產生的Membership,雖然也能做會員管理,
可是會產生一個新的資料庫,以下範例也是簡單的會員管理,
比較容易與自己建造的資料庫作結合。
Code First EF 4.1 with the Altairis Membership/Role Provider

MVC 3 New Master Page Layout

張貼者: Tony

MVC3 全新master page的設計與方法
祥解ASP.NET MVC 3 新的Layout布局系統

Database First、Model First、Code First

張貼者: Tony

Database First、Model First、Code First 三種開發模式

Database First 詳細介紹

Code First 詳細介紹
1.利用Code產生資料庫
2.自訂欄位屬性參考文章
補充要使用Data annotations
必須先引用 System.ComponentModel.DataAnnotations
3.CodeFirst利用SQL-CE產生資料庫
在Web.config字串為
<connectionStrings>
    <add name="ApplicationDB" connectionString="DataSource=|DataDirectory|ApplicationDB.sdf" providerName="System.Data.SqlServerCe.4.0" />
 </connectionStrings>

Nuget

張貼者: Tony

Nuget 套件管理工具
在使用 Visual Studio 2010 開發專案的過程中隨時安裝、更新套件,像是 jQuery, ELMAH, log4net, … 等等目前共有上千種套件可供選擇。

使用方法可參考以下網址有詳細的文章介紹
1.保哥的論壇介紹基本安裝使用
2.介紹Nuget在傳統ASP.NET下使用

The Will Will Web

技術分享
MVP版主

重灌狂人

資訊分享

wowboxBlog

提供網頁設計相關資訊

KingKong Bruce記事

技術分享

C# Examples

csharp相關技術與範例

黑暗執行緒

技術分享
MVP版主

杨延成

技術分享
作者文章對於EF有詳細介紹

月光下的嘆息

工具分享
介紹許多好用的工具程式

Dot blogs

DotNet

格子樑/艾倫郭

技術分享
MVP版主