コード例 #1
0
        public static List <DocumentFile> GetList(SqlTransaction trans, int documentID)
        {
            List <DocumentFile> list = new List <DocumentFile>();

            SqlParameter[] sps = new SqlParameter[1];

            sps[0]       = new SqlParameter("@DocumentID", SqlDbType.Int);
            sps[0].Value = documentID;

            if (trans == null)
            {
                using (SqlDataReader dataReader = SPHelper.ExecuteReader(SpNames.List, sps))
                {
                    DocumentFile df;
                    while (dataReader.Read())
                    {
                        df              = new DocumentFile();
                        df.DocumentID   = (int)dataReader["DocumentID"];
                        df.DepartmentID = (int)dataReader["DepartmentID"];
                        df.WorkerID     = (int)dataReader["WorkerID"];
                        df.FileID       = (int)dataReader["FileID"];
                        df.FileName     = Convert.ToString(dataReader["FileName"]) + "." +
                                          Convert.ToString(dataReader["Extension"]);
                        df.Extension = Convert.ToString(dataReader["Extension"]);
                        list.Add(df);
                    }
                }
            }
            else
            {
                using (SqlDataReader dataReader = SPHelper.ExecuteReader(trans, SpNames.List, sps))
                {
                    DocumentFile df;
                    while (dataReader.Read())
                    {
                        df              = new DocumentFile();
                        df.DocumentID   = (int)dataReader["DocumentID"];
                        df.DepartmentID = (int)dataReader["DepartmentID"];
                        df.WorkerID     = (int)dataReader["WorkerID"];
                        df.FileID       = (int)dataReader["FileID"];
                        df.FileName     = Convert.ToString(dataReader["FileName"]) + "." +
                                          Convert.ToString(dataReader["Extension"]);
                        df.Extension = Convert.ToString(dataReader["Extension"]);
                        list.Add(df);
                    }
                }
            }
            return(list);
        }
コード例 #2
0
        public static void Delete(SqlTransaction trans, int fileID, int documentID, Worker worker)
        {
            DocumentFile df = new DocumentFile(trans, fileID, worker);

            if (df.DepartmentID != worker.DepartmentID)
            {
                throw new AccessException(worker.LastName + " " + worker.FirstName + " " + worker.MiddleName, "Delete");
            }

            SqlParameter[] sps = new SqlParameter[2];

            sps[0]       = new SqlParameter("@FileID", SqlDbType.Int);
            sps[0].Value = fileID;

            sps[1]       = new SqlParameter("@DocumentID", SqlDbType.Int);
            sps[1].Value = documentID;

            SPHelper.ExecuteNonQuery(trans, SpNames.Delete, sps);
        }