Example #1
0
 private void buttonBack_Click(object sender, EventArgs e)
 {
     DeliverySchedule deliveryschedule = new DeliverySchedule();
     deliveryschedule.SetDate(viewdate,0);
     deliveryschedule.Show();
     this.Close();
 }
        private void Exit_Click(object sender, EventArgs e)
        {
            if (_bw2 != null)
            {
                _bw2.Dispose();
            }
            if (_bw1 != null)
            {
                _bw1.Dispose();
            }

            DeliverySchedule deliveryschedule=new DeliverySchedule();
            deliveryschedule.SetDate(viewdate,0);
            deliveryschedule.Show();
            this.Close();
        }
        private void button9_Click(object sender, EventArgs e)
        {
            try
            {
                //check blank fields
                if (textInvoice.Text == "" || textValue.Text == "" || textCustomer.Text == "" || textStreet.Text == "" || textCity.Text == "" || textState.Text == "")
                {
                    toolStripStatusLabel2.Text = "Some required fields are blank.";
                    return;
                }
                string pattern = @"^\$?\-?([1-9]{1}[0-9]{0,2}(\,\d{3})*(\.\d{0,2})?|[1-9]{1}\d{0,}(\.\d{0,2})?|0(\.\d{0,2})?|(\.\d{1,2}))$|^\-?\$?([1-9]{1}\d{0,2}(\,\d{3})*(\.\d{0,2})?|[1-9]{1}\d{0,}(\.\d{0,2})?|0(\.\d{0,2})?|(\.\d{1,2}))$|^\(\$?([1-9]{1}\d{0,2}(\,\d{3})*(\.\d{0,2})?|[1-9]{1}\d{0,}(\.\d{0,2})?|0(\.\d{0,2})?|(\.\d{1,2}))\)$";
                if (!Regex.IsMatch(textValue.Text, pattern))
                {
                    textValue.Focus();
                    toolStripStatusLabel2.Text = "Value must be a U.S. dollar amount (dollar symbol is optional).";
                    return;
                }
                pattern = @"^[0-9]+$";
                if (!Regex.IsMatch(textInvoice.Text, pattern))
                {
                    textInvoice.Focus();
                    toolStripStatusLabel2.Text = "Invoice number must be a number.";
                    return;
                }

                newinvoice = new Invoice(Int32.Parse(textInvoice.Text), DataFormat.FormatMoneyToInt(textValue.Text), currentday, textCustomer.Text, textStreet.Text, "", textCity.Text, textState.Text, textZip.Text, longitude, latitude, currentday.AddYears(1));
                List < Invoice > toadd = new List<Invoice>();
                toadd.Add(newinvoice);
                mysql_invoices.AddInvoices(toadd,false);
            }
            catch {
                toolStripStatusLabel2.Text = "Failed to update invoice.";
                return;
            }
            if (flag == true)
            {
                DeliverySchedule deliveryschedule = new DeliverySchedule();
                deliveryschedule.SetDate(currentday,0);
                deliveryschedule.Show();
                this.Close();
            }
            else
            {
                ConfigureTruckRoute configureroute = new ConfigureTruckRoute();
                configureroute.SetData(currentday, driver);
                configureroute.Show();
            }
            this.Close();
        }
 private void Cancel_Click(object sender, EventArgs e)
 {
     if (flag == true)
     {
         DeliverySchedule deliveryschedule = new DeliverySchedule();
         deliveryschedule.SetDate(currentday,0);
         deliveryschedule.Show();
         this.Close();
     }
     else
     {
         ConfigureTruckRoute configureroute = new ConfigureTruckRoute();
         configureroute.SetData(currentday, driver);
         configureroute.Show();
     }
         this.Close();
 }
        private void Cancel_Click_1(object sender, EventArgs e)
        {
            try
            {
                newinvoice.addr1 = textStreet.Text;
                newinvoice.addr2 = "";
                newinvoice.city = textCity.Text;
                newinvoice.state = textState.Text;
                newinvoice.zip = textZip.Text;
                newinvoice.latitude = currentgeodata.latitude[listAddresses.SelectedIndex];
                newinvoice.longitude = currentgeodata.longitude[listAddresses.SelectedIndex];
                mysql_invoices.UpdateInvoice(newinvoice, inputinvoice);
                if (_bw != null)
                {
                    _bw.Dispose();
                }

            }
            catch
            {

            }
            if (caller == 0)
            {

                DeliverySchedule deliveryschedule = new DeliverySchedule();
                deliveryschedule.SetDate(viewdate,0);
                deliveryschedule.Show();
                this.Close();
            }
            else if(caller==1)
            {
                ConfigureTruckRoute configureroute = new ConfigureTruckRoute();
                configureroute.SetData(viewdate, driverinfo);
                configureroute.Show();
            }
            else if (caller == 2)
            {
                EditInvoice editinvoice = new EditInvoice();
                editinvoice.SetInvoice(inputinvoice, flag,viewdate,driverinfo,0);
                editinvoice.Show();
            }
            this.Close();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //optimizationrunning = false;
            if (matrixbuilder != null)
            {
                for (int i = 0; i < matrixbuilder.bws.Count; i++)
                {
                    matrixbuilder.points.Clear();
                    if (matrixbuilder.bws[i] != null)
                    {
                        //matrixbuilder.bws[i].CancelAsync();
                    }
                }
            }

            if (_bw1 != null)
            {
                _bw1.CancelAsync();
            }
            if (_bw2 != null)
            {
                _bw2.CancelAsync();
            }
            if (_bw3 != null)
            {
                _bw3.CancelAsync();
            }
            if (_bw4 != null)
            {
                _bw4.CancelAsync();
            }

            DeliverySchedule deliveryschedule = new DeliverySchedule();
            deliveryschedule.SetDate(viewdate,0);
            deliveryschedule.Show();
            this.Close();
        }
        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 { }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                //check blank fields
                if (textInvoice.Text == "" || textValue.Text == "" || textCustomer.Text == "" || textStreet.Text == "" || textCity.Text == "" || textZip.Text == "" || textState.Text == "")
                {
                    toolStripStatusLabel1.Text = "Some required fields are blank.";
                }

                string pattern = @"^\$?\-?([1-9]{1}[0-9]{0,2}(\,\d{3})*(\.\d{0,2})?|[1-9]{1}\d{0,}(\.\d{0,2})?|0(\.\d{0,2})?|(\.\d{1,2}))$|^\-?\$?([1-9]{1}\d{0,2}(\,\d{3})*(\.\d{0,2})?|[1-9]{1}\d{0,}(\.\d{0,2})?|0(\.\d{0,2})?|(\.\d{1,2}))$|^\(\$?([1-9]{1}\d{0,2}(\,\d{3})*(\.\d{0,2})?|[1-9]{1}\d{0,}(\.\d{0,2})?|0(\.\d{0,2})?|(\.\d{1,2}))\)$";
                if (!Regex.IsMatch(textValue.Text, pattern))
                {
                    textValue.Focus();
                    toolStripStatusLabel1.Text = "Value must be a U.S. dollar amount (dollar symbol is optional).";
                    return;
                }
                pattern = @"^[0-9]+$";
                if (!Regex.IsMatch(textInvoice.Text, pattern))
                {
                    textInvoice.Focus();
                    toolStripStatusLabel1.Text = "Invoice number must be a number.";
                    return;
                }
                newinvoice.number = Int32.Parse(textInvoice.Text);
                newinvoice.value = DataFormat.FormatMoneyToInt(textValue.Text);
                newinvoice.customername = textCustomer.Text;
                newinvoice.due = DatePicker.Value;
                newinvoice.addr1 = textStreet.Text;
                newinvoice.addr2="";
                newinvoice.city = textCity.Text;
                newinvoice.zip = textZip.Text;
                newinvoice.state = textState.Text;

                mysql_invoices.UpdateInvoice(newinvoice, inputinvoice);
            }
            catch
            {
                toolStripStatusLabel1.Text = "Failed to update invoice.";
                return;
            }

            if (caller == true)
            {
                DeliverySchedule deliveryschedule = new DeliverySchedule();
                deliveryschedule.SetDate(viewdate,this.selection);
                deliveryschedule.Show();
                this.Close();
            }
            else
            {
                ConfigureTruckRoute configureroute = new ConfigureTruckRoute();
                configureroute.SetData(viewdate, driverinfo);
                configureroute.Show();

            }
            this.Close();
        }
 private void Cancel_Click_1(object sender, EventArgs e)
 {
     if (caller == true)
     {
         DeliverySchedule deliveryschedule = new DeliverySchedule();
         deliveryschedule.SetDate(viewdate,this.selection);
         deliveryschedule.Show();
         this.Close();
     }
     else
     {
         ConfigureTruckRoute configureroute = new ConfigureTruckRoute();
         configureroute.SetData(viewdate, driverinfo);
         configureroute.Show();
     }
     this.Close();
 }