Esempio n. 1
0
        public List <Participant1> GetParticpantData(int activityId)
        {
            List <Participant1> participantList = new List <Participant1>();
            string tableName = "Participants1";

            connection = new OleDbConnection(Properties.Settings.Default.DatabaseAddress);
            command    = connection.CreateCommand();

            command.CommandText = "SELECT * FROM " + tableName + " WHERE [activityid]=" + activityId;
            connection.Open();

            OleDbDataReader dr = command.ExecuteReader();

            while (dr.Read())
            {
                Participant1 participant = new Participant1();
                participant.Pid    = Convert.ToInt32(dr[0].ToString());
                participant.Name   = dr[1].ToString();
                participant.Kebele = dr[2].ToString();
                participant.Sex    = dr[4].ToString();
                participant.Age    = Convert.ToInt32(dr[5].ToString());

                participantList.Add(participant);
            }
            connection.Close();
            dr.Close();
            return(participantList);
        }
Esempio n. 2
0
        private void PopulateFields(int activityId)
        {
            Activity1Helper helper   = new Activity1Helper();
            Activity1       activity = helper.GetActivityData(activityId);

            if (activity != null)
            {
                comboBox1.Text        = activity.Region;
                comboBox2.Text        = activity.Zone;
                textBox1.Text         = activity.Place;
                comboBox3.Text        = activity.Woreda;
                comboBox4.Text        = activity.Kebele;
                dateTimePicker1.Value = activity.ActivityDate;
                textBox2.Text         = activity.Duration;
                textBox3.Text         = activity.IssuesRaised;
                textBox4.Text         = activity.AgreedActionPoints;
                textBox6.Text         = activity.FacilitatorName;
                textBox7.Text         = activity.Position;
            }
            List <Participant1> participantsList = helper.GetParticpantData(activityId);

            for (int i = 0; i < participantsList.Count; i++)
            {
                Participant1 participant = (Participant1)participantsList[i];
                string[]     row         = { dataGridView2.RowCount + "", participant.Name, participant.Kebele, participant.Sex, participant.Age.ToString() };
                dataGridView2.Rows.Add(row);
            }
        }
Esempio n. 3
0
        private void UpdateLocalParticipant(Participant1 participant, int participantRemoteId)
        {
            //make sync_status to 1
            //change remote id to new remote id
            string          tableName   = "Participants1";
            OleDbConnection connection2 = new OleDbConnection(Properties.Settings.Default.DatabaseAddress);
            OleDbCommand    command2    = connection2.CreateCommand();

            command2.CommandText = "UPDATE " + tableName + " SET [sync_status]=1, [remoteactivityid]=@RemoteActivityId, [remoteparticipantid]=@RemoteParticipantId WHERE ID=" + participant.Pid;
            command2.Parameters.AddWithValue("@RemoteActivityId", activityRemoteId);
            command2.Parameters.AddWithValue("@RemoteParticipantId", participantRemoteId);

            connection2.Open();
            command2.ExecuteNonQuery();
            connection2.Close();
        }
Esempio n. 4
0
        public int InsertParticipant(Participant1 participant, MySqlConnection myConnection)
        {
            int participantRemoteId = -1;

            try
            {
                MySqlCommand myCommand = myConnection.CreateCommand();
                myCommand.CommandText = "INSERT INTO Participants1 (`pname`, `kebele`, `woreda`, `sex`, `age`, `disabled`, `activityid`, `remoteactivityid`) VALUES(@PName, @Kebele, @Woreda, @Sex, @Age, @Disabled, @ActivityId, @RemoteActivityId);";

                myCommand.Parameters.AddWithValue("@PName", participant.Name);
                myCommand.Parameters.AddWithValue("@Kebele", participant.Kebele);
                myCommand.Parameters.AddWithValue("@Woreda", participant.Woreda);
                myCommand.Parameters.AddWithValue("@Sex", participant.Sex);
                myCommand.Parameters.AddWithValue("@Age", participant.Age);
                myCommand.Parameters.AddWithValue("@Disabled", participant.Disabled);
                myCommand.Parameters.AddWithValue("@ActivityId", participant.ActivityId);
                myCommand.Parameters.AddWithValue("@RemoteActivityId", activityRemoteId);

                //ID=Convert.ToInt32(command.ExecuteScalar());
                myCommand.ExecuteNonQuery();

                myCommand.CommandText = "SELECT @@IDENTITY";
                MySqlDataReader dr = myCommand.ExecuteReader();
                while (dr.Read())
                {
                    participantRemoteId = Convert.ToInt32(dr[0].ToString());
                }
                //update local database
                UpdateLocalParticipant(participant, participantRemoteId);
                dr.Close();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (myConnection != null)
                {
                    //myConnection.Close();
                }
            }
            return(participantRemoteId);
        }
Esempio n. 5
0
        public int SendParticipantsListToServer(List <Participant1> participantsList)
        {
            int syncSuccessful = -1;

            //connect to remote database
            MySqlHelper mySqlHelper = new MySqlHelper();

            if (mySqlHelper.OpenConnection())
            {
                MySqlConnection myConnection = mySqlHelper.Connection;

                for (int i = 0; i < participantsList.Count; i++)
                {
                    Participant1 participant = (Participant1)participantsList[i];
                    syncSuccessful = InsertParticipant(participant, myConnection);
                }
                mySqlHelper.CloseConnection();
            }

            return(syncSuccessful);
        }
Esempio n. 6
0
        public int Insert(Activity1 activity, List <Participant1> participantsList)
        {
            int activityId = -1;

            try
            {
                command.CommandText = "INSERT INTO Activity1 ([region], [zone], woreda, kebele, [activity_date], [user_id], facilitator_name, [position], issues_raised, agreed_action_points, [localtimestamp], [mac], [place], [duration]) VALUES(@Region, @Zone, @Woreda, @Kebele, '" + activity.ActivityDate + "', @UserId, @FacilitatorName, @Position, @IssuesRaised, @AgreedActionPoints, '" + activity.LocalTimeStamp + "', @Mac, @Place, @Duration);";// '"+activity.Region+"', '"+activity.Zone+"', '" +activity.Woreda + "', '" +activity.Kebele + "', '" +activity.ActivityDate + "', '" +activity.UserId + "', '" +activity.FacilitatorName + "', '" +activity.Position + "' , '" +activity.LocalTimeStamp + "', '" +activity.Mac + "', '" +activity.Place + "', '" +activity.Duration+ "')";

                command.Parameters.AddWithValue("@Region", activity.Region);
                command.Parameters.AddWithValue("@Zone", activity.Zone);
                command.Parameters.AddWithValue("@Woreda", activity.Woreda);
                command.Parameters.AddWithValue("@Kebele", activity.Kebele);
                //command.Parameters.AddWithValue("@ActivityDate", activity.ActivityDate);
                command.Parameters.AddWithValue("@UserId", activity.UserId);
                command.Parameters.AddWithValue("@FacilitatorName", activity.FacilitatorName);
                command.Parameters.AddWithValue("@Position", activity.Position);
                command.Parameters.AddWithValue("@IssuesRaised", activity.IssuesRaised);
                command.Parameters.AddWithValue("@AgreedActionPoints", activity.AgreedActionPoints);
                //command.Parameters.AddWithValue("@LocalTimeStamp", activity.LocalTimeStamp);
                command.Parameters.AddWithValue("@Mac", activity.Mac);
                command.Parameters.AddWithValue("@Place", activity.Place);
                command.Parameters.AddWithValue("@Duration", activity.Duration);
                connection.Open();
                //ID=Convert.ToInt32(command.ExecuteScalar());
                command.ExecuteNonQuery();

                command.CommandText = "SELECT @@IDENTITY";
                OleDbDataReader dr = command.ExecuteReader();
                while (dr.Read())
                {
                    activityId = Convert.ToInt32(dr[0].ToString());
                }
                dr.Close();
                //command.CommandType = CommandType.Text;
                //int ID = command.ExecuteNonQuery();
                if (activityId != -1)
                {
                    for (int i = 0; i < participantsList.Count; i++)
                    {
                        Participant1 participant = (Participant1)participantsList[i];
                        OleDbCommand command2    = connection.CreateCommand();
                        command2.CommandText = "INSERT INTO Participants1 (pname, kebele, sex, age, activityid) VALUES(@Name, @Kebele, @Sex, @Age, @ActivityId);";// '"+activity.Region+"', '"+activity.Zone+"', '" +activity.Woreda + "', '" +activity.Kebele + "', '" +activity.ActivityDate + "', '" +activity.UserId + "', '" +activity.FacilitatorName + "', '" +activity.Position + "' , '" +activity.LocalTimeStamp + "', '" +activity.Mac + "', '" +activity.Place + "', '" +activity.Duration+ "')";

                        command2.Parameters.AddWithValue("@Name", participant.Name);
                        command2.Parameters.AddWithValue("@Kebele", participant.Kebele);
                        command2.Parameters.AddWithValue("@Sex", participant.Sex);
                        command2.Parameters.AddWithValue("@Age", participant.Age);
                        command2.Parameters.AddWithValue("@ActivityId", activityId);

                        command2.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                }
            }
            return(activityId);
        }
Esempio n. 7
0
 /// <summary>
 /// Ctor for all elements
 /// </summary>
 public PLClinicalDocument(II id, CE <string> code, ST title, TS effectiveTime, CE <x_BasicConfidentialityKind> confidentialityCode, CS <string> languageCode, II setId, INT versionNumber, TS copyTime, RecordTarget recordTarget, Author author, DataEnterer dataEnterer, Informant12 informant, Custodian custodian, InformationRecipient informationRecipient, LegalAuthenticator legalAuthenticator, Authenticator authenticator, Participant1 participant, InFulfillmentOf inFulfillmentOf, DocumentationOf documentationOf, RelatedDocument relatedDocument, Authorization authorization, Component1 componentOf, Component2 component)
     : base(id, code, title, effectiveTime, confidentialityCode, languageCode, setId, versionNumber, copyTime, recordTarget, author, dataEnterer, informant, custodian, informationRecipient, legalAuthenticator, authenticator, participant, inFulfillmentOf, documentationOf, relatedDocument, authorization, componentOf, component)
 {
     this.PertinentInformation = new List <PertinentInformation>();
 }
Esempio n. 8
0
        private void SaveData(int saveOrUpdate)
        {
            if (mainFieldsValid())
            {
                //MessageBox.Show("All fields valid. Ready to submit data to database.");
                Activity1Helper helper   = new Activity1Helper();
                Activity1       activity = new Activity1();
                //(region, zone, woreda, kebele, activity_date, user_id, facilitator_name, position, localtimestamp, mac)
                activity.Region          = comboBox1.Text;
                activity.Zone            = comboBox2.Text;
                activity.Woreda          = comboBox3.Text;
                activity.Kebele          = comboBox4.Text;
                activity.ActivityDate    = dateTimePicker1.Value;
                activity.UserId          = Properties.Settings.Default.UID; //change this using property stored id of currently logged in user
                activity.FacilitatorName = textBox6.Text;                   //make name of logged in user available in this field
                activity.Position        = textBox7.Text;
                activity.LocalTimeStamp  = DateTime.Now;
                activity.Mac             = GetMacAddress();
                activity.Place           = textBox1.Text;
                activity.Duration        = textBox2.Text;

                activity.IssuesRaised       = textBox3.Text;
                activity.AgreedActionPoints = textBox4.Text;

                List <Participant1> participantsList = new List <Participant1>();
                if (dataGridView2.RowCount > 1)
                {
                    for (int i = 0; i < dataGridView2.Rows.Count - 1; i++)//-1 to avoid empty row
                    {
                        Participant1 participant = new Participant1();
                        if (dataGridView2.Rows[i].Cells[1].Value != null)
                        {
                            participant.Name = dataGridView2.Rows[i].Cells[1].Value.ToString();
                        }
                        if (dataGridView2.Rows[i].Cells[2].Value != null)
                        {
                            participant.Kebele = dataGridView2.Rows[i].Cells[2].Value.ToString();
                        }
                        if (dataGridView2.Rows[i].Cells[3].Value != null)
                        {
                            participant.Sex = dataGridView2.Rows[i].Cells[3].Value.ToString();
                        }
                        if (dataGridView2.Rows[i].Cells[4].Value != null)
                        {
                            participant.Age = Convert.ToInt32(dataGridView2.Rows[i].Cells[4].Value.ToString());
                        }
                        //participant.Age = 2;
                        participantsList.Add(participant);

                        //MessageBox.Show(dataGridView2.Rows[i].Cells[1].Value.ToString());
                    }
                }

                int id = helper.Insert(activity, participantsList);
                if (id > 0)
                {
                    InsertRegionAndKebeleData();
                    //MessageBox.Show("Activity data added successfully!");
                    MessageBox.Show("Activity data added successfully!", "Successfully Addition", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    //check internet connection before syncing data
                    if (saveOrUpdate == 1)//update button clicked
                    {
                        if (CheckInternet("http://" + Session.Properties.Settings.Default.RemoteDatabaseAddress))
                        {
                            SyncData();
                        }
                    }
                    //this.Close(); //or Reset fields

                    this.Close();
                }
            }
        }
Esempio n. 9
0
        private static void MakeParticipantNode(ClinicalDocument ccda)
        {
            Participant1 participant = new Participant1();
            participant.TypeCode = new CS<ParticipationType>(ParticipationType.IND);

            participant.AssociatedEntity = new AssociatedEntity();

            participant.AssociatedEntity.ClassCode = new CS<RoleClassAssociative>(RoleClassAssociative.PersonalRelationship);

            participant.AssociatedEntity.Addr = new SET<AD>(
                new AD(
                    new ADXP[]{
                            new ADXP("100 Marshall Lane", AddressPartType.StreetAddressLine),
                            new ADXP("Springfield", AddressPartType.City),
                            new ADXP("VA", AddressPartType.State),
                            new ADXP("22153", AddressPartType.PostalCode),
                            new ADXP("US", AddressPartType.Country)}));
            participant.AssociatedEntity.Telecom = new SET<TEL>(new TEL("tel:+1(571)555-0179;ext=221"));

            participant.AssociatedEntity.AssociatedPerson = new Person();
            participant.AssociatedEntity.AssociatedPerson.Name = new SET<PN>(
                new PN(
                    new List<ENXP>{
                    new ENXP("Kathleen", EntityNamePartType.Given),
                    new ENXP("McReary", EntityNamePartType.Family)}));

            ccda.Participant = new List<Participant1>();
            ccda.Participant.Add(participant);
        }