public void SetInvoice(Invoice invoice,bool caller,DateTime date,DriverInfo driver,int selection)
 {
     inputinvoice = invoice;
     this.caller = caller;
     this.viewdate = date;
     this.driverinfo = driver;
     this.selection = selection;
 }
 public void SetInvoice(Invoice invoice,int caller,DateTime date,DriverInfo driver,bool flag)
 {
     this.flag = flag;
     inputinvoice = invoice;
     this.caller = caller;
     this.viewdate = date;
     this.driverinfo = driver;
     currentgeodata = new GeoData();
 }
        void bw1_RunWorkerCompleted(object sender,
                                   RunWorkerCompletedEventArgs e)
        {
            try
            {

                    ThreadArgs results= (ThreadArgs)e.Result;
                    if (listInvoices.SelectedIndex == results.selection)
                    {
                        GeoData currentgeodata = results.geodata;
                        Invoice newinvoice = new Invoice(viewinvoices[listInvoices.SelectedIndex].number, viewinvoices[listInvoices.SelectedIndex].value, viewinvoices[listInvoices.SelectedIndex].due, viewinvoices[listInvoices.SelectedIndex].customername, currentgeodata.street[0], "", currentgeodata.city[0], currentgeodata.state[0], currentgeodata.zip[0], currentgeodata.longitude[0], currentgeodata.latitude[0], viewinvoices[listInvoices.SelectedIndex].delivered);

                        mysql_invoices.UpdateInvoice(newinvoice, viewinvoices[listInvoices.SelectedIndex]);
                        viewinvoices[listInvoices.SelectedIndex] = newinvoice;
                        findAddress.Image = RRS.Properties.Resources.greencheck;
                        if (pointadded == true)
                        {
                            webkitBrowser2.StringByEvaluatingJavaScriptFromString("map.removeShape(current);");
                        }
                        webkitBrowser2.StringByEvaluatingJavaScriptFromString("var current=new MQA.Poi( {lat:" + viewinvoices[listInvoices.SelectedIndex].latitude + ", lng:" + viewinvoices[listInvoices.SelectedIndex].longitude + "} );");
                        webkitBrowser2.StringByEvaluatingJavaScriptFromString("map.addShape(current);");
                        pointadded = true;

                    }
                    else
                    {

                    }

            }
            catch
            {
                findAddress.Image = RRS.Properties.Resources.redx;
            }
        }
 void bw1_RunWorkerCompleted(object sender,
                            RunWorkerCompletedEventArgs e)
 {
     try
     {
         ThreadArgs threadargs = (ThreadArgs)e.Result;
         GeoData currentgeodata = threadargs.geodata;
         if (threadargs.list == 2)
         {
             int index = threadargs.selection;
             Invoice newinvoice = new Invoice(viewinvoices[index].number, viewinvoices[index].value, viewinvoices[index].due, viewinvoices[index].customername, currentgeodata.street[0], "", currentgeodata.city[0], currentgeodata.state[0], currentgeodata.zip[0], currentgeodata.longitude[0], currentgeodata.latitude[0], viewinvoices[index].delivered);
             mysql_invoices.UpdateInvoice(newinvoice, viewinvoices[index]);
             viewinvoices[index] = newinvoice;
             findAddress.Image = RRS.Properties.Resources.greencheck;
         }
         if (threadargs.list == 1)
         {
             int index=threadargs.selection;
             Invoice newinvoice = new Invoice(scheduledinvoices[index].number, scheduledinvoices[index].value, scheduledinvoices[index].due, scheduledinvoices[index].customername, currentgeodata.street[0], "", currentgeodata.city[0], currentgeodata.state[0], currentgeodata.zip[0], currentgeodata.longitude[0], currentgeodata.latitude[0], scheduledinvoices[index].delivered);
             mysql_invoices.UpdateInvoice(newinvoice, scheduledinvoices[index]);
             scheduledinvoices[index] = newinvoice;
             findAddress.Image = RRS.Properties.Resources.greencheck;
         }
     }
     catch
     {
         findAddress.Image = RRS.Properties.Resources.redx;
     }
 }
        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 EditInvoice_Load(object sender, EventArgs e)
        {
            try
            {
                textInvoice.Text = "";
                textValue.Text = "";
                textCustomer.Text = "";
                textStreet.Text = "";
                textCity.Text = "";
                textZip.Text = "";
                textState.Text = "";
                listAddresses.Items.Clear();
                listAddresses.Enabled = false;
                toolStripStatusLabel1.Text = "";
                mysql_invoices = new MySQL_Invoices(GlobalVar.sqlhost, GlobalVar.sqlport, GlobalVar.sqldatabase, GlobalVar.sqlusername, "");

                newinvoice = mysql_invoices.GetInvoice(inputinvoice.number);
                if (newinvoice != null)
                {

                    textInvoice.Text = newinvoice.number.ToString();
                    textValue.Text = DataFormat.FormatMoneyToString(newinvoice.value);
                    if(newinvoice.addr1!="")
                    {
                    textStreet.Text = newinvoice.addr1;
                    }
                    else
                    {
                        textStreet.Text = newinvoice.addr2;
                    }
                    textCustomer.Text = newinvoice.customername;
                    textCity.Text = newinvoice.city;
                    textZip.Text = newinvoice.zip;
                    textState.Text = newinvoice.state;

                }
                else { Cancel_Click(null, null); }
            }
            catch
            {
                Cancel_Click(null, null);
            }
        }
