示例#1
0
文件: Form1.cs 项目: natz247/FGMIS2
        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);
            }
        }
示例#2
0
文件: Form1.cs 项目: natz247/FGMIS2
        private void DeleteActivity()
        {
            Activity1Helper helper = new Activity1Helper();
            int             result = helper.DeleteActivity(activityId);

            if (result > 0)
            {
                MessageBox.Show("Activity data deleted successfully!", "Successfully Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            else
            {
                MessageBox.Show("Activity data deletetion failed!", "Uh oh!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
示例#3
0
文件: Form1.cs 项目: natz247/FGMIS2
 private void syncBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     syncHelper       = new Activity1Helper();
     activityList     = syncHelper.GetUnsyncedActivityList();
     participantsList = syncHelper.GetUnsyncedParticpansList();
     if (activityList.Count > 0)
     {
         //sync data
         syncStatus = syncHelper.SendActivityListToServer(activityList);
     }
     if (participantsList.Count > 0)
     {
         //sync data
         participantsSyncStatus = syncHelper.SendParticipantsListToServer(participantsList);
     }
 }
示例#4
0
文件: Form1.cs 项目: natz247/FGMIS2
        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();
                }
            }
        }