Skip to content

Commit

Permalink
edit textBox1 key-down events
Browse files Browse the repository at this point in the history
  • Loading branch information
me1237guy committed Sep 13, 2021
1 parent 93bc194 commit 303b0b9
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 0 deletions.
Binary file modified ReportApp/.vs/ReportApp/v15/.suo
Binary file not shown.
Binary file modified ReportApp/.vs/ReportApp/v15/Server/sqlite3/storage.ide-wal
Binary file not shown.
1 change: 1 addition & 0 deletions ReportApp/ReportApp/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions ReportApp/ReportApp/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,51 @@ private void textBox1_KeyUp(object sender, KeyEventArgs e)

}
}

private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
AddOrder();
LoadData();
MoveToKeyRow();
}
}
public void AddOrder()
{
Order order = new Order();
order.Number = textBox1.Text;

System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Reset();
sw.Start();
var count = daoService.AddOrder(order);
sw.Stop();

//印出所花費的總秒數
string result1 = sw.Elapsed.TotalSeconds.ToString();
if (count == 0)
{
this.Text = $"資料已寫入完成,花費:{result1}";
}
else
{
this.Text = $"該筆資料重複: {order.Number} ";
}
}

private int MoveToKeyRow()
{
Order order = new Order();
order.Number = this.textBox1.Text;
var orders = daoService.GetOrder();
int pos = orders.FindIndex(a => a.Number == order.Number);
if (pos > 0)
{
dataGridView1.Rows[pos].Selected = true;
dataGridView1.FirstDisplayedScrollingRowIndex = pos;
}
return pos;
}
}
}
Binary file modified ReportApp/ReportApp/bin/Release/ReportApp.exe
Binary file not shown.
Binary file modified ReportApp/ReportApp/bin/Release/ReportApp.pdb
Binary file not shown.
Binary file modified ReportApp/ReportApp/bin/Release/data.db
Binary file not shown.
Binary file not shown.
Binary file modified ReportApp/ReportApp/obj/Release/ReportApp.exe
Binary file not shown.
Binary file modified ReportApp/ReportApp/obj/Release/ReportApp.pdb
Binary file not shown.

0 comments on commit 303b0b9

Please sign in to comment.