Example #7
0
        public List<LineItem> GetLineItems(Invoice invoice)
        {
            List<LineItem> lineitems = new List<LineItem>();

            try
            {

                MySqlConnection theconnection = Connect();
                List<DriverInfo> drivers = new List<DriverInfo>();
                MySqlDataReader rdr = Select("SELECT * FROM invoice_line_data WHERE inl_inv_number='" + invoice.number+ "';", theconnection);
                while (rdr.Read())
                {
                    LineItem toinsert = new LineItem((int)rdr[0],(int)rdr[1],(string)rdr[2],(int)rdr[3]);
                    lineitems.Add(toinsert);
                }
                Disconnect();
                return (lineitems);
            }
            catch {
                Disconnect();
                return (null); }
        }
Example #8
0
 public bool UpdateInvoice(Invoice invoice,Invoice originalinvoice)
 {
     try
     {
         MySqlConnection theconnection = Connect();
         invoice.customername = invoice.customername.Replace("\'", "\\'");
         invoice.customername = invoice.customername.Replace("\"", "\\\"");
         string updatequery = "UPDATE invoice_data SET `INV_NUMBER`=" + invoice.number + ", `INV_SALES_AMOUNT`=" + invoice.value + ", `INV_DUE_DATE`='" + invoice.due.ToShortDateString() + "', `INV_CUSTOMER_NAME`='" + invoice.customername + "', `INV_ADDR_LN1`='" + invoice.addr1 + "',`INV_ADDR_LN2`='" + invoice.addr2 + "', `INV_CITY`='" + invoice.city + "', `INV_STATE`='" + invoice.state + "', `INV_ZIP`='" + invoice.zip + "', `INV_LATITUDE`=" + invoice.latitude + ", `INV_LONGITUDE`=" + invoice.longitude + ", `INV_DELIVERED_DATE`='" + invoice.delivered.ToShortDateString() + "' WHERE `INV_NUMBER`="+originalinvoice.number+";";
         Update(updatequery, theconnection);
         //do line items
         updatequery = "UPDATE invoice_line_data SET `INL_INV_NUMBER`=" + invoice.number + " WHERE `INL_INV_NUMBER`=" + originalinvoice.number + ";";
         Update(updatequery, theconnection);
         Disconnect();
         return (true);
     }
     catch
     {
         Disconnect();
         return (false);
     }
 }
Example #9
0
        public List<Invoice> GetInvoices(DateTime date)
        {
            StreamWriter sw=new StreamWriter("test.txt");
                sw.WriteLine("test");
                List<Invoice> invoices = new List<Invoice>();

                try
                {

                    MySqlConnection theconnection = Connect();
                    List<DriverInfo> drivers = new List<DriverInfo>();
                    string selectquery = "SELECT * FROM INVOICE_DATA WHERE inv_due_date LIKE '%" + date.ToShortDateString() + "%' OR inv_due_date LIKE '%" + date.ToString("M/d/yy") + "%' OR inv_due_date LIKE '%" + date.ToString("M/d/yyyy") + "%' OR inv_due_date LIKE '%" + date.ToString("MM/d/yy") + "%';";
                    MySqlDataReader rdr = Select(selectquery, theconnection);
                    sw.WriteLine(selectquery);
                    while (rdr.Read())
                    {

                        Invoice toinsert = new Invoice((int)rdr[0], (int)rdr[1], DateTime.Parse((string)rdr[2]), (string)rdr[3], (string)rdr[4], (string)rdr[5], (string)rdr[6], (string)rdr[7], (string)rdr[8], (double)rdr[9], (double)rdr[10], DateTime.Parse((string)rdr[11]));
                        sw.WriteLine((string)rdr[3]);
                        invoices.Add(toinsert);
                    }

                }
                catch { sw.WriteLine("test2"); }
                sw.WriteLine("test4");
                sw.Close();
                Disconnect();
                return (invoices);
        }
Example #10
0
        public Invoice GetInvoice(int number)
        {
            try
                {

                    MySqlConnection theconnection = Connect();
                    List<DriverInfo> drivers = new List<DriverInfo>();
                    MySqlDataReader rdr = Select("SELECT * FROM INVOICE_DATA WHERE inv_number=" + number + ";", theconnection);
                    rdr.Read();
                        Invoice toreturn = new Invoice((int)rdr[0], (int)rdr[1], DateTime.Parse((string)rdr[2]), (string)rdr[3], (string)rdr[4], (string)rdr[5], (string)rdr[6], (string)rdr[7], (string)rdr[8], (double)rdr[9], (double)rdr[10], DateTime.Parse((string)rdr[11]));
                        Disconnect();

                                return (toreturn);
                }
                catch {
                    Disconnect();
                    return (null); }
        }
Example #11
0
 public List<Invoice> GetBlocks(DateTime date)
 {
     try
         {
             List<Invoice> invoices = new List<Invoice>();
             MySqlConnection theconnection = Connect();
             string getblockquery = "SELECT * FROM invoice_block WHERE inv_due_date LIKE '%" + date.ToShortDateString() + "%' OR inv_due_date LIKE '%" + date.ToString("M/d/yy") + "%' OR inv_due_date LIKE '%" + date.ToString("M/d/yyyy") + "%' OR inv_due_date LIKE '%" + date.ToString("MM/d/yy") + "%';";
             MySqlDataReader rdr = Select(getblockquery, theconnection);
             while (rdr.Read())
             {
                 Invoice toinsert = new Invoice((int)rdr[0], 0,DateTime.Parse((string)rdr[1]), "", "", "", "", "", "", 0, 0, DateTime.Parse((string)rdr[1]));
                 invoices.Add(toinsert);
             }
             Disconnect();
             return (invoices);
         }
         catch { Disconnect();
         return null;
         }
 }
Example #12
0
 public bool DeleteInvoice(Invoice invoice)
 {
     try
     {
         MySqlConnection theconnection = Connect();
         string deletequery="DELETE FROM invoice_data WHERE INV_NUMBER="+invoice.number+";";
         Delete(deletequery,theconnection);
         Disconnect();
         return (false);
     }
     catch
     {
         Disconnect();
             return(false);
     }
 }
Example #13
0
 public void BlockInvoice(Invoice invoice)
 {
     try
         {
             MySqlConnection theconnection = Connect();
             string blockquery = "INSERT INTO invoice_block (`INV_NUMBER`,`INV_DUE_DATE`) VALUES("+invoice.number+",'"+invoice.due+"');";
             Insert(blockquery, theconnection);
                 Disconnect();
         }
         catch { Disconnect(); }
 }
