Пример #1
0
        //do one or the other (default invoice)
        public List<Invoice> FilterInvoices(DateTime date,List<int> invoice)
        {
            try
            {

                List<Invoice> filteredinvoices = new List<Invoice>();

                    mysql_invoices = new MySQL_Invoices(GlobalVar.sqlhost, GlobalVar.sqlport, GlobalVar.sqldatabase, GlobalVar.sqlusername, "");
                    List<Invoice> blockedinvoices= mysql_invoices.GetBlocks(date);
                    for (int i = 0; i < rawinvoices.Count; i++)
                    {
                        if ((rawinvoices[i].due.Day == date.Day && rawinvoices[i].due.Month == date.Month && rawinvoices[i].due.Year == date.Year))
                        {
                            filteredinvoices.Add(rawinvoices[i]);
                            if (blockedinvoices != null)
                            {
                                for (int j = 0; j < blockedinvoices.Count; j++)
                                {
                                    if (rawinvoices[i].number == blockedinvoices[j].number)
                                    {
                                        filteredinvoices.RemoveAt(filteredinvoices.Count - 1);
                                    }
                                }
                            }
                        }
                        else
                        {
                            for (int j = 0; j < invoice.Count; j++)
                            {
                                if (rawinvoices[i].number == invoice[j])
                                {
                                    filteredinvoices.Add(rawinvoices[i]);
                                }
                            }
                        }
                    }

                        return (filteredinvoices);

            }
            catch
            {
                return null;
            }
        }
Пример #2
0
        void bw3_DoWork(object sender, DoWorkEventArgs e)
        {
            DateTime viewdate = logDate.Value;
            try
            {
                //get invoices for current day
                MySQL MySQLHandle = new MySQL(GlobalVar.sqlhost, GlobalVar.sqlport, GlobalVar.sqldatabase, GlobalVar.sqlusername, "");
                MySqlConnection sqlReader = MySQLHandle.Connect();
                string selectquery = "SELECT `invoice` FROM shipping_log WHERE `date_delivered` LIKE '" + logDate.Value.ToString("yyyy-MM-dd") + "';";
                MySqlDataReader dataReader = MySQLHandle.Select(selectquery, sqlReader);
                List<int> invoices = new List<int>();
                for (int i = 0; dataReader.Read();i++ )
                {

                    invoices.Add(dataReader.GetInt32(0));
                }
                dataReader.Close();
                sqlReader.Close();
                rrsdatareader = new RRSDataReader(GlobalVar.sqlsettings.RRSHeaderFile, GlobalVar.sqlsettings.RRSLinesFile);
                rrsdatareader.ReadInvoices(viewdate);

                List<Invoice> filteredinvoices = rrsdatareader.FilterInvoices(viewdate, invoices);

                //List<LineItem> filteredlineitems = rrsdatareader.FilterLineItems(filteredinvoices);
                List<Invoice> newfilteredinvoices = new List<Invoice>(filteredinvoices);
                mysql_invoices = new MySQL_Invoices(GlobalVar.sqlhost, GlobalVar.sqlport, GlobalVar.sqldatabase, GlobalVar.sqlusername, "");
                newfilteredinvoices = mysql_invoices.AddInvoices(newfilteredinvoices, false);
                mysql_invoices.UpdateInvoices(filteredinvoices, viewdate, true);
                dataReader.Close();
                sqlReader.Close();
                MySQLHandle.Disconnect();

            }
            catch { }
        }