2015年11月19日 星期四

資料庫

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

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

        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
    }
}

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 WindowsFormsApplication3
{
    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();
            }
        }

    }
}