DataBase4
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[] a = new int[10];
int k = 0,i,b;
float sum = 0;
public Form1()
{
InitializeComponent();
textBox1.DataBindings.Add("Text", bindingSource3, "name", true);
textBox2.DataBindings.Add("Text", bindingSource3, "math", true);
a[0] = 0;
a[1] = 0;
a[2] = 0;
}
private void bindingSource1_CurrentChanged(object sender, EventArgs e)
{
}
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 button2_Click_1(object sender, EventArgs e)
{
bindingSource3.MoveNext();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
bindingSource3.MoveFirst();
}
private void button3_Click(object sender, EventArgs e)
{
b= bindingSource3.Count;
for (i = 0; i < b; i++)
{
a[i] = int.Parse(textBox2.Text);
bindingSource3.MoveNext();
}
for (i = 0; i < b; i++)
{
sum += a[i];
}
textBox3.Text = (sum/b).ToString();
button3.Enabled = false;
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
}
}
沒有留言:
張貼留言