目前分類:C# Net (95)

瀏覽方式: 標題列表 簡短摘要

費氏數列 依據維基所說的,印出的結果如下
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233……

    protected void Page_Load(object sender, EventArgs e)
    {
        int Num = 10;

文章標籤

Roger 發表在 痞客邦 留言(0) 人氣()

放在網頁
        <asp:GridView ID="GridView1" runat="server" OnPageIndexChanging="GridView1_PageIndexChanging" AllowPaging="True" AutoGenerateColumns="False">
            <Columns>
                <asp:TemplateField HeaderText="學號">
                    <ItemTemplate>

文章標籤

Roger 發表在 痞客邦 留言(0) 人氣()

        題目:輸入100~999的數字,將每一個數字拆開來並做加、減、乘的計算,將結果顯示畫面上。例: 984 加:9+8+4=21


        int intMath = 548;

        // 將個位數、十位數、百位數拆開來
        int a = intMath / 100;

Roger 發表在 痞客邦 留言(0) 人氣()

        Label1.Text = "";
        int intThisMoney = Convert.ToInt32(TextBox1.Text.Trim());
        int[] MoneyTypes = { 2000, 1000, 500, 200, 100, 50, 10, 5, 1 };
        string strMessage = "";
        for (int i = 0; i < MoneyTypes.Length; i++)

文章標籤

Roger 發表在 痞客邦 留言(0) 人氣()

題目: 輸入一個數字,判斷是不是質數

        Label1.Text = "";
        int number = Convert.ToInt32(TextBox1.Text.Trim());
        int aa = 0;
        for (int i = 1; i <= number; i++)

文章標籤

Roger 發表在 痞客邦 留言(0) 人氣()

        // 輸入一個數子,列出1到此數字的所有質數
        Label1.Text = "";
        int number = Convert.ToInt32(TextBox1.Text.Trim());
        int aa = 1;
        for (int i = 2; i <= number; i++)

文章標籤

Roger 發表在 痞客邦 留言(0) 人氣()

        int num_while = 0;
        while (num_while < 50)
        {
            num_while++;
        }

文章標籤

Roger 發表在 痞客邦 留言(0) 人氣()

        for (int ii =0 ;ii <GridView1.Rows.Count ;ii++)
        {
            // 取的 GridView 第ii行,第一列的值
            string strValue = GridView1.Rows[ii].Cells[0].Text.ToString().Trim();
            // 抓取 GridView 內元件的值

文章標籤

Roger 發表在 痞客邦 留言(0) 人氣()

    DataTable table = new DataTable();
    table.Columns.Add("Weight", typeof(int));
    table.Columns.Add("Name", typeof(string));
    table.Columns.Add("Breed", typeof(string));
    table.Columns.Add("Date", typeof(DateTime));

文章標籤

Roger 發表在 痞客邦 留言(0) 人氣()

        DataTable dtTable = new DataTable();
        DataRow row;

        // 建立欄位
        dtTable.Columns.Add("JOB_ID", typeof(int));
        dtTable.Columns.Add("JOB_TITLE", typeof(string));

文章標籤

Roger 發表在 痞客邦 留言(0) 人氣()

【Web.config檔案】

<connectionStrings>
        <add name="MyBookstore_ConnectionString" connectionString="
Data Source=127.0.0.1;Initial Catalog=MyBookstore;Persist Security Info=True;User ID=帳號;Password=密碼"          providerName="System.Data.SqlClient" />
</connectionStrings>

 

文章標籤

Roger 發表在 痞客邦 留言(0) 人氣()

string strErrorLine = new System.Diagnostics.StackTrace(ex, true).GetFrame(0).GetFileLineNumber().ToString();
string currentName = new System.Diagnostics.StackTrace(ex, true).GetFrame(0).GetMethod().Name;
string callName = new System.Diagnostics.StackTrace(ex, true).GetFrame(0).GetFileName();

string strBodyMsg = "";
strBodyMsg += "訊息提示: " + ex.Message.ToString() + "<br>";

文章標籤

Roger 發表在 痞客邦 留言(0) 人氣()

private void button1_Click(object sender, EventArgs e)
{
    OpenFileDialog file = new OpenFileDialog();
    file.ShowDialog();
    textBox1.Text = file.SafeFileName;

Roger 發表在 痞客邦 留言(0) 人氣()

private void button1_Click(object sender, EventArgs e)
{
    FolderBrowserDialog path = new FolderBrowserDialog();
    path.ShowDialog();
    textBox1.Text = path.SelectedPath;

Roger 發表在 痞客邦 留言(0) 人氣()

判斷C:\Test 是否存在

若不存在則透過 System.IO.Directory.CreateDirectory(dirPath); 來建立資料夾

 

string dirPath = @"C:\Test";

if (Directory.Exists(dirPath))

文章標籤

Roger 發表在 痞客邦 留言(0) 人氣()

<add name="DatabaseConnectionString" connectionString="Data Source=.\SQLEXPRESS;Integrated Security=True;AttachDBFileName=|DataDirectory|\資料庫.mdf; User Instance=True" />


Roger 發表在 痞客邦 留言(0) 人氣()

一、先設定印表機的格式
開始 --> 設定 --> 印表機及傳真  --> 檔案 --> 伺服器內容 --> 格式內 加入
中一刀 格式
使用英制
寛度 : 8.5英吋

文章標籤

Roger 發表在 痞客邦 留言(0) 人氣()

顯示出屬性視窗,在屬性視窗的上方可以找到像閃電一樣的圖案,

點擊之後就會找到相對應事件

輸入事件名稱之後就會進入編寫程式的畫面。


Roger 發表在 痞客邦 留言(0) 人氣()

加入null值 => System.DBNull.Value

SqlParameter para=new SqlParameter("@param",(object)DBNull.Value);


Roger 發表在 痞客邦 留言(0) 人氣()

DataGridView1.Columns["ContactName"].DisplayIndex = 0;
DataGridView1.Columns["ContactTitle"].DisplayIndex = 1;
DataGridView1.Columns["City"].DisplayIndex = 2;
DataGridView1.Columns["Country"].DisplayIndex = 3;
DataGridView1.Columns["CompanyName"].DisplayIndex = 4;

Roger 發表在 痞客邦 留言(0) 人氣()