tdsflight.cs

来自「航空公司用的简单管理系统」· CS 代码 · 共 57 行

CS
57
字号
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.Common;
using System.ComponentModel;
using System;

namespace SouthernAir.Business.TypeDataSet {

    [DataObject]
    partial class tdsFlight
    { 
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public static BSAFlightDataTable GetResult(string strObjectAddress, string strYear, string strMonth, string strDay,
            string strPrice)
        {
            string strDate = strYear + "-" + strMonth + "-" + strDay;
            string strConn = "Data Source=192.168.210.203;Initial Catalog=TRTESTDB;Persist Security Info=True;User ID=test001;Password=test001-";
            string strSQL = "";
            if (strPrice == "无要求")
            {
                strSQL = "Select * From BSAFlight Where ObjectAddress = '" + strObjectAddress + "' and FlightDate = '" + strDate + "'";
            }
            else if (strPrice == "800以内")
            {
                strSQL = "Select * From BSAFlight Where ObjectAddress = '" + strObjectAddress + "' and FlightDate = '" + strDate + "' and CPrice <= 800";
            }
            else if (strPrice == "1000以内")
            {
                strSQL = "Select * From BSAFlight Where ObjectAddress = '" + strObjectAddress + "' and FlightDate = '" + strDate + "' and CPrice <= 1000";
            }
            else if (strPrice == "1200以内")
            {
                strSQL = "Select * From BSAFlight Where ObjectAddress = '" + strObjectAddress + "' and FlightDate = '" + strDate + "' and CPrice <= 1200";
            }
            else if (strPrice == "1500以内")
            {
                strSQL = "Select * From BSAFlight Where ObjectAddress = '" + strObjectAddress + "' and FlightDate = '" + strDate + "' and CPrice <= 1500";
            }
            else 
            {
                strSQL = "Select * From BSAFlight";
            }
            using (SqlConnection conn = new SqlConnection(strConn))
            {
                conn.Open();
                SqlDataAdapter da = new SqlDataAdapter(strSQL, conn);
                DataSet ds = new DataSet();
                da.Fill(ds, "Result");
                BSAFlightDataTable oDataTable = new BSAFlightDataTable();
                oDataTable.Merge(ds.Tables["Result"]);
                return oDataTable;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?