private void RefreshData(bool listflag,int select)
        {
            routes = mysql_routes.GetRouteInfo(viewdate);
            for (int i = 0; i < routes.Count; i++)
            {
                routes[i].invoicerouteinfo = mysql_invoiceroutes.GetRouteInfo(routes[i]);
                if (driver.number == routes[i].drivernumber)
                { viewroute = routes[i]; }
            }
            viewinvoices = new List<Invoice>();
            viewlineitems = new List<LineItem>();

            //set date

            this.Text = "Configure Driver Route - "+driver.name +" - "+ viewdate.Month + "/" + viewdate.Day + "/" + viewdate.Year + " - " + viewdate.DayOfWeek;

            //zero out areas
            //add in the route time???
            currentnumberofstops = 0;
            textEstimatedCost.Text = "";
            textValueMain.Text = "";
            textTotalMiles.Text = "";
            textTotalTime.Text = "";
            textCostPercentage.Text = "";
            listRouteItems.Items.Clear();
            listAllItems.Items.Clear();
            textInvoice.Text = "";
            textCustomer.Text = "";
            textStreet.Text = "";
            textCity.Text = "";
            textZip.Text = "";
            textState.Text = "";
            textValue.Text = "";
            listLineItems.Items.Clear();
            counter = 0;
            buttonPrint.Enabled = false;
            RefreshInvoices(listflag,select);
            RefreshMap();
        }
 private void addRoute_Click(object sender, EventArgs e)
 {
     RouteInfo routeinfo = new RouteInfo(0, viewdate, companydrivers[listCompanyDrivers.SelectedIndex].number,0);
     mysql_routes.AddRouteInfo(routeinfo);
     NextDayRefresh(0);
 }
Ejemplo n.º 3
0
        public RouteInfo GetRouteInfo(InvoiceRouteInfo invoicerouteinfo)
        {
            try
            {
                MySqlConnection theconnection = Connect();

                MySqlDataReader rdr = Select("SELECT * FROM delivery_route_data WHERE DR_ROUTE_NUMBER=" + invoicerouteinfo.routenumber.ToString() + " ;", theconnection);
                rdr.Read();
                    RouteInfo toinsert = new RouteInfo((int)rdr[2], DateTime.Parse((String)rdr[0]), (int)rdr[1], (int)rdr[3]);

                Disconnect();
                return (toinsert);
            }
            catch
            {
                Disconnect();
                return null;
            }
        }
Ejemplo n.º 4
0
        public bool updateMileage(RouteInfo routeinfo)
        {
            try
            {
                MySqlConnection theconnection = Connect();
                string updatequery = "UPDATE delivery_route_data SET `DR_MILES`=" + routeinfo.miles + " WHERE DR_ROUTE_NUMBER="+routeinfo.number+";";
                Update(updatequery, theconnection);
                Disconnect();
                return true;
            }
            catch
            {

                Disconnect();
                return false;
            }
        }
Ejemplo n.º 5
0
 public List<RouteInfo> GetRouteInfo(int ID)
 {
     try
     {
         MySqlConnection theconnection = Connect();
         List<RouteInfo> routeinfo = new List<RouteInfo>();
         MySqlDataReader rdr = Select("SELECT * FROM delivery_route_data WHERE DR_DRV_NUMBER=" + ID.ToString() + " ;", theconnection);
         while (rdr.Read())
         {
             RouteInfo toinsert = new RouteInfo((int)rdr[2], DateTime.Parse((String)rdr[0]),(int)rdr[1], (int)rdr[3]);
             routeinfo.Add(toinsert);
         }
         Disconnect();
         return (routeinfo);
     }
     catch
     {
         Disconnect();
         return null;
     }
 }