Example #14
0
        public void ReadInvoices(DateTime date)
        {
            // TODO: Set date value.

            OleDbConnection dbConn = new OleDbConnection(@"Provider=vfpoledb.1;Data Source="+invoicefile+";Collating Sequence=general");
            try
            {

            // Initialize database connection.

            dbConn.Open();

                // Open connection.
                OleDbCommand command= new OleDbCommand("select INVNO,NAME,ADD1,ADD2,CITY,STATE,ZIP,SNAME,SADD1,SADD2,SCITY,SSTATE,SZIP,WHEN_REQ,SUBTOTAL,SHIPVIA,ORDDATE from oehead.dbf",dbConn);
                Invoice invoicetoadd;
                OleDbDataReader reader= command.ExecuteReader();

                while (reader.Read())
                {
                    string raw = (string)reader[13];
                    string[] dates = raw.Split('/');
                    try
                    {

                        int[] dates_int = new int[3];
                        if (dates.Length >= 3)
                        {
                            dates[0] = dates[0].Trim();
                            dates[1] = dates[1].Trim();
                            dates[2] = dates[2].Trim();
                            dates[2] = dates[2].Substring(0, 4);
                            if (dates[0][0] == '0')
                            {
                                dates[0] = dates[0].Remove(0, 1);
                            }
                            if (dates[1][0] == '0')
                            {
                                dates[1] = dates[1].Remove(0, 1);
                            }

                        }
                        else { continue; }
                    }
                    catch { }
                    if (dates[0] == date.Month.ToString() && dates[1] == date.Day.ToString() && dates[2] == date.Year.ToString())
                    {

                    if ((string)reader[2] != "                                   " || (string)reader[8] != "                                   ")
                    {

                        DateTime due = new DateTime();
                        try
                        {
                        String duestring=dates[0]+"/"+dates[1]+"/"+dates[2];

                        duestring = duestring.Trim();
                        String[] duearray = duestring.Split(' ');

                            due = DateTime.Parse(duearray[0]);
                        }
                        catch { continue; }
                        try{
                        DateTime order = (DateTime)reader[16];
                        int dueint = due.Year * 12 + due.Month;
                        int orderint = order.Year * 12 + order.Month;
                        if (!((dueint - orderint) > 2) && !((dueint - orderint) < -2))
                        {
                        if (!reader[15].ToString().Contains("WILL CALL"))
                        {
                            if ((string)reader[11].ToString().Trim() == "" || (string)reader[7].ToString().Substring(0, 4) == "SAME")
                            {
                                invoicetoadd = new Invoice(Int32.Parse((string)reader[0]), System.Decimal.Multiply((System.Decimal)reader[14],100), due, (string)reader[1], (string)reader[2], (string)reader[3], (string)reader[4], (string)reader[5], (string)reader[6], 0, 0, DateTime.Now.AddYears(1));

                            }
                            else
                            {
                                invoicetoadd = new Invoice(Int32.Parse((string)reader[0]), System.Decimal.Multiply((System.Decimal)reader[14],100), due, (string)reader[1], (string)reader[8], (string)reader[9], (string)reader[10], (string)reader[11], (string)reader[12], 0, 0, DateTime.Now.AddYears(1));

                            }

                            invoicetoadd.customername = invoicetoadd.customername.Trim();
                            invoicetoadd.addr1 = invoicetoadd.addr1.Trim();
                            invoicetoadd.addr2 = invoicetoadd.addr2.Trim();
                            invoicetoadd.addr1=invoicetoadd.addr1.Replace('#', ' ');
                            invoicetoadd.addr2=invoicetoadd.addr2.Replace('#', ' ');
                            invoicetoadd.city = invoicetoadd.city.Trim();
                            invoicetoadd.state = invoicetoadd.state.Trim();
                            invoicetoadd.zip = invoicetoadd.zip.Trim();
                            int i = Math.Abs(invoicetoadd.number);
                            while (i >= 10)
                                i /= 10;
                            if(i!=8)
                            {
                            rawinvoices.Add(invoicetoadd);
                            }
                        }
                    }else{
                    }
                    }
                        catch{}
                    }
                    else
                    {

                    }
                }
                }
            }
            catch { }

                // Close connection.
                dbConn.Close();
        }
 private void EditInvoice_Load(object sender, EventArgs e)
 {
     try
     {
         textInvoice.Text = "";
         textValue.Text = "";
         textCustomer.Text = "";
         textStreet.Text = "";
         textCity.Text = "";
         textZip.Text = "";
         textState.Text = "";
         listAddresses.Items.Clear();
         button1.Enabled = false;
         toolStripStatusLabel1.Text = "";
         mysql_invoices = new MySQL_Invoices(GlobalVar.sqlhost, GlobalVar.sqlport, GlobalVar.sqldatabase, GlobalVar.sqlusername, "");
         mysql_lineitems = new MySQL_LineItems(GlobalVar.sqlhost, GlobalVar.sqlport, GlobalVar.sqldatabase, GlobalVar.sqlusername, "");
         newinvoice = mysql_invoices.GetInvoice(inputinvoice.number);
         if (newinvoice != null)
         {
             lineitems = mysql_lineitems.GetLineItems(newinvoice);
             textInvoice.Text = newinvoice.number.ToString();
             textValue.Text = DataFormat.FormatMoneyToString(newinvoice.value);
             if (newinvoice.addr1 != "")
             {
                 textStreet.Text = newinvoice.addr1;
             }
             else
             {
                 textStreet.Text = newinvoice.addr2;
             }
             textCustomer.Text = newinvoice.customername;
             textCity.Text = newinvoice.city;
             textZip.Text = newinvoice.zip;
             textState.Text = newinvoice.state;
             for (int i = 0; i < lineitems.Count; i++)
             {
                 string toinsert = lineitems[i].description + " - " + DataFormat.FormatMoneyToString(lineitems[i].value);
                 listAddresses.Items.Add(toinsert);
             }
             DatePicker.Value = newinvoice.due;
             button1.Enabled = true;
         }
         else { Cancel_Click(null, null); }
     }
     catch
     {
         Cancel_Click(null, null);
     }
 }