コード例 #1
0
        public List <DomainModels.Status> GetStatuses()
        {
            List <DomainModels.Status> StatusOptions = new List <DomainModels.Status>();

            using (SqlConnection con = new SqlConnection(getConnectionStringFromSettings()))
            {
                try
                {
                    con.Open();
                    string sqlCmdText = "SELECT StatusID, StatusText, StatusObjectID FROM dbo.Status";
                    using (SqlCommand command = new SqlCommand(sqlCmdText, con))
                    {
                        SqlDataReader sReader = command.ExecuteReader();
                        while (sReader.Read())
                        {
                            int    id                 = DBHelper.GetValueOrDefault <int>(sReader, sReader.GetOrdinal("StatusID"));
                            string text               = sReader["StatusText"].ToString();
                            int    statObjId          = DBHelper.GetValueOrDefault <int>(sReader, sReader.GetOrdinal("StatusObjectID"));
                            DomainModels.Status nStat = new DomainModels.Status(id, text, statObjId);
                            StatusOptions.Add(nStat);
                        }
                    }
                }
                catch (Exception ex)
                {
                    string     strErr = " Exception Error in DataProvider GetStatuses(). Details: " + ex.ToString();
                    MessageLog alog   = new MessageLog(MessageType.Exception, " GetStatuses Exception Message=" + strErr);
                    logger.Error(alog.CreateAuditLogMessage());
                    throw;
                }
                return(StatusOptions);
            }
        }
コード例 #2
0
        public List <DomainModels.Status> GetStatusesFilteredByLocation(string locationShort)
        {
            List <DomainModels.Status> StatusOptions = new List <DomainModels.Status>();

            using (SqlConnection con = new SqlConnection(getConnectionStringFromSettings()))
            {
                try
                {
                    con.Open();
                    string sqlCmdText = string.Empty;

                    if (locationShort.CompareTo("NOS") == 0)
                    {
                        sqlCmdText = "SELECT S.StatusID, StatusText, StatusObjectID FROM dbo.Status S INNER JOIN dbo.LocationStatusRelation LSR ON LSR.StatusID = S.StatusID " +
                                     "WHERE LocationShort = @LOCATION AND S.StatusID <> 10 ORDER BY SortOrder";        //Filter out Departed option
                    }
                    else
                    {
                        sqlCmdText = "SELECT S.StatusID, StatusText, StatusObjectID FROM dbo.Status S INNER JOIN dbo.LocationStatusRelation LSR ON LSR.StatusID = S.StatusID WHERE LocationShort = @LOCATION ORDER BY SortOrder";
                    }

                    using (SqlCommand command = new SqlCommand(sqlCmdText, con))
                    {
                        command.Parameters.Add(new SqlParameter("@LOCATION", locationShort));
                        SqlDataReader sReader = command.ExecuteReader();
                        while (sReader.Read())
                        {
                            int    id                 = DBHelper.GetValueOrDefault <int>(sReader, sReader.GetOrdinal("StatusID"));
                            string text               = sReader["StatusText"].ToString();
                            int?   statObjId          = DBHelper.GetValueOrDefault <int?>(sReader, sReader.GetOrdinal("StatusObjectID"));
                            DomainModels.Status nStat = new DomainModels.Status(id, text, statObjId);
                            StatusOptions.Add(nStat);
                        }
                    }
                }
                catch (Exception ex)
                {
                    string     strErr = " Exception Error in DataProvider GetStatuses(). Details: " + ex.ToString();
                    MessageLog alog   = new MessageLog(MessageType.Exception, " GetStatuses Exception Message=" + strErr);
                    logger.Error(alog.CreateAuditLogMessage());
                    throw;
                }
                return(StatusOptions);
            }
        }