📄 formtraffic.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlServerCe;
namespace SQLCE_RDA
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class FormTraffic : System.Windows.Forms.Form
{
private System.Windows.Forms.TabControl tabControl2;
private System.Windows.Forms.TabPage tabPage5;
private System.Windows.Forms.TabPage tabPage7;
private System.Windows.Forms.ListView listViewObs;
private System.Windows.Forms.ColumnHeader columnHeader4;
private System.Windows.Forms.ColumnHeader columnHeader5;
private System.Windows.Forms.ColumnHeader columnHeader6;
private System.Windows.Forms.Label labelLocation;
private System.Windows.Forms.Label labelReg;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button buttonAddCar;
private System.Windows.Forms.TextBox textBoxLocation;
private System.Windows.Forms.TextBox textBoxReg;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox textBoxDate;
private System.Windows.Forms.TextBox textBoxtime;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox textBoxNote;
private int m_CurrentCarID;
private System.Windows.Forms.Button buttonAddObs;
private BindingSource bindingSource1;
private System.ComponentModel.IContainer components;
private DataGrid dataGrid1;
private DataGridTableStyle dataGridTableStyle1;
private DataGridTextBoxColumn dataGridTextBoxColumn1;
private DataGridTextBoxColumn dataGridTextBoxColumn2;
private DataGridTextBoxColumn dataGridTextBoxColumn3;
private Button buttonPush;
private DataSet carsDataSet = null;
private SqlCeDataAdapter carsAdapter = null;
private SqlCeConnection carsConnection = null;
public FormTraffic()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
carsConnection = new SqlCeConnection(@"Data Source=\My Documents\TrafficRDA.sdf");
string SQL = "SELECT CarID, Reg , Location FROM Cars ORDER BY Reg ";
carsAdapter = new SqlCeDataAdapter(SQL, carsConnection);
// Derive the Insert, Update, Delete commands
SqlCeCommandBuilder cbr = new SqlCeCommandBuilder(carsAdapter);
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.tabControl2 = new System.Windows.Forms.TabControl();
this.tabPage5 = new System.Windows.Forms.TabPage();
this.buttonPush = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.buttonAddCar = new System.Windows.Forms.Button();
this.textBoxLocation = new System.Windows.Forms.TextBox();
this.textBoxReg = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.tabPage7 = new System.Windows.Forms.TabPage();
this.textBoxNote = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.textBoxtime = new System.Windows.Forms.TextBox();
this.textBoxDate = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.buttonAddObs = new System.Windows.Forms.Button();
this.listViewObs = new System.Windows.Forms.ListView();
this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
this.columnHeader5 = new System.Windows.Forms.ColumnHeader();
this.columnHeader6 = new System.Windows.Forms.ColumnHeader();
this.labelLocation = new System.Windows.Forms.Label();
this.labelReg = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components);
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle();
this.dataGridTextBoxColumn1 = new System.Windows.Forms.DataGridTextBoxColumn();
this.dataGridTextBoxColumn2 = new System.Windows.Forms.DataGridTextBoxColumn();
this.dataGridTextBoxColumn3 = new System.Windows.Forms.DataGridTextBoxColumn();
this.tabControl2.SuspendLayout();
this.tabPage5.SuspendLayout();
this.tabPage7.SuspendLayout();
this.SuspendLayout();
//
// tabControl2
//
this.tabControl2.Controls.Add(this.tabPage5);
this.tabControl2.Controls.Add(this.tabPage7);
this.tabControl2.Location = new System.Drawing.Point(0, 8);
this.tabControl2.Name = "tabControl2";
this.tabControl2.SelectedIndex = 0;
this.tabControl2.Size = new System.Drawing.Size(232, 280);
this.tabControl2.TabIndex = 0;
//
// tabPage5
//
this.tabPage5.Controls.Add(this.dataGrid1);
this.tabPage5.Controls.Add(this.buttonPush);
this.tabPage5.Controls.Add(this.label2);
this.tabPage5.Controls.Add(this.buttonAddCar);
this.tabPage5.Controls.Add(this.textBoxLocation);
this.tabPage5.Controls.Add(this.textBoxReg);
this.tabPage5.Controls.Add(this.label1);
this.tabPage5.Location = new System.Drawing.Point(4, 25);
this.tabPage5.Name = "tabPage5";
this.tabPage5.Size = new System.Drawing.Size(224, 251);
this.tabPage5.Text = "Cars";
//
// buttonPush
//
this.buttonPush.Location = new System.Drawing.Point(8, 224);
this.buttonPush.Name = "buttonPush";
this.buttonPush.Size = new System.Drawing.Size(89, 24);
this.buttonPush.TabIndex = 6;
this.buttonPush.Text = "Push";
this.buttonPush.Click += new System.EventHandler(this.buttonPush_Click);
//
// label2
//
this.label2.Location = new System.Drawing.Point(8, 156);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(64, 16);
this.label2.Text = "Location:";
//
// buttonAddCar
//
this.buttonAddCar.Enabled = false;
this.buttonAddCar.Location = new System.Drawing.Point(137, 224);
this.buttonAddCar.Name = "buttonAddCar";
this.buttonAddCar.Size = new System.Drawing.Size(81, 24);
this.buttonAddCar.TabIndex = 1;
this.buttonAddCar.Text = "Add Car";
this.buttonAddCar.Click += new System.EventHandler(this.buttonAddCar_Click);
//
// textBoxLocation
//
this.textBoxLocation.Location = new System.Drawing.Point(8, 172);
this.textBoxLocation.MaxLength = 100;
this.textBoxLocation.Multiline = true;
this.textBoxLocation.Name = "textBoxLocation";
this.textBoxLocation.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.textBoxLocation.Size = new System.Drawing.Size(216, 40);
this.textBoxLocation.TabIndex = 2;
//
// textBoxReg
//
this.textBoxReg.Location = new System.Drawing.Point(80, 132);
this.textBoxReg.MaxLength = 10;
this.textBoxReg.Name = "textBoxReg";
this.textBoxReg.Size = new System.Drawing.Size(96, 23);
this.textBoxReg.TabIndex = 3;
this.textBoxReg.TextChanged += new System.EventHandler(this.textBoxReg_TextChanged);
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 132);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(104, 24);
this.label1.Text = "Registration:";
//
// tabPage7
//
this.tabPage7.Controls.Add(this.textBoxNote);
this.tabPage7.Controls.Add(this.label6);
this.tabPage7.Controls.Add(this.textBoxtime);
this.tabPage7.Controls.Add(this.textBoxDate);
this.tabPage7.Controls.Add(this.label5);
this.tabPage7.Controls.Add(this.label3);
this.tabPage7.Controls.Add(this.buttonAddObs);
this.tabPage7.Controls.Add(this.listViewObs);
this.tabPage7.Controls.Add(this.labelLocation);
this.tabPage7.Controls.Add(this.labelReg);
this.tabPage7.Controls.Add(this.label4);
this.tabPage7.Location = new System.Drawing.Point(4, 25);
this.tabPage7.Name = "tabPage7";
this.tabPage7.Size = new System.Drawing.Size(224, 251);
this.tabPage7.Text = "Observations";
//
// textBoxNote
//
this.textBoxNote.Location = new System.Drawing.Point(8, 216);
this.textBoxNote.MaxLength = 100;
this.textBoxNote.Name = "textBoxNote";
this.textBoxNote.Size = new System.Drawing.Size(136, 23);
this.textBoxNote.TabIndex = 0;
//
// label6
//
this.label6.Location = new System.Drawing.Point(8, 200);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(64, 16);
this.label6.Text = "Note:";
//
// textBoxtime
//
this.textBoxtime.Location = new System.Drawing.Point(96, 172);
this.textBoxtime.Name = "textBoxtime";
this.textBoxtime.Size = new System.Drawing.Size(80, 23);
this.textBoxtime.TabIndex = 2;
//
// textBoxDate
//
this.textBoxDate.Location = new System.Drawing.Point(8, 172);
this.textBoxDate.Name = "textBoxDate";
this.textBoxDate.Size = new System.Drawing.Size(80, 23);
this.textBoxDate.TabIndex = 3;
//
// label5
//
this.label5.Location = new System.Drawing.Point(96, 156);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(80, 16);
this.label5.Text = "Time:";
//
// label3
//
this.label3.Location = new System.Drawing.Point(8, 156);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 16);
this.label3.Text = "Date:";
//
// buttonAddObs
//
this.buttonAddObs.Location = new System.Drawing.Point(152, 216);
this.buttonAddObs.Name = "buttonAddObs";
this.buttonAddObs.Size = new System.Drawing.Size(72, 24);
this.buttonAddObs.TabIndex = 6;
this.buttonAddObs.Text = "Add Obs";
//
// listViewObs
//
this.listViewObs.Columns.Add(this.columnHeader4);
this.listViewObs.Columns.Add(this.columnHeader5);
this.listViewObs.Columns.Add(this.columnHeader6);
this.listViewObs.FullRowSelect = true;
this.listViewObs.Location = new System.Drawing.Point(8, 56);
this.listViewObs.Name = "listViewObs";
this.listViewObs.Size = new System.Drawing.Size(232, 88);
this.listViewObs.TabIndex = 7;
this.listViewObs.View = System.Windows.Forms.View.Details;
//
// columnHeader4
//
this.columnHeader4.Text = "ObsID";
this.columnHeader4.Width = 45;
//
// columnHeader5
//
this.columnHeader5.Text = "Date/Time";
this.columnHeader5.Width = 80;
//
// columnHeader6
//
this.columnHeader6.Text = "Note";
this.columnHeader6.Width = 100;
//
// labelLocation
//
this.labelLocation.Location = new System.Drawing.Point(8, 28);
this.labelLocation.Name = "labelLocation";
this.labelLocation.Size = new System.Drawing.Size(216, 28);
this.labelLocation.Text = "Parked here";
//
// labelReg
//
this.labelReg.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
this.labelReg.Location = new System.Drawing.Point(136, 8);
this.labelReg.Name = "labelReg";
this.labelReg.Size = new System.Drawing.Size(88, 20);
this.labelReg.Text = "XXX";
//
// label4
//
this.label4.Location = new System.Drawing.Point(8, 8);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(120, 16);
this.label4.Text = "List of observations for ";
//
// dataGrid1
//
this.dataGrid1.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(128)))));
this.dataGrid1.DataSource = this.bindingSource1;
this.dataGrid1.Location = new System.Drawing.Point(6, 3);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(213, 123);
this.dataGrid1.TabIndex = 9;
this.dataGrid1.TableStyles.Add(this.dataGridTableStyle1);
this.dataGrid1.CurrentCellChanged += new System.EventHandler(this.dataGrid1_CurrentCellChanged);
//
// dataGridTableStyle1
//
this.dataGridTableStyle1.GridColumnStyles.Add(this.dataGridTextBoxColumn1);
this.dataGridTableStyle1.GridColumnStyles.Add(this.dataGridTextBoxColumn2);
this.dataGridTableStyle1.GridColumnStyles.Add(this.dataGridTextBoxColumn3);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -