Пример #1
0
        private void AddProtocolActivityToListView(ProtocolActivity item)
        {
            ListViewItem listViewItem = this.MainListView.Items.Add(item.CreatedDate.ToString("MM/dd/yyyy"));

            listViewItem.SubItems.Add(item.CreatedBy);
            listViewItem.SubItems.Add(item.ProtocolEvent.Description);
        }
        private void InsertProtocolActivity(int eventID)
        {
            ProtocolTemplate title            = GetSelectedTemplateFromView();
            ProtocolActivity protocolActivity = new ProtocolActivity(title, eventID, loginInfo.UserName);

            QProtocolActivities.InsertItem(protocolActivity);
        }
        public static IList SelectItems(int requestID, int templateID)
        {
            IList results = new List <ProtocolActivity>()
            {
            };

            try
            {
                using (SqlConnection connection = new SqlConnection(CONNECTION_STRING))
                {
                    connection.Open();

                    using (SqlCommand command = new SqlCommand("pa_select_all_activities", connection))
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.Add("@RequestID", SqlDbType.Int).Value  = requestID;
                        command.Parameters.Add("@TemplateID", SqlDbType.Int).Value = templateID;
                        SqlDataReader reader = command.ExecuteReader();
                        while (reader.Read())
                        {
                            ProtocolActivity activity = CreateNewProtocolActivity(requestID, templateID, reader);
                            results.Add(activity);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.CreateLogFile(ErrorFormName, "SelectProtocolActivity", ex);
            }
            return(results);
        }
        private void SubmitSelectedTemplate(Template item)
        {
            QProtocolRequestTemplates.InsertItem(this.request.ID, item.ID, loginInfo.UserName);
            ProtocolActivity protocolActivity = new ProtocolActivity(this.request.ID, item.ID, 1, loginInfo.UserName);

            QProtocolActivities.InsertItem(protocolActivity);
            RefreshTemplateListView();
        }
        private static ProtocolActivity CreateNewProtocolActivity(int requestID, int templateID, SqlDataReader reader)
        {
            ProtocolActivity activity = new ProtocolActivity();

            activity.RequestID                 = requestID;
            activity.TemplateID                = templateID;
            activity.ProtocolEvent.ID          = Convert.ToInt32(reader[0].ToString());
            activity.ProtocolEvent.Description = reader[1].ToString();
            activity.CreatedBy                 = reader[2].ToString();
            activity.CreatedDate               = Convert.ToDateTime(reader[3].ToString());

            return(activity);
        }
        private IList CreateProtocolActivityList(int eventID)
        {
            IList protocolActivities = new List <ProtocolActivity>()
            {
            };

            foreach (int titleIndex in this.view.ListViewSelectedIndexes)
            {
                ProtocolTemplate title            = this.templates[titleIndex] as ProtocolTemplate;
                ProtocolActivity protocolActivity = new ProtocolActivity(title, eventID, loginInfo.UserName);
                protocolActivities.Add(protocolActivity);
            }
            return(protocolActivities);
        }
        public static void InsertItem(ProtocolActivity activity)
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(CONNECTION_STRING))
                {
                    connection.Open();
                    using (SqlCommand command = new SqlCommand("pa_insert_activity", connection))
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.Add("@RequestID", SqlDbType.Int).Value      = activity.RequestID;
                        command.Parameters.Add("@TemplateID", SqlDbType.Int).Value     = activity.TemplateID;
                        command.Parameters.Add("@EventID", SqlDbType.Int).Value        = activity.ProtocolEvent.ID;
                        command.Parameters.Add("@CreatedBy", SqlDbType.NVarChar).Value = activity.CreatedBy;

                        int result = command.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.CreateLogFile(ErrorFormName, "InsertProtocolActivity", ex);
            }
        }