Beispiel #1
0
        public int Insert(ReportClass1 report, List <Output> outputsList)
        {
            int reportId = -1;

            try
            {
                command.CommandText = "INSERT INTO Report1 ([partner],[title],[period],[pyear],[plocation],[apopulation],[tpopulation],[budget],[description],[goal],[objective],[strategies],[tgroups],[participation],[coordination],[challenges],[stories],[engagement],[issues],[sustainability],[risks],[accountability],[minitoring],[uid],[localtimestamp],[remoteid],[remotetimestamp],[mac],[sync_status],[submit_status],[submissiondate]) VALUES(@partner,@title,@period,@pyear,@plocation,@apopulation,@tpopulation,@budget,@description,@goal,@objective,@strategies,@tgroups,@participation,@coordination,@challenges,@stories,@engagement,@issues,@sustainability,@risks,@accountability,@minitoring,@uid,'" + report.Localtimestamp + "',@remoteid,'" + report.Remotetimestamp + "',@mac,0,0,'" + report.Submissiondate + "');";

                command.Parameters.AddWithValue("@Partner", report.Partner);
                command.Parameters.AddWithValue("@title", report.Title);
                command.Parameters.AddWithValue("@period", report.Period);
                command.Parameters.AddWithValue("@pyear", report.Pyear);
                command.Parameters.AddWithValue("@plocation", report.Plocation);
                command.Parameters.AddWithValue("@apopulation", report.Apopulation);
                command.Parameters.AddWithValue("@tpopulation", report.Tpopulation);
                command.Parameters.AddWithValue("@budget", report.Budget);
                command.Parameters.AddWithValue("@description", report.Description);
                command.Parameters.AddWithValue("@goal", report.Goal);
                command.Parameters.AddWithValue("@objective", report.Objective);
                command.Parameters.AddWithValue("@strategies", report.Strategies);
                command.Parameters.AddWithValue("@tgroups", report.Tgroups);
                command.Parameters.AddWithValue("@participation", report.Participation);
                command.Parameters.AddWithValue("@coordination", report.Coordination);
                command.Parameters.AddWithValue("@challenges", report.Challenges);
                command.Parameters.AddWithValue("@stories", report.Stories);
                command.Parameters.AddWithValue("@engagement", report.Engagement);
                command.Parameters.AddWithValue("@issues", report.Issues);
                command.Parameters.AddWithValue("@sustainability", report.Sustainability);
                command.Parameters.AddWithValue("@risks", report.Risks);
                command.Parameters.AddWithValue("@accountability", report.Accountability);
                command.Parameters.AddWithValue("@minitoring", report.Monitoring);
                command.Parameters.AddWithValue("@uid", report.Uid);
                //command.Parameters.AddWithValue("@localtimestamp",report.Localtimestamp);
                command.Parameters.AddWithValue("@remoteid", report.Remoteid);
                //command.Parameters.AddWithValue("@remotetimestamp",report.Remotetimestamp);
                command.Parameters.AddWithValue("@mac", report.Mac);
                //command.Parameters.AddWithValue("@sync_status",report.Syncstatus);
                //command.Parameters.AddWithValue("@submit_status",report.Submitstatus);
                //command.Parameters.AddWithValue("@submissiondate", report.Submissiondate);
                connection.Open();
                //ID=Convert.ToInt32(command.ExecuteScalar());
                command.ExecuteNonQuery();

                command.CommandText = "SELECT @@IDENTITY";
                OleDbDataReader dr = command.ExecuteReader();
                while (dr.Read())
                {
                    reportId = Convert.ToInt32(dr[0].ToString());
                }
                dr.Close();
                //command.CommandType = CommandType.Text;
                //int ID = command.ExecuteNonQuery();
                if (reportId != -1)
                {
                    for (int i = 0; i < outputsList.Count; i++)
                    {
                        Output       output   = (Output)outputsList[i];
                        OleDbCommand command2 = connection.CreateCommand();
                        command2.CommandText = "INSERT INTO [Output] ([title],[type],[activityid],[reportid],[plannedm],[plannedf],[actualm],[actualf],[results],[deviation]) VALUES(@title,@type,@activityid,@reportid,@plannedm,@plannedf,@actualm,@actualf,@results,@deviation);";

                        command2.Parameters.AddWithValue("@title", output.Title);
                        command2.Parameters.AddWithValue("@type", output.Type);
                        command2.Parameters.AddWithValue("@activityid", output.Activityid);
                        command2.Parameters.AddWithValue("@reportid", reportId);
                        command2.Parameters.AddWithValue("@plannedm", output.Plannedm);
                        command2.Parameters.AddWithValue("@plannedf", output.Plannedf);
                        command2.Parameters.AddWithValue("@actualm", output.Actualm);
                        command2.Parameters.AddWithValue("@actualf", output.Actualf);
                        command2.Parameters.AddWithValue("@results", output.Results);
                        command2.Parameters.AddWithValue("@deviation", output.Deviation);

                        command2.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                }
            }
            return(reportId);
        }
Beispiel #2
0
        private void button26_Click(object sender, EventArgs e)
        {
            string partner     = (comboBox1.Text).Trim();
            string pyear       = (comboBox2.Text).Trim();
            string title       = (textBox1.Text).Trim();
            string period      = (textBox2.Text).Trim();
            string tpopulation = (textBox3.Text).Trim();
            string apopulation = (textBox4.Text).Trim();
            string plocation   = (textBox5.Text).Trim();
            string budget      = (textBox6.Text).Trim();
            string objective   = (textBox7.Text).Trim();
            string goal        = (textBox8.Text).Trim();
            string strategies  = (textBox9.Text).Trim();
            string tgroups     = (textBox10.Text).Trim();
            string description = (textBox12.Text).Trim();

            string participation  = (textBox16.Text).Trim();
            string coordination   = (textBox11.Text).Trim();
            string challenges     = (textBox13.Text).Trim();
            string stories        = (textBox14.Text).Trim();
            string engagement     = (textBox15.Text).Trim();
            string issues         = (textBox17.Text).Trim();
            string sustainability = (textBox18.Text).Trim();
            string risks          = (textBox19.Text).Trim();
            string accountability = (textBox20.Text).Trim();
            string monitoring     = (textBox21.Text).Trim();

            if (ValidateFields())
            {
                //save report data
                report                = new ReportClass1();
                report.Partner        = partner;
                report.Pyear          = Convert.ToInt32(pyear);
                report.Title          = title;
                report.Period         = period;
                report.Tpopulation    = Convert.ToInt32(tpopulation);
                report.Apopulation    = Convert.ToInt32(apopulation);
                report.Plocation      = plocation;
                report.Budget         = budget;
                report.Objective      = objective;
                report.Goal           = goal;
                report.Strategies     = strategies;
                report.Tgroups        = tgroups;
                report.Description    = description;
                report.Participation  = participation;
                report.Coordination   = coordination;
                report.Challenges     = challenges;
                report.Stories        = stories;
                report.Engagement     = engagement;
                report.Issues         = issues;
                report.Sustainability = sustainability;
                report.Risks          = risks;
                report.Accountability = accountability;
                report.Monitoring     = monitoring;

                report.Uid            = Properties.Settings.Default.UID;
                report.Localtimestamp = DateTime.Now;
                report.Mac            = GetMacAddress();

                outputsList = new List <Output>();
                ExtractDataGridViewData(output1, outputsList, 1);
                ExtractDataGridViewData(output2, outputsList, 2);
                ExtractDataGridViewData(output3, outputsList, 3);

                panel28.Visible          = true;
                scrollabalePanel.Enabled = false;
                reportInsertBackgroundWorker.RunWorkerAsync();
            }
        }