2015年12月17日 星期四


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

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            textBox1.DataBindings.Add("Text", bindingSource1, "name", true);
            textBox2.DataBindings.Add("Text", bindingSource1, "sex", true);
            textBox3.DataBindings.Add("Text", bindingSource1, "tel", true);
            textBox4.DataBindings.Add("Text", bindingSource1, "stu_no", true);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: 這行程式碼會將資料載入 'db1DataSet.DataTable1' 資料表。您可以視需要進行移動或移除。
            this.dataTable1TableAdapter.Fill(this.db1DataSet.DataTable1);
            // TODO: 這行程式碼會將資料載入 'db1DataSet.record' 資料表。您可以視需要進行移動或移除。
            this.recordTableAdapter.Fill(this.db1DataSet.record);
            // TODO: 這行程式碼會將資料載入 'db1DataSet.person' 資料表。您可以視需要進行移動或移除。
            this.personTableAdapter.Fill(this.db1DataSet.person);

        }

        private void button1_Click(object sender, EventArgs e)
        {
            bindingSource1.MoveFirst();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            bindingSource1.MoveNext();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            bindingSource1.MovePrevious();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {

        }

        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                bindingSource1.AddNew();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            try
            {
                bindingSource1.EndEdit();
                
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }

}





tabcontrol - tabpage
binding Source
datagridview
bindingNavigator - biding source

textbox
label

2015年12月11日 星期五

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 WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        int[] array = new int[4];
        int mysum = 0;
        public Form1()
        {
            InitializeComponent();
            textBox1.DataBindings.Add("Text", bindingSource3, "name", true);
            textBox2.DataBindings.Add("Text", bindingSource3, "math", true);
            array[0] = 0;
            array[1] = 0;
            array[2] = 0;
            array[3] = 0;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: 這行程式碼會將資料載入 'db1DataSet.DataTable1' 資料表。您可以視需要進行移動或移除。
            this.dataTable1TableAdapter.Fill(this.db1DataSet.DataTable1);
            // TODO: 這行程式碼會將資料載入 'db1DataSet.record' 資料表。您可以視需要進行移動或移除。
            this.recordTableAdapter.Fill(this.db1DataSet.record);
            // TODO: 這行程式碼會將資料載入 'db1DataSet.person' 資料表。您可以視需要進行移動或移除。
            this.personTableAdapter.Fill(this.db1DataSet.person);

        }

        private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void bindingNavigatorMoveNextItem2_Click(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            bindingSource3.MoveFirst();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            bindingSource3.MoveNext();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            array[0] = int.Parse(textBox2.Text);
            for (int i = 0; i < 3; i++)
            {
                array[i] = int.Parse(textBox2.Text);
                bindingSource3.MoveNext();
            }
            for (int i = 0; i < 3; i++)
            {
                array[i] = mysum + array[i];
            }
            textBox3.Text = mysum.ToString();
        }
    }
}


tabcontrol - tabpage
binding Source
datagridview
bindingNavigator - biding source

textbox
label


2015年12月3日 星期四

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 WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: 這行程式碼會將資料載入 'db1DataSet1.DataTable2' 資料表。您可以視需要進行移動或移除。
            this.dataTable2TableAdapter.Fill(this.db1DataSet1.DataTable2);
            // TODO: 這行程式碼會將資料載入 'db1DataSet.DataTable1' 資料表。您可以視需要進行移動或移除。
            this.dataTable1TableAdapter.Fill(this.db1DataSet.DataTable1);
            // TODO: 這行程式碼會將資料載入 'db1DataSet.record' 資料表。您可以視需要進行移動或移除。
            this.recordTableAdapter.Fill(this.db1DataSet.record);
            // TODO: 這行程式碼會將資料載入 'db1DataSet.person' 資料表。您可以視需要進行移動或移除。
            this.personTableAdapter.Fill(this.db1DataSet.person);

        }

        private void button1_Click(object sender, EventArgs e)
        {
            // If you are not at the end of the list, move to the next item
            // in the BindingSource.
            if (bindingSource1.Position + 1 < bindingSource1.Count)
                bindingSource1.MoveNext();

            // Otherwise, move back to the first item.
            else
                bindingSource1.MoveFirst();


        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            // Force the form to repaint.
            //this.Invalidate();
            //textBox1.DataBindings.Add("Text", bindingSource1, "name");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            // If you are not at the end of the list, move to the next item
            // in the BindingSource.
            if (bindingSource1.Position - 1 > bindingSource1.Count)
                bindingSource1.MoveNext();

            // Otherwise, move back to the first item.
            else
                bindingSource1.MoveFirst();


        }

        private void button3_Click(object sender, EventArgs e)
        {
            // Force the form to repaint.
            this.Invalidate();
            textBox1.DataBindings.Add("Text", bindingSource1, "name");
        }


    }
}


binding Source - dataset
tabcontrol
datagridview
bindingNavigator
textbox



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

2015年10月30日 星期五

6x6 隨機變數 不重複

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 WindowsFormsApplication1
{

    public partial class Form1 : Form
    {
        public System.Windows.Forms.Button Button1;
        Random rand = new Random();

        Button[,] Buttons = new System.Windows.Forms.Button[5, 5];

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            for (int i = 1; i < 5; ++i)
            {
                for (int j = 1; j < 5; j++)
                {


                    Buttons[i, j] = new Button();
                    Buttons[i, j].Size = new Size(50, 50);

                    Buttons[i, j].Location = new Point(i * 50, j * 50);
                    this.Controls.Add(Buttons[i, j]);//出現在畫面中
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            int x, y, a;
            int[] myarray = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
            for (int i = 15; i > 1; i--)
            {

                x = rand.Next(0, i);
                y = myarray[x];
                myarray[x] = myarray[i];
                myarray[i] = y;

            }
            for (int j = 1; j < 5; j++)
            {
                for (int i = 1; i < 5; i++)
                {
                    a = myarray[(j - 1) * 4 + (i - 1)];
                    Buttons[i, j].Text = Convert.ToString(a);
                    this.Controls.Add(Buttons[i, j]);
                }
            }
        }
        }
}

2015年10月23日 星期五

程式設計工藝大師

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 WindowsFormsApplication2
{
   
    public partial class Form1 : Form
    {
        int radmoney1 = 100,radmoney2 = 100,radmoney3 = 100;
        int radmoney4 = 100, radmoney5 = 100, radmoney6 = 100;
        int radmoney7 = 100, radmoney8 = 100, radmoney9 = 100;
        public Form1()
        {
            InitializeComponent();
            button1.Enabled = false;
            button2.Enabled = false;
            button3.Enabled = false;
            button4.Enabled = false;
            button5.Enabled = false;
            button6.Enabled = false;
            button7.Enabled = false;
            button8.Enabled = false;
            button9.Enabled = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
        }

        private void button10_Click(object sender, EventArgs e)
        {
            Random rnd = new Random();
            radmoney1 = rnd.Next(0, 9);
            radmoney2 = rnd.Next(0, 9);
            radmoney3 = rnd.Next(0, 9);
            radmoney4 = rnd.Next(0, 9);
            radmoney5 = rnd.Next(0, 9);
            radmoney6 = rnd.Next(0, 9);
            radmoney7 = rnd.Next(0, 9);
            radmoney8 = rnd.Next(0, 9);
            radmoney9 = rnd.Next(0, 9);
            button1.Text = radmoney1.ToString();
            button2.Text = radmoney2.ToString();
            button3.Text = radmoney3.ToString();
            button4.Text = radmoney4.ToString();
            button5.Text = radmoney5.ToString();
            button6.Text = radmoney6.ToString();
            button7.Text = radmoney7.ToString();
            button8.Text = radmoney8.ToString();
            button9.Text = radmoney9.ToString();
            while (radmoney1 == radmoney2 || radmoney1 == radmoney3
                || radmoney1 == radmoney4 || radmoney1 == radmoney5
                || radmoney1 == radmoney6 || radmoney1 == radmoney7
                || radmoney1 == radmoney8 || radmoney1 == radmoney9
                || radmoney2 == radmoney3 || radmoney2 == radmoney4
                || radmoney2 == radmoney5 || radmoney2 == radmoney6
                || radmoney2 == radmoney7 || radmoney2 == radmoney8
                || radmoney2 == radmoney9 || radmoney3 == radmoney4
                || radmoney3 == radmoney5 || radmoney3 == radmoney6
                || radmoney3 == radmoney7 || radmoney3 == radmoney8
                || radmoney3 == radmoney9 || radmoney4 == radmoney5
                || radmoney4 == radmoney6 || radmoney4 == radmoney7
                || radmoney4 == radmoney8 || radmoney4 == radmoney9
                || radmoney5 == radmoney6 || radmoney5 == radmoney7
                || radmoney5 == radmoney8 || radmoney5 == radmoney9
                || radmoney6 == radmoney7 || radmoney6 == radmoney8
                || radmoney6 == radmoney9 || radmoney7 == radmoney8
                || radmoney7 == radmoney9 || radmoney8 == radmoney9)
            {
                //MessageBox.Show("Dot net perls is awesome")
                radmoney1 = rnd.Next(0, 9);
                radmoney2 = rnd.Next(0, 9);
                radmoney3 = rnd.Next(0, 9);
                radmoney4 = rnd.Next(0, 9);
                radmoney5 = rnd.Next(0, 9);
                radmoney6 = rnd.Next(0, 9);
                radmoney7 = rnd.Next(0, 9);
                radmoney8 = rnd.Next(0, 9);
                radmoney9 = rnd.Next(0, 9);
                button1.Text = radmoney1.ToString();
                button2.Text = radmoney2.ToString();
                button3.Text = radmoney3.ToString();
                button4.Text = radmoney4.ToString();
                button5.Text = radmoney5.ToString();
                button6.Text = radmoney6.ToString();
                button7.Text = radmoney7.ToString();
                button8.Text = radmoney8.ToString();
                button9.Text = radmoney9.ToString();
            }



            //button10.Enabled = false;
        }
    }
}

2015年10月16日 星期五

程式設計工藝大師
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 WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        int c1 = 0,c2 = 0,c3 = 0, d1 = 0, d2 = 0, d3 = 0, radmoney1 = 100, radmoney2 = 100, radmoney3 = 100;
        public Form1()
        {
            InitializeComponent();
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }
        private void button1_Click(object sender, EventArgs e)
        {
     
        }
        private void button2_Click(object sender, EventArgs e)
        {
         
        }
        private void button3_Click(object sender, EventArgs e)
        {

        }

        private void button4_Click(object sender, EventArgs e)
        {
            c1 = 0;
            c2 = 0;
            c3 = 0;
            d1 = 1;
            d2 = 2;
            d3 = 0;
            timer1.Enabled = true;
            timer2.Enabled = true;
            timer3.Enabled = true;
            Random rnd = new Random();
            radmoney1 = rnd.Next(1, 101);
            radmoney2 = rnd.Next(1, 101);
            radmoney3 = rnd.Next(1, 101);
            button4.Text = radmoney1.ToString() + radmoney2.ToString() + radmoney3.ToString();



        }

        private void timer1_Tick(object sender, EventArgs e)
        {
       
            c1 = c1 + 1;
            d1 = c1 % 2;
         
            if (c1 >= radmoney1) timer1.Enabled = false;
         
         
            button1.Text = d1.ToString();
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            c2 = c2 + 1;
            d2 = c2 % 2;
            if (c2 >= radmoney2) timer2.Enabled = false;
            button2.Text = d2.ToString();
        }

        private void timer3_Tick(object sender, EventArgs e)
        {
            c3 = c3 + 1;
            d3 = c3 % 2;
            if (c3 >= radmoney3) timer3.Enabled = false;
            button3.Text = d3.ToString();

        }
        private void timer4_Tick(object sender, EventArgs e)
        {
            button4.Text = "start";

            if (d1 == d2 && d2 == d3)
            {
                button5.Text = "win";
            }
            else
            {
                button5.Text = "flaut";
               
            }

    }
}

2015年10月2日 星期五

程式設計工藝大師

應數物件導向設計C# 
d0250713 邱建理



namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        int c=0,d=0;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
          
       }

        private void timer1_Tick(object sender, EventArgs e)
        {
          c = c + 1;
          d = c % 3;
          if (d == 1)
          {
              button1.BackColor = System.Drawing.Color.Red;
            button2.BackColor = System.Drawing.Color.Black;
            button3.BackColor = System.Drawing.Color.Black;
        }
            else if (d==2)
            {
            button2.BackColor = System.Drawing.Color.Yellow;
            button1.BackColor = System.Drawing.Color.Black;
            button3.BackColor = System.Drawing.Color.Black;
            }
                else if(d==0)
          {   button3.BackColor = System.Drawing.Color.Green;
            button2.BackColor = System.Drawing.Color.Black;
            button1.BackColor = System.Drawing.Color.Black;
            
            button1.Text = c.ToString();
        }
  
        }

        private void button3_Click(object sender, EventArgs e)
        {

        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }
    }
}