Ejemplo n.º 6
0
 public List<RouteInfo> GetRouteInfo(DateTime date)
 {
     try
     {
         MySqlConnection theconnection = Connect();
         List<RouteInfo> routeinfo = new List<RouteInfo>();
         string selectquery = "SELECT * FROM delivery_route_data WHERE DR_DATE LIKE '%" + date.ToShortDateString() + "%' OR DR_DATE LIKE '%" + date.ToString("M/d/yy") + "%' OR DR_DATE LIKE '%" + date.ToString("M/d/yyyy") + "%' OR DR_DATE LIKE '%" + date.ToString("MM/d/yy") + "%';";
         MySqlDataReader rdr = Select(selectquery, theconnection);
         while (rdr.Read())
         {
             RouteInfo toinsert = new RouteInfo((int)rdr[2], DateTime.Parse((String)rdr[0]), (int)rdr[1],(int)rdr[3]);
             routeinfo.Add(toinsert);
         }
         Disconnect();
         return (routeinfo);
     }
     catch
     {
         Disconnect();
         return null;
     }
 }
Ejemplo n.º 7
0
 public bool AddRouteInfo(RouteInfo routeinfo)
 {
     try
     {
         MySqlConnection theconnection = Connect();
         string insertquery = "INSERT INTO delivery_route_data (`DR_DATE`, `DR_DRV_NUMBER`, `DR_ROUTE_NUMBER`,DR_MILES) VALUES ('" + routeinfo.date + "', " + routeinfo.drivernumber + ", NULL,"+routeinfo.miles+");";
         Insert(insertquery, theconnection);
         Disconnect();
         return true;
     }
     catch
     {
         Disconnect();
         return false;
     }
 }
Ejemplo n.º 8
0
        public List<InvoiceRouteInfo> GetRouteInfo(RouteInfo route)
        {
            try
            {
                MySqlConnection theconnection=Connect();

                MySqlDataReader rdr = Select("SELECT * FROM invoice_route_data WHERE IR_ROUTE_NUMBER=" + route.number + " ;", theconnection);
                List<InvoiceRouteInfo> routeinfo= new List<InvoiceRouteInfo>();
                while (rdr.Read())
                {
                    InvoiceRouteInfo input = new InvoiceRouteInfo((int)rdr[0], (int)rdr[1], (int)rdr[2]);
                    routeinfo.Add(input);
                }
                        Disconnect();

                return (routeinfo);
            }
            catch
            {

                Disconnect();
                return null;
            }
        }
Ejemplo n.º 9
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                //DialogResult result = MessageBox.Show("Saving changes will remove all configured routes for the current day and replace them with optimized routes.  Are you sure?", "Warning", MessageBoxButtons.YesNo);
                //if (result == DialogResult.Yes)
                //{

                   // for (int i = 0; i < driverassignments.Count; i++)
                    //{
                     //   mysql_routes.DeleteRouteInfo(companydrivers[driverassignments[i]].number, viewdate);
                    //}
                    for (int i = 0; i < driverassignments.Count; i++)
                    {
                        RouteInfo toadd = new RouteInfo(0, viewdate, companydrivers[driverassignments[i]].number, distances[i]);
                        mysql_routes.AddRouteInfo(toadd);
                    }
                    List<RouteInfo> currentroutes = mysql_routes.GetRouteInfo(viewdate);

                    for (int i = 0; i < driverassignments.Count; i++)
                    {
                        int routenumber = 0;
                        for (int j = 0; j < currentroutes.Count; j++)
                        {
                            if (currentroutes[j].drivernumber == companydrivers[driverassignments[i]].number)
                            {
                                routenumber = currentroutes[j].number;
                            }
                        }
                        for (int j = 0; j < optimizedroutes[i].Count; j++)
                        {
                            optimizedroutes[i][j].routenumber = routenumber;
                            InvoiceRouteInfo toadd = new InvoiceRouteInfo(optimizedroutes[i][j].invoicenumber, optimizedroutes[i][j].routenumber, optimizedroutes[i][j].stop);
                            mysql_invoiceroutes.AddRouteInfo(toadd);
                        }

                    }
                    DeliverySchedule deliveryschedule = new DeliverySchedule();
                    deliveryschedule.SetDate(viewdate,0);
                    deliveryschedule.Show();
                    this.Close();
                }
            //}
            catch { }
        }