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

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

編輯:.NET實例教程


控制層:

1.處理界面需求 包括按鈕的顯示,起點站,終點站的查詢.等等,代碼中有詳細的注釋,這裡不再多說

 



using System;
using System.Data;

namespace train
...{
    /**//// <summary>
    /// ScheduleSystem:業務
    /// </summary>
    public class ScheduleSystem
    ...{
        public Schedule schedule;
        private frmMain frmtrain;
        private DataTable dt;
        public ScheduleSystem(frmMain frmtrain)
        ...{
            this.frmtrain=frmtrain;
            schedule=new Schedule();
            dt=new DataTable();
             }


        /**//// <summary>
        /// 根據起點站、終點站得到列車信息
        /// </summary>
        /// <param name="fromcity">起點站</param>
        /// <param name="tocity">終點站</param>
        public void GetScheduleList(string fromcity,string tocity)
        ...{    
            //            frmtrain.dgtraindetails.DataSource=null;
            frmtrain.dgtrainresult.DataSource=schedule.SearchScheduleList(fromcity,tocity);
            dt=(DataTable)frmtrain.dgtrainresult.DataSource;
            //如果沒有直達車則選擇中間站
            if(dt.Rows.Count==0)
            ...{
                frmtrain.btnexportXML.Visible=false;
                frmtrain.btnexport.Visible=false;
                frmtrain.btnprint.Visible=false;
              &n  
bsp; GetMidList(tocity);
            }
            else
            ...{
                frmtrain.btnexportXML.Visible=true;
                frmtrain.btnexport.Visible=true;
                frmtrain.btnprint.Visible=true;
            }
            
            frmtrain.tabdisplay.SelectedIndex=1;
            
        }


        /**//// <summary>
        /// 顯示用用戶單擊某列車的詳細信息
        /// </summary>
        /// <param name="code">列車的車次</param>
        public void GetMidScheduleList(string code)
        ...{
            frmtrain.dgtraindetails.DataSource=schedule.SearchMidScheduleList(code);
     ;       frmtrain.tabdisplay.SelectedIndex=2;
            frmtrain.btnprint.Visible=true;
            frmtrain.btnexport.Visible=true;
            frmtrain.btnexportXML.Visible=true;
        }


        /**//// <summary>
        /// 得到中間站的信息
        /// </summary>
        /// <param name="tocity">終點站的名字</param>
        private void GetMidList(string tocity)
        ...{
            frmtrain.cboMdiStation.DataSource=schedule.SearchMidList(tocity);
            frmtrain.cboMdiStation.DisplayMember="cityname";
            frmtrain.cboMdiStation.DroppedDown=true;
            frmtrain.dgtraindetails.DataSource=null;

        }


        /**//// <summary>
    &n
bsp;   /// 根據列車的車次獲得列車詳細信息
        /// </summary>
        /// <param name="code">列車車次</param>
        public void GetScheduleByCode(string code)
        ...{
            frmtrain.dgtrainresult.DataSource=schedule.SearchScheduleByCode(code);
            dt=(DataTable)frmtrain.dgtrainresult.DataSource;
            if(dt.Rows.Count==0)
            ...{
                frmtrain.btnexportXML.Visible=false;
                frmtrain.btnexport.Visible=false;
                frmtrain.btnprint.Visible=false;
            }
            else
            ...{
                frmtrain.btnexportXML.Visible=true;
                frmtrain.btnexport.Visible=true;
                frmtrain.btnprint.Visible=true;
            }

 frmtrain.tabdisplay.SelectedIndex=1;

        }
        
        /**//// <summary>
        /// 根據選擇的中間站得到起點站、中間站、終點站的詳細信息
        /// </summary>
        /// <param name="fromcity">起點站</param>
        /// <param name="midcity">中間站</param>
        /// <param name="finalcity">終點站</param>
        public void GetMidStation(string fromcity,string midcity,string finalcity)
        ...{
            frmtrain.dgtrainresult.DataSource=schedule.SearchMidStation(fromcity,midcity,finalcity);
            dt=(DataTable)frmtrain.dgtrainresult.DataSource;
            if(dt.Rows.Count==0)
            ...{
                frmtrain.btnexportXML.Visible=false;
                frmtrain.btnexport.Visible=false;
                frmtrain.btnprint.Visible=false;
            }

else

            ...{
                frmtrain.btnexportXML.Visible=true;
                frmtrain.btnexport.Visible=true;
                frmtrain.btnprint.Visible=true;
            }
            frmtrain.tabdisplay.SelectedIndex=1;
        }

        /**//// <summary>
        /// 打印按扭的顯示與隱藏
        /// </summary>
        public void showprintbutton()
        ...{
                switch(frmtrain.tabdisplay.SelectedIndex)
                ...{

 case 1:
                        if(frmtrain.dgtrainresult.DataSource!=null)
                        ...{
                            dt=(DataTable)frmtrain.dgtrainresult.DataSource;
                            if(dt.Rows.Count!=0)
                            ...{
                                frmtrain.btnexportXML.Visible=true;
                                frmtrain.btnexport.Visible=true;
                                frmtrain.btnprint.Visible=true;
                            }
                            else
                            ...{
                                frmtrain.btnexportXML.Visible=false;

 frmtrain.btnexport.Visible=false;

                                frmtrain.btnprint.Visible=false;
                            }
                        }
                        else
                        ...{
                            frmtrain.btnexportXML.Visible=false;
                            frmtrain.btnexport.Visible=false;
                            frmtrain.btnprint.Visible=false;
                        }
                        break;
                    case 2:
                        if(frmtrain.dgtraindetails.DataSource!=null)
                        ...{
                            dt=(DataTable)frmtrain.dgtraindetails.DataSource;
                            if(dt.Rows.Count!=0)

  ...{
                                frmtrain.btnexportXML.Visible=true;
                                frmtrain.btnexport.Visible=true;
                                frmtrain.btnprint.Visible=true;
                            }
                            else
                            ...{
                                frmtrain.btnexportXML.Visible=false;
                                frmtrain.btnexport.Visible=false;
                                frmtrain.btnprint.Visible=false;
                            }
                        }
                        else
                        ...{   frmtrain.btnexportXML.Visible=false;
                            frmtrain.btnexport.Visible=false;
                            frmtrain.btnprint.Visible=false;
                        }
                        break;
                    case 0:
                        frmtrain.btnexportXML.Visible=false;
                        frmtrain.btnexport.Visible=false;
                        frmtrain.btnprint.Visible=false;
                        break;
                }
            
        
        }

        /**//// <summary>
        /// 導入數據
        /// </summary>
        /// <returns>返回一個bool值以表示是否導入成功</returns>
        public bool ImportData()
        ...{
      ImportData importdata=new ImportData();
            dt=importdata.ImportDataFromXML();
            if(dt!=null)
            ...{
                frmtrain.dgtrainresult.DataSource=dt;
                frmtrain.tabdisplay.SelectedIndex=1;
                return true;
            }
            else
            ...{
                return false;
            }
        }
    }
}

 


 

 

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