예제 #1
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            upDateDataGridView();
            achelp = new AccessHelper();
            if (cbbxMode.Text == "")
            {
                MessageBox.Show("Please select the query mode ");
                return;
            }
            else
            {
                string strCbxCondition = "";
                if (cbbxMode.Text == "Dates")
                {
                    strCbxCondition = "\"" + cbxCondition.Text + "\"";
                    //strSelectSql = "SELECT * FROM DeviceMsg where (" + cbbxMode.Text + "=" + cbxCondition.Text + ")";
                }
                else
                {
                    strCbxCondition = "'" + cbxCondition.Text + "'";
                }
                string    strSelectSql = "SELECT IpAddress ,DeviceNum,Dates,Times,OrderNum,CarriageNum,ArtNo,SetWeight,LoadedWeight,TotalAmount FROM DeviceMsg where (" + cbbxMode.Text + "=" + strCbxCondition + ")";
                DataTable dt           = new System.Data.DataTable();
                dt = achelp.GetDataTableFromDB(strSelectSql);
                DataGridView1.DataSource = dt;

                DataGridView1.Columns[DataGridView1.Columns.Count - 1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                DataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
            }
        }
예제 #2
0
 void TxtOderCsvToolStripMenuItemClick(object sender, EventArgs e)
 {
     if (OpenFileDialog1.ShowDialog() != DialogResult.OK)
     {
         return;
     }
     loadCsv(OpenFileDialog1.FileName);
     DataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
 }
예제 #3
0
        private void upDateDataGridView()
        {
            CheckForIllegalCrossThreadCalls = false;
            achelp = new AccessHelper();
            DataTable dt           = new DataTable();
            string    strSelectSql = "SELECT IpAddress ,DeviceNum,Dates,Times,OrderNum,CarriageNum,ArtNo,SetWeight,LoadedWeight,TotalAmount from DeviceMsg ";

            dt = achelp.GetDataTableFromDB(strSelectSql);
            DataGridView1.DataSource = dt;//SetDGVSourceFunction(ds); // ds;
            // DataGridView1.DataMember = "dt";
            DataGridView1.Columns[DataGridView1.Columns.Count - 1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            DataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
        }
예제 #4
0
        public void ConfigureGridControl()
        {
            dataSet1.Tables.Clear();

            moTable = dataSet1.Tables.Add("BarData");
            moTable.Columns.Add("Index", typeof(int));
            moTable.Columns.Add("TradeDate", typeof(DateTime));
            moTable.Columns.Add("Time", typeof(DateTime));
            moTable.Columns.Add("Open", typeof(double));
            moTable.Columns.Add("High", typeof(double));
            moTable.Columns.Add("Low", typeof(double));
            moTable.Columns.Add("Close", typeof(double));
            moTable.Columns.Add("Volume", typeof(int));

            DataGridView1.DataSource = moTable;

            DataGridView1.AutoResizeColumns();

            DataGridView1.Sort(DataGridView1.Columns["Time"], System.ComponentModel.ListSortDirection.Descending);
        }
예제 #5
0
        private void  // ERROR: Handles clauses are not supported in C#
        moBarData_DataLoadComplete(object sender, T4.API.ChartData.DataLoadCompleteEventArgs e)
        {
            // NOTE: This event is raised on it's own thread. If you are updating a GUI application with the chart data (like this example), don't forget that you
            //       MUST marshall this update onto the GUI thread before you modify any GUI components.
            // (This is the same for all T4 API events.)

            if (this.InvokeRequired)
            {
                // An invoke is required to update the GUI, simply invoke back to this same mthod.
                this.BeginInvoke(new T4.API.ChartData.DataLoadCompleteEventHandler(moBarData_DataLoadComplete), new object[] {
                    sender,
                    e
                });

                // Don't forget to exit now!
                return;
            }

            // On the GUI thread now, update the chart.

            if (e.Status == DataLoadStatus.Failed)
            {
                Trace.WriteLine("IChartDataRequest_ChartDataComplete: Chart data request failed.");
                return;
            }
            else
            {
                // Sometimes, you won't get all the historical data you requested. This could happen if there isn't chart data available all the back to the start date you requested.
                Trace.WriteLine(string.Format("IChartDataRequest_ChartDataComplete: Status: {0}, Dates Requested: {1}, Dates Received: {2}", e.Status, e.DateRangeRequested, e.DateRangeProcessed));
            }

            chart1.Series["candlestickSeries"].Points.Clear();
            chart1.Series["candlestickVolumeSeries"].Points.Clear();
            chart1.Series["movingAverageSeries"].Points.Clear();
            int dataPointHigh = int.MinValue;
            int dataPointLow  = int.MaxValue;

            // Before iterating the data collection, you MUST lock it. This will prevent live trade updates from modifying the collection as you read it.
            moBarData.Lock();


            try {
                for (int i = 0; i <= moBarData.TradeBars.Count - 1; i++)
                {
                    T4.API.ChartData.BarDataPoint oBar = (T4.API.ChartData.BarDataPoint)moBarData.TradeBars[i];

                    Trace.WriteLine(string.Format("TradeDate: {6}, Time: {5}, Open: {0}, High: {1}, Low: {2}, Close: {3}, Volume: {4}", oBar.OpenTicks, oBar.HighTicks, oBar.LowTicks, oBar.CloseTicks, oBar.Volume, oBar.Time, oBar.TradeDate));

                    moTable.Rows.Add(i, oBar.TradeDate, oBar.Time, oBar.OpenTicks, oBar.HighTicks, oBar.LowTicks, oBar.CloseTicks, oBar.Volume);

                    // Add candlestick to chart (high, low, open, close).
                    object[] multipleValues = new object[] { oBar.HighTicks, oBar.LowTicks, oBar.OpenTicks, oBar.CloseTicks };
                    chart1.Series[0].Points.AddXY(oBar.Time, multipleValues);
                    chart1.Series[1].Points.AddXY(oBar.Time, oBar.Volume);

                    // See if our maximum and minimum values on the chart have changed (we will use this for axis scaling).
                    dataPointHigh = Math.Max(dataPointHigh, oBar.HighTicks);
                    dataPointLow  = Math.Min(dataPointLow, oBar.LowTicks);
                }

                DataGridView1.AutoResizeColumns();
                chart1.ChartAreas[0].AxisY.Minimum = dataPointLow;
                chart1.ChartAreas[0].AxisY.Maximum = dataPointHigh;

                /*
                 * IList<DateTime> listx = new List<DateTime>();
                 * IList<double> listy = new List<double>();
                 *
                 * //iterate and add your values to the two lists: listx and listy
                 *
                 * //when you're done, bind the lists to the points collection
                 * yourSeries.Points.DataBindXY(listx, listy);
                 */
            } catch (Exception ex) {
                Trace.WriteLine("Error loading chart data: " + ex.ToString());
            } finally {
                // If you don't be sure to unlock the data collection, you probably won't get any live trade updates.
                moBarData.Unlock();
            }
        }