📄 mainform.cs
字号:
this.timerExit.Tick += new System.EventHandler(this.timerExit_Tick);
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(600, 450);
this.Controls.Add(this.plMain);
this.Controls.Add(this.plLeft);
this.Controls.Add(this.plRight);
this.Controls.Add(this.plTop);
this.Controls.Add(this.plBotton);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "阳光公交宝典";
this.Load += new System.EventHandler(this.MainForm_Load);
this.plTop.ResumeLayout(false);
this.plBotton.ResumeLayout(false);
this.plLeft.ResumeLayout(false);
this.plMain.ResumeLayout(false);
this.panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).EndInit();
this.panel1.ResumeLayout(false);
this.panel4.ResumeLayout(false);
this.panel6.ResumeLayout(false);
this.panel5.ResumeLayout(false);
this.panel8.ResumeLayout(false);
this.panel7.ResumeLayout(false);
this.panel3.ResumeLayout(false);
this.plToolbar.ResumeLayout(false);
this.plRight.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
#region 应用程序的主入口点=====================================
/// <summary>
/// 应用程序的主入口点。
/// </summary>
// [STAThread]
// static void Main()
// {
// Application.Run(new MainForm());
//
// }
private void pictureBox6_Click(object sender, System.EventArgs e)
{
this.Close();
}
#endregion
#region 翻页按钮事件处理=======================================
private void btnFirst_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.btnBrowseFirstMouseOver = true;
this.DrawBrowseButton(1);
}
private void btnFirst_MouseLeave(object sender, System.EventArgs e)
{
this.btnBrowseFirstMouseDown = false;
this.btnBrowseFirstMouseOver = false;
this.DrawBrowseButton(1);
}
private void btnFirst_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.btnBrowseFirstMouseDown = true;
this.DrawBrowseButton(1);
}
private void btnPrv_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.btnBrowsePrvMouseOver = true;
this.DrawBrowseButton(2);
}
private void btnPrv_MouseLeave(object sender, System.EventArgs e)
{
this.btnBrowsePrvMouseDown = false;
this.btnBrowsePrvMouseOver = false;
this.DrawBrowseButton(2);
}
private void btnPrv_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.btnBrowsePrvMouseDown = true;
this.DrawBrowseButton(2);
}
private void btnNext_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.btnBrowseNextMouseOver = true;
this.DrawBrowseButton(3);
}
private void btnNext_MouseLeave(object sender, System.EventArgs e)
{
this.btnBrowseNextMouseDown = false;
this.btnBrowseNextMouseOver = false;
this.DrawBrowseButton(3);
}
private void btnNext_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.btnBrowseNextMouseDown = true;
this.DrawBrowseButton(3);
}
private void btnLast_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.btnBrowseLastMouseOver = true;
this.DrawBrowseButton(4);
}
private void btnLast_MouseLeave(object sender, System.EventArgs e)
{
this.btnBrowseLastMouseDown = false;
this.btnBrowseLastMouseOver = false;
this.DrawBrowseButton(4);
}
private void btnLast_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.btnBrowseLastMouseDown = true;
this.DrawBrowseButton(4);
}
#endregion
#region 绑定tVCityList=========================================
/// <summary>
/// 绑定tVCityList
/// </summary>
private void CityList()
{
//清空树形目录
this.tVCityList.Nodes.Clear();
//获取城市的数据集
DataSet ds = new City().GetCity();
//创建省市表PROVINCE
DataTable dtProvince = ds.Tables["Province"];
//创建城市表CITY
DataTable dtCity = ds.Tables["City"];
//取出所有的数据
for(int i = 0; i < dtProvince.Rows.Count; i++)
{
this.tVCityList.Nodes.Add(dtProvince.Rows[i]["ProvinceName"].ToString());
DataRow[] drArray = dtCity.Select("ProvinceID='"+dtProvince.Rows[i]["ProvinceID"]+"'");
for(int j = 0;j < drArray.Length; j++)
{
DataRow dr = drArray[j];
this.tVCityList.Nodes[i].Nodes.Add(new TreeNode(dr["CityName"].ToString()));
}
}
}
#endregion
#region 填充某一城市下的所有公交车的数据=======================
/// <summary>
/// 填充某一城市下的所有公交车的数据
/// </summary>
private void BusInfo()
{
ds = Bus.GetBusDataset(this.mCityID,this.mBrowseEnum,this.mLastBusID);
DataTable dt = ds.Tables[0];
//清除LISVIEW所有数据
this.lVBusList.Items.Clear();
for(int i = 0; i < dt.Rows.Count; i++)
{
string[] items = new string[]{dt.Rows[i]["BusName"].ToString(),dt.Rows[i]["BusType"].ToString(),dt.Rows[i]["BusStartStop"].ToString(),dt.Rows[i]["BusEndStop"].ToString(),dt.Rows[i]["BusDescription"].ToString()};
this.lVBusList.Items.Add(new ListViewItem(items));
}
if(dt.Rows.Count>0)
{
this.mLastBusID = Convert.ToInt32(dt.Rows[dt.Rows.Count-1]["BusID"].ToString());
this.pageSize = Bus.PageSize;
this.totalPageCount = Bus.TotalPageCount;
this.totalRecordCount = Bus.TotalRecordCount;
}
else
{
this.pageSize = Bus.PageSize;
this.totalPageCount = 1;
this.totalRecordCount = 0;
}
}
#endregion
#region 根据城市名称取回城市信息===============================
/// <summary>
/// 根据城市名称取回城市信息
/// </summary>
private void GetCityInfo()
{
try
{
DataSet ds = new DataAccess.City().GetCity(this.mCityName);
DataTable dt = ds.Tables[0];
this.mCityID = Convert.ToInt32(dt.Rows[0]["CityID"].ToString());
this.mCityName = dt.Rows[0]["CityName"].ToString();
cityID = this.mCityID;
}
catch
{
}
}
#endregion
#region 选中树形目录第一次加载的节点===========================
private void SetCityList()
{
for(int i = 0;i<this.tVCityList.Nodes.Count;i++)
{
if(this.tVCityList.Nodes[i].Nodes.Count>0)
{
for(int j = 0;j< this.tVCityList.Nodes[i].Nodes.Count;j++)
{
if(this.tVCityList.Nodes[i].Nodes[j].Text == this.mCityName)
{
this.tVCityList.SelectedNode = this.tVCityList.Nodes[i].Nodes[j];
}
}
}
else
{
if(this.tVCityList.Nodes[i].Text== this.mCityName)
{
this.tVCityList.SelectedNode = this.tVCityList.Nodes[i];
}
}
}
}
#endregion
#region 设置信息===============================================
private void StatisticInfo()
{
this.lbFoot.Visible = true;
string result = "";
result = "当前城市:"+this.mCityName+"【总共"+this.totalRecordCount.ToString()+"条记录】";
this.lbTitle.Text = result;
this.lbFoot.Text = "【每页"+this.pageSize.ToString()+"条记录,总共"+this.totalPageCount.ToString()+"页,当前页码:"+this.pageIndex.ToString()+"/"+this.totalPageCount.ToString()+"】";
}
#endregion
#region 选择节点事件处理=======================================
private void tVCityList_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
this.mCityName = e.Node.Text.ToString();
this.lVBusList.Items.Clear();
//根据城市名称取回城市信息
this.GetCityInfo();
//填充某一城市下的所有公交车的数据
this.BusInfo();
//设置信息
this.StatisticInfo();
}
#endregion
#region 翻页处理===============================================
private void btnFirst_Click(object sender, System.EventArgs e)
{
this.mBrowseEnum = DataBrowseEnum.BrowseEnum.First;
this.pageIndex = 1;
//填充某一城市下的所有公交车的数据
this.BusInfo();
//设置信息
this.StatisticInfo();
}
private void btnPrv_Click(object sender, System.EventArgs e)
{
this.mBrowseEnum = DataBrowseEnum.BrowseEnum.Prv;
if(pageIndex > 1 )
{
this.pageIndex--;
//填充某一城市下的所有公交车的数据
this.BusInfo();
//设置信息
this.StatisticInfo();
}
}
private void btnNext_Click(object sender, System.EventArgs e)
{
this.mBrowseEnum = DataBrowseEnum.BrowseEnum.Next;
if(pageIndex < totalPageCount)
{
this.pageIndex++;
//填充某一城市下的所有公交车的数据
this.BusInfo();
//设置信息
this.StatisticInfo();
}
}
private void btnLast_Click(object sender, System.EventArgs e)
{
this.mBrowseEnum = DataBrowseEnum.BrowseEnum.Last;
this.pageIndex = this.totalPageCount;
//填充某一城市下的所有公交车的数据
this.BusInfo();
//设置信息
this.StatisticInfo();
}
#endregion
#region 移动窗口===============================================
private void pictureBox4_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(e.Button == MouseButtons.Left)
{
Point mousePoint = Control.MousePosition;
mousePoint.Offset(this.m_pOffset.X,this.m_pOffset.Y);
this.Location = mousePoint;
this.xPos = mousePoint.X;
this.yPos = mousePoint.Y;
if(xPos < 0)
{
xPos = 0;
}
if(yPos < 0)
{
yPos = 0;
}
this.locationMain.X = xPos;
this.locationMain.Y = yPos;
}
}
private void pictureBox4_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.m_pOffset = new Point(-e.X,-e.Y);
}
#endregion
#region 绘制窗体标题===========================================
private void pictureBox4_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
try
{
Point p = new Point(this.pictureBox4.Location.X-40,this.pictureBox4.Location.Y+5);
Graphics g = e.Graphics;
g.DrawString(SystemMessage.SYSTEM_TITLE+"公交信息列表",new Font("宋体",10),Brushes.Yellow,p);
Point p2 = new Point(p.X+1,p.Y+1);
g.DrawString(SystemMessage.SYSTEM_TITLE+"公交信息列表",new Font("宋体",10),Brushes.DarkBlue,p2);
//g.Dispose();
}
catch(System.Exception ex)
{
throw new Exception(ex.Message);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -