public int InsertFlight(FlightBDto flight, ref int flightId)
        {
            Database db = null;
            DbCommand dbCmd = null;
            int Result = 0;
            try
            {
                db = DatabaseFactory.CreateDatabase(DALHelper.CRM_CONNECTION_STRING);
                dbCmd = db.GetStoredProcCommand("dbo.USP_FARE_FLIGHT_MASTER_INSERT");

                if (flight.AirlineId != 0)
                    db.AddInParameter(dbCmd, "@AIRLINE_ID", DbType.Int32, flight.AirlineId);
                else
                    db.AddInParameter(dbCmd, "@AIRLINE_ID", DbType.Int32, DBNull.Value);

                if (flight.DaysInOperation != 0)
                    db.AddInParameter(dbCmd, "@DAYS_IN_OPERATION", DbType.Int32, flight.DaysInOperation);
                else
                    db.AddInParameter(dbCmd, "@DAYS_IN_OPERATION", DbType.Int32, DBNull.Value);

                if (flight.EffectiveFrom != DateTime.MinValue)
                    db.AddInParameter(dbCmd, "@EFFECTIVE_FROM", DbType.DateTime, flight.EffectiveFrom);
                else
                    db.AddInParameter(dbCmd, "@EFFECTIVE_FROM", DbType.DateTime, DBNull.Value);

                if (flight.DestinationCity != 0)
                    db.AddInParameter(dbCmd, "@DESTINATION_CITY_ID", DbType.Int32, flight.DestinationCity);
                else
                    db.AddInParameter(dbCmd, "@DESTINATION_CITY_ID", DbType.Int32, DBNull.Value);

                if (flight.SourceCity != 0)
                    db.AddInParameter(dbCmd, "@SOURCE_CITY_ID", DbType.Int32, flight.SourceCity);
                else
                    db.AddInParameter(dbCmd, "@SOURCE_CITY_ID", DbType.Int32, DBNull.Value);

                //if (flight.Duration != 0)
                db.AddInParameter(dbCmd, "@DURATION", DbType.Decimal, flight.Duration);
                //else
                //    db.AddInParameter(dbCmd, "@DURATION", DbType.Decimal, DBNull.Value);

                if (flight.TimeOfArrival != DateTime.MinValue)
                    db.AddInParameter(dbCmd, "@ARRIVAL_TIME", DbType.DateTime, flight.TimeOfArrival);
                else
                    db.AddInParameter(dbCmd, "@ARRIVAL_TIME", DbType.DateTime, DBNull.Value);

                if (flight.TimeOfDeparture != DateTime.MinValue)
                    db.AddInParameter(dbCmd, "@DEP_TIME", DbType.DateTime, flight.TimeOfDeparture);
                else
                    db.AddInParameter(dbCmd, "@DEP_TIME", DbType.DateTime, DBNull.Value);

                if (!String.IsNullOrEmpty(flight.FlightNo))
                    db.AddInParameter(dbCmd, "@FLIGHT_NO", DbType.String, flight.FlightNo);
                else
                    db.AddInParameter(dbCmd, "@FLIGHT_NO", DbType.String, DBNull.Value);

                db.AddInParameter(dbCmd, "@IS_STOP", DbType.Boolean, flight.IsStop);

                if (!String.IsNullOrEmpty(flight.Via))
                    db.AddInParameter(dbCmd, "@VIA", DbType.String, flight.Via);
                else
                    db.AddInParameter(dbCmd, "@VIA", DbType.String, DBNull.Value);

              //  if (flight.Currancy != 0)
                    db.AddInParameter(dbCmd, "@CURRENCY_ID", DbType.Int32, flight.Currancy);
               // else
                  //  db.AddInParameter(dbCmd, "@CURRENCY_ID", DbType.Int32, DBNull.Value);

               // if (flight.TotalFare != 0)
                    db.AddInParameter(dbCmd, "@TOTAL_FARE", DbType.Int32, flight.TotalFare);
              //  else
                //    db.AddInParameter(dbCmd, "@TOTAL_FARE", DbType.Int32, DBNull.Value);

               // if (flight.Tax != 0)
                    db.AddInParameter(dbCmd, "@TAX", DbType.Decimal, flight.Tax);
                //else
                //    db.AddInParameter(dbCmd, "@TAX", DbType.Decimal, DBNull.Value);

               // if (flight.GST != 0)
                    db.AddInParameter(dbCmd, "@GST", DbType.Decimal, flight.GST);
                //else
                //    db.AddInParameter(dbCmd, "@GST", DbType.Decimal, DBNull.Value);

                db.AddInParameter(dbCmd, "@DISPLAY_ON_WEB", DbType.Boolean, flight.IsDisplayonweb);

                if (flight.UserId != 0)
                    db.AddInParameter(dbCmd, "@USER_ID", DbType.Int32, flight.UserId);
                else
                    db.AddInParameter(dbCmd, "@USER_ID", DbType.Int32, DBNull.Value);

                db.AddOutParameter(dbCmd, "@FLIGHT_ID", DbType.Int32, 9);
                Result = db.ExecuteNonQuery(dbCmd);
                flightId = Convert.ToInt32(db.GetParameterValue(dbCmd, "@FLIGHT_ID"));
            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, DALHelper.DAL_EXP_POLICYNAME);
                if (rethrow)
                {
                    throw ex;
                }
            }
            finally
            {
                DALHelper.Destroy(ref dbCmd);
            }
            return Result;
        }
        public int UpdateFlightCurrencyPriceDetails(FlightBDto flightGds)
        {
            Database db = null;
            DbCommand dbCmd = null;
            int Result = 0;
            try
            {
                db = DatabaseFactory.CreateDatabase(DALHelper.CRM_CONNECTION_STRING);
                dbCmd = db.GetStoredProcCommand(DALHelper.USP_FARE_FLIGHT_CURRENCY_PRICE_UPDATE);

                db.AddInParameter(dbCmd, "@CURRENCY_PRICE_ID", DbType.Int32, flightGds.CurrancyPriceId);
                db.AddInParameter(dbCmd, "@FLIGHT_ID", DbType.Int32, flightGds.FlightId);
                db.AddInParameter(dbCmd, "@FLIGHT_CURRENCY", DbType.Int32, flightGds.Currancy);
               // if (flightGds.Adult_Amt != 0)
                    db.AddInParameter(dbCmd, "@AUDULT_AMT", DbType.Decimal, flightGds.Adult_Amt);
               // else
                //    db.AddInParameter(dbCmd, "@AUDULT_AMT", DbType.Decimal, DBNull.Value);


              //  if (flightGds.Adult_Tax != 0)
                    db.AddInParameter(dbCmd, "@AUDULT_TAX", DbType.Decimal, flightGds.Adult_Tax);
              //  else
                //    db.AddInParameter(dbCmd, "@AUDULT_TAX", DbType.Decimal, DBNull.Value);


               // if (flightGds.Adult_Gst != 0)
                    db.AddInParameter(dbCmd, "@AUDULT_GST", DbType.Decimal, flightGds.Adult_Gst);
              //  else
                  //  db.AddInParameter(dbCmd, "@AUDULT_GST", DbType.Decimal, DBNull.Value);
                

                //if (flightGds.Child_Amt != 0)
                    db.AddInParameter(dbCmd, "@CHILD_AMT", DbType.Decimal, flightGds.Child_Amt);
               // else
                //    db.AddInParameter(dbCmd, "@CHILD_AMT", DbType.Decimal, DBNull.Value);


               // if (flightGds.Child_Tax != 0)
                    db.AddInParameter(dbCmd, "@CHILD_TAX", DbType.Decimal, flightGds.Child_Tax);
                //else
                  //  db.AddInParameter(dbCmd, "@CHILD_TAX", DbType.Decimal, DBNull.Value);


              //  if (flightGds.Child_Gst != 0)
                    db.AddInParameter(dbCmd, "@CHILD_GST", DbType.Decimal, flightGds.Child_Gst);
              //  else
                //    db.AddInParameter(dbCmd, "@CHILD_GST", DbType.Decimal, DBNull.Value);   

               // if (flightGds.Infant_Amt != 0)
                    db.AddInParameter(dbCmd, "@INFANT_AMT", DbType.Decimal, flightGds.Infant_Amt);
               // else
                  //  db.AddInParameter(dbCmd, "@INFANT_AMT", DbType.Decimal, DBNull.Value);


              //  if (flightGds.Infant_Tax != 0)
                    db.AddInParameter(dbCmd, "@INFANT_TAX", DbType.Decimal, flightGds.Infant_Tax);
               // else
                  //  db.AddInParameter(dbCmd, "@INFANT_TAX", DbType.Decimal, DBNull.Value);


             //   if (flightGds.Infant_Gst != 0)
                    db.AddInParameter(dbCmd, "@INFANT_GST", DbType.Decimal, flightGds.Infant_Gst);
              //  else
                //    db.AddInParameter(dbCmd, "@INFANT_GST", DbType.Decimal, DBNull.Value);

                db.AddOutParameter(dbCmd, "@ISEXIST", DbType.Int32, 1);
                int r = db.ExecuteNonQuery(dbCmd);
                Result = Convert.ToInt32(db.GetParameterValue(dbCmd, "@ISEXIST"));
                return Result;
               
            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, DALHelper.DAL_EXP_POLICYNAME);
                if (rethrow)
                {
                    throw ex;
                }
            }
            finally
            {
                DALHelper.Destroy(ref dbCmd);
            }
            return 0;
        }