2015年11月19日 星期四

C# 資料庫

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void bindingSource1_CurrentChanged(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: 這行程式碼會將資料載入 'dbDataSet.工作表1_舊' 資料表。您可以視需要進行移動或移除。
            this.工作表1_舊TableAdapter.Fill(this.dbDataSet.工作表1_舊);

        }
    }
}




bindsource      連接資料庫

detamember   連接清單


2015年11月5日 星期四

程式設計工藝大師


加減乘除

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            float a = float.Parse(textBox1.Text), b = float.Parse(textBox2.Text);
            label2.Text = (a + b).ToString();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            float a = float.Parse(textBox1.Text), b = float.Parse(textBox2.Text);
            label2.Text = (a - b).ToString();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            float a = float.Parse(textBox1.Text), b = float.Parse(textBox2.Text);
            label2.Text = (a * b).ToString();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            float a = float.Parse(textBox1.Text), b = float.Parse(textBox2.Text);
            if (b == 0)
            {
                label2.Text = "分母不能為零";
            }
            else
            {
                label2.Text = (a / b).ToString();
            }
        }
    }
}