コード例 #1
0
ファイル: DayOfOperation.cs プロジェクト: zaieda/TemPOS
        public static DayOfOperation GetLatestInYear(short year)
        {
            DayOfOperation result = null;
            SqlConnection  cn     = GetConnection();

            using (SqlCommand cmd = new SqlCommand("SELECT TOP 1 * FROM DayOfOperation WHERE DayOfOperationStartOfDayWhen<=@LastDayOfYear ORDER BY DayOfOperationStartOfDayWhen DESC", cn))
            {
                BuildSqlParameter(cmd, "@LastDayOfYear", SqlDbType.DateTime, new DateTime(year, 12, 31, 23, 59, 59));
                SqlDataReader rdr = cmd.ExecuteReader();
                if (rdr.Read())
                {
                    result = BuildDayOfOperation(rdr);
                }
                rdr.Close();
            }
            FinishedWithConnection(cn);
            return(result);
        }
コード例 #2
0
ファイル: DayOfOperation.cs プロジェクト: zaieda/TemPOS
        public static DayOfOperation Get(int id)
        {
            DayOfOperation result = null;
            SqlConnection  cn     = GetConnection();

            using (SqlCommand cmd = new SqlCommand("SELECT * FROM DayOfOperation WHERE DayOfOperationId=" + id, cn))
            {
                using (SqlDataReader rdr = cmd.ExecuteReader())
                {
                    if (rdr.Read())
                    {
                        result = BuildDayOfOperation(rdr);
                    }
                }
            }
            FinishedWithConnection(cn);
            return(result);
        }
コード例 #3
0
ファイル: DayOfOperation.cs プロジェクト: zaieda/TemPOS
        public static DayOfOperation GetEarliestInYear(short year)
        {
            DayOfOperation result = null;
            SqlConnection  conn   = GetConnection();

            using (SqlCommand cmd = new SqlCommand("SELECT TOP 1 * FROM DayOfOperation WHERE DayOfOperationStartOfDayWhen>=@FirstDayOfYear ORDER BY DayOfOperationStartOfDayWhen", conn))
            {
                BuildSqlParameter(cmd, "@FirstDayOfYear", SqlDbType.DateTime, new DateTime(year, 1, 1, 0, 0, 0));
                using (SqlDataReader rdr = cmd.ExecuteReader())
                {
                    if (rdr.Read())
                    {
                        result = BuildDayOfOperation(rdr);
                    }
                }
            }
            FinishedWithConnection(conn);
            return(result);
        }
コード例 #4
0
ファイル: DayOfOperation.cs プロジェクト: zaieda/TemPOS
        private static int GetHighestDayOfOperationId()
        {
            DayOfOperation highestDayOfOperation = null;
            int            highestId             = 0;
            SqlConnection  cn = GetConnection();

            using (SqlCommand cmd =
                       new SqlCommand("SELECT TOP 1 * FROM DayOfOperation ORDER BY DayOfOperationId DESC", cn))
            {
                using (SqlDataReader rdr = cmd.ExecuteReader())
                {
                    if (rdr.Read())
                    {
                        highestDayOfOperation = BuildDayOfOperation(rdr);
                    }
                }
            }
            FinishedWithConnection(cn);
            if (highestDayOfOperation != null)
            {
                highestId = highestDayOfOperation.Id;
            }
            return(highestId);
        }