程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> .NET實例教程 >> 列車時刻查詢系統(北大青鳥大二寒假作業) 源代碼(一)2

列車時刻查詢系統(北大青鳥大二寒假作業) 源代碼(一)2

編輯:.NET實例教程

            // lblxl
            // 
            this.lblxl.BackColor = System.Drawing.Color.Transparent;
            this.lblxl.Location = new System.Drawing.Point(272, 192);
            this.lblxl.Name = "lblxl";
            this.lblxl.Size = new System.Drawing.Size(24, 24);
            this.lblxl.TabIndex = 15;
            this.lblxl.Tag = "西寧";
            this.lblxl.Click += new System.EventHandler(this.lblwlmq_Click);
            // 
            // lblym
            // 
            this.lblym.BackColor = System.Drawing.Color.Transparent;
            this.lblym.Location = new System.Drawing.Point(240, 144);
            this.lblym.Name = "lblym";
            this.lblym.Size = new System.Drawing.Size(24, 24);
            this.lblym.TabIndex = 14;
            this.lblym.Tag = "玉門";
            this.lblym.Click += new System.EventHandler(this.lblwlmq_Click);

// 

            // lblgel
            // 
            this.lblgel.BackColor = System.Drawing.Color.Transparent;
            this.lblgel.Location = new System.Drawing.Point(208, 192);
            this.lblgel.Name = "lblgel";
            this.lblgel.Size = new System.Drawing.Size(24, 24);
            this.lblgel.TabIndex = 13;
            this.lblgel.Tag = "格爾木";
            this.lblgel.Click += new System.EventHandler(this.lblwlmq_Click);
            // 
            // lblhm
            // 
            this.lblhm.BackColor = System.Drawing.Color.Transparent;
            this.lblhm.Location = new System.Drawing.Point(208, 112);
            this.lblhm.Name = "lblhm";
            this.lblhm.Size = new System.Drawing.Size(24, 24);
            this.lblhm.TabIndex = 12;
            this.lblhm.Tag = "哈密";
            this.lblhm.Click += new System.EventHandler(this.lblwlmq_Click);
            // 
            // lblwlmq
            // 
            this.lblwlmq.BackColor = System.Drawing.Color.Transparent;
            this.lblwlmq.Location = new System.Drawing.Point(160, 96);
            this.lblwlmq.Name = "lblwlmq";
            this.lblwlmq.Size = new System.Drawing.Size(24, 24);
            this.lblwlmq.TabIndex = 11;
            this.lblwlmq.Tag = "烏魯木齊";
            this.lblwlmq.Click += new System.EventHandler(this.lblwlmq_Click);
            // 
            // tabtrainresult
            // 
            this.tabtrainresult.Controls.Add(this.dgtrainresult);
            this.tabtrainresult.Location = new System.Drawing.Point(4, 21);
            this.tabtrainresult.Name = "tabtrainresult";
            this.tabtrainresult.Size = new System.Drawing.Size(720, 391);
            this.tabtrainresult.TabIndex = 1;
            this.tabtrainresult.Text = "查詢結果";
            // 
            // dgtrainresult
            // 
            this.dgtrainresult.DataMember = "";
            this.dgtrainresult.Dock = System.Windows.Forms.DockStyle.Fill;
            this.dgtrainresult.HeaderForeColor = System.Drawing.SystemColors.ControlText;
            this.dgtrainresult.Location = new System.Drawing.Point(0, 0);
            this.dgtrainresult.Name = "dgtrainresult";
            this.dgtrainresult.ReadOnly = true;
            this.dgtrainresult.Size = new System.Drawing.Size(720, 391);
            this.dgtrainresult.TabIndex = 0;
            this.dgtrainresult.Click += new System.EventHandler(this.dgtrainresult_Click);
            this.dgtrainresult.CurrentCellChanged += new System.EventHandler(this.dgtrainresult_Click);
            // 
            // tabtraindetails

 // 

            this.tabtraindetails.Controls.Add(this.dgtraindetails);
            this.tabtraindetails.Location = new System.Drawing.Point(4, 21);
            this.tabtraindetails.Name = "tabtraindetails";
            this.tabtraindetails.Size = new System.Drawing.Size(720, 391);
            this.tabtraindetails.TabIndex = 2;
            this.tabtraindetails.Text = "車次詳細信息";
            // 
            // dgtraindetails
            // 
            this.dgtraindetails.DataMember = "";
            this.dgtraindetails.Dock = System.Windows.Forms.DockStyle.Fill;
            this.dgtraindetails.HeaderForeColor = System.Drawing.SystemColors.ControlText;
            this.dgtraindetails.Location = new System.Drawing.Point(0, 0);
            this.dgtraindetails.Name = "dgtraindetails";
            this.dgtraindetails.ReadOnly = true;
            this.dgtraindetails.Size = new System.Drawing.Size(720, 391);
            this.dgtraindetails.TabIndex = 0;
            // 
            // btnprint
            // 
            this.btnprint.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.btnprint.Location = new System.Drawing.Point(464, 72);
            this.btnprint.Name = "btnprint";
            this.btnprint.TabIndex = 11;
            this.btnprint.Text = "打印";
            this.btnprint.Visible = false;
            this.btnprint.Click += new System.EventHandler(this.btnprint_Click);
            // 
            // btnexport
            // 
            this.btnexport.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.btnexport.Location = new System.Drawing.Point(552, 8);
            this.btnexport.Name = "btnexport";
            this.btnexport.TabIndex = 12;
            this.btnexport.Text = "導出為文本";
            this.btnexport.Visible = false;
            this.btnexport.Click += new System.EventHandler(this.btnexport_Click);
            // 
            // btnexportXML
            // 
            this.btnexportXML.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.btnexportXML.Location = new System.Drawing.Point(552, 40);
            this.btnexportxml.Name = "btnexportXML";
            this.btnexportXML.TabIndex = 13;
            this.btnexportxml.Text = "導出為XML";
            this.btnexportXML.Visible = false;
            this.btnexportxml.Click += new System.EventHandler(this.btnexportXML_Click);
            // 
            // btnImportData
            // 
            this.btnImportData.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.btnImportData.Location = new System.Drawing.Point(464, 8);
    &nb
