📄 frmcarpark.cs
字号:
this.label3.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.label3.Location = new System.Drawing.Point(16, 136);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(112, 23);
this.label3.TabIndex = 2;
this.label3.Text = "车主:";
//
// label2
//
this.label2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label2.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.label2.Location = new System.Drawing.Point(16, 80);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(112, 23);
this.label2.TabIndex = 1;
this.label2.Text = "车牌:";
//
// label1
//
this.label1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label1.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.label1.Location = new System.Drawing.Point(16, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(112, 23);
this.label1.TabIndex = 0;
this.label1.Text = "车位:";
//
// label5
//
this.label5.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label5.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.label5.Location = new System.Drawing.Point(16, 256);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(112, 23);
this.label5.TabIndex = 3;
this.label5.Text = "区域:";
//
// textBox5
//
this.textBox5.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.textBox5.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.textBox5.Location = new System.Drawing.Point(176, 256);
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(144, 23);
this.textBox5.TabIndex = 7;
this.textBox5.Text = "";
//
// button1
//
this.button1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button1.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.button1.Location = new System.Drawing.Point(328, 352);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(94, 24);
this.button1.TabIndex = 3;
this.button1.Text = "移除车辆";
//
// button3
//
this.button3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button3.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.button3.Location = new System.Drawing.Point(440, 352);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(90, 24);
this.button3.TabIndex = 5;
this.button3.Text = "关闭";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button4.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.button4.Location = new System.Drawing.Point(224, 352);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(88, 24);
this.button4.TabIndex = 6;
this.button4.Text = "添加车辆";
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// frmcarpark
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(544, 398);
this.Controls.Add(this.button3);
this.Controls.Add(this.button1);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.treeView1);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.button4);
this.Name = "frmcarpark";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "停车管理";
this.Load += new System.EventHandler(this.frmcarpark_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
private void frmcarpark_Load(object sender, System.EventArgs e)
{
objSqlConn=new SqlConnection("database=atorregulate;user id=sa;password=;SERVER=(local)");
objDataSet1=new DataSet();
objDataSet2=new DataSet();
objSqlConn.Open();
objSqlDataAdapter=new SqlDataAdapter("select*from carpark",objSqlConn);
objSqlDataAdapter.Fill(objDataSet1,"carpark");
objSqlDataAdapter=new SqlDataAdapter("select Ccarnumber from carpark",objSqlConn);
objSqlDataAdapter.Fill(objDataSet2,"carpark");
ewq1();
/*TreeNode objNodeParent;
foreach(DataRow objDataRow in objDataSet2.Tables[0].Rows)
{
objNodeParent=treeView1.Nodes.Add(objDataRow["Ccarnumber"].ToString());
objNodeParent.Tag=objDataRow;
}*/
}
private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
ewq2();
string var=e.Node.Text;
foreach(DataRow objDataRow in objDataSet1.Tables[0].Rows)
{
if(var==objDataRow["Ccarnumber"].ToString())
{
textBox1.Text=objDataRow["Cnumber"].ToString();
textBox2.Text=objDataRow["Cstate"].ToString();
textBox3.Text=objDataRow["Ccarnumber"].ToString();
textBox4.Text=objDataRow["Cmaster"].ToString();
textBox5.Text=objDataRow["Cdelt"].ToString();
}
}
}
private void radioButton1_CheckedChanged(object sender, System.EventArgs e)
{
this.treeView1.Nodes.Clear();
ewq1();
}
private void radioButton2_CheckedChanged(object sender, System.EventArgs e)
{
this.treeView1.Nodes.Clear();
i=0;
for (int b=0;b<objDataSet1.Tables[0].Rows.Count;b++)
{
i++;
}
string[] a=new string[i];
for (int b=0;b<objDataSet1.Tables[0].Rows.Count;b++)
{
a[b]=objDataSet1.Tables[0].Rows[b]["Cdelt"].ToString() ;
}
int z=i;int q=1;
for(int b=0;b<z;b++)
{
for(int c=b+1;c<z;c++ )
{
if(a[b]==a[c])
{a[c]=a[z-1];z--;c--;}
}
}
TreeNode objNodeParent;
for(int d=0;d<z;d++)
{
objNodeParent=treeView1.Nodes.Add(a[d].ToString());
objNodeParent.Tag=a[d];
TreeNode objewq;
TreeNode objdsa;
for (int b=0;b<objDataSet1.Tables[0].Rows.Count;b++)
{
if(a[d]==objDataSet1.Tables[0].Rows[b]["Cdelt"].ToString())
{
objewq=objNodeParent.Nodes.Add(objDataSet1.Tables[0].Rows[b]["cadd"].ToString());
objdsa= objewq.Nodes.Add(objDataSet1.Tables[0].Rows[b]["Ccarnumber"].ToString());
}
//}
//ewq3();
}
}
}
private void button4_Click(object sender, System.EventArgs e)
{
try
{
if(this.textBox1.Text != string.Empty && this.textBox2.Text != string.Empty && this.textBox3.Text != string.Empty && this.textBox4.Text != string.Empty && this.textBox5.Text != string.Empty)
{
DataRow objDataRow = this.objDataSet1.Tables["car"].NewRow();
objDataRow["Cnumber"]=textBox1.Text;
objDataRow["Cstate"]=textBox2.Text;
objDataRow["Ccarnumber"]=textBox3.Text;
objDataRow["Cmaster"]=textBox4.Text;
objDataRow["Cdelt"]=textBox5.Text;
this.objDataSet1.Tables["car"].Rows.Add(objDataRow);
this.objDataSet1.HasChanges(DataRowState.Added);
this.objSqlDataAdapter.Update(this.objDataSet1,"car");
MessageBox.Show("***************");
}
else
{
MessageBox.Show("提供完整的详细信息");
}
}
catch(Exception Ex)
{
MessageBox.Show(Ex.Message.ToString());
}
}
private void button3_Click(object sender, System.EventArgs e)
{
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -