我的项目是风力赛车系统,其中有2所学校竞争自己的自制风力螺旋桨,该螺旋桨连接到给定的玩具车套件上。应用程序启动时,风扇和计时器将打开。
这些是我的数据保存部分代码;
`string q = "SELECT * from Placing";
cmd.CommandText = q;
con.Open();
try
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "*.csv ( comma separated value) |*.csv"; //save in what format
sfd.OverwritePrompt = false;
if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
btnLaunch.Enabled = false;
btnStart.Enabled = true;
path = sfd.FileName; //path is where you save the file at
}
btnLaunch.Enabled = false;
btnStart.Enabled = true;
}
catch (Exception etc)
{
MessageBox.Show("An error occured: " + etc.Message);
}`
[Excel]`using (StreamWriter sw = new StreamWriter(MyProperty, true))
{
//write into excel file
sw.WriteLine("RACE" + " " + racenumber1++ + "," + (cmbSch1.SelectedIndex + 1) + "," + cmbSch1.Text + "," + st1 + " " + "seconds" + "," + DateTime.Now);
sw.WriteLine("RACE" + " " + racenumber2++ + "," + (cmbSch2.SelectedIndex + 1) + "," + cmbSch2.Text + "," + st2 + " " + "seconds" + "," + DateTime.Now);
sw.Dispose();
}`
[Timer]`TimeSpan elapsed = sw1.Elapsed;
lblTimer1.Text = String.Format("{2:00}.{3:00}",
Math.Floor(elapsed.TotalHours), elapsed.Minutes,
elapsed.Seconds, elapsed.Milliseconds / 10);
st1 = lblTimer1.Text;`