예제 #1
0
        public CY.GFive.Core.Business.File SelectByName(string FileName)
        {
            if (string.IsNullOrEmpty(FileName))
                return null;

            SqlServerUtility sql = new SqlServerUtility();

            sql.AddParameter("@Name", SqlDbType.NVarChar, FileName, 30);

            SqlDataReader reader = sql.ExecuteSqlReader(SqlSelectFileByName);

            if (reader != null && !reader.IsClosed && reader.Read())
            {
                Core.Business.File file = new Core.Business.File();

                if (!reader.IsDBNull(0)) file.Id = reader.GetInt32(0);
                if (!reader.IsDBNull(1)) file.UpLoadDate = reader.GetDateTime(1);
                if (!reader.IsDBNull(2)) file.FileName = reader.GetString(2);
                if (!reader.IsDBNull(3)) file.FileCode = reader.GetString(3);
                if (!reader.IsDBNull(4)) file.FileCate = reader.GetString(4);
                if (!reader.IsDBNull(5)) file.UserCode = reader.GetString(5);
                if (!reader.IsDBNull(6)) file.DepartCode = reader.GetString(6);

                reader.Close();

                file.MarkOld();

                return file;
            }
            else
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();

                return null;
            }
        }
예제 #2
0
        public IList<Core.Business.File> GetAllFile()
        {
            IList<Core.Business.File> filelist = new List<Core.Business.File>();
            SqlServerUtility sql = new SqlServerUtility();

            SqlDataReader reader = sql.ExecuteSqlReader(SqlGetAllFile);

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.File file = new Core.Business.File();

                    if (!reader.IsDBNull(0)) file.Id = reader.GetInt32(0);
                    if (!reader.IsDBNull(1)) file.UpLoadDate = reader.GetDateTime(1);
                    if (!reader.IsDBNull(2)) file.FileName = reader.GetString(2);
                    if (!reader.IsDBNull(3)) file.FileCode = reader.GetString(3);
                    if (!reader.IsDBNull(4)) file.FileCate = reader.GetString(4);
                    if (!reader.IsDBNull(5)) file.UserCode = reader.GetString(5);
                    if (!reader.IsDBNull(6)) file.DepartCode = reader.GetString(6);

                    file.MarkOld();
                    filelist.Add(file);
                }
                reader.Close();
            }
            return filelist;
        }