sp;       this.btnImportData.Name = "btnImportData";
            this.btnImportData.TabIndex = 14;
            this.btnImportData.Text = "導入XML";
            this.btnImportData.Click += new System.EventHandler(this.btnImportData_Click);
            // 
            // frmMain
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
            this.ClIEntSize = new System.Drawing.Size(630, 508);
            this.Controls.Add(this.btnImportData);
            this.Controls.Add(this.btnexportXML);
            this.Controls.Add(this.btnexport);
            this.Controls.Add(this.btnprint);
            this.Controls.Add(this.panel1);
            this.Controls.Add(this.btnquery2);
            this.Controls.Add(this.btnquery1);
            this.Controls.Add(this.lbltrainnum);
            this.Controls.Add(this.txttrainnum);
            this.Controls.Add(this.cboMdiStation);
            this.Controls.Add(this.txtfinalstation);
            this.Controls.Add(this.txtbeginstation);
            this.Controls.Add(this.lblfinalstation);
            this.Controls.Add(this.lblmidstation);
            this.Controls.Add(this.lblbeginstation);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
            this.Name = "frmMain";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text =&nbs
p;"列車時刻查詢";
            this.panel1.ResumeLayout(false);
            this.tabdisplay.ResumeLayout(false);
            this.tabmap.ResumeLayout(false);
            this.tabtrainresult.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.dgtrainresult)).EndInit();
            this.tabtraindetails.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.dgtraindetails)).EndInit();
            this.ResumeLayout(false);

        }
        #endregion

        /**//// <summary>
        /// 應用程序的主入口點。
        /// </summary>
        [STAThread]
        static void Main() 
        ...{
            Application.Run(new frmMain());
        }

   /**//// <summary>
        /// 設置站點名稱
        /// </summary>
        /// <param name="station">站點的名稱</param>
        public void setstation(string station)
        ...{
            if(txtbeginstation.Focused)
            ...{
                txtbeginstation.Text=station;
                return;
            }
            if(txtfinalstation.Focused)
            ...{
                txtfinalstation.Text=station;
                return;
            }
        }
        //點擊標簽根據當前控件的tag,添入適當的起點終點站
        private void lblwlmq_Click(object sender, System.EventArgs e)

...{
            Control control=(Control)sender;
            setstation(control.Tag.ToString());
        }    

        //根據起點站、終點站查詢列車信息
        private void btnquery1_Click(object sender, System.EventArgs e)
        ...{    
            schedulesystem.GetScheduleList(txtbeginstation.Text,txtfinalstation.Text);
        }
        
        //單擊DataGrid得到列車的詳細信息
        private void dgtrainresult_Click(object sender, System.EventArgs e)
        ...{
            if(dgtrainresult.DataSource!=null)
            ...{
                schedulesystem.GetMidScheduleList(dgtrainresult[dgt
rainresult.CurrentRowIndex,0].ToString());
            }
        }
        //根據列車車次查詢列車信息
        private void btnquery2_Click(object sender, System.EventArgs e)
        ...{
            schedulesystem.GetScheduleByCode(txttrainnum.Text);
        }
        //打印按扭的顯示與隱藏
        private void tabdisplay_SelectedIndExchanged(object sender, System.EventArgs e)
        ...{
            schedulesystem.showprintbutton();
        }
        //打印
        private void btnprint_Click(object sender, System.EventArgs e)
        ...{
            if(this.tabdisplay.SelectedIndex==1)

   ...{

                printer=new DataGridPrinter(this.schedulesystem.schedule.GetTableResult());
            }
            if(this.tabdisplay.SelectedIndex==2)
            ...{
                printer=new DataGridPrinter(this.schedulesystem.schedule.GetTableDetails());
            }
            try
            ...{
                printer.Print();
            }
            catch(Exception ex)
            ...{
                MessageBox.Show(ex.Message);
            }
        }

        private void txtbeginstation_Enter(object sender, System.EventArgs e)

...{

            cboMdiStation.DataSource=null;
            txttrainnum.Text="";
        }

        private void cboMdiStation_SelectionChangeCommitted(object sender, System.EventArgs e)
        ...{
            schedulesystem.GetMidStation(txtbeginstation.Text,cboMdiStation.SelectedText,txtfinalstation.Text);
        }

        private void txttrainnum_Enter(object sender, System.EventArgs e)
        ...{
            this.dgtraindetails.DataSource=null;
            cboMdiStation.DataSource=null;
            txtbeginstation.Text="";
            txtfinalstation.Text="";
        }

        private void btnexport_Click(object sender, System.EventArgs e)

  ...{

            if(this.tabdisplay.SelectedIndex==1)
            ...{
                if(export.Export(this.schedulesystem.schedule.GetTableResult()))
                ...{
                    MessageBox.Show(this,"導出文本文件成功!","成功",MessageBoxButtons.OK,MessageBoxIcon.Asterisk);
                }
                else
                ...{
                    MessageBox.Show(this,"用戶取消操作","失敗",MessageBoxButtons.OK,MessageBoxIcon.Error);
                }
            }
            if(this.tabdisplay.SelectedIndex==2)

 ...{

                if(export.Export(this.schedulesystem.schedule.GetTableDetails()))
                ...{
                    MessageBox.Show(this,"導出文本文件成功!","成功",MessageBoxButtons.OK,MessageBoxIcon.Asterisk);
                }
                else
                ...{
                    MessageBox.Show(this,"用戶取消操作!","失敗",MessageBoxButtons.OK,MessageBoxIcon.Error);
                }
            }
        }

        private void btnexportXML_Click(object sender, System.EventArgs e)
        ...{
            if(this.tabdisplay.SelectedIndex==1)

   ...{

                if(export.exportXML(this.schedulesystem.schedule.GetTableResult()))
                ...{
                    MessageBox.Show(this,"導出XML文件成功!","成功",MessageBoxButtons.OK,MessageBoxIcon.Asterisk);
                }
                else
                ...{
                    MessageBox.Show(this,"用戶取消操作","失敗",MessageBoxButtons.OK,MessageBoxIcon.Error);
                }
            }
            if(this.tabdisplay.SelectedIndex==2)
            ...{
                if(export.exportXML(this.schedulesystem.schedule.GetTableDetails()))
              &n
bsp; ...{
                    MessageBox.Show(this,"導出XML文件成功!","成功",MessageBoxButtons.OK,MessageBoxIcon.Asterisk);
                }
                else
                ...{
                    MessageBox.Show(this,"用戶取消操作!","失敗",MessageBoxButtons.OK,MessageBoxIcon.Error);
                }
            }
        }

        private void btnImportData_Click(object sender, System.EventArgs e)
        ...{
            if(schedulesystem.ImportData())
            ...{
                MessageBox.Show(this,"導入成功!","成功",MessageBoxButtons.OK,MessageBoxIcon.Asterisk);
            }
            else

..{
                MessageBox.Show(this,"用戶取消操作!","失敗",MessageBoxButtons.OK,MessageBoxIcon.Error);
            }
        }
    }
}

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved