Структурированная система хранения документов предприятия
Снижение накладных расходов при ведении учета бумажной документации в малых организациях за счет создания электронной базы документов. Критерии эффективности функционирования структурированной системы хранения документов, особенности ее разработки.
Рубрика | Программирование, компьютеры и кибернетика |
Вид | дипломная работа |
Язык | русский |
Дата добавления | 27.01.2016 |
Размер файла | 803,6 K |
Отправить свою хорошую работу в базу знаний просто. Используйте форму, расположенную ниже
Студенты, аспиранты, молодые ученые, использующие базу знаний в своей учебе и работе, будут вам очень благодарны.
using DKCore. ConcreteDocuments. Interfaces. DB;
using DKCore. DataBase. Objects;
namespace DKCore. DataBase
{
public class DBDocumentSelector
{
public DBDocumentSelector ()
{
ConcreteDocFilters = new Dictionary<DBO_DocType, DBConcreteInfoFilter> ();
}
// Фильтр 1 (по документам в целом)
public DBDocumentFilter DocumentFilter { get; set; }
// Фильтр 1 (по документам в целом)
public DBCommonInfoFilter CommonInfoFilter { get; set; }
// Фильтры по каждому из типов документов
public Dictionary<DBO_DocType, DBConcreteInfoFilter> ConcreteDocFilters { get; set; }
}
}
Файл DBCompleFieldAttribute
using System;
using System. Collections. Generic;
using System. Linq;
using System. Text;
namespace DKCore. DataBase. Attributes
{
// / <summary>
// / Атрибут указывает, что при извлечении объекта из источника (базы) значение этого свойства
// / должно так же интерпретироваться как объект базы, поля которого рекурсивно заполняются
// / из источника с добавлением префикса
// / </summary>
[AttributeUsage (AttributeTargets. Property, Inherited = true, AllowMultiple = false)]
public class DBComplexField: System. Attribute
{
public DBComplexField (string _prefix = "")
{
prefix = _prefix;
}
// Префикс к полям
private string prefix;
public string Prefix
{
get { return prefix; }
}
}
}
Файл DBFieldNameAttribute
using System;
using System. Collections. Generic;
using System. Linq;
using System. Text;
namespace DKCore. DataBase. Attributes
{
[AttributeUsage (AttributeTargets. Property, Inherited = true, AllowMultiple = false)]
public class DBFieldNameAttribute: System. Attribute
{
public DBFieldNameAttribute (string field_name, bool use_postfix = false, bool is_primary_key = false)
{
fieldName = field_name;
usePostfix = use_postfix;
isPrimaryKey = is_primary_key;
}
// Имя поля в базе
private string fieldName;
public string FieldName
{
get { return fieldName; }
}
// Использовать постфикс к полям таблицы
private bool usePostfix;
public bool UsePostfix
{
get { return usePostfix; }
}
// Это поле ключевое
private bool isPrimaryKey;
public bool IsPrimaryKey
{
get { return isPrimaryKey; }
}
}
}
Фала DBTableName. cs
using System;
using System. Collections. Generic;
using System. Linq;
using System. Text;
namespace DKCore. DataBase. Attributes
{
[AttributeUsage (AttributeTargets. Class, Inherited = false, AllowMultiple = false)]
public class DBTableNameAttribute: System. Attribute
{
public DBTableNameAttribute (string table_name, string table_postfix)
{
tableName = table_name;
tablePostfix = table_postfix;
}
// Имя таблицы в базе
private string tableName;
public string TableName
{
get { return tableName; }
}
// Префикс к полям таблицы
private string tablePostfix;
public string TablePostfix
{
get { return tablePostfix; }
}
}
}
Файл DBModule_Documents
using System;
using System. Collections. Generic;
using System. Linq;
using System. Text;
using System. Data. SQLite;
using System. Windows;
using System. Collections. ObjectModel;
using System. Reflection;
using System. Data;
using DKCore. DataBase. Objects;
using DKCore. DataBase;
using DKCore. DataBase. Attributes;
namespace DKCore. DataBase. Modules
{
public class DBModule_Documents: DBModuleBase
{
// Типы документов
// Загружаются при старте программы (init)
private Dictionary<string, DBO_DocType> docTypes; // Имя типа => тип
private Dictionary<long?, DBO_DocType> docTypesByID; // ID типа => тип
private ObservableCollection<DBO_DocType> docTypeList; // Список типов
override public void Init ()
{
// Тип документа
DB. Schema. addTable (new DBTable ("doc_type", "id_doc_type"));
// Картотека
DB. Schema. addTable (new DBTable ("card_case", "id_card_case"));
var table = DB. Schema. addTable (new DBTable ("card_folder", "id_card_folder"));
table. addForeignKey (new DBForeighLink ("id_card_case", DB. Schema. getTable ("card_case"), "id_card_case"));
// Документ
table = DB. Schema. addTable (new DBTable ("document", "id_document"));
table. addForeignKey (new DBForeighLink ("id_d_type", DB. Schema. getTable ("doc_type"), "id_doc_type"));
table. addForeignKey (new DBForeighLink ("id_card_folder", DB. Schema. getTable ("card_folder"), "id_card_folder"));
// Получение списка типов документов
using (var dbhelper = BeginTransaction ())
using (var com = new DBCommand ("SELECT * FROM v_notdel_doc_type"))
{
docTypeList = dbhelper. fetchAll<DBO_DocType> (com);
docTypes = new Dictionary<string, DBO_DocType> ();
docTypesByID = new Dictionary<long?, DBO_DocType> ();
foreach (var dt in docTypeList)
{
docTypes. Add (dt. Name, dt);
docTypesByID. Add (dt. ID, dt);
}
}
}
//
public FoundedCount getFoundedCount (DBDocumentFilter doc_filter, DBO_DocType doc_type)
{
using (var dbhelper = BeginTransaction ())
{
//
var query = new DBQueryBuilder (DB. Schema);
query. SELECT ("COUNT (*) count"). FROM ("document"). LIMIT (1);
doc_filter. apply (query);
//
using (var com = new DBCommand (query. BuildQuery ()))
{
doc_filter. passParams (com);
//
using (var reader = dbhelper. executeReader (com))
{
if (reader. Read ())
{
var res = new FoundedCount ();
res. DocType = doc_type;
res. Count = reader. readField<long> ("count");
return res;
}
else return null;
}
}
}
}
// Возвращает список годов, которые присуствует в архиве (+days дней от текущего момента)
public ObservableCollection<int> getArchiveYears (int days)
{
using (var dbhelper = BeginTransaction ())
{
ObservableCollection<int> result = new ObservableCollection<int> ();
using (var com = new DBCommand ())
{
if (DBDocumentFilter. IsAutoArchiveEnabled)
{
com.commandText =
"SELECT ifnull (elapsing_year, force_year) AS elapsing_year, ifnull (force_year, elapsing_year) AS force_year " +
"FROM v_documents_year " +
"WHERE elapsing_min IS NOT NULL AND elapsing_min < date (CURRENT_TIMESTAMP, '-" + days. ToString () + " days') OR " +
"force_min IS NOT NULL " +
"ORDER BY elapsing_year DESC, force_year DESC";
}
else
{
com.commandText =
"SELECT DISTINCT force_year AS elapsing_year, force_year AS force_year " +
"FROM v_documents_year " +
"WHERE force_min IS NOT NULL " +
"ORDER BY elapsing_year DESC, force_year DESC";
}
using (var reader = dbhelper. executeReader (com))
{
int last_year = int. MaxValue;
while (reader. Read ())
{
int elapsing_year = reader. readField<int> ("elapsing_year");
int force_year = reader. readField<int> ("force_year");
int year = (elapsing_year > force_year)? force_year: elapsing_year;
if (year < last_year)
{
result. Add (year);
last_year = year;
}
}
}
}
return result;
}
}
// Удалить все документы, удовлетворяющие фильтру
// Связанные файлы НЕ удаляются
public void deleteAllDocWithFilter (DBDocumentFilter filter, DBHelper dbhelper)
{
var query = new DBQueryBuilder (DB. Schema);
query. FROM ("document");
filter. apply (query);
using (var com = new DBCommand ("DELETE" + query. BuildQuery ()))
{
filter. passParams (com);
dbhelper. executeNonQuery (com);
}
}
public void deleteAllDocWithFilter (DBDocumentFilter filter)
{
using (var dbhelper = BeginTransaction ())
{
deleteAllDocWithFilter (filter, dbhelper);
}
}
// Поместить в корзину документ doc
public void throwDocumentToBin (DBO_Document doc)
{
using (var dbhelper = BeginTransaction ())
using (var com = new DBCommand ("UPDATE document SET is_in_recycle_bin = 1 WHERE id_document = @id_document"))
{
com. Parameters. AddWithValue ("@id_document", doc. ID);
doc. IsInRecycleBin = true;
dbhelper. executeNonQuery (com);
}
}
// Принудительно поместить документ в архив
public void forcePutInArchive (DBO_Document doc)
{
using (var dbhelper = BeginTransaction ())
using (var com = new DBCommand ("UPDATE document SET force_close_time = @force_close_time WHERE id_document = @id_document"))
{
var close_time = DateTime. Now;
com. Parameters. AddWithValue ("@force_close_time", close_time);
com. Parameters. AddWithValue ("@id_document", doc. ID);
doc. ForceCloseDate = close_time;
dbhelper. executeNonQuery (com);
}
}
// Отменить принудительное помещение в архив
public void forceGetFromArchive (DBO_Document doc)
{
using (var dbhelper = BeginTransaction ())
using (var com = new DBCommand ("UPDATE document SET force_close_time = @force_close_time WHERE id_document = @id_document"))
{
com. Parameters. AddWithValue ("@force_close_time", null);
com. Parameters. AddWithValue ("@id_document", doc. ID);
doc. ForceCloseDate = null;
dbhelper. executeNonQuery (com);
}
}
// Восстановить из корзины документ doc
public void restoreDocumentFromBin (DBO_Document doc)
{
using (var dbhelper = BeginTransaction ())
using (var com = new DBCommand ("UPDATE document SET is_in_recycle_bin = 0 WHERE id_document = @id_document"))
{
com. Parameters. AddWithValue ("@id_document", doc. ID);
doc. IsInRecycleBin = false;
dbhelper. executeNonQuery (com);
}
}
// Возвращает список документов указнного типа в выбранный период
public ObservableCollection<DBO_Document> getDocumentsWithFilter (DBDocumentFilter filter, DBHelper dbhelper)
{
var query = new DBQueryBuilder (DB. Schema);
query. SELECT ("*"). FROM ("document", "d"). JOIN ("doc_type", "t"). WHERE (" [is_deleted] = 0", "doc_type"). ORDER_BY ("name_document");
filter. apply (query);
using (var com = new DBCommand (query. BuildQuery ()))
{
filter. passParams (com);
return dbhelper. fetchAll<DBO_Document> (com);
}
}
public ObservableCollection<DBO_Document> getDocumentsWithFilter (DBDocumentFilter filter)
{
using (var dbhelper = BeginTransaction ())
{
return getDocumentsWithFilter (filter, dbhelper);
}
}
// Возвращает список типов документа в выбранный период
// (либо за указанный год в архиве, когда year! = null, либо +days дней от текущего момента)
public ObservableCollection<DBO_DocType> getDocTypesWithFilter (DBDocumentFilter filter)
{
using (var dbhelper = BeginTransaction ())
{
var query = new DBQueryBuilder (DB. Schema);
query. SELECT ("t. *"). FROM ("document", "d"). JOIN ("doc_type", "t"). WHERE (" [is_deleted] = 0", "doc_type"). GROUP_BY (" [id_doc_type]", "doc_type");
filter. apply (query);
using (var com = new DBCommand (query. BuildQuery ()))
{
filter. passParams (com);
return dbhelper. fetchAll<DBO_DocType> (com);
}
}
}
// Возаращет тип документа с заданным именем
public DBO_DocType getDocTypeWithName (string name)
{
if (docTypes. ContainsKey (name)) return docTypes [name];
else return null;
}
// Возаращет тип документа с заданным ID
public DBO_DocType getDocTypeWithID (long? id)
{
if (docTypesByID. ContainsKey (id)) return docTypesByID [id];
else return null;
}
// Возвращает все типы документов
public ObservableCollection<DBO_DocType> getDocTypes ()
{
return docTypeList;
}
}
}
Файл DBModule_CardCase. cs
using System;
using System. Collections. Generic;
using System. Linq;
using System. Text;
using System. Data. SQLite;
using System. Windows;
using System. Collections. ObjectModel;
using System. Reflection;
using System. Data;
using DKCore. DataBase. Objects;
using DKCore. DataBase;
using DKCore. DataBase. Attributes;
namespace DKCore. DataBase. Modules
{
public class DBModule_CardCase: DBModuleBase
{
override public void Init ()
{
// Картотека
DB. Schema. addTable (new DBTable ("card_case", "id_card_case"));
var table = DB. Schema. addTable (new DBTable ("card_folder", "id_card_folder"));
table. addForeignKey (new DBForeighLink ("id_card_case", DB. Schema. getTable ("card_case"), "id_card_case"));
}
// Возвращает все ящики в картотеке
public ObservableCollection<DBO_CardCase> getCardCases ()
{
using (var dbhelper = BeginTransaction ())
using (var com = new DBCommand ("SELECT * FROM v_notdel_card_case"))
{
return dbhelper. fetchAll<DBO_CardCase> (com);
}
}
// Удаляет.
// Физически запись не удаляется
public bool deleteCardCase (DBO_CardCase obj)
{
using (var dbhelper = BeginTransaction ())
{
obj. IsDeleted = true;
dbhelper. update<DBO_CardCase> (obj, new { IsDeleted = 0 });
}
return true;
}
// Переименовывает ящик
// Возвращает false, если ящик с таким именем уже существует
public bool renameCardCase (DBO_CardCase obj, string new_name)
{
using (var dbhelper = BeginTransaction (true, true))
{
try
{
bool already_exist = false;
// Проверка на повтор
using (var com_sel = new DBCommand ("SELECT 1 FROM v_notdel_card_case WHERE title_card_case = @title_card_case"))
{
com_sel. Parameters. AddWithValue ("@title_card_case", new_name);
using (var reader = dbhelper. executeReader (com_sel)) already_exist = reader. Read ();
}
if (! already_exist)
{
// Изменение в базе
using (var com_upd = new DBCommand ("UPDATE card_case SET title_card_case = @title_card_case WHERE id_card_case = @id_card_case"))
{
com_upd. Parameters. AddWithValue ("@title_card_case", new_name);
com_upd. Parameters. AddWithValue ("@id_card_case", obj. ID);
dbhelper. executeNonQuery (com_upd);
dbhelper.commit ();
obj. Title = new_name;
return true;
}
}
else return false;
}
catch (Exception e)
{
dbhelper. Rollback ();
MessageBox. Show (e. ToString ());
return false;
}
}
}
// Возвращает все отсортированные по имени
public ObservableCollection<DBO_CardCase> getCardCasesSortedByTitle ()
{
using (var dbhelper = BeginTransaction ())
using (var com = new DBCommand ("SELECT * FROM v_notdel_card_case ORDER BY title_card_case"))
{
return dbhelper. fetchAll<DBO_CardCase> (com);
}
}
// Добавление нового
// dbhelper - объект текущей транзакции
public bool addCardCase (DBO_CardCase obj, DBHelper dbhelper)
{
dbhelper. insert<DBO_CardCase> (obj);
obj. ID = dbhelper. getLastInsertedID ("card_case", "id_card_case");
return true;
}
public bool addCardCase (DBO_CardCase obj)
{
using (var dbhelper = BeginTransaction ())
{
return addCardCase (obj, dbhelper);
}
}
// Возвращает все ящики в картотеке
public ObservableCollection<DBO_CardFolder> getCardFolders (DBO_CardCase card_case)
{
using (var dbhelper = BeginTransaction ())
using (var com = new DBCommand ("SELECT * FROM v_notdel_card_folder WHERE id_card_case = @id_card_case"))
{
com. Parameters. AddWithValue ("@id_card_case", card_case. ID);
return dbhelper. fetchAll<DBO_CardFolder> (com);
}
}
// Возвращает все отсортированные по имени
public ObservableCollection<DBO_CardFolder> getCardFoldersSortedByTitle (DBO_CardCase card_case)
{
using (var dbhelper = BeginTransaction ())
using (var com = new DBCommand ("SELECT * FROM v_notdel_card_folder WHERE id_card_case = @id_card_case ORDER BY title_card_folder"))
{
com. Parameters. AddWithValue ("@id_card_case", card_case. ID);
return dbhelper. fetchAll<DBO_CardFolder> (com);
}
}
// Добавление нового
// dbhelper - объект текущей транзакции
public bool addCardFolder (DBO_CardFolder obj, DBHelper dbhelper)
{
dbhelper. insert<DBO_CardFolder> (obj);
obj. ID = dbhelper. getLastInsertedID ("card_folder", "id_card_folder");
return true;
}
public bool addCardFolder (DBO_CardFolder obj)
{
using (var dbhelper = BeginTransaction ())
{
return addCardFolder (obj, dbhelper);
}
}
// Удаляет.
// Физически запись не удаляется
public bool deleteCardFolder (DBO_CardFolder obj)
{
using (var dbhelper = BeginTransaction ())
{
obj. IsDeleted = true;
dbhelper. update<DBO_CardFolder> (obj, new { IsDeleted = 0 });
}
return true;
}
// Переименовывает папку в ящике
// Возвращает false, если ящик с таким именем уже существует
public bool renameCardFolder (DBO_CardFolder obj, string new_name)
{
using (var dbhelper = BeginTransaction (true, true))
{
try
{
bool already_exist = false;
// Проверка на повтор
using (var com_sel = new DBCommand ("SELECT 1 FROM v_notdel_card_folder WHERE id_card_case = @id_card_case AND title_card_folder = @title_card_folder"))
{
com_sel. Parameters. AddWithValue ("@title_card_folder", new_name);
com_sel. Parameters. AddWithValue ("@id_card_case", obj. CardCaseID);
using (var reader = dbhelper. executeReader (com_sel)) already_exist = reader. Read ();
}
if (! already_exist)
{
// Изменение в базе
using (var com_upd = new DBCommand ("UPDATE card_folder SET title_card_folder = @title_card_folder WHERE id_card_folder = @id_card_folder"))
{
com_upd. Parameters. AddWithValue ("@title_card_folder", new_name);
com_upd. Parameters. AddWithValue ("@id_card_folder", obj. ID);
dbhelper. executeNonQuery (com_upd);
dbhelper.commit ();
obj. Title = new_name;
return true;
}
}
else return false;
}
catch (Exception e)
{
dbhelper. Rollback ();
MessageBox. Show (e. ToString ());
return false;
}
}
}
// Возвращает "Пустую запись"
private DBO_CardFolder whitespaceCardFolder;
private DBO_CardFolder getWhiteSpaceCardFolder (DBHelper dbhelper)
{
if (whitespaceCardFolder == null)
{
using (var com = new DBCommand ("SELECT * FROM card_folder WHERE title_card_folder = '' LIMIT 1"))
{
whitespaceCardFolder = dbhelper. fetchOne<DBO_CardFolder> (com);
if (whitespaceCardFolder == null)
{
whitespaceCardFolder = new DBO_CardFolder () { Title = "", IsDeleted = true };
addCardFolder (whitespaceCardFolder, dbhelper);
}
}
}
return whitespaceCardFolder;
}
}
}
Файл DBModule_FastSearch. cs
using System;
using System. Collections. Generic;
using System. Linq;
using System. Text;
using System. Data. SQLite;
using System. Windows;
using System. Collections. ObjectModel;
using System. Reflection;
using System. Data;
using DKCore. DataBase. Objects;
using DKCore. DataBase;
using DKCore. DataBase. Attributes;
namespace DKCore. DataBase. Modules
{
public class DBModule_FastSearch: DBModuleBase
{
override public void Init ()
{
// Поисковый тег
DB. Schema. addTable (new DBTable ("search_tag", "id_search_tag"));
// Связь документов и тегов:
var table = DB. Schema. addTable (new DBTable ("lnk_document_and_search_tag", "id_document"));
table. addForeignKey (new DBForeighLink ("id_document", DB. Schema. getTable ("document")));
table. addForeignKey (new DBForeighLink ("id_search_tag", DB. Schema. getTable ("search_tag")));
}
// Быстрый поиск текст search_text, возвращающий count результатов
public ObservableCollection<DBO_Document> fastSearch (string search_text, int count)
{
using (var dbhelper = BeginTransaction ())
{
var query = new DBQueryBuilder (DB. Schema);
query. SELECT_DISTINCT (" [*]", "document")
. FROM ("document", "d"). JOIN_LEFT ("lnk_document_and_search_tag", "lnk"). JOIN_LEFT ("search_tag", "s")
. WHERE ("UnicodeUpper ([1. title_search_tag]) LIKE @tag_like OR UnicodeUpper ([2. name_document]) LIKE @name_like", "search_tag", "document")
. ORDER_BY (" [updated_time]", true, "document")
. LIMIT (count);
using (var com = new DBCommand (query. BuildQuery ()))
{
com. Parameters. AddWithValue ("@tag_like", "%" + search_text. ToUpper () + "%");
com. Parameters. AddWithValue ("@name_like", search_text. ToUpper () + "%");
return dbhelper. fetchAll<DBO_Document> (com);
}
}
}
// Добавляет тег поиска search_tag к документу document
public void addSearchTag (DBO_Document document, string search_tag, DBHelper dbhelper)
{
if (search_tag! = null)
{
using (var com = new DBCommand ("SELECT * FROM search_tag WHERE title_search_tag = @title_search_tag"))
{
com. Parameters. AddWithValue ("@title_search_tag", search_tag);
SearchTag st = dbhelper. fetchOne<SearchTag> (com);
if (st == null)
{
st = new SearchTag () { Title = search_tag };
dbhelper. insert<SearchTag> (st);
st. ID = dbhelper. getLastInsertedID ("search_tag", "id_search_tag");
}
dbhelper. insertValues
(
"lnk_document_and_search_tag",
new Dictionary<string, object> () { { "id_document", document. ID }, { "id_search_tag", st. ID } }
);
}
}
}
// Добавляет информацию для поиска, специфичную document
public void addDocumentSearchInfo (DBO_Document document, DBHelper dbhelper)
{
// addSearchTag (document, document. Name, dbhelper);
}
// Удаление старых поисковых тегов для докумета с ID = id
public void clearSearchInfo (long? id, DBHelper dbhelper)
{
using (var com = new DBCommand ("DELETE FROM lnk_document_and_search_tag WHERE id_document = @id_document"))
{
com. Parameters. AddWithValue ("@id_document", id);
dbhelper. executeNonQuery (com);
}
}
}
}
Файл DBModule_FIles. cs
using System;
using System. Collections. Generic;
using System. Linq;
using System. Text;
using System. Data. SQLite;
using System. Windows;
using System. Collections. ObjectModel;
using System. Reflection;
using System. Data;
using DKCore. DataBase. Objects;
using DKCore. DataBase;
using DKCore. DataBase. Attributes;
namespace DKCore. DataBase. Modules
{
public class DBModule_Files: DBModuleBase
{
override public void Init ()
{
// Файлы:
var table = DB. Schema. addTable (new DBTable ("doc_file", "id_doc_file"));
table. addForeignKey (new DBForeighLink ("id_document", DB. Schema. getTable ("document")));
// Кол-во файлов в документе
table = DB. Schema. addTable (new DBTable ("v_documents_file_count", "id_document"));
table. addForeignKey (new DBForeighLink ("id_document", DB. Schema. getTable ("document")));
}
// Добавление нового файла в базу, назначение ему ID
public bool addDocFile (DBO_DocFile file, DBHelper dbhelper)
{
dbhelper. insert<DBO_DocFile> (file);
file. ID = dbhelper. getLastInsertedID ("doc_file", "id_doc_file");
return true;
}
// Добавление новой папки в базу, назначение ей ID
public bool addDocFileFolder (DBO_DocFileFolder folder, DBHelper dbhelper)
{
dbhelper. insert<DBO_DocFileFolder> (folder);
folder. ID = dbhelper. getLastInsertedID ("doc_file_folder", "id_doc_file_folder");
return true;
}
// Обновление пути файла в хранилище
public void updateStoragePath (DBO_DocFile file, DBHelper dbhelper)
{
dbhelper. update<DBO_DocFile> (file, new { StoragePath = 0 });
}
// Обновление данных файла
public void updateFileInfo (DBO_DocFile file)
{
using (var dbhelper = BeginTransaction ())
{
dbhelper. update<DBO_DocFile> (file);
}
}
// Обновление данных папки
public void updateFolderInfo (DBO_DocFileFolder file)
{
using (var dbhelper = BeginTransaction ())
{
dbhelper. update<DBO_DocFileFolder> (file);
}
}
// Возвращает все файлы, связанные с документом
public ObservableCollection<DBO_DocFile> getDocFiles (DBO_Document doc)
{
using (var dbhelper = BeginTransaction ())
using (var com = new DBCommand ("SELECT * FROM v_notdel_doc_file WHERE id_document = @id_document"))
{
com. Parameters. AddWithValue ("@id_document", doc. ID);
return dbhelper. fetchAll<DBO_DocFile> (com);
}
}
// Возвращает все файлы, связанные с документом, находящиеся в заданной папке
public ObservableCollection<DBO_DocFile> getDocFiles (DBO_Document doc, long? folder_id)
{
return getDocFiles (doc. ID, folder_id);
}
public ObservableCollection<DBO_DocFile> getDocFiles (long? doc_id, long? folder_id)
{
var folder_id_query = "parent_id_doc_file_folder = @folder_id";
if (folder_id == null) folder_id_query = "parent_id_doc_file_folder IS NULL";
using (var dbhelper = BeginTransaction ())
using (var com = new DBCommand ("SELECT * FROM v_notdel_doc_file WHERE id_document = @id_document AND " + folder_id_query))
{
com. Parameters. AddWithValue ("@id_document", doc_id);
com. Parameters. AddWithValue ("@folder_id", folder_id);
return dbhelper. fetchAll<DBO_DocFile> (com);
}
}
// Возвращает все папки, находящиеся в указанной
public ObservableCollection<DBO_DocFileFolder> getDocFolders (DBO_Document doc, long? folder_id)
{
return getDocFolders (doc. ID, folder_id);
}
public ObservableCollection<DBO_DocFileFolder> getDocFolders (long? doc_id, long? folder_id)
{
var folder_id_query = "parent_id_doc_file_folder = @folder_id";
if (folder_id == null) folder_id_query = "parent_id_doc_file_folder IS NULL";
using (var dbhelper = BeginTransaction ())
using (var com = new DBCommand ("SELECT * FROM v_notdel_doc_file_folder WHERE id_document = @id_document AND " + folder_id_query))
{
com. Parameters. AddWithValue ("@id_document", doc_id);
com. Parameters. AddWithValue ("@folder_id", folder_id);
return dbhelper. fetchAll<DBO_DocFileFolder> (com);
}
}
// Удалитьвсе записи о прикрепленных файлах для документа
public void deleteAllFiles (DBO_Document doc, DBHelper dbhelper)
{
using (var com = new DBCommand ("DELETE FROM doc_file WHERE id_document = @id_document"))
{
com. Parameters. AddWithValue ("@id_document", doc. ID);
dbhelper. executeNonQuery (com);
}
}
// Удалитьвсе записи о прикрепленных папках для документа
public void deleteAllFolders (DBO_Document doc, DBHelper dbhelper)
{
using (var com = new DBCommand ("DELETE FROM doc_file_folder WHERE id_document = @id_document"))
{
com. Parameters. AddWithValue ("@id_document", doc. ID);
dbhelper. executeNonQuery (com);
}
}
}
}
Файла AddDocument. xaml. cs
using System;
using System. Collections. Generic;
using System. Linq;
using System. Text;
using System. Windows;
using System. Windows. Controls;
using System. Windows. Data;
using System. Windows. Documents;
using System. Windows. Input;
using System. Windows. Media;
using System. Windows. Media. Imaging;
using System. Windows. Shapes;
using System. Collections. ObjectModel;
using System.runtime. Serialization;
using System.runtime. Serialization. Formatters;
using System.runtime. Serialization. Formatters. Binary;
using DKCore. DataBase. Objects;
using DKeeper. Logic. API;
using DKeeper. Forms. EditListForm;
using DKCore. ConcreteDocuments. Interfaces. Forms;
using DKeeper. Forms.common;
using DKCore. DataBase. Modules;
using DKCore. FormsI;
namespace DKeeper. Forms. AddDocument
{
// / <summary>
// / Interaction logic for AddDocument. xaml
// / </summary>
public partial class AddDocument: Window
{
private Dictionary<DBO_DocType, ICDocAddPage> recentDocTypes;
private ICDocAddPage currentDocPage;
private ObservableCollection<DBO_DocFile> editedFiles;
private ObservableCollection<DBO_DocFileFolder> editedFolders;
public DBO_Document CurrentDocument
{
get { return DataContext as DBO_Document; }
}
public bool OpenAfterClose { get; set; }
public AddDocument ()
{
recentDocTypes = new Dictionary<DBO_DocType, ICDocAddPage> ();
DataContext = new DBO_Document ();
editedFiles = new ObservableCollection<DBO_DocFile> ();
editedFolders = new ObservableCollection<DBO_DocFileFolder> ();
InitializeComponent ();
// lstAttachedFiles. ItemsSource = attachedFiles;
OpenAfterClose = false;
}
private void Window_Loaded (object sender, RoutedEventArgs e)
{
// Загрузка типов документов
var doctype_list = new ObservableCollection<DBO_DocType> ();
foreach (var addin in App. ConcreteDocAddins)
{
doctype_list. Add (addin. Value. DocTypeDBO);
}
cmbxDocTypes. ItemsSource = doctype_list;
cmbxCardCase. ItemsSource = App. DB. Module<DBModule_CardCase> (). getCardCasesSortedByTitle ();
}
// Смена типа документов
private void cmbDocTypes_SelectionChanged (object sender, SelectionChangedEventArgs e)
{
DBO_DocType selected = ( (ComboBox) sender). SelectedItem as DBO_DocType;
ICDocAddPage page = null;
if (selected! = null)
{
if (recentDocTypes. ContainsKey (selected)) page = recentDocTypes [selected];
else
{
if (App. ConcreteDocAddins. ContainsKey (selected. Name))
{
page = App. ConcreteDocAddins [selected. Name]. getNewAddPage ();
recentDocTypes [selected] = page;
}
}
}
if (page! = null)
{
frameConcreteDoc. Navigate (page);
currentDocPage = page;
}
}
private void insertToDB ()
{
try
{
var card_case = cmbxCardCase. SelectedItem as DBO_CardCase;
if (card_case == null)
{
if (cmbxCardCase. Text! = "") card_case = new DBO_CardCase () { Title = cmbxCardCase. Text };
}
var card_folder = cmbxCardFolder. SelectedItem as DBO_CardFolder;
if (card_folder == null)
{
if (cmbxCardFolder. Text! = "") card_folder = new DBO_CardFolder () { Title = cmbxCardFolder. Text };
}
// MessageBox. Show ("-3");
// Сам документ
var full_doc_info = new DBO_FullDocInfo ();
full_doc_info.commonInfo = CurrentDocument;
full_doc_info. CardCase = card_case;
full_doc_info. CardFolder = card_folder;
bool result = currentDocPage. insertConcreteDocToDB (full_doc_info);
if (result)
{
// MessageBox. Show ("-2");
// Прикрепленные файлы
result = result && App. API<DocumentsAPI> (). addAttachedFolders (CurrentDocument, editedFolders);
result = result && App. API<DocumentsAPI> (). addAttachedFiles (CurrentDocument, editedFiles);
if (! result)
{
MessageBox. Show ("Документ #" + CurrentDocument. ID + " был добавлен, " +
"однако в процессе создания возникли ошибки и не все данные были сохранены." +
"Рекомендуется повторно отредактировать документ");
}
DialogResult = result;
Close ();
}
}
catch (Exception e)
{
MessageBox. Show (e. ToString ());
}
}
private void OK_Click (object sender, RoutedEventArgs e)
{
insertToDB ();
}
private void Cancel_Click (object sender, RoutedEventArgs e)
{
DialogResult = false;
Close ();
}
private void cmbxCardCase_SelectionChanged (object sender, SelectionChangedEventArgs e)
{
var card_case = cmbxCardCase. SelectedItem as DBO_CardCase;
cmbxCardFolder. Text = "";
if (card_case! = null)
{
cmbxCardFolder. ItemsSource = App. DB. Module<DBModule_CardCase> (). getCardFoldersSortedByTitle (card_case);
}
else
{
cmbxCardFolder. ItemsSource = null;
}
}
private void btnCardCase_Click (object sender, RoutedEventArgs e)
{
var editlist = new EditListForm. EditListForm ();
var settings = new EditListSettings<DBO_CardCase> ();
settings. GetElemsFunc = App. DB. Module<DBModule_CardCase> (). getCardCasesSortedByTitle;
settings. AddElemFunc = App. DB. Module<DBModule_CardCase> (). addCardCase;
settings. DeleteElemFunc = App. DB. Module<DBModule_CardCase> (). deleteCardCase;
editlist. EditListSettings = settings;
editlist. SelectingObjTitle = "Картотека - ящик";
var res = editlist. ShowDialog ();
if (editlist. ListWasChanged)
{
// Обновление списка
cmbxCardCase. ItemsSource = App. DB. Module<DBModule_CardCase> (). getCardCases ();
}
if (res == true)
{
var sel = (DBO_CardCase) editlist. SelectedItem;
DBO_CardCase lst_sel = null;
foreach (var item in cmbxCardCase. Items)
{
var as_dbo = item as DBO_CardCase;
if (as_dbo! = null && sel. ID == as_dbo. ID)
{
lst_sel = as_dbo;
break;
}
}
cmbxCardCase. SelectedItem = lst_sel;
}
}
private void btnCardFolder_Click (object sender, RoutedEventArgs e)
{
var card_case = cmbxCardCase. SelectedItem as DBO_CardCase;
if (card_case! = null)
{
var editlist = new EditListForm. EditListForm ();
var settings = new EditListSettings<DBO_CardFolder> ();
settings. GetElemsFunc = ( () => App. DB. Module<DBModule_CardCase> (). getCardFoldersSortedByTitle (card_case));
settings. AddElemFunc = ( (card_folder) => { card_folder. CardCaseID = card_case. ID; return App. DB. Module<DBModule_CardCase> (). addCardFolder (card_folder); });
settings. DeleteElemFunc = App. DB. Module<DBModule_CardCase> (). deleteCardFolder;
editlist. EditListSettings = settings;
editlist. SelectingObjTitle = "Картотека - папка";
var res = editlist. ShowDialog ();
if (editlist. ListWasChanged)
{
// Обновление списка
cmbxCardFolder. ItemsSource = App. DB. Module<DBModule_CardCase> (). getCardFolders (card_case);
}
if (res == true)
{
var sel = (DBO_CardFolder) editlist. SelectedItem;
DBO_CardFolder lst_sel = null;
foreach (var item in cmbxCardFolder. Items)
{
var as_dbo = item as DBO_CardFolder;
if (as_dbo! = null && sel. ID == as_dbo. ID)
{
lst_sel = as_dbo;
break;
}
}
cmbxCardFolder. SelectedItem = lst_sel;
}
}
}
private void Window_Closed (object sender, EventArgs e)
{
// Удаление временных файлов
foreach (var file in editedFiles)
{
if (file. IsTemporary)
{
try { System. IO. File. Delete (file. LocalPath); }
catch (Exception) { }
}
}
}
private void AddFile_Click (object sender, RoutedEventArgs e)
{
// var open_dialog2 = new Ookii. Dialogs. Wpf. VistaOpenFileDialog ();
var files = App. API<InterfaceAPI> (). openFileDialog (true);
if (files! = null)
{
foreach (var filepath in files)
{
var file = new DBO_DocFile ();
file. LocalPath = filepath. ToString ();
file. OrigName = System. IO. Path. GetFileName (filepath);
file. Title = System. IO. Path. GetFileName (filepath);
setDocFileAsEdited (file);
addToDocFiles (file, SelectedDocFolderTreeItem);
}
}
}
private void ScanFile_Click (object sender, RoutedEventArgs e)
{
var title = String. Format ("Изображение{0}. jpg", editedFiles. Count + 1);
var file = App. API<ScannerAPI> (). OpenScanDocDialog (title);
if (file! = null)
{
file. OrigName = System. IO. Path. GetFileName (title);
setDocFileAsEdited (file);
addToDocFiles (file, SelectedDocFolderTreeItem);
}
}
private void AddFolder_Click (object sender, RoutedEventArgs e)
{
var folder = new DBO_DocFileFolder ();
folder. Title = String. Format ("Новая папка{0}", editedFolders. Count + 1);
setDocFileAsEdited (folder);
addToDocFiles (folder, SelectedDocFolderTreeItem);
}
private TreeViewItem bubbleToTreeViewItem (object source)
{
DependencyObject obj = (DependencyObject) source;
while (obj! = null && obj! = treeDocFiles && obj is Visual)
{
if (obj is TreeViewItem)
{
return (TreeViewItem) obj;
}
obj = VisualTreeHelper. GetParent (obj);
}
return null;
}
private void DeleteAttachedFile_Executed (object sender, ExecutedRoutedEventArgs e)
{
var node = bubbleToTreeViewItem (e. Parameter);
if (node is DocFileTreeItem)
{
deleteFromDocFiles ( (DocFileTreeItem) node);
}
else if (node is DocFileFolderTreeItem)
{
deleteFromDocFiles ( (DocFileFolderTreeItem) node);
}
}
/*
private void lstAttachedFiles_MouseDoubleClick (object sender, MouseButtonEventArgs e)
{
var file = lstAttachedFiles. SelectedItem as DBO_DocFile;
if (file! = null && file. LocalPath! = null)
{
App. API<DocumentsAPI> (). openAttachedFile (file);
}
}
*/
private void Window_Closing (object sender, System.componentModel. CancelEventArgs e)
{
}
private DocFileFolderTreeItem SelectedDocFolderTreeItem
{
get
{
var selected = treeDocFiles. SelectedItem;
if (selected is DocFileTreeItem)
{
var ftree = (DocFileTreeItem) selected;
return ftree. Parent as DocFileFolderTreeItem;
}
else
{
return selected as DocFileFolderTreeItem;
}
}
}
// Удаляет узел из дерева
private void deleteNodeFromDocFileTree (TreeViewItem item)
{
if (item. Parent == treeDocFiles)
{
treeDocFiles. Items. Remove (item);
// Осталась только надпись "Файлы: "
if (treeDocFiles. Items. Count == 1) treeDocFiles. Items. RemoveAt (0);
}
else
{
var parent = item. Parent as TreeViewItem;
if (parent! = null) parent. Items. Remove (item);
}
}
private void deleteFromDocFiles (object item, bool quite = false)
{
if (item is DocFileFolderTreeItem) deleteFromDocFiles ( (DocFileFolderTreeItem) item, quite);
else if (item is DocFileTreeItem) deleteFromDocFiles ( (DocFileTreeItem) item, quite);
}
private void deleteFromDocFiles (DocFileFolderTreeItem folder_item, bool quite = false)
{
var folder = folder_item. Folder;
if (folder! = null)
{
if (! quite && folder. IsDeleted! = true && folder_item. Items. Count > 0)
{
var res = MessageBox. Show ("Удалить папку '" + folder. Title + "' и все ее содержимое?", "Подтверждение удаления", MessageBoxButton. OKCancel);
if (res == MessageBoxResult. Cancel) return; // Отмена
}
if (folder. IsDeleted! = true)
{
// Удаление потомков
// var children = new List<object> ();
// foreach (var ch in folder_item. Items) children. Add (ch);
// foreach (var ch in children) deleteFromDocFiles (ch, true);
for (int i = folder_item. Items. Count - 1; i >= 0; i--)
{
deleteFromDocFiles (folder_item. Items [i], true);
}
// Удаление узла
if (folder. existInDB || folder_item. Items. Count > 0)
{
setDocFileAsEdited (folder);
folder. IsDeleted = true;
}
else
{
if (folder. IsChanged) editedFolders. Remove (folder);
deleteNodeFromDocFileTree (folder_item);
}
}
else folder. IsDeleted = false;
}
}
private void deleteFromDocFiles (DocFileTreeItem file_item, bool quite = false)
{
var file = file_item. File;
if (file! = null)
{
if (file. IsDeleted! = true)
{
if (file. existInDB)
{
setDocFileAsEdited (file);
file. IsDeleted = true;
}
else
{
if (file. IsTemporary)
{
try { System. IO. File. Delete (file. LocalPath); }
catch (Exception) { }
}
if (file. IsChanged) editedFiles. Remove (file);
deleteNodeFromDocFileTree (file_item);
}
}
else
{
// Восстановление
var parent = file_item. Parent as DocFileFolderTreeItem;
if (parent! = null)
{
parent. Folder. IsDeleted = false;
}
}
}
}
private void addToDocFiles (DBO_DocFileFolder folder, DocFileFolderTreeItem parent_folder)
{
var tree_item = new DocFileFolderTreeItem ();
tree_item. Folder = folder;
if (parent_folder == null)
{
folder. ParentDocFolder = null;
if (treeDocFiles. Items. Count == 0)
{
var dummy = new TreeViewItem ();
dummy. Header = "Файлы: ";
treeDocFiles. Items. Add (dummy);
}
treeDocFiles. Items. Add (tree_item);
}
else
{
folder. ParentDocFolder = parent_folder. Folder;
parent_folder. IsExpanded = true;
parent_folder. Items. Add (tree_item);
}
}
private void setDocFileAsEdited (object file_or_folder)
{
if (file_or_folder is DBO_DocFile) setDocFileAsEdited ( (DBO_DocFile) file_or_folder);
else if (file_or_folder is DBO_DocFileFolder) setDocFileAsEdited ( (DBO_DocFileFolder) file_or_folder);
}
private void setDocFileAsEdited (DBO_DocFile file)
{
if (file. IsChanged! = true)
{
editedFiles. Add (file);
file. IsChanged = true;
}
}
private void setDocFileAsEdited (DBO_DocFileFolder folder)
{
if (folder. IsChanged! = true)
{
editedFolders. Add (folder);
folder. IsChanged = true;
}
}
private void addToDocFiles (DBO_DocFile file, DocFileFolderTreeItem parent_folder)
{
var tree_item = new DocFileTreeItem ();
tree_item. File = file;
if (parent_folder == null)
{
file. ParentDocFolder = null;
if (treeDocFiles. Items. Count == 0)
{
var dummy = new TreeViewItem ();
dummy. Header = "Файлы: ";
treeDocFiles. Items. Add (dummy);
}
treeDocFiles. Items. Add (tree_item);
}
else
{
file. ParentDocFolder = parent_folder. Folder;
parent_folder. IsExpanded = true;
parent_folder. Items. Add (tree_item);
}
}
private void treeDocFiles_Expanded (object sender, RoutedEventArgs e)
{
var folder_item = e. Source as DocFileFolderTreeItem;
if (folder_item! = null)
{
if (folder_item. Items. Count == 1 && folder_item. Items [0] == null)
{
folder_item. Items. Clear ();
if (folder_item. Folder. existInDB)
{
var folders = App. DB. Module<DBModule_Files> (). getDocFolders (CurrentDocument, folder_item. Folder. ID);
foreach (var f in folders) addToDocFiles (f, folder_item);
var files = App. DB. Module<DBModule_Files> (). getDocFiles (CurrentDocument, folder_item. Folder. ID);
foreach (var f in files) addToDocFiles (f, folder_item);
}
}
}
}
private void treeDocFiles_MouseDoubleClick (object sender, MouseButtonEventArgs e)
{
var item = bubbleToTreeViewItem (e. OriginalSource) as DocFileTreeItem;
if (item! = null)
{
var file = item. File;
if (file! = null && file. LocalPath! = null)
{
App. API<DocumentsAPI> (). openAttachedFile (file);
}
}
}
private void treeDocFiles_KeyUp (object sender, KeyEventArgs e)
{
}
private void treeDocFiles_Renamed (object o, DKCustomControls. RenamingRoutedEventArgs e)
{
e. NewName = e. NewName. Trim ();
e. Cancel = true;
// Определение объекта
var item = bubbleToTreeViewItem (e. OriginalSource);
var obj_title = "файла";
if (item is DocFileFolderTreeItem) obj_title = "папки";
if (String. IsNullOrEmpty (e. NewName)) MessageBox. Show ("Имя " + obj_title + " не задано");
else if (e. NewName =="." || e. NewName ==". ") MessageBox. Show ("Недопустимое имя " + obj_title);
else if (e. NewName. IndexOfAny (System. IO. Path. GetInvalidFileNameChars ())! = - 1) MessageBox. Show ("Недопустимые символы в имени " + obj_title);
else if (item is DocFileTreeItem)
{
if (System. IO. Path. GetExtension (e. NewName)! = System. IO. Path. GetExtension (e. OldName))
{
var res = MessageBox. Show ("Вы действительно хотите изменить расширение файла?", "Переименование файла", MessageBoxButton. YesNo);
e. Cancel = res == MessageBoxResult. No;
}
else e. Cancel = false;
}
else e. Cancel = false;
if (e. Cancel == false)
{
if (item is DocFileFolderTreeItem)
{
var folder = (DocFileFolderTreeItem) item;
folder. Folder. Title = e. NewName;
setDocFileAsEdited (folder. Folder);
}
else
{
var file = (DocFileTreeItem) item;
file. File. Title = e. NewName;
setDocFileAsEdited (file. File);
}
}
}
[Serializable]
public class DragDataItem: ISerializable
{
public TreeViewItem Item { get; set; }
public DragDataItem ()
{
}
public DragDataItem (SerializationInfo info, StreamingContext context)
{
}
public void GetObjectData (SerializationInfo info, StreamingContext context)
{
}
}
Point startPoint;
private void treeDocFiles_MouseLeftButtonDown (object sender, MouseButtonEventArgs e)
{
startPoint = e. GetPosition (null);
}
private void treeDocFiles_MouseMove (object sender, MouseEventArgs e)
{
if (e. LeftButton == MouseButtonState. Pressed)
{
var mousePos = e. GetPosition (null);
var diff = startPoint - mousePos;
if (Math. Abs (diff. X) > SystemParameters. MinimumHorizontalDragDistance || Math. Abs (diff. Y) > SystemParameters. MinimumVerticalDragDistance)
{
var tree_item = bubbleToTreeViewItem (e. OriginalSource);
if (Mouse. Captured == null && tree_item! = null && (tree_item is DocFileFolderTreeItem || tree_item is DocFileTreeItem))
{
var dr = new DragDataItem ();
dr. Item = tree_item;
try
{
DragDrop. DoDragDrop (treeDocFiles, dr, DragDropEffects. Move);
}
catch (Exception) { }
}
}
}
}
private bool checkCanDrop (TreeViewItem tree_item, TreeViewItem dragged)
{
if (tree_item == null || tree_item is DocFileTreeItem) return false;
if (tree_item is DocFileFolderTreeItem)
{
var folder_item = (DocFileFolderTreeItem) tree_item;
var own_id = folder_item. Folder. ID;
while (folder_item! = null)
{
if (folder_item. Folder. IsDeleted == true) return false;
if (folder_item == dragged) return false;
else if (own_id! = null && folder_item. Folder. ParentDocFolderID == own_id) return false;
folder_item = folder_item. Parent as DocFileFolderTreeItem;
}
}
return true;
}
private void treeDocFiles_DragOver (object sender, DragEventArgs e)
{
var tree_item = bubbleToTreeViewItem (e. OriginalSource);
DragDataItem dragged_tm = null;
try
{
dragged_tm = e. Data. GetData (typeof (DragDataItem)) as DragDataItem;
}
catch (Exception) { }
if (dragged_tm! = null)
{
var dragged = dragged_tm. Item;
if (! checkCanDrop (tree_item, dragged))
{
e. Effects = DragDropEffects. None;
}
}
e. Handled = true;
}
private void treeDocFiles_Drop (object sender, DragEventArgs e)
{
e. Effects = DragDropEffects. None;
e. Handled = true;
var tree_item = bubbleToTreeViewItem (e. OriginalSource);
DragDataItem dragged_tm = null;
try
{
dragged_tm = e. Data. GetData (typeof (DragDataItem)) as DragDataItem;
}
catch (Exception) { }
if (dragged_tm! = null)
{
var dragged = dragged_tm. Item;
if (dragged! = tree_item && checkCanDrop (tree_item, dragged))
{
var par = dragged. Parent as ItemsControl;
par. Items. Remove (dragged);
tree_item. IsExpanded = true;
DBO_DocFileFolder folder = null;
//
if (tree_item is DocFileFolderTreeItem)
{
tree_item. Items. Add (dragged);
folder = ( (DocFileFolderTreeItem) tree_item). Folder;
}
else treeDocFiles. Items. Add (dragged);
//
var drag_file = dragged as DocFileTreeItem;
var drag_folder = dragged as DocFileFolderTreeItem;
if (drag_file! = null)
{
drag_file. File. ParentDocFolder = folder;
setDocFileAsEdited (drag_file. File);
}
else if (drag_folder! = null)
{
drag_folder. Folder. ParentDocFolder = folder;
setDocFileAsEdited (drag_folder. Folder);
}
}
}
}
}
}
Файл AddDocument. xaml
<Window x: Class="DKeeper. Forms. AddDocument. AddDocument"
xmlns="http://schemas. microsoft.com/winfx/2006/xaml/presentation"
xmlns: x="http://schemas. microsoft.com/winfx/2006/xaml"
xmlns: local_db_obj="clr-namespace: DKCore. DataBase. Objects; assembly=DKCore"
xmlns: dkctrls="clr-namespace: DKCustomControls; assembly=DKCustomControls"
Title="Добавить документ" Height="550" Width="400" Background="{StaticResource FormBackgroundBrush}"
Loaded="Window_Loaded" Closing="Window_Closing" Closed="Window_Closed" xmlns: my="clr-namespace: DKeeper. Forms. AddDocument">
<Window. Resources>
<ResourceDictionary>
<ResourceDictionary. MergedDictionaries>
<ResourceDictionary Source=". /Resources/DocFilesDictonary. xaml"></ResourceDictionary>
</ResourceDictionary. MergedDictionaries>
</ResourceDictionary>
</Window. Resources>
<Grid>
<Grid. RowDefinitions>
<RowDefinition MinHeight="60" Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition MinHeight="70" Height="Auto"></RowDefinition>
</Grid. RowDefinitions>
<TextBlock FontSize="20" Margin="15, 10" VerticalAlignment="Center">Добавить документ</TextBlock>
<! - Тип документа - ->
<Grid Grid. Row="1" Margin="15 0 15 15" Width="{Binding ElementName=DocPropertiesGrid, Path=ActualWidth}" HorizontalAlignment="Left">
<Grid. ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="110" SharedSizeGroup="DialogLabelsGroup"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid. ColumnDefinitions>
<Label Target="{Binding ElementName=cmbxDocTypes}">_Тип документа*: </Label>
<ComboBox Grid. Column="1" Name="cmbxDocTypes" TextSearch. TextPath="Title" DisplayMemberPath="Title" SelectedIndex="0" SelectionChanged="cmbDocTypes_SelectionChanged"></ComboBox>
</Grid>
<Grid Grid. Row="2" >
<ScrollViewer VerticalScrollBarVisibility="Auto" Name="ScrollSpace">
<Grid IsSharedSizeScope="True" Margin="15 0 15 15" Name="DocPropertiesGrid">
<Grid. RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid. RowDefinitions>
<! - Область для полей конкретных типов документов - ->
<StackPanel Grid. Row="1" Grid. ColumnSpan="2">
<TextBlock FontSize="18" Margin="0 0 0 10" Text="{Binding ElementName=cmbxDocTypes, Path=SelectedItem. Title}"></TextBlock>
<! - -<GroupBox Padding="5">-->
<Grid>
<Grid. RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="100"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid. RowDefinitions>
<Grid. ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid. ColumnDefinitions>
<Frame Grid. ColumnSpan="2" Name="frameConcreteDoc" JournalOwnership="OwnsJournal" NavigationUIVisibility="Hidden" Focusable="False"></Frame>
<DockPanel Grid. ColumnSpan="2" Grid. Row="1" Margin="0 0 0 5" LastChildFill="True">
<Label DockPanel. Dock="Top" Target="{Binding ElementName=txtComment}">Краткое _описание: </Label>
<TextBox Name="txtComment" AcceptsReturn="True" Text="{Binding Comment, Mode=TwoWay, Converter={StaticResource ResourceKey=NullableTextConverter}}"></TextBox>
</DockPanel>
<Label Grid. Row="2" Target="{Binding ElementName=cmbxCardCase}">Позиция в _картотеке: </Label>
<Grid Grid. Row="2" Grid. Column="1" VerticalAlignment="Top">
<Grid. ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid. ColumnDefinitions>
<DockPanel>
<Button Focusable="False" DockPanel. Dock="Right" MinWidth="22" Click="btnCardCase_Click" VerticalAlignment="Top" >. </Button>
<ComboBox Name="cmbxCardCase" IsEditable="True" VerticalAlignment="Top" TextSearch. TextPath="Title" DisplayMemberPath="Title" SelectionChanged="cmbxCardCase_SelectionChanged"></ComboBox>
</DockPanel>
<TextBlock Grid. Column="1" Margin="5 0">-</TextBlock>
<DockPanel Grid. Column="2">
<Button Focusable="False" DockPanel. Dock="Right" MinWidth="22" Click="btnCardFolder_Click" VerticalAlignment="Top" Content=". ">
<Button. Style>
<Style TargetType="{x: Type Button}">
<Style. Triggers>
<DataTrigger Binding="{Binding ElementName=cmbxCardCase,Path=SelectedItem}" Value="{x: Null}">
<Setter Property="IsEnabled" Value="False"></Setter>
</DataTrigger>
</Style. Triggers>
</Style>
</Button. Style>
</Button>
<ComboBox Name="cmbxCardFolder" Grid. Column="2" IsEditable="True" VerticalAlignment="Top" TextSearch. TextPath="Title" DisplayMemberPath="Title" SelectedValue="{Binding CardFolderID, Mode=TwoWay}" SelectedValuePath="ID"></ComboBox>
<DockPanel. Style>
<Style TargetType="{x: Type DockPanel}">
<Style. Triggers>
<DataTrigger Binding="{Binding ElementName=cmbxCardCase,Path=Text}" Value="">
<Setter Property="IsEnabled" Value="False"></Setter>
</DataTrigger>
</Style. Triggers>
</Style>
</DockPanel. Style>
</DockPanel>
</Grid>
</Grid>
<! - -</GroupBox>-->
</StackPanel>
<! - Общая информация документов - ->
<Expander Grid. Row="3" Grid. ColumnSpan="2" Header="Прикрепленные файлы" IsExpanded="True" Margin="0 15 0 0">
<StackPanel >
<StackPanel Orientation="Horizontal" Margin="5, 5, 0, 5" HorizontalAlignment="Right">
<Image VerticalAlignment="Center" Margin="0 0 5 0" Source="{StaticResource ResourceKey=Icon_PaperClipDark}" Width="8"></Image>
<TextBlock VerticalAlignment="Center">Прикрепить: </TextBlock>
<Button Margin="5 0 0 0" Click="AddFile_Click" Padding="5 0" ToolTip="Прикрепить файл">Файл</Button>
<Button Margin="5 0 0 0" Click="ScanFile_Click" Padding="5 0" ToolTip="Сканировать документ">Скан</Button>
<Button Margin="5 0 0 0" Click="AddFolder_Click" Padding="5 0" ToolTip="Создать папку">Папку</Button>
</StackPanel>
<TreeView Name="treeDocFiles" TreeViewItem. Expanded="treeDocFiles_Expanded" TreeViewItem. MouseDoubleClick="treeDocFiles_MouseDoubleClick" KeyUp="treeDocFiles_KeyUp" dkctrls: RenamingTextBox. Renamed="treeDocFiles_Renamed" Style="{StaticResource DocFileTreeStyle}" MouseMove="treeDocFiles_MouseMove" Drop="treeDocFiles_Drop" DragOver="treeDocFiles_DragOver" MouseLeftButtonDown="treeDocFiles_MouseLeftButtonDown">
<TreeView.commandBindings>
<CommandBinding Command="Delete" Executed="DeleteAttachedFile_Executed"></CommandBinding>
</TreeView.commandBindings>
</TreeView>
<! - -<Grid Margin="5, 5, 0, 5" HorizontalAlignment="Right">
<Grid. ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="120" ></ColumnDefinition>
</Grid. ColumnDefinitions>
<Grid. RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid. RowDefinitions>
<Button Grid. Row="0" Margin="0 0 0 4" Padding="6 1" Click="AddFile_Click">
<StackPanel Orientation="Horizontal">
<Image Margin="0 0 5 0" Source="{StaticResource ResourceKey=Icon_PaperClipDark}" Width="8"></Image>
<TextBlock>Прикрепить файл</TextBlock>
</StackPanel>
</Button>
<Button Grid. Row="1" Padding="6 1" Click="ScanFile_Click">Сканировать документ</Button>
</Grid>-->
<! - -<Grid>
<ListBox Name="lstAttachedFiles" BorderThickness="0" Background="{StaticResource FormBackgroundBrush}" HorizontalAlignment="Left" HorizontalContentAlignment="Stretch" MouseDoubleClick="lstAttachedFiles_MouseDoubleClick" dkctrls: RenamingTextBox. Renamed="FileTitle_Renamed" >
Подобные документы
Основные особенности нормативного и методического обеспечения архивного хранения электронных документов. Общие требования к организации и проведению учета электронных архивных документов. Рассмотрение инновационных методов учета в делопроизводстве.
курсовая работа [255,8 K], добавлен 31.08.2015Программные средства выполнения, обращения и хранения электронных документов на предприятии. Правовое и методическое обеспечение сохранности информационных ресурсов в организациях Республики Беларусь. Создание электронной регистрационной карточки.
реферат [25,4 K], добавлен 17.04.2015Порядок разработки, учета, хранения, размножения и уничтожения секретных (конфиденциальных) документов. Режим секретности при обработке секретных документов с применением средств вычислительной техники и технических средств иностранного производства.
реферат [442,4 K], добавлен 01.02.2013Анализ существующих поисковых систем и используемых ими алгоритмов поиска документов. Разработка информационно-поисковой системы словарного типа, способной осуществлять релевантный поиск документов, особенности ее структуры и информационно-поисковой базы.
дипломная работа [942,1 K], добавлен 19.05.2011Составление пакета программной документации. Анализ функционирования и совершенствование программы. Стандарты, регламентирующие ее эксплуатацию. Изучение требований к составу, содержанию и оформлению документов. Порядок хранения и обновления файлов.
курсовая работа [31,2 K], добавлен 02.08.2015Межбиблиотечный абонемент и доставка документов входит в число важнейших средств функционирования информационного пространства. Проблема стандартизации технологии и терминологии в библиотечном деле. Перспективы развития электронной доставки документов.
контрольная работа [24,2 K], добавлен 17.11.2010Понятие системы электронной доставки документов, становление и развитие. Схема функционирования и основные технологические этапы, получение и обработка заказов. Программы для изготовления копий, их хранение. Проблемы, возникающие при работе службы ЭДД.
реферат [26,1 K], добавлен 10.10.2009Анализ механизма функционирования программы Lotus Notes, позволяющей организовать процесс создания и распространения документов более удобным путем, объединяя документы в базы документов. Основные элементы интерфейса. Работа с папками, обработка почты.
контрольная работа [4,0 M], добавлен 06.10.2010Понятие шаблона документа, анализ последовательности действий для его создания. Несколько замечаний по поводу тактики создания шаблонов. Специфика создания документов с использованием слияния. Особенность использования программы Microsoft Graph.
реферат [17,1 K], добавлен 05.10.2011Проблемы авторского права в работе службы электронной доставки документов в библиотечно-библиографическом обслуживании. Характеристика ЭДД как современной службы по работе с удаленными пользователями, анализ ее работы в Российской национальной библиотеке.
дипломная работа [2,3 M], добавлен 18.09.2011