예제 #1
0
        public bool Update()
        {
            SqlConnection sqlConnection = new SqlConnection(Properties.Settings.Default.AirlineConnectionString);

            sqlConnection.Open();
            try
            {
                // add flight record
                SqlCommand cmd = new SqlCommand("update " + TableName + " set "
                                                + "CarrierNo = '" + CarrierNo + "'" + ","
                                                + "Start = '" + Start + "'" + ","
                                                + "Destination = '" + Destination + "'" + ","
                                                + "LeavingAt = '" + LeavingAt.ToString("yyyy/MM/dd HH:mm:ss") + "'" + ","
                                                + "ArrivalAt = '" + ArrivalAt.ToString("yyyy/MM/dd HH:mm:ss") + "'" + ","
                                                + "EconomyPrice = " + EconomyPrice + ","
                                                + "EconomyCount = " + EconomyCount + ","
                                                + "EconomyPlusPrice = " + EconomyPlusPrice + ","
                                                + "EconomyPlusCount = " + EconomyPlusCount + ","
                                                + "BusinessPrice = " + BusinessPrice + ","
                                                + "BusinessCount = " + BusinessCount
                                                + " where " + Key + " = '" + FlightNo + "'", sqlConnection);
                return(cmd.ExecuteNonQuery() > 0);
            }
            catch
            {
            }
            finally
            {
                sqlConnection.Close();
            }
            return(false);
        }
예제 #2
0
        public bool Add()
        {
            SqlConnection sqlConnection = new SqlConnection(Properties.Settings.Default.AirlineConnectionString);

            sqlConnection.Open();
            try
            {
                // add flight record
                SqlCommand cmd = new SqlCommand("insert into " + TableName + " values("
                                                + "'" + FlightNo + "'" + ","
                                                + "'" + CarrierNo + "'" + ","
                                                + "'" + Start + "'" + ","
                                                + "'" + Destination + "'" + ","
                                                + "'" + LeavingAt.ToString("yyyy/MM/dd HH:mm:ss") + "'" + ","
                                                + "'" + ArrivalAt.ToString("yyyy/MM/dd HH:mm:ss") + "'" + ","
                                                + EconomyPrice + ","
                                                + EconomyCount + ","
                                                + EconomyPlusPrice + ","
                                                + EconomyPlusCount + ","
                                                + BusinessPrice + ","
                                                + BusinessCount
                                                + ")", sqlConnection);
                return(cmd.ExecuteNonQuery() > 0);
            }
            catch
            {
            }
            finally
            {
                sqlConnection.Close();
            }
            return(false);
        }