public List <FILE_COMPONENT> getDataSource()
        {
            List <FILE_COMPONENT> list = new List <FILE_COMPONENT>();
            FILE_COMPONENT        obj  = null;
            SqlConnection         conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            String sql = "USE [rbi]" +
                         "SELECT [FileID]" +
                         ",[ComponentID]" +
                         ",[FileDocName]" +
                         ",[FileType]" +
                         ",[FileDescription]" +
                         ",[OriFileName]" +
                         ",[FileBinary]" +
                         ",[FileSize]" +
                         ",[FileExt]" +
                         ",[DateUploaded]" +
                         "  FROM [rbi].[dbo].[FILE_COMPONENT]";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        if (reader.HasRows)
                        {
                            obj             = new FILE_COMPONENT();
                            obj.FileID      = reader.GetInt32(0);
                            obj.ComponentID = reader.GetInt32(1);
                            obj.FileDocName = reader.GetString(2);
                            obj.FileType    = reader.GetInt32(3);
                            if (!reader.IsDBNull(4))
                            {
                                obj.FileDescription = reader.GetString(4);
                            }
                            obj.OriFileName  = reader.GetString(5);
                            obj.FileBinary   = (byte[])reader[6];
                            obj.FileSize     = reader.GetString(7);
                            obj.FileExt      = reader.GetString(8);
                            obj.DateUploaded = reader.GetDateTime(9);
                            list.Add(obj);
                        }
                    }
                }
            }
            catch
            {
                MessageBox.Show("GET DATA SOURCE FAIL!");
            }
            finally
            {
                conn.Close();
            }
            return(list);
        }
Exemplo n.º 2
0
 public void delete(FILE_COMPONENT obj)
 {
     DAL.delete(obj.FileID);
 }
Exemplo n.º 3
0
 public void edit(FILE_COMPONENT obj)
 {
     DAL.edit(obj.FileID, obj.ComponentID, obj.FileDocName, obj.FileType, obj.FileDescription, obj.OriFileName, obj.FileBinary[0],
              obj.FileSize, obj.FileExt, obj.DateUploaded);
 }