Exemple #1
0
        private void button6_Click(object sender, EventArgs e)  //应力在线保存预览
        {
            string date_t = year + "-" + month + "-" + day;
            string date_y = year1 + "-" + month1 + "-" + day1;

            gt.setToday(date_t);
            gt.setYesToday(date_y);
            gt.setWorkFace(working_face);
            string constr_test   = "server=.;database=UPRESSURE;uid=sa;pwd=sakjdx";
            string sqlString_ins = string.Format(@"IF NOT EXISTS(SELECT 1 
                                                                 FROM [UPRESSURE].[dbo].[地表沉降数据] 
                                                                 WHERE  [日期] = '{0}')
                                                   BEGIN
                                                   INSERT INTO
                                                   [UPRESSURE].[dbo].[地表沉降数据]([日期], [观察日期], [最大沉降量],
                                                                                    [平均沉降量], [最大沉降位置])
                                                   VALUES('{0}', N'{1}', N'{2}', N'{3}', N'{4}')
                                                   END
                                                   ELSE
                                                   BEGIN
                                                   UPDATE [UPRESSURE].[dbo].[地表沉降数据]
                                                   SET [观察日期] = N'{1}', [最大沉降量] = N'{2}', 
                                                   [平均沉降量] = N'{3}', [最大沉降位置] = N'{4}'
                                                   WHERE [日期] = '{0}'
                                                   END", date_t,
                                                 (textBox7.Text == "") ? null : textBox7.Text,
                                                 (textBox8.Text == "") ? null : textBox8.Text,
                                                 (textBox9.Text == "") ? null : textBox9.Text,
                                                 (textBox10.Text == "") ? null : textBox10.Text
                                                 );

            using (SqlConnection sqlConnection = new SqlConnection(constr_test))
            {
                bool conok = SqlExtensions.QuickOpen(sqlConnection, 5000);  //连接到数据库
                if (conok)
                {
                    SqlCommand cmd_ins = new SqlCommand(sqlString_ins, sqlConnection);
                    cmd_ins.ExecuteNonQuery();
                    Properties.Settings.Default.Save();
                    MessageBox.Show("完成");
                    StressTest st = new StressTest(working_face);
                    st.Start(gt);
                    MessageBox.Show("应力监测ok");
                }
            }
        }
Exemple #2
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            string date_t = year + "-" + month + "-" + day;
            string date_y = year1 + "-" + month1 + "-" + day1;

            gt.setToday(date_t);
            gt.setYesToday(date_y);
            gt.setWorkFace(working_face);
            string constr_test   = "server=.;database=UPRESSURE;uid=sa;pwd=sakjdx";
            string sqlString_ins = string.Format(@"IF NOT EXISTS(SELECT 1 
                                                                 FROM [UPRESSURE].[dbo].[地表沉降数据] 
                                                                 WHERE  [日期] = '{0}')
                                                   BEGIN
                                                   INSERT INTO
                                                   [UPRESSURE].[dbo].[地表沉降数据]([日期], [观察日期], [最大沉降量],
                                                                                    [平均沉降量], [最大沉降位置])
                                                   VALUES('{0}', N'{1}', N'{2}', N'{3}', N'{4}')
                                                   END
                                                   ELSE
                                                   BEGIN
                                                   UPDATE [UPRESSURE].[dbo].[地表沉降数据]
                                                   SET [观察日期] = N'{1}', [最大沉降量] = N'{2}', 
                                                   [平均沉降量] = N'{3}', [最大沉降位置] = N'{4}'
                                                   WHERE [日期] = '{0}'
                                                   END", date_t,
                                                 (textBox7.Text == "") ? null : textBox7.Text,
                                                 (textBox8.Text == "") ? null : textBox8.Text,
                                                 (textBox9.Text == "") ? null : textBox9.Text,
                                                 (textBox10.Text == "") ? null : textBox10.Text
                                                 );

            using (SqlConnection sqlConnection = new SqlConnection(constr_test))
            {
                bool conok = SqlExtensions.QuickOpen(sqlConnection, 5000);  //连接到数据库
                if (conok)
                {
                    SqlCommand cmd_ins = new SqlCommand(sqlString_ins, sqlConnection);
                    cmd_ins.ExecuteNonQuery();
                    Properties.Settings.Default.Save();
                    //MessageBox.Show("完成");
                }
            }

            try
            {
                StressTest st = new StressTest(working_face);
                st.Start(gt);

                for (int i = 0; i < 100; i++)
                {
                    Thread.Sleep(100);
                    worker.ReportProgress(i);
                }

                MessageBox.Show("完成");
                MessageBox.Show("应力监测ok");
            }
            catch (Exception)
            {
                MessageBox.Show("应力监测数据错误");
            }
            sign[5] = true;
            for (int i = 0; i < sign.Length; i++)
            {
                if (sign[i] == false)
                {
                    sign_ = false;
                }
            }
            if (sign_ == true)
            {
                button2.Enabled = true;
            }
            sign_ = true;
        }