Скачать 0.76 Mb.
|
Рисунок В.1 – Главное окно программы Рисунок В.2 – Вид тестирования Рисунок В.3 – Вид журнала тестирований Рисунок В.4 – Вид программы при добавлении пользователя Рисунок В.5 – Вид программы при добавлении документа Рисунок В.6 – Вид программы при создании и редактировании тестов Приложение Г ЛИСТИНГ программы
using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Data.SqlClient; using TestSystem.Data; namespace TestSystem { class DataAccess { string connectionString; public DataAccess(string cntnString) { connectionString = cntnString; } public void Execute(string commandtext) { using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); if (connection.State == ConnectionState.Closed) throw new ApplicationException("Соединение с базой сервера закрыто!"); using (SqlCommand command = new SqlCommand(commandtext, connection)) { command.CommandType = CommandType.Text; command.CommandTimeout = 10000; command.ExecuteScalar(); } } } public void Execute(SqlCommand command) { using (SqlConnection connection = new SqlConnection(connectionString)) { command.Connection = connection; command.CommandTimeout = 10000; connection.Open(); if (connection.State == ConnectionState.Closed) throw new ApplicationException("Соединение с базой сервера закрыто!"); command.ExecuteScalar(); } } public DataSet Select(string commandText, string[] tableNames) { DataSet dataSet = new DataSet(); using (SqlConnection connection = new SqlConnection(connectionString)) { using (SqlCommand command = new SqlCommand(commandText, connection)) { connection.Open(); if (connection.State == ConnectionState.Closed) throw new ApplicationException("Соединение с базой сервера закрыто!"); using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { adapter.SelectCommand = command; if (tableNames != null && tableNames.Length > 0) { for (int i = 0; i < tableNames.Length; i++) { StringBuilder sb = new StringBuilder("Table"); if (i > 0) sb.Append(i); adapter.TableMappings.Add(sb.ToString(), tableNames[i]); } } adapter.Fill(dataSet); return dataSet; } } } } public DataSet Select(SqlCommand command, string[] tableNames) { using (SqlConnection connection = new SqlConnection(connectionString)) { command.Connection = connection; connection.Open(); if (connection.State == ConnectionState.Closed) throw new ApplicationException("Соединение с базой сервера закрыто!"); DataSet dataSet = new DataSet(); using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { if (tableNames != null && tableNames.Length > 0) { for (int i = 0; i < tableNames.Length; i++) { StringBuilder sb = new StringBuilder("Table"); if (i > 0) sb.Append(i); adapter.TableMappings.Add(sb.ToString(), tableNames[i]); } } adapter.Fill(dataSet); return dataSet; } } } public void AppendParameter(SqlCommand command, string name, TParamBase param) { AppendParameter(command, name, param, ParameterDirection.Input); } public void AppendParameter(SqlCommand command, string name, TParamBase param, ParameterDirection direction) { SqlParameter sqlparam = command.CreateParameter(); sqlparam.ParameterName = "@" + name.TrimStart('@'); sqlparam.DbType = param.Type; sqlparam.Direction = direction; sqlparam.Value = param.Value; command.Parameters.Add(sqlparam); } public UsersDataSet LoadUsers(int? groupId) { UsersDataSet users = new UsersDataSet(); using (SqlCommand command = new SqlCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "dbo.ui_LoadUsers"; AppendParameter(command, "GroupId", new TInt(groupId)); users.Merge(Select(command, new string[] { "Users" })); } return users; } public UserGroupsDataSet LoadGroups() { UserGroupsDataSet groups = new UserGroupsDataSet(); using (SqlCommand command = new SqlCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "dbo.ui_LoadUserGroups"; groups.Merge(Select(command, new string[] { "UserGroups" })); } return groups; } public DocumentsDataSet LoadDocuments() { DocumentsDataSet documents = new DocumentsDataSet(); using (SqlCommand command = new SqlCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "dbo.ui_LoadDocuments"; documents.Merge(Select(command, new string[] { "Documents" })); } return documents; } public TestsDataSet LoadTests(int? documentId) { TestsDataSet tests = new TestsDataSet(); using (SqlCommand command = new SqlCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "dbo.ui_LoadTests"; AppendParameter(command, "DocumentId", new TInt(documentId)); tests.Merge(Select(command, new string[] { "Tests" })); } return tests; } public JournalDataSet LoadJournal(int? groupId, int? userId, int? documentId, DateTime? dateFrom, DateTime? dateInto, bool? groupBy) { JournalDataSet journal = new JournalDataSet(); using (SqlCommand command = new SqlCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "dbo.ui_LoadJournal"; AppendParameter(command, "GroupId", new TInt(groupId)); AppendParameter(command, "UserId", new TInt(userId)); AppendParameter(command, "DocumentId", new TInt(documentId)); AppendParameter(command, "DateFrom", new TDateTime(dateFrom)); AppendParameter(command, "DateInto", new TDateTime(dateInto)); journal.Merge(Select(command, new string[] { "Journal" })); } return journal; } public JournalDataSet LoadJournalDetail(DateTime? testDate, string userName, string testName) { JournalDataSet journal = new JournalDataSet(); using (SqlCommand command = new SqlCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "dbo.ui_LoadJournalDetail"; AppendParameter(command, "TestDate", new TDateTime(testDate)); AppendParameter(command, "UserName", new TString(userName, 300)); AppendParameter(command, "TestName", new TString(testName, 500)); journal.Merge(Select(command, new string[] { "JournalDetail" })); } return journal; } public AnswerZonesDataSet LoadAnswerZones(int testId) { AnswerZonesDataSet zones = new AnswerZonesDataSet(); using (SqlCommand command = new SqlCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "dbo.ui_LoadAnswerZone"; AppendParameter(command, "TestId", new TInt(testId)); zones.Merge(Select(command, new string[] { "AnswerZones" })); } return zones; } public int AddUser(string name, string password, int groupId) { int id = -1; using (SqlCommand command = new SqlCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "dbo.ui_AddUser"; AppendParameter(command, "Name", new TString(name, 100)); AppendParameter(command, "Password", new TString(password, 50)); AppendParameter(command, "GroupId", new TInt(groupId)); AppendParameter(command, "Id", new TInt(id), ParameterDirection.Output); Execute(command); id = (int)command.Parameters["@Id"].Value; } return id; } public bool EditUser(int id, string name, string password, int? groupId) { int result = 0; using (SqlCommand command = new SqlCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "dbo.ui_EditUser"; AppendParameter(command, "Name", new TString(name, 100)); AppendParameter(command, "Password", new TString(password, 50)); AppendParameter(command, "GroupId", new TInt(groupId)); AppendParameter(command, "Id", new TInt(id)); AppendParameter(command, "Result", new TInt(result), ParameterDirection.ReturnValue); Execute(command); return ((int)command.Parameters["@Result"].Value) == 1; } } public bool DropUser(int id) { int result = 0; using (SqlCommand command = new SqlCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "dbo.ui_DropUser"; AppendParameter(command, "Id", new TInt(id)); AppendParameter(command, "Result", new TInt(result), ParameterDirection.ReturnValue); Execute(command); return ((int)command.Parameters["@Result"].Value) == 1; } } public bool DropUserGroup(int id) { int result = 0; using (SqlCommand command = new SqlCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "dbo.ui_DropUserGroup"; AppendParameter(command, "Id", new TInt(id)); AppendParameter(command, "Result", new TInt(result), ParameterDirection.ReturnValue); Execute(command); return ((int)command.Parameters["@Result"].Value) == 1; } } public int AddUserGroup(string name) { int id = -1; using (SqlCommand command = new SqlCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "dbo.ui_AddUserGroup"; AppendParameter(command, "Name", new TString(name, 100)); AppendParameter(command, "Id", new TInt(id), ParameterDirection.Output); Execute(command); id = (int)command.Parameters["@Id"].Value; } return id; } public int AddDocument(int ownerId, string name, int type, byte[] document) { int id = -1; using (SqlCommand command = new SqlCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "dbo.ui_AddDocument"; AppendParameter(command, "OwnerId", new TInt(ownerId)); AppendParameter(command, "Name", new TString(name, 150)); AppendParameter(command, "Type", new TInt(type)); AppendParameter(command, "Document", new TBinary(document)); AppendParameter(command, "Id", new TInt(id), ParameterDirection.Output); Execute(command); id = (int)command.Parameters["@Id"].Value; } return id; } public int AddJournal(int userId, int testId, DateTime testDate, int tenths) { int id = -1; using (SqlCommand command = new SqlCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "dbo.ui_AddJournal"; AppendParameter(command, "UserId", new TInt(userId)); AppendParameter(command, "TestId", new TInt(testId)); AppendParameter(command, "TestDate", new TDateTime(testDate)); AppendParameter(command, "Tenths", new TInt(tenths)); AppendParameter(command, "Id", new TInt(id), ParameterDirection.Output); Execute(command); id = (int)command.Parameters["@Id"].Value; } return id; } public DocumentsDataSet.DocumentsRow FetchDocument(int id) { DocumentsDataSet documents = new DocumentsDataSet(); using (SqlCommand command = new SqlCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "dbo.ui_FetchDocument"; AppendParameter(command, "Id", new TInt(id)); documents.Merge(Select(command, new string[] { "Documents" })); if (documents.Tables.Count > 0 && documents.Tables["Documents"].Rows.Count > 0) { return (DocumentsDataSet.DocumentsRow)documents.Tables["Documents"].Rows[0]; } } return null; } public bool DropDocument(int id) { int result = 0; using (SqlCommand command = new SqlCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "dbo.ui_DropDocument"; AppendParameter(command, "Id", new TInt(id)); AppendParameter(command, "Result", new TInt(result), ParameterDirection.ReturnValue); Execute(command); return ((int)command.Parameters["@Result"].Value) == 1; } } public bool DropSection(int id) { int result = 0; using (SqlCommand command = new SqlCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "dbo.ui_DropSection"; AppendParameter(command, "Id", new TInt(id)); AppendParameter(command, "Result", new TInt(result), ParameterDirection.ReturnValue); Execute(command); return ((int)command.Parameters["@Result"].Value) == 1; } } public TestsDataSet.TestsRow FetchTest(int id) { TestsDataSet tests = new TestsDataSet(); using (SqlCommand command = new SqlCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "dbo.ui_FetchTest"; AppendParameter(command, "Id", new TInt(id)); tests.Merge(Select(command, new string[] { "Tests" })); if (tests.Tables.Count > 0 && tests.Tables["Tests"].Rows.Count > 0) { return (TestsDataSet.TestsRow)tests.Tables["Tests"].Rows[0]; } } return null; } public int AddTest(int documentId, string question, int method, string answer) { TestsDataSet tests = new TestsDataSet(); int id = -1; using (SqlCommand command = new SqlCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "dbo.ui_AddTest"; AppendParameter(command, "DocumentId", new TInt(documentId)); AppendParameter(command, "Question", new TString(question, 250)); AppendParameter(command, "Method", new TInt(method)); |
Учебно-методический комплекс дисциплины сд. Ф. 18 Методика обучения изобразительной деятельности Целью его является изучение современного состояния эстетического образования дошкольников на основе ознакомления с искусствоведческими... | Анализ современного состояния Единой Энергетической Системы России,... В работе представлен анализ современного состояния Единой Энергетической Системы России, основных проблем в энергетике России, а... | ||
Русский народный костюм как источник вдохновения для создания современного костюма Образовательная: научить методам создания эскиза современного костюма на основе русского костюма | Анализ деяельности педагогического коллектива, направленой на обеспечение... Анализ деяельности педагогического коллектива, направленой на обеспечение базового образования, анализ состояния преподавания и процесса... | ||
Структура архитектуры ивс "атмосферные аэрозоли" Широкий класс задач, связанных с обеспечением контроля состояния атмосферы крупного промышленного центра требуют создания специализированных... | Знакомство с чудесной дымкой Целью его является изучение современного состояния эстетического образования дошкольников на основе ознакомления с искусствоведческими... | ||
Обзор систем дистанционного обучения (сдо) Персональный менеджмент: Учеб методический комплекс / Авт и сост.: М. Б. Дюжева. – Омск: Типография «с-принт», 2011. – 85 с | Работа представляет собой краткий обзор состояния дел в области разработки... Изложены базовые принципы построения ситемы управления на базе поведенческих реакций и архитектуры системы управления группой летательных... | ||
Конспект нод по образовательной деятельности Целью его является изучение современного состояния эстетического образования дошкольников на основе ознакомления с искусствоведческими... | Исследование современного состояния производства специальной одежды из огнезащитных тканей В статье представлены результаты исследования современного состояния производства специальной одежды из огнезащитных тканей | ||
Конспект занятия по развитию речи на тему Целью его является изучение современного состояния эстетического образования дошкольников на основе ознакомления с искусствоведческими... | Конспект занятия в старшей группе мбдоу д/с №8 Целью его является изучение современного состояния эстетического образования дошкольников на основе ознакомления с искусствоведческими... | ||
«Зима» Цель: способствовать развитию экспрессивной речи Целью его является изучение современного состояния эстетического образования дошкольников на основе ознакомления с искусствоведческими... | Занятие по лепке в младшей группе на тему: «Цыплята» Цель Целью его является изучение современного состояния эстетического образования дошкольников на основе ознакомления с искусствоведческими... | ||
Конспект открытого занятия по изобразительной деятельности в средней группе Целью его является изучение современного состояния эстетического образования дошкольников на основе ознакомления с искусствоведческими... | Конспект занятия по лепке (предметной) в средней группе Тема: "Кукла" Целью его является изучение современного состояния эстетического образования дошкольников на основе ознакомления с искусствоведческими... |