//grab the select report
        private void showReport()
        {
            String date = LogDates.SelectedItem.ToString(), dsub = "";

            Console.WriteLine("date: " + date);
            //reformats the selected date text to match that of the database
            if (!date.Equals(""))
            {
                dsub = date.Substring(date.IndexOf(' '));
                date = date.Substring(0, date.IndexOf(' '));
                String[] dateN = date.Split('/');
                date = dateN[2] + "-" + dateN[0] + "-" + dateN[1];

                //grabs the selected accident from the database
                accidents = TTStruct.requestLog(date + dsub, id);

                //parses the string into 3 sections for the cars, accident type, and the notes
                String[] accident = accidents.Split('|');

                //displays the accident report on the gui
                numCars.Text  = accident[0];
                acciType.Text = accident[1];
                LogNotes.Text = accident[2];
            }
        }
 //reset the timer
 private void resetTimer()
 {
     TTStruct.ResetTime(id);
     count      = 0;
     Timer.Text = "00:00:00";
     Console.WriteLine("Done.");
 }
 //grabs the info from the database and stores it in local variables
 private void getInfo()
 {
     weight    = TTStruct.getWeight(this.id);
     mile      = TTStruct.getMileage(this.id);
     driveTime = TTStruct.GetTime(this.id);
     date      = TTStruct.getDate(this.id);
     time      = TTStruct.GetTimeSecs(this.id);
 }
        //the login algorithm decider for the process 1 of DFD
        private void loginDecider()
        {
            int id = TTStruct.Login(usrnm.Text, pwrd.Text);

            if (displayOutput(id))
            {
                mainMenu(id);
            }
        }
        //end the timer and update the timer in the database
        private void endTimer()
        {
            timer1.Stop();

            int previousTime = TTStruct.GetTimeSecs(id);

            int totalTime = previousTime + count;

            TTStruct.UpdateTime(totalTime, id);
        }
        //remove an address that has been reached
        private void RouteList_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            //makes sure the route has stops to remove
            if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0)
            {
                TTStruct.RemoveStop(e.RowIndex + 1, routeID);
                toSetDataTable       = TTStruct.LoadRoutes(routeID);
                routeList.DataSource = toSetDataTable;
            }
        }
        //the decider for the main menu form
        private void mDecider(String m)
        {
            switch (m)
            {
            //displays the currently signed in user
            case "display":
                String name = TTStruct.GetName(id);
                loggedIn.Text = "Logged in as: " + name;
                break;

            case "tw":
                this.Hide();
                Weight mm = new Weight(id);
                mm.Show();
                break;

            case "ur":
                this.Hide();
                Receipt r = new Receipt(this.id);
                r.Show();
                break;

            case "ti":
                this.Hide();
                Info i = new Info(id);
                i.Show();
                break;

            case "sr":
                this.Hide();
                Route re = new Route(id);
                re.Show();
                break;

            case "us":
                this.Hide();
                UpdateDate1 us = new UpdateDate1(id);
                us.Show();
                break;

            case "a":
                this.Hide();
                Accident a = new Accident(id);
                a.Show();
                break;

            case "um":
                this.Hide();
                UpdateMileage1 um = new UpdateMileage1(id);
                um.Show();
                break;
            }
        }
        //display the dates
        private void display()
        {
            LogDates.Items.Clear();
            dates = "";

            //grabs the accident dates of the user
            dates = TTStruct.displayLogs(id);

            //separates the dates and stores them in the listbox on the gui
            String[] datesList = dates.Split('|');
            for (int i = 0; i < datesList.Length; i++)
            {
                LogDates.Items.Add(datesList[i]);
            }
        }
Exemple #9
0
        //update the mileage in the db
        private void updateMileage1()
        {
            bool test = TTStruct.updateDistance(textBox2.Value, id);

            if (test)
            {
                //show erro message if update was successful and display new mileage
                label3.Show();
                displayNew();
            }
            else
            {
                //show error message if update failed
                label4.Show();
            }
        }
Exemple #10
0
        //update the service date
        private void updateServ()
        {
            bool test = TTStruct.setDate(calendar.SelectionStart.Year, calendar.SelectionStart.Month, calendar.SelectionStart.Day, this.id);

            if (test)
            {
                //show if update was a success
                label3.Show();
            }
            else
            {
                //show if update was a failure
                label4.Show();
            }
            //display the new date
            displayNew("" + TTStruct.getDate(this.id));
        }
Exemple #11
0
 //upload pic to database
 private void uploadPic()
 {
     if (fileNamePath != null && destination != null)
     {
         File.Copy(fileNamePath, destination);
         TTStruct.UploadReceipt(filename, this.id);
         label2.Text    = "Your receipt has been uploaded";
         label2.Visible = true;
         fileNamePath   = null;
         destination    = null;
     }
     else
     {
         //display error if wrong or no file was select
         label2.Text    = "ERROR: file not selected";
         label2.Visible = true;
     }
 }
Exemple #12
0
 //displays the current mileage from the db
 private void displayCurrent()
 {
     this.label2.Text = "Total Miles:" + TTStruct.getMileage(id);
 }
Exemple #13
0
 //display current date
 private void displayCur()
 {
     this.label2.Text = "Last Service Date:" + TTStruct.getDate(this.id);
 }