コード例 #1
0
ファイル: Form1.cs プロジェクト: chrislin123/M10Service
        private void btnRTI10_Click(object sender, EventArgs e)
        {
            try
            {
                //string sStation = "C0A530";
                string sStation = ddlstation.Text;

                RtiProc oRtiProc = new RtiProc(ddlver.Text, sStation, ddlTimeDelay.Text, sConnectionString,ddltype.Text);
                //進行計算
                oRtiProc.RtiCal();

                dataGridView2.DataSource = oRtiProc.dt_rti;
                dataGridView2.AutoGenerateColumns = true;

                dataGridView3.DataSource = oRtiProc.dt_rti90;
                dataGridView3.AutoGenerateColumns = true;

                lblrti10.Text = oRtiProc.dRTI10.ToString();
                lblrti30.Text = oRtiProc.dRTI30.ToString();
                lblrti50.Text = oRtiProc.dRTI50.ToString();
                lblrti70.Text = oRtiProc.dRTI70.ToString();
                lblrti90.Text = oRtiProc.dRTI90.ToString();

            }
            catch (Exception)
            {

                throw;
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: chrislin123/M10Service
        private void btnstart_Click(object sender, EventArgs e)
        {
            try
            {
                int rowindex = 0;
                foreach (DataRow dr in dt_rtidetail.Rows)
                {
                    string sStation = dr["station"].ToString();

                    //工作延時(delaytime)
                    dr["delaytime"] = ddlTimeDelay.Text;
                    Application.DoEvents();

                    //移動資料行
                    dataGridView1.CurrentCell = dataGridView1.Rows[rowindex].Cells[0];

                    //取得總筆數
                    ssql = " select count(*) as total from RtiData "
                         + " where station = '" + sStation + "' "
                         + " and ver = '" + ddlver.Text + "' "
                         ;
                    if (ddlTimeDelay.Text != "0")
                    {
                        ssql += " and raindelay > " + ddlTimeDelay.Text + " ";
                    }
                    oDal.CommandText = ssql;
                    string sTotalcount = oDal.Value().ToString().Trim();
                    dr["totalcount"] = sTotalcount;

                    Application.DoEvents();

                    //取得開始時間
                    ssql = " select MIN(date)  from RtiData "
                         + " where station = '" + sStation + "' "
                         + " and ver = '" + ddlver.Text + "' "
                         ;
                    if (ddlTimeDelay.Text != "0")
                    {
                        ssql += " and raindelay > " + ddlTimeDelay.Text + " ";
                    }
                    oDal.CommandText = ssql;
                    string sStartDate = oDal.Value().ToString().Trim();
                    dr["startdate"] = sStartDate;

                    Application.DoEvents();

                    //取得結束時間
                    ssql = " select MAX(date)  from RtiData "
                         + " where station = '" + sStation + "' "
                         + " and ver = '" + ddlver.Text + "' "
                         ;
                    if (ddlTimeDelay.Text != "0")
                    {
                        ssql += " and raindelay > " + ddlTimeDelay.Text + " ";
                    }
                    oDal.CommandText = ssql;
                    string sEndDate = oDal.Value().ToString().Trim();
                    dr["enddate"] = sEndDate;

                    Application.DoEvents();

                    RtiProc oRtiProc = new RtiProc(ddlver.Text, sStation, ddlTimeDelay.Text, sConnectionString,ddltype.Text);
                    //進行計算
                    oRtiProc.RtiCal();

                    //計算RTI10
                    dr["rti10"] = oRtiProc.dRTI10.ToString();
                    Application.DoEvents();

                    //計算RTI30
                    dr["rti30"] = oRtiProc.dRTI30.ToString();
                    Application.DoEvents();

                    //計算RTI50
                    dr["rti50"] = oRtiProc.dRTI50.ToString();
                    Application.DoEvents();

                    //計算RTI70
                    dr["rti70"] = oRtiProc.dRTI70.ToString();
                    Application.DoEvents();

                    //計算RTI90
                    dr["rti90"] = oRtiProc.dRTI90.ToString();
                    Application.DoEvents();

                    //寫入資料庫
                    InsertData(dr);

                    rowindex++;
                }

            }
            catch (Exception)
            {
                throw;
            }
        }