Exemplo n.º 1
0
        private void cboBeats_SelectedIndexChanged(object sender, EventArgs e)
        {
            SQLCode sql = new SQLCode();

            if (cboBeats.Text.ToUpper() != "SELECT")
            {
                string where = "AND Beat = '" + cboBeats.Text + "'";
                cboCallsigns.Items.Clear();
                cboTrucks.Items.Clear();
                cboDrivers.Items.Clear();
                List <string> callSigns = sql.getData(startDateTime, endDateTime, "CALLSIGNS", where);
                List <string> trucks    = sql.getData(startDateTime, endDateTime, "TRUCKS", where);
                List <string> drivers   = sql.getData(startDateTime, endDateTime, "DRIVERS", where);
                foreach (string s in callSigns)
                {
                    cboCallsigns.Items.Add(s);
                }
                foreach (string s in trucks)
                {
                    cboTrucks.Items.Add(s);
                }
                foreach (string s in drivers)
                {
                    cboDrivers.Items.Add(s);
                }
                cboCallsigns.SelectedIndex = 0;
                cboTrucks.SelectedIndex    = 0;
                cboDrivers.SelectedIndex   = 0;
            }
            else
            {
                string where = "NA";
                cboCallsigns.Items.Clear();
                cboTrucks.Items.Clear();
                cboDrivers.Items.Clear();
                List <string> callSigns = sql.getData(startDateTime, endDateTime, "CALLSIGNS", where);
                List <string> trucks    = sql.getData(startDateTime, endDateTime, "TRUCKS", where);
                List <string> drivers   = sql.getData(startDateTime, endDateTime, "DRIVERS", where);
                foreach (string s in callSigns)
                {
                    cboCallsigns.Items.Add(s);
                }
                foreach (string s in trucks)
                {
                    cboTrucks.Items.Add(s);
                }
                foreach (string s in drivers)
                {
                    cboDrivers.Items.Add(s);
                }
                cboCallsigns.SelectedIndex = 0;
                cboTrucks.SelectedIndex    = 0;
                cboDrivers.SelectedIndex   = 0;
            }
        }
Exemplo n.º 2
0
        private void btnPreLoad_Click(object sender, EventArgs e)
        {
            /*
             * string startTime = string.Empty;
             * string endTime = string.Empty;
             * string startDate = string.Empty;
             * string endDate = string.Empty;
             *
             * if (tEndTime.Text != "hh:mm:ss" && tEndTime.Text != "hh:mm:ss")
             * {
             *  startTime = tStartTime.Text;
             *  endTime = tEndTime.Text;
             * }
             * else
             * {
             *  MessageBox.Show("Invalid time");
             *  return;
             * }
             * if (string.IsNullOrEmpty(dStartDate.Text) || string.IsNullOrEmpty(dEndDate.Text))
             * {
             *  MessageBox.Show("Invalid date");
             *  return;
             * }
             * try
             * {
             *  startDateTime = Convert.ToDateTime(dStartDate.Text + " " + startTime);
             *  endDateTime = Convert.ToDateTime(dEndDate.Text + " " + endTime);
             * }
             * catch (Exception ex)
             * {
             *  MessageBox.Show(ex.Message);
             *  return;
             * }
             *
             * TimeSpan ts = endDateTime - startDateTime;
             * if (ts.TotalHours > 12)
             * {
             *  MessageBox.Show("Time range must not be more than 12 hours");
             *  return;
             * }
             */

            bool chkTime = checkTimeRange();

            if (!chkTime)
            {
                return;
            }
            Cursor             = Cursors.WaitCursor;
            btnPreLoad.Enabled = false;
            try
            {
                SQLCode sql = new SQLCode();

                List <string> trucks    = sql.getData(startDateTime, endDateTime, "TRUCKS");
                List <string> drivers   = sql.getData(startDateTime, endDateTime, "DRIVERS");
                List <string> callsigns = sql.getData(startDateTime, endDateTime, "CALLSIGNS");
                //List<string> beats = sql.getData(startDateTime, endDateTime, "BEATS");
                //List<string> contractors = sql.getData(startDateTime, endDateTime, "CONTRACTORS");

                //cboContractors.Items.Clear();
                //cboBeats.Items.Clear();
                cboCallsigns.Items.Clear();
                cboTrucks.Items.Clear();
                cboDrivers.Items.Clear();

                /*
                 * foreach (string s in contractors)
                 * { cboContractors.Items.Add(s); }
                 * foreach (string s in beats)
                 * { cboBeats.Items.Add(s); }
                 * */
                foreach (string s in callsigns)
                {
                    cboCallsigns.Items.Add(s);
                }
                foreach (string s in trucks)
                {
                    cboTrucks.Items.Add(s);
                }
                foreach (string s in drivers)
                {
                    cboDrivers.Items.Add(s);
                }
                //cboBeats.SelectedIndex = 0;
                cboCallsigns.SelectedIndex = 0;
                cboTrucks.SelectedIndex    = 0;
                cboDrivers.SelectedIndex   = 0;
                //cboContractors.SelectedIndex = 0;
            }
            catch (TimeoutException tx)
            {
                MessageBox.Show("The System has timed out trying to load your requested date, please select a smaller date/time range", "Error");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor                    = Cursors.Arrow;
            btnPreLoad.Enabled        = true;
            btnLoadData.Enabled       = true;
            btnPlayback.BackColor     = System.Drawing.Color.Red;
            btnStopPlayback.BackColor = System.Drawing.Color.Red;
            btnPlayback.Enabled       = false;
            btnStopPlayback.Enabled   = false;
            btnLoadData.BackColor     = System.Drawing.Color.LightGreen;
            btnExportData.BackColor   = System.Drawing.Color.Red;
            btnExportData.Enabled     = false;
        }