public bool GetConnection()
        {
            string ConnectionString = string.Empty;

            if (_DatabaseConnection == null || _DatabaseConnection.State == ConnectionState.Closed)
            {
                if (ConnectionString == string.Empty)
                {
                    //ConnectionString = ConfigurationManager.ConnectionStrings["ReservationConnectionString"].ConnectionString.ToString();
                }
                _DatabaseConnection = new SqlConnection();
                //_DatabaseConnection.ConnectionString = ConnectionString;
                ConnectionString = @"Data Source=IBM-5163992E35F\NetSDK;Initial Catalog=Reservation;Integrated Security=True";
                _DatabaseConnection.ConnectionString = ConnectionString;
                try
                {
                    _DatabaseConnection.Open();
                }
                catch (Exception ex)
                {
                    GenFunctions.LogError("clsDatabaseManager.GetConnection", ex.Message.ToString());
                    ConnectionString = string.Empty;
                    return(false);
                }
                ConnectionString = string.Empty;
            }
            return(true);
        }
        public bool GetConnection(string DatabaseType)
        {
            string ConnectionString = string.Empty;

            if (string.Compare(DatabaseType, "APPDB", true) == 0)
            {
                if (_DatabaseConnection == null || _DatabaseConnection.State == ConnectionState.Closed)
                {
                    if (ConnectionString == string.Empty)
                    {
                        GetConnectionString();
                    }
                    _DatabaseConnection = new SqlConnection();
                    _DatabaseConnection.ConnectionString = ConnectionString;
                    try
                    {
                        _DatabaseConnection.Open();
                    }
                    catch (Exception ex)
                    {
                        GenFunctions.LogError("clsDatabaseManager.GetConnection", ex.Message.ToString());
                        ConnectionString = string.Empty;
                        return(false);
                    }
                    ConnectionString = string.Empty;
                }
            }
            if (string.Compare(DatabaseType, "REMDB", true) == 0)
            {
                if (_RemoteConnection == null || _RemoteConnection.State == ConnectionState.Closed)
                {
                    if (ConnectionString == string.Empty)
                    {
                        GetConnectionString();
                    }
                    _RemoteConnection = new SqlConnection();
                    _RemoteConnection.ConnectionString = ConnectionString;
                    try
                    {
                        _RemoteConnection.Open();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        ConnectionString = string.Empty;
                        return(false);
                    }
                    ConnectionString = string.Empty;
                }
            }

            return(true);
        }
 public bool ExecuteQuery(String strActionString)
 {
     InitializeDatabaseConnection();
     try
     {
         SqlCommand SC = new SqlCommand(strActionString, ApplicationConnection);
         SC.CommandType = CommandType.Text;
         SC.ExecuteNonQuery();
         return(true);
     }
     catch (Exception E)
     {
         Console.WriteLine(E.Message);
         GenFunctions.LogError("clsDatabaseManager.ExecuteQuery", E.Message);
         return(false);
     }
 }
Beispiel #4
0
        public clsBookingRoomReportsData[] GetDetailedBookingDetails(int BookingId)
        {
            clsBookingRoomReportsData[] oBRD = null;
            clsDatabaseManager          oDB  = null;

            try
            {
                oDB = new clsDatabaseManager();
                string sProcName = "up_GetDetailedBookingDetails";
                oDB.DbCmd = oDB.GetStoredProcCommand(sProcName);
                oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@BookingId", DbType.Int32, BookingId);
                DataSet dsBRD = null;
                dsBRD = oDB.ExecuteDataSet(oDB.DbCmd);
                oDB   = null;

                if (dsBRD != null)
                {
                    oBRD = new clsBookingRoomReportsData[dsBRD.Tables[0].Rows.Count];
                    for (int i = 0; i < oBRD.Length; i++)
                    {
                        oBRD[i] = new clsBookingRoomReportsData();
                        oBRD[i].RoomCategory    = dsBRD.Tables[0].Rows[i][0].ToString();
                        oBRD[i].RoomType        = dsBRD.Tables[0].Rows[i][1].ToString();
                        oBRD[i].TotalBooked     = Convert.ToInt32(dsBRD.Tables[0].Rows[i][2].ToString());
                        oBRD[i].TotalWaitlisted = Convert.ToInt32(dsBRD.Tables[0].Rows[i][3].ToString());
                    }
                    dsBRD = null;
                }
            }
            catch (Exception exp)
            {
                oDB = null;
                GenFunctions.LogError("clsBookingRoomReportsHandler.GetDetailedBookingDetails", exp.Message);
                return(null);
            }
            finally
            {
                oDB = null;
            }
            return(oBRD);